Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | |
| 7 #include "base/compiler_specific.h" | |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 9 |
| 8 namespace { | 10 namespace { |
| 9 | 11 |
| 10 void DoAdd(int a, int b, int c, int* res) { | 12 void DoAdd(int a, int b, int c, int* res) { |
| 11 *res = a + b + c; | 13 *res = a + b + c; |
| 12 } | 14 } |
| 13 | 15 |
| 14 struct Addy { | 16 struct Addy { |
| 15 Addy() { } | 17 Addy() { } |
| 16 void DoAdd(int a, int b, int c, int d, int* res) { | 18 void DoAdd(int a, int b, int c, int d, int* res) { |
| 17 *res = a + b + c + d; | 19 *res = a + b + c + d; |
| 18 } | 20 } |
| 19 }; | 21 }; |
| 20 | 22 |
| 21 struct Addz { | 23 struct Addz { |
| 22 Addz() { } | 24 Addz() { } |
| 23 void DoAdd(int a, int b, int c, int d, int e, int* res) { | 25 void DoAdd(int a, int b, int c, int d, int e, int* res) { |
| 24 *res = a + b + c + d + e; | 26 *res = a + b + c + d + e; |
| 25 } | 27 } |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 } // namespace | 30 } // namespace |
| 29 | 31 |
| 30 TEST(TupleTest, Basic) { | 32 TEST(TupleTest, Basic) { |
| 31 Tuple0 t0 = MakeTuple(); | 33 Tuple0 t0 ALLOW_UNUSED = MakeTuple(); |
|
willchan no longer on Chromium
2010/03/30 17:13:18
I don't much care, but I'm not sure of the point o
| |
| 32 Tuple1<int> t1(1); | 34 Tuple1<int> t1(1); |
| 33 Tuple2<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee")); | 35 Tuple2<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee")); |
| 34 Tuple3<int, int, int> t3(1, 2, 3); | 36 Tuple3<int, int, int> t3(1, 2, 3); |
| 35 Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a); | 37 Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a); |
| 36 Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a); | 38 Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a); |
| 37 Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a); | 39 Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a); |
| 38 | 40 |
| 39 EXPECT_EQ(1, t1.a); | 41 EXPECT_EQ(1, t1.a); |
| 40 EXPECT_EQ(1, t2.a); | 42 EXPECT_EQ(1, t2.a); |
| 41 EXPECT_EQ(1, t3.a); | 43 EXPECT_EQ(1, t3.a); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 EXPECT_EQ(2, CopyLogger::TimesConstructed); | 119 EXPECT_EQ(2, CopyLogger::TimesConstructed); |
| 118 EXPECT_EQ(1, CopyLogger::TimesCopied); | 120 EXPECT_EQ(1, CopyLogger::TimesCopied); |
| 119 | 121 |
| 120 // Now they should be different, since the function call will make a copy. | 122 // Now they should be different, since the function call will make a copy. |
| 121 res = false; | 123 res = false; |
| 122 DispatchToFunction(&SomeLoggerMethCopy, tuple); | 124 DispatchToFunction(&SomeLoggerMethCopy, tuple); |
| 123 EXPECT_FALSE(res); | 125 EXPECT_FALSE(res); |
| 124 EXPECT_EQ(3, CopyLogger::TimesConstructed); | 126 EXPECT_EQ(3, CopyLogger::TimesConstructed); |
| 125 EXPECT_EQ(2, CopyLogger::TimesCopied); | 127 EXPECT_EQ(2, CopyLogger::TimesCopied); |
| 126 } | 128 } |
| OLD | NEW |