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

Side by Side Diff: testing/gmock/test/gmock-internal-utils_test.cc

Issue 3427004: clang: update gtest/gmock (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: yakshave Created 10 years, 3 months 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
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 EXPECT_EQ("foo bar", ConvertIdentifierNameToWords("_foo_bar_")); 89 EXPECT_EQ("foo bar", ConvertIdentifierNameToWords("_foo_bar_"));
90 EXPECT_EQ("foo and bar", ConvertIdentifierNameToWords("_foo__and_bar")); 90 EXPECT_EQ("foo and bar", ConvertIdentifierNameToWords("_foo__and_bar"));
91 } 91 }
92 92
93 TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) { 93 TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) {
94 EXPECT_EQ("foo bar 123", ConvertIdentifierNameToWords("Foo_bar123")); 94 EXPECT_EQ("foo bar 123", ConvertIdentifierNameToWords("Foo_bar123"));
95 EXPECT_EQ("chapter 11 section 1", 95 EXPECT_EQ("chapter 11 section 1",
96 ConvertIdentifierNameToWords("_Chapter11Section_1_")); 96 ConvertIdentifierNameToWords("_Chapter11Section_1_"));
97 } 97 }
98 98
99 // Tests that CompileAssertTypesEqual compiles when the type arguments are
100 // equal.
101 TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {
102 CompileAssertTypesEqual<void, void>();
103 CompileAssertTypesEqual<int*, int*>();
104 }
105
106 // Tests that RemoveReference does not affect non-reference types.
107 TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) {
108 CompileAssertTypesEqual<int, RemoveReference<int>::type>();
109 CompileAssertTypesEqual<const char, RemoveReference<const char>::type>();
110 }
111
112 // Tests that RemoveReference removes reference from reference types.
113 TEST(RemoveReferenceTest, RemovesReference) {
114 CompileAssertTypesEqual<int, RemoveReference<int&>::type>();
115 CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>();
116 }
117
118 // Tests GMOCK_REMOVE_REFERENCE_.
119
120 template <typename T1, typename T2>
121 void TestGMockRemoveReference() {
122 CompileAssertTypesEqual<T1, GMOCK_REMOVE_REFERENCE_(T2)>();
123 }
124
125 TEST(RemoveReferenceTest, MacroVersion) {
126 TestGMockRemoveReference<int, int>();
127 TestGMockRemoveReference<const char, const char&>();
128 }
129
130
131 // Tests that RemoveConst does not affect non-const types.
132 TEST(RemoveConstTest, DoesNotAffectNonConstType) {
133 CompileAssertTypesEqual<int, RemoveConst<int>::type>();
134 CompileAssertTypesEqual<char&, RemoveConst<char&>::type>();
135 }
136
137 // Tests that RemoveConst removes const from const types.
138 TEST(RemoveConstTest, RemovesConst) {
139 CompileAssertTypesEqual<int, RemoveConst<const int>::type>();
140 CompileAssertTypesEqual<char[2], RemoveConst<const char[2]>::type>();
141 CompileAssertTypesEqual<char[2][3], RemoveConst<const char[2][3]>::type>();
142 }
143
144 // Tests GMOCK_REMOVE_CONST_.
145
146 template <typename T1, typename T2>
147 void TestGMockRemoveConst() {
148 CompileAssertTypesEqual<T1, GMOCK_REMOVE_CONST_(T2)>();
149 }
150
151 TEST(RemoveConstTest, MacroVersion) {
152 TestGMockRemoveConst<int, int>();
153 TestGMockRemoveConst<double&, double&>();
154 TestGMockRemoveConst<char, const char>();
155 }
156
157 // Tests that AddReference does not affect reference types.
158 TEST(AddReferenceTest, DoesNotAffectReferenceType) {
159 CompileAssertTypesEqual<int&, AddReference<int&>::type>();
160 CompileAssertTypesEqual<const char&, AddReference<const char&>::type>();
161 }
162
163 // Tests that AddReference adds reference to non-reference types.
164 TEST(AddReferenceTest, AddsReference) {
165 CompileAssertTypesEqual<int&, AddReference<int>::type>();
166 CompileAssertTypesEqual<const char&, AddReference<const char>::type>();
167 }
168
169 // Tests GMOCK_ADD_REFERENCE_.
170
171 template <typename T1, typename T2>
172 void TestGMockAddReference() {
173 CompileAssertTypesEqual<T1, GMOCK_ADD_REFERENCE_(T2)>();
174 }
175
176 TEST(AddReferenceTest, MacroVersion) {
177 TestGMockAddReference<int&, int>();
178 TestGMockAddReference<const char&, const char&>();
179 }
180
181 // Tests GMOCK_REFERENCE_TO_CONST_.
182
183 template <typename T1, typename T2>
184 void TestGMockReferenceToConst() {
185 CompileAssertTypesEqual<T1, GMOCK_REFERENCE_TO_CONST_(T2)>();
186 }
187
188 TEST(GMockReferenceToConstTest, Works) {
189 TestGMockReferenceToConst<const char&, char>();
190 TestGMockReferenceToConst<const int&, const int>();
191 TestGMockReferenceToConst<const double&, double>();
192 TestGMockReferenceToConst<const string&, const string&>();
193 }
194
195 TEST(PointeeOfTest, WorksForSmartPointers) { 99 TEST(PointeeOfTest, WorksForSmartPointers) {
196 CompileAssertTypesEqual<const char, 100 CompileAssertTypesEqual<const char,
197 PointeeOf<internal::linked_ptr<const char> >::type>(); 101 PointeeOf<internal::linked_ptr<const char> >::type>();
198 } 102 }
199 103
200 TEST(PointeeOfTest, WorksForRawPointers) { 104 TEST(PointeeOfTest, WorksForRawPointers) {
201 CompileAssertTypesEqual<int, PointeeOf<int*>::type>(); 105 CompileAssertTypesEqual<int, PointeeOf<int*>::type>();
202 CompileAssertTypesEqual<const char, PointeeOf<const char*>::type>(); 106 CompileAssertTypesEqual<const char, PointeeOf<const char*>::type>();
203 CompileAssertTypesEqual<void, PointeeOf<void*>::type>(); 107 CompileAssertTypesEqual<void, PointeeOf<void*>::type>();
204 } 108 }
205 109
206 TEST(GetRawPointerTest, WorksForSmartPointers) { 110 TEST(GetRawPointerTest, WorksForSmartPointers) {
207 const char* const raw_p4 = new const char('a'); // NOLINT 111 const char* const raw_p4 = new const char('a'); // NOLINT
208 const internal::linked_ptr<const char> p4(raw_p4); 112 const internal::linked_ptr<const char> p4(raw_p4);
209 EXPECT_EQ(raw_p4, GetRawPointer(p4)); 113 EXPECT_EQ(raw_p4, GetRawPointer(p4));
210 } 114 }
211 115
212 TEST(GetRawPointerTest, WorksForRawPointers) { 116 TEST(GetRawPointerTest, WorksForRawPointers) {
213 int* p = NULL; 117 int* p = NULL;
214 // Don't use EXPECT_EQ as no NULL-testing magic on Symbian. 118 // Don't use EXPECT_EQ as no NULL-testing magic on Symbian.
215 EXPECT_TRUE(NULL == GetRawPointer(p)); 119 EXPECT_TRUE(NULL == GetRawPointer(p));
216 int n = 1; 120 int n = 1;
217 EXPECT_EQ(&n, GetRawPointer(&n)); 121 EXPECT_EQ(&n, GetRawPointer(&n));
218 } 122 }
219 123
124 // Tests KindOf<T>.
125
220 class Base {}; 126 class Base {};
221 class Derived : public Base {}; 127 class Derived : public Base {};
222 128
223 // Tests that ImplicitlyConvertible<T1, T2>::value is a compile-time constant.
224 TEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) {
225 GMOCK_COMPILE_ASSERT_((ImplicitlyConvertible<int, int>::value), const_true);
226 GMOCK_COMPILE_ASSERT_((!ImplicitlyConvertible<void*, int*>::value),
227 const_false);
228 }
229
230 // Tests that ImplicitlyConvertible<T1, T2>::value is true when T1 can
231 // be implicitly converted to T2.
232 TEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) {
233 EXPECT_TRUE((ImplicitlyConvertible<int, double>::value));
234 EXPECT_TRUE((ImplicitlyConvertible<double, int>::value));
235 EXPECT_TRUE((ImplicitlyConvertible<int*, void*>::value));
236 EXPECT_TRUE((ImplicitlyConvertible<int*, const int*>::value));
237 EXPECT_TRUE((ImplicitlyConvertible<Derived&, const Base&>::value));
238 EXPECT_TRUE((ImplicitlyConvertible<const Base, Base>::value));
239 }
240
241 // Tests that ImplicitlyConvertible<T1, T2>::value is false when T1
242 // cannot be implicitly converted to T2.
243 TEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) {
244 EXPECT_FALSE((ImplicitlyConvertible<double, int*>::value));
245 EXPECT_FALSE((ImplicitlyConvertible<void*, int*>::value));
246 EXPECT_FALSE((ImplicitlyConvertible<const int*, int*>::value));
247 EXPECT_FALSE((ImplicitlyConvertible<Base&, Derived&>::value));
248 }
249
250 // Tests KindOf<T>.
251
252 TEST(KindOfTest, Bool) { 129 TEST(KindOfTest, Bool) {
253 EXPECT_EQ(kBool, GMOCK_KIND_OF_(bool)); // NOLINT 130 EXPECT_EQ(kBool, GMOCK_KIND_OF_(bool)); // NOLINT
254 } 131 }
255 132
256 TEST(KindOfTest, Integer) { 133 TEST(KindOfTest, Integer) {
257 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(char)); // NOLINT 134 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(char)); // NOLINT
258 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(signed char)); // NOLINT 135 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(signed char)); // NOLINT
259 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned char)); // NOLINT 136 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned char)); // NOLINT
260 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(short)); // NOLINT 137 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(short)); // NOLINT
261 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned short)); // NOLINT 138 EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned short)); // NOLINT
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 EXPECT_FALSE((LosslessArithmeticConvertible<double, float>::value)); 252 EXPECT_FALSE((LosslessArithmeticConvertible<double, float>::value));
376 if (sizeof(double) == sizeof(long double)) { // NOLINT 253 if (sizeof(double) == sizeof(long double)) { // NOLINT
377 // In some implementations (e.g. MSVC), double and long double 254 // In some implementations (e.g. MSVC), double and long double
378 // have the same size. 255 // have the same size.
379 EXPECT_TRUE((LosslessArithmeticConvertible<long double, double>::value)); 256 EXPECT_TRUE((LosslessArithmeticConvertible<long double, double>::value));
380 } else { 257 } else {
381 EXPECT_FALSE((LosslessArithmeticConvertible<long double, double>::value)); 258 EXPECT_FALSE((LosslessArithmeticConvertible<long double, double>::value));
382 } 259 }
383 } 260 }
384 261
385 // Tests that IsAProtocolMessage<T>::value is a compile-time constant.
386 TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {
387 GMOCK_COMPILE_ASSERT_(IsAProtocolMessage<ProtocolMessage>::value, const_true);
388 GMOCK_COMPILE_ASSERT_(!IsAProtocolMessage<int>::value, const_false);
389 }
390
391 // Tests that IsAProtocolMessage<T>::value is true when T is
392 // ProtocolMessage or a sub-class of it.
393 TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {
394 EXPECT_TRUE(IsAProtocolMessage< ::proto2::Message>::value);
395 EXPECT_TRUE(IsAProtocolMessage<ProtocolMessage>::value);
396 #if GMOCK_HAS_PROTOBUF_
397 EXPECT_TRUE(IsAProtocolMessage<const TestMessage>::value);
398 #endif // GMOCK_HAS_PROTOBUF_
399 }
400
401 // Tests that IsAProtocolMessage<T>::value is false when T is neither
402 // ProtocolMessage nor a sub-class of it.
403 TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {
404 EXPECT_FALSE(IsAProtocolMessage<int>::value);
405 EXPECT_FALSE(IsAProtocolMessage<const Base>::value);
406 }
407
408 // Tests IsContainerTest.
409
410 class NonContainer {};
411
412 TEST(IsContainerTestTest, WorksForNonContainer) {
413 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<int>(0)));
414 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<char[5]>(0)));
415 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<NonContainer>(0)));
416 }
417
418 TEST(IsContainerTestTest, WorksForContainer) {
419 EXPECT_EQ(sizeof(IsContainer),
420 sizeof(IsContainerTest<std::vector<bool> >(0)));
421 EXPECT_EQ(sizeof(IsContainer),
422 sizeof(IsContainerTest<std::map<int, double> >(0)));
423 }
424
425 // Tests the TupleMatches() template function. 262 // Tests the TupleMatches() template function.
426 263
427 TEST(TupleMatchesTest, WorksForSize0) { 264 TEST(TupleMatchesTest, WorksForSize0) {
428 tuple<> matchers; 265 tuple<> matchers;
429 tuple<> values; 266 tuple<> values;
430 267
431 EXPECT_TRUE(TupleMatches(matchers, values)); 268 EXPECT_TRUE(TupleMatches(matchers, values));
432 } 269 }
433 270
434 TEST(TupleMatchesTest, WorksForSize1) { 271 TEST(TupleMatchesTest, WorksForSize1) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 "^\nTest log\\.\nStack trace:\n")); 395 "^\nTest log\\.\nStack trace:\n"));
559 } else { 396 } else {
560 EXPECT_STREQ("", GetCapturedStdout().c_str()); 397 EXPECT_STREQ("", GetCapturedStdout().c_str());
561 } 398 }
562 GMOCK_FLAG(verbose) = old_flag; 399 GMOCK_FLAG(verbose) = old_flag;
563 } 400 }
564 401
565 // Tests that when the stack_frames_to_skip parameter is negative, 402 // Tests that when the stack_frames_to_skip parameter is negative,
566 // Log() doesn't include the stack trace in the output. 403 // Log() doesn't include the stack trace in the output.
567 TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) { 404 TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
405 const string saved_flag = GMOCK_FLAG(verbose);
568 GMOCK_FLAG(verbose) = kInfoVerbosity; 406 GMOCK_FLAG(verbose) = kInfoVerbosity;
569 CaptureStdout(); 407 CaptureStdout();
570 Log(INFO, "Test log.\n", -1); 408 Log(INFO, "Test log.\n", -1);
571 EXPECT_STREQ("\nTest log.\n", GetCapturedStdout().c_str()); 409 EXPECT_STREQ("\nTest log.\n", GetCapturedStdout().c_str());
410 GMOCK_FLAG(verbose) = saved_flag;
572 } 411 }
573 412
574 // Tests that in opt mode, a positive stack_frames_to_skip argument is 413 // Tests that in opt mode, a positive stack_frames_to_skip argument is
575 // treated as 0. 414 // treated as 0.
576 TEST(LogTest, NoSkippingStackFrameInOptMode) { 415 TEST(LogTest, NoSkippingStackFrameInOptMode) {
577 CaptureStdout(); 416 CaptureStdout();
578 Log(WARNING, "Test log.\n", 100); 417 Log(WARNING, "Test log.\n", 100);
579 const String log = GetCapturedStdout(); 418 const String log = GetCapturedStdout();
580 #if defined(NDEBUG) && GTEST_GOOGLE3_MODE_ 419 #if defined(NDEBUG) && GTEST_GOOGLE3_MODE_
581 // In opt mode, no stack frame should be skipped. 420 // In opt mode, no stack frame should be skipped.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 567 }
729 568
730 // Verifies that ON_CALL prints provided _ argument. 569 // Verifies that ON_CALL prints provided _ argument.
731 TEST(OnCallTest, LogsAnythingArgument) { 570 TEST(OnCallTest, LogsAnythingArgument) {
732 EXPECT_THAT(GrabOutput(OnCallAnyArgumentLogger, kInfoVerbosity), 571 EXPECT_THAT(GrabOutput(OnCallAnyArgumentLogger, kInfoVerbosity),
733 HasSubstr("ON_CALL(mock, TestMethodArg(_)")); 572 HasSubstr("ON_CALL(mock, TestMethodArg(_)"));
734 } 573 }
735 574
736 #endif // GTEST_HAS_STREAM_REDIRECTION_ 575 #endif // GTEST_HAS_STREAM_REDIRECTION_
737 576
738 // Tests ArrayEq().
739
740 TEST(ArrayEqTest, WorksForDegeneratedArrays) {
741 EXPECT_TRUE(ArrayEq(5, 5L));
742 EXPECT_FALSE(ArrayEq('a', 0));
743 }
744
745 TEST(ArrayEqTest, WorksForOneDimensionalArrays) {
746 const int a[] = { 0, 1 };
747 long b[] = { 0, 1 };
748 EXPECT_TRUE(ArrayEq(a, b));
749 EXPECT_TRUE(ArrayEq(a, 2, b));
750
751 b[0] = 2;
752 EXPECT_FALSE(ArrayEq(a, b));
753 EXPECT_FALSE(ArrayEq(a, 1, b));
754 }
755
756 TEST(ArrayEqTest, WorksForTwoDimensionalArrays) {
757 const char a[][3] = { "hi", "lo" };
758 const char b[][3] = { "hi", "lo" };
759 const char c[][3] = { "hi", "li" };
760
761 EXPECT_TRUE(ArrayEq(a, b));
762 EXPECT_TRUE(ArrayEq(a, 2, b));
763
764 EXPECT_FALSE(ArrayEq(a, c));
765 EXPECT_FALSE(ArrayEq(a, 2, c));
766 }
767
768 // Tests ArrayAwareFind().
769
770 TEST(ArrayAwareFindTest, WorksForOneDimensionalArray) {
771 const char a[] = "hello";
772 EXPECT_EQ(a + 4, ArrayAwareFind(a, a + 5, 'o'));
773 EXPECT_EQ(a + 5, ArrayAwareFind(a, a + 5, 'x'));
774 }
775
776 TEST(ArrayAwareFindTest, WorksForTwoDimensionalArray) {
777 int a[][2] = { { 0, 1 }, { 2, 3 }, { 4, 5 } };
778 const int b[2] = { 2, 3 };
779 EXPECT_EQ(a + 1, ArrayAwareFind(a, a + 3, b));
780
781 const int c[2] = { 6, 7 };
782 EXPECT_EQ(a + 3, ArrayAwareFind(a, a + 3, c));
783 }
784
785 // Tests CopyArray().
786
787 TEST(CopyArrayTest, WorksForDegeneratedArrays) {
788 int n = 0;
789 CopyArray('a', &n);
790 EXPECT_EQ('a', n);
791 }
792
793 TEST(CopyArrayTest, WorksForOneDimensionalArrays) {
794 const char a[3] = "hi";
795 int b[3];
796 CopyArray(a, &b);
797 EXPECT_TRUE(ArrayEq(a, b));
798
799 int c[3];
800 CopyArray(a, 3, c);
801 EXPECT_TRUE(ArrayEq(a, c));
802 }
803
804 TEST(CopyArrayTest, WorksForTwoDimensionalArrays) {
805 const int a[2][3] = { { 0, 1, 2 }, { 3, 4, 5 } };
806 int b[2][3];
807 CopyArray(a, &b);
808 EXPECT_TRUE(ArrayEq(a, b));
809
810 int c[2][3];
811 CopyArray(a, 2, c);
812 EXPECT_TRUE(ArrayEq(a, c));
813 }
814
815 // Tests NativeArray.
816
817 TEST(NativeArrayTest, ConstructorFromArrayWorks) {
818 const int a[3] = { 0, 1, 2 };
819 NativeArray<int> na(a, 3, kReference);
820 EXPECT_EQ(3U, na.size());
821 EXPECT_EQ(a, na.begin());
822 }
823
824 TEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) {
825 typedef int Array[2];
826 Array* a = new Array[1];
827 (*a)[0] = 0;
828 (*a)[1] = 1;
829 NativeArray<int> na(*a, 2, kCopy);
830 EXPECT_NE(*a, na.begin());
831 delete[] a;
832 EXPECT_EQ(0, na.begin()[0]);
833 EXPECT_EQ(1, na.begin()[1]);
834
835 // We rely on the heap checker to verify that na deletes the copy of
836 // array.
837 }
838
839 TEST(NativeArrayTest, TypeMembersAreCorrect) {
840 StaticAssertTypeEq<char, NativeArray<char>::value_type>();
841 StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>();
842
843 StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>();
844 StaticAssertTypeEq<const bool(*)[2], NativeArray<bool[2]>::const_iterator>();
845 }
846
847 TEST(NativeArrayTest, MethodsWork) {
848 const int a[3] = { 0, 1, 2 };
849 NativeArray<int> na(a, 3, kCopy);
850 ASSERT_EQ(3U, na.size());
851 EXPECT_EQ(3, na.end() - na.begin());
852
853 NativeArray<int>::const_iterator it = na.begin();
854 EXPECT_EQ(0, *it);
855 ++it;
856 EXPECT_EQ(1, *it);
857 it++;
858 EXPECT_EQ(2, *it);
859 ++it;
860 EXPECT_EQ(na.end(), it);
861
862 EXPECT_THAT(na, Eq(na));
863
864 NativeArray<int> na2(a, 3, kReference);
865 EXPECT_THAT(na, Eq(na2));
866
867 const int b1[3] = { 0, 1, 1 };
868 const int b2[4] = { 0, 1, 2, 3 };
869 EXPECT_THAT(na, Not(Eq(NativeArray<int>(b1, 3, kReference))));
870 EXPECT_THAT(na, Not(Eq(NativeArray<int>(b2, 4, kCopy))));
871 }
872
873 TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
874 const char a[2][3] = { "hi", "lo" };
875 NativeArray<char[3]> na(a, 2, kReference);
876 ASSERT_EQ(2U, na.size());
877 EXPECT_EQ(a, na.begin());
878 }
879
880 // Tests StlContainerView. 577 // Tests StlContainerView.
881 578
882 TEST(StlContainerViewTest, WorksForStlContainer) { 579 TEST(StlContainerViewTest, WorksForStlContainer) {
883 StaticAssertTypeEq<std::vector<int>, 580 StaticAssertTypeEq<std::vector<int>,
884 StlContainerView<std::vector<int> >::type>(); 581 StlContainerView<std::vector<int> >::type>();
885 StaticAssertTypeEq<const std::vector<double>&, 582 StaticAssertTypeEq<const std::vector<double>&,
886 StlContainerView<std::vector<double> >::const_reference>(); 583 StlContainerView<std::vector<double> >::const_reference>();
887 584
888 typedef std::vector<char> Chars; 585 typedef std::vector<char> Chars;
889 Chars v1; 586 Chars v1;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 EXPECT_EQ(2, a3.begin()[2]); 643 EXPECT_EQ(2, a3.begin()[2]);
947 644
948 // Makes sure a1 and a3 aren't aliases. 645 // Makes sure a1 and a3 aren't aliases.
949 a1[0] = 3; 646 a1[0] = 3;
950 EXPECT_EQ(0, a3.begin()[0]); 647 EXPECT_EQ(0, a3.begin()[0]);
951 } 648 }
952 649
953 } // namespace 650 } // namespace
954 } // namespace internal 651 } // namespace internal
955 } // namespace testing 652 } // namespace testing
OLDNEW
« no previous file with comments | « testing/gmock/test/gmock-generated-matchers_test.cc ('k') | testing/gmock/test/gmock-matchers_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698