| 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 | 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 12 matching lines...) Expand all Loading... |
| 23 struct Addz { | 23 struct Addz { |
| 24 Addz() { } | 24 Addz() { } |
| 25 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) { |
| 26 *res = a + b + c + d + e; | 26 *res = a + b + c + d + e; |
| 27 } | 27 } |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 TEST(TupleTest, Basic) { | 32 TEST(TupleTest, Basic) { |
| 33 Tuple0 t0 ALLOW_UNUSED = MakeTuple(); | 33 Tuple0 t0 = MakeTuple(); |
| 34 ALLOW_UNUSED_LOCAL(t0); |
| 34 Tuple1<int> t1(1); | 35 Tuple1<int> t1(1); |
| 35 Tuple2<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee")); | 36 Tuple2<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee")); |
| 36 Tuple3<int, int, int> t3(1, 2, 3); | 37 Tuple3<int, int, int> t3(1, 2, 3); |
| 37 Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a); | 38 Tuple4<int, int, int, int*> t4(1, 2, 3, &t1.a); |
| 38 Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a); | 39 Tuple5<int, int, int, int, int*> t5(1, 2, 3, 4, &t4.a); |
| 39 Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a); | 40 Tuple6<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &t4.a); |
| 40 | 41 |
| 41 EXPECT_EQ(1, t1.a); | 42 EXPECT_EQ(1, t1.a); |
| 42 EXPECT_EQ(1, t2.a); | 43 EXPECT_EQ(1, t2.a); |
| 43 EXPECT_EQ(1, t3.a); | 44 EXPECT_EQ(1, t3.a); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 EXPECT_EQ(2, CopyLogger::TimesConstructed); | 120 EXPECT_EQ(2, CopyLogger::TimesConstructed); |
| 120 EXPECT_EQ(1, CopyLogger::TimesCopied); | 121 EXPECT_EQ(1, CopyLogger::TimesCopied); |
| 121 | 122 |
| 122 // Now they should be different, since the function call will make a copy. | 123 // Now they should be different, since the function call will make a copy. |
| 123 res = false; | 124 res = false; |
| 124 DispatchToFunction(&SomeLoggerMethCopy, tuple); | 125 DispatchToFunction(&SomeLoggerMethCopy, tuple); |
| 125 EXPECT_FALSE(res); | 126 EXPECT_FALSE(res); |
| 126 EXPECT_EQ(3, CopyLogger::TimesConstructed); | 127 EXPECT_EQ(3, CopyLogger::TimesConstructed); |
| 127 EXPECT_EQ(2, CopyLogger::TimesCopied); | 128 EXPECT_EQ(2, CopyLogger::TimesCopied); |
| 128 } | 129 } |
| OLD | NEW |