Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // Windows has no ssize_t type. | 286 // Windows has no ssize_t type. |
287 EXPECT_EQ("-2", Print(static_cast<ssize_t>(-2))); // ssize_t. | 287 EXPECT_EQ("-2", Print(static_cast<ssize_t>(-2))); // ssize_t. |
288 #endif // !GTEST_OS_WINDOWS | 288 #endif // !GTEST_OS_WINDOWS |
289 } | 289 } |
290 | 290 |
291 // Floating-points. | 291 // Floating-points. |
292 TEST(PrintBuiltInTypeTest, FloatingPoints) { | 292 TEST(PrintBuiltInTypeTest, FloatingPoints) { |
293 EXPECT_EQ("1.5", Print(1.5f)); // float | 293 EXPECT_EQ("1.5", Print(1.5f)); // float |
294 EXPECT_EQ("-2.5", Print(-2.5)); // double | 294 EXPECT_EQ("-2.5", Print(-2.5)); // double |
295 // Earlier Symbian OpenC implementations had stream formatting bugs, | 295 // Earlier Symbian OpenC implementations had stream formatting bugs, |
296 // among other things formatting 9.5 as "9.". | 296 // among other things formatting 9.5 as "9.". |
Zhanyong Wan
2009/09/15 21:32:50
So you are testing the OpenC implementation instea
mika.raento
2009/09/16 14:21:29
On 2009/09/15 21:32:50, Zhanyong Wan wrote:I got
| |
297 EXPECT_EQ("9.5", Print(9.5)); // double | 297 EXPECT_EQ("9.5", Print(9.5)); // double |
298 } | 298 } |
299 | 299 |
300 // Since ::std::stringstream::operator<<(const void *) formats the pointer | 300 // Since ::std::stringstream::operator<<(const void *) formats the pointer |
301 // output differently with different compilers, we have to create the expected | 301 // output differently with different compilers, we have to create the expected |
302 // output first and use it as our expectation. | 302 // output first and use it as our expectation. |
303 static string PrintPointer(const void *p) { | 303 static string PrintPointer(const void *p) { |
304 ::std::stringstream expected_result_stream; | 304 ::std::stringstream expected_result_stream; |
305 expected_result_stream << p; | 305 expected_result_stream << p; |
306 return expected_result_stream.str(); | 306 return expected_result_stream.str(); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
786 const list<int> l1(a1, a1 + 2); | 786 const list<int> l1(a1, a1 + 2); |
787 const list<int> l2(a2, a2 + 3); | 787 const list<int> l2(a2, a2 + 3); |
788 | 788 |
789 vector<list<int> > v; | 789 vector<list<int> > v; |
790 v.push_back(l1); | 790 v.push_back(l1); |
791 v.push_back(l2); | 791 v.push_back(l2); |
792 EXPECT_EQ("{ { 1, 2 }, { 3, 4, 5 } }", Print(v)); | 792 EXPECT_EQ("{ { 1, 2 }, { 3, 4, 5 } }", Print(v)); |
793 } | 793 } |
794 | 794 |
795 TEST(PrintStlContainerTest, OneDimensionalNativeArray) { | 795 TEST(PrintStlContainerTest, OneDimensionalNativeArray) { |
796 const int a[] = { 1, 2, 3 }; | 796 const int a[3] = { 1, 2, 3 }; |
797 NativeArray<int> b(a, kReference); | 797 NativeArray<int> b(a, 3, kReference); |
798 EXPECT_EQ("{ 1, 2, 3 }", Print(b)); | 798 EXPECT_EQ("{ 1, 2, 3 }", Print(b)); |
799 } | 799 } |
800 | 800 |
801 TEST(PrintStlContainerTest, TwoDimensionalNativeArray) { | 801 TEST(PrintStlContainerTest, TwoDimensionalNativeArray) { |
802 const int a[][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; | 802 const int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; |
803 NativeArray<int[3]> b(a, kReference); | 803 NativeArray<int[3]> b(a, 2, kReference); |
804 EXPECT_EQ("{ { 1, 2, 3 }, { 4, 5, 6 } }", Print(b)); | 804 EXPECT_EQ("{ { 1, 2, 3 }, { 4, 5, 6 } }", Print(b)); |
805 } | 805 } |
806 | 806 |
807 // Tests printing tuples. | 807 // Tests printing tuples. |
808 | 808 |
809 // Tuples of various arities. | 809 // Tuples of various arities. |
810 TEST(PrintTupleTest, VariousSizes) { | 810 TEST(PrintTupleTest, VariousSizes) { |
811 tuple<> t0; | 811 tuple<> t0; |
812 EXPECT_EQ("()", Print(t0)); | 812 EXPECT_EQ("()", Print(t0)); |
813 | 813 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1097 | 1097 |
1098 TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTersely) { | 1098 TEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTersely) { |
1099 const int n = 1; | 1099 const int n = 1; |
1100 EXPECT_THAT(UniversalTersePrintTupleFieldsToStrings( | 1100 EXPECT_THAT(UniversalTersePrintTupleFieldsToStrings( |
1101 tuple<const int&, const char*>(n, "a")), | 1101 tuple<const int&, const char*>(n, "a")), |
1102 ElementsAre("1", "\"a\"")); | 1102 ElementsAre("1", "\"a\"")); |
1103 } | 1103 } |
1104 | 1104 |
1105 } // namespace gmock_printers_test | 1105 } // namespace gmock_printers_test |
1106 } // namespace testing | 1106 } // namespace testing |
LEFT | RIGHT |