| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/edk/system/channel_endpoint_id.h" | 5 #include "mojo/edk/system/channel_endpoint_id.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 EXPECT_FALSE(invalid != invalid); | 23 EXPECT_FALSE(invalid != invalid); |
| 24 EXPECT_FALSE(bootstrap != bootstrap); | 24 EXPECT_FALSE(bootstrap != bootstrap); |
| 25 EXPECT_NE(invalid, bootstrap); | 25 EXPECT_NE(invalid, bootstrap); |
| 26 | 26 |
| 27 EXPECT_FALSE(invalid < invalid); | 27 EXPECT_FALSE(invalid < invalid); |
| 28 EXPECT_LT(invalid, bootstrap); | 28 EXPECT_LT(invalid, bootstrap); |
| 29 | 29 |
| 30 EXPECT_FALSE(invalid.is_valid()); | 30 EXPECT_FALSE(invalid.is_valid()); |
| 31 EXPECT_TRUE(bootstrap.is_valid()); | 31 EXPECT_TRUE(bootstrap.is_valid()); |
| 32 | 32 |
| 33 EXPECT_FALSE(invalid.is_remotely_allocated()); |
| 34 EXPECT_FALSE(bootstrap.is_remotely_allocated()); |
| 35 |
| 33 // Test assignment. | 36 // Test assignment. |
| 34 ChannelEndpointId copy; | 37 ChannelEndpointId copy; |
| 35 copy = bootstrap; | 38 copy = bootstrap; |
| 36 EXPECT_EQ(copy, bootstrap); | 39 EXPECT_EQ(copy, bootstrap); |
| 37 copy = invalid; | 40 copy = invalid; |
| 38 EXPECT_EQ(copy, invalid); | 41 EXPECT_EQ(copy, invalid); |
| 39 } | 42 } |
| 40 | 43 |
| 41 // Tests values of invalid and bootstrap IDs. (This tests implementation | 44 // Tests values of invalid and bootstrap IDs. (This tests implementation |
| 42 // details.) | 45 // details.) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 EXPECT_EQ(2u, id2.value()); | 82 EXPECT_EQ(2u, id2.value()); |
| 80 } | 83 } |
| 81 | 84 |
| 82 } // namespace | 85 } // namespace |
| 83 | 86 |
| 84 // Tests that the generator handles wrap-around correctly. (This tests | 87 // Tests that the generator handles wrap-around correctly. (This tests |
| 85 // implementation details.) This test isn't in an anonymous namespace, since | 88 // implementation details.) This test isn't in an anonymous namespace, since |
| 86 // it needs to be friended. | 89 // it needs to be friended. |
| 87 TEST(LocalChannelEndpointIdGeneratorTest, WrapAround) { | 90 TEST(LocalChannelEndpointIdGeneratorTest, WrapAround) { |
| 88 LocalChannelEndpointIdGenerator gen; | 91 LocalChannelEndpointIdGenerator gen; |
| 89 gen.next_channel_endpoint_id_.value_ = static_cast<uint32_t>(-1); | 92 gen.next_channel_endpoint_id_.value_ = |
| 93 ChannelEndpointId::kRemotelyAllocatedFlag - 1; |
| 90 | 94 |
| 91 ChannelEndpointId id = gen.GetNext(); | 95 ChannelEndpointId id = gen.GetNext(); |
| 92 EXPECT_TRUE(id.is_valid()); | 96 EXPECT_TRUE(id.is_valid()); |
| 93 EXPECT_EQ(static_cast<uint32_t>(-1), id.value()); | 97 EXPECT_FALSE(id.is_remotely_allocated()); |
| 98 EXPECT_EQ(ChannelEndpointId::kRemotelyAllocatedFlag - 1, id.value()); |
| 94 | 99 |
| 95 id = gen.GetNext(); | 100 id = gen.GetNext(); |
| 96 EXPECT_TRUE(id.is_valid()); | 101 EXPECT_TRUE(id.is_valid()); |
| 102 EXPECT_FALSE(id.is_remotely_allocated()); |
| 97 EXPECT_EQ(1u, id.value()); | 103 EXPECT_EQ(1u, id.value()); |
| 98 } | 104 } |
| 99 | 105 |
| 100 } // namespace system | 106 } // namespace system |
| 101 } // namespace mojo | 107 } // namespace mojo |
| OLD | NEW |