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

Side by Side Diff: base/tuple_unittest.cc

Issue 785153002: Add index access support to base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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 | « base/tuple.h ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/tuple.h" 5 #include "base/tuple.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 EXPECT_EQ(1, t5.a); 50 EXPECT_EQ(1, t5.a);
51 EXPECT_EQ(2, t5.b); 51 EXPECT_EQ(2, t5.b);
52 EXPECT_EQ(3, t5.c); 52 EXPECT_EQ(3, t5.c);
53 EXPECT_EQ(4, t5.d); 53 EXPECT_EQ(4, t5.d);
54 EXPECT_EQ(1, t6.a); 54 EXPECT_EQ(1, t6.a);
55 EXPECT_EQ(2, t6.b); 55 EXPECT_EQ(2, t6.b);
56 EXPECT_EQ(3, t6.c); 56 EXPECT_EQ(3, t6.c);
57 EXPECT_EQ(4, t6.d); 57 EXPECT_EQ(4, t6.d);
58 EXPECT_EQ(5, t6.e); 58 EXPECT_EQ(5, t6.e);
59 59
60 EXPECT_EQ(1, t1.Get<0>());
61 EXPECT_EQ(1, t2.Get<0>());
62 EXPECT_EQ(1, t3.Get<0>());
63 EXPECT_EQ(2, t3.Get<1>());
64 EXPECT_EQ(3, t3.Get<2>());
65 EXPECT_EQ(1, t4.Get<0>());
66 EXPECT_EQ(2, t4.Get<1>());
67 EXPECT_EQ(3, t4.Get<2>());
68 EXPECT_EQ(1, t5.Get<0>());
69 EXPECT_EQ(2, t5.Get<1>());
70 EXPECT_EQ(3, t5.Get<2>());
71 EXPECT_EQ(4, t5.Get<3>());
72 EXPECT_EQ(1, t6.Get<0>());
73 EXPECT_EQ(2, t6.Get<1>());
74 EXPECT_EQ(3, t6.Get<2>());
75 EXPECT_EQ(4, t6.Get<3>());
76 EXPECT_EQ(5, t6.Get<4>());
77
60 EXPECT_EQ(1, t1.a); 78 EXPECT_EQ(1, t1.a);
61 DispatchToFunction(&DoAdd, t4); 79 DispatchToFunction(&DoAdd, t4);
62 EXPECT_EQ(6, t1.a); 80 EXPECT_EQ(6, t1.a);
63 81
64 int res = 0; 82 int res = 0;
65 DispatchToFunction(&DoAdd, MakeTuple(9, 8, 7, &res)); 83 DispatchToFunction(&DoAdd, MakeTuple(9, 8, 7, &res));
66 EXPECT_EQ(24, res); 84 EXPECT_EQ(24, res);
67 85
68 Addy addy; 86 Addy addy;
69 EXPECT_EQ(1, t4.a); 87 EXPECT_EQ(1, t4.a);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 EXPECT_EQ(2, CopyLogger::TimesConstructed); 138 EXPECT_EQ(2, CopyLogger::TimesConstructed);
121 EXPECT_EQ(1, CopyLogger::TimesCopied); 139 EXPECT_EQ(1, CopyLogger::TimesCopied);
122 140
123 // Now they should be different, since the function call will make a copy. 141 // Now they should be different, since the function call will make a copy.
124 res = false; 142 res = false;
125 DispatchToFunction(&SomeLoggerMethCopy, tuple); 143 DispatchToFunction(&SomeLoggerMethCopy, tuple);
126 EXPECT_FALSE(res); 144 EXPECT_FALSE(res);
127 EXPECT_EQ(3, CopyLogger::TimesConstructed); 145 EXPECT_EQ(3, CopyLogger::TimesConstructed);
128 EXPECT_EQ(2, CopyLogger::TimesCopied); 146 EXPECT_EQ(2, CopyLogger::TimesCopied);
129 } 147 }
OLDNEW
« no previous file with comments | « base/tuple.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698