39using ::std::tr1::make_tuple;
40using ::std::tr1::tuple;
41using ::std::tr1::tuple_element;
42using ::std::tr1::tuple_size;
43using ::testing::StaticAssertTypeEq;
46TEST(tuple_element_Test, ReturnsElementType) {
47 StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>();
48 StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>();
49 StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>();
54TEST(tuple_size_Test, ReturnsNumberOfFields) {
64TEST(ComparisonTest, ComparesWithSelf) {
65 const tuple<int, char, bool>
a(5,
'a',
false);
72TEST(ComparisonTest, ComparesEqualTuples) {
73 const tuple<int, bool>
a(5,
true), b(5,
true);
80TEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) {
81 typedef tuple<const int, char> FooTuple;
83 const FooTuple
a(0,
'x');
84 const FooTuple b(1,
'a');
89 const FooTuple c(1,
'b');
96TEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) {
97 typedef tuple<int&, const char&> FooTuple;
101 const FooTuple
a(i, ch);
104 const FooTuple b(
j, ch);
110 const char ch2 =
'b';
111 const FooTuple c(
j, ch2);
119TEST(ReferenceFieldTest, IsAliasOfReferencedVariable) {
121 tuple<bool, int&> t(
true, n);
125 <<
"Changing a underlying variable should update the reference field.";
130 <<
"The address of a reference field should equal the address of "
131 <<
"the underlying variable.";
135 <<
"Changing a reference field should update the underlying variable.";
140TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {
153 tuple<int, double> a2, b2;
158 tuple<double, char, bool*> a3, b3;
164 tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;
179TEST(TupleConstructorTest, ConstructsFromFields) {
186 tuple<int, char> b(5,
'a');
192 tuple<bool, const int&> c(
true, m);
198TEST(TupleConstructorTest, CopyConstructor) {
199 tuple<double, bool>
a(0.0,
true);
200 tuple<double, bool> b(
a);
208TEST(TupleConstructorTest, ConstructsFromDifferentTupleType) {
209 tuple<int, int, char>
a(0, 1,
'a');
210 tuple<double, long, int> b(
a);
218TEST(TupleConstructorTest, ConstructsFromPair) {
219 ::std::pair<int, char>
a(1,
'a');
220 tuple<int, char> b(
a);
221 tuple<int, const char&> c(
a);
225TEST(TupleAssignmentTest, AssignsToSameTupleType) {
226 const tuple<int, long>
a(5, 7L);
235TEST(TupleAssignmentTest, AssignsToDifferentTupleType) {
236 const tuple<int, long, bool>
a(1, 7L,
true);
237 tuple<long, int, bool> b;
245TEST(TupleAssignmentTest, AssignsFromPair) {
246 const ::std::pair<int, bool>
a(5,
true);
261 typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple;
264 a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2),
265 b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {}
271TEST_F(BigTupleTest, Construction) {
277TEST_F(BigTupleTest, get) {
282 const BigTuple
a(a_);
288TEST_F(BigTupleTest, Comparisons) {
296TEST(MakeTupleTest, WorksForScalarTypes) {
298 a = make_tuple(
true, 5);
302 tuple<char, int, long> b;
303 b = make_tuple(
'a',
'b', 5);
309TEST(MakeTupleTest, WorksForPointers) {
310 int a[] = { 1, 2, 3, 4 };
311 const char*
const str =
"hi";
314 tuple<const char*, int*> t;
315 t = make_tuple(str,
p);
#define TEST_F(test_fixture, test_name)
#define EXPECT_EQ(val1, val2)
#define EXPECT_DOUBLE_EQ(val1, val2)
#define EXPECT_TRUE(condition)
#define TEST(test_case_name, test_name)
#define EXPECT_FALSE(condition)
static const Reg8 ch(Operand::CH)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a