Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: mojo/edk/system/channel_endpoint_id_unittest.cc

Issue 647553004: Mojo: Make room for remotely-allocated channel endpoint IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@channel_endpoint_id_tests
Patch Set: bah Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/channel_endpoint_id.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_endpoint_id.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698