aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gmock-internal-utils_test.cc37
-rw-r--r--test/gmock-nice-strict_test.cc29
-rw-r--r--test/gmock-printers_test.cc8
3 files changed, 44 insertions, 30 deletions
diff --git a/test/gmock-internal-utils_test.cc b/test/gmock-internal-utils_test.cc
index 4867e119..d3a16ad3 100644
--- a/test/gmock-internal-utils_test.cc
+++ b/test/gmock-internal-utils_test.cc
@@ -815,34 +815,19 @@ TEST(CopyArrayTest, WorksForTwoDimensionalArrays) {
// Tests NativeArray.
-TEST(NativeArrayTest, ConstructorFromArrayReferenceWorks) {
+TEST(NativeArrayTest, ConstructorFromArrayWorks) {
const int a[3] = { 0, 1, 2 };
- NativeArray<int> na(a, kReference);
+ NativeArray<int> na(a, 3, kReference);
EXPECT_EQ(3, na.size());
EXPECT_EQ(a, na.begin());
}
-TEST(NativeArrayTest, ConstructorFromTupleWorks) {
- int a[3] = { 0, 1, 2 };
- int* const p = a;
- // Tests with a plain pointer.
- NativeArray<int> na(make_tuple(p, 3U), kReference);
- EXPECT_EQ(a, na.begin());
-
- const linked_ptr<char> b(new char);
- *b = 'a';
- // Tests with a smart pointer.
- NativeArray<char> nb(make_tuple(b, 1), kCopy);
- EXPECT_NE(b.get(), nb.begin());
- EXPECT_EQ('a', nb.begin()[0]);
-}
-
TEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) {
typedef int Array[2];
Array* a = new Array[1];
(*a)[0] = 0;
(*a)[1] = 1;
- NativeArray<int> na(*a, kCopy);
+ NativeArray<int> na(*a, 2, kCopy);
EXPECT_NE(*a, na.begin());
delete[] a;
EXPECT_EQ(0, na.begin()[0]);
@@ -861,8 +846,8 @@ TEST(NativeArrayTest, TypeMembersAreCorrect) {
}
TEST(NativeArrayTest, MethodsWork) {
- const int a[] = { 0, 1, 2 };
- NativeArray<int> na(a, kCopy);
+ const int a[3] = { 0, 1, 2 };
+ NativeArray<int> na(a, 3, kCopy);
ASSERT_EQ(3, na.size());
EXPECT_EQ(3, na.end() - na.begin());
@@ -877,18 +862,18 @@ TEST(NativeArrayTest, MethodsWork) {
EXPECT_THAT(na, Eq(na));
- NativeArray<int> na2(a, kReference);
+ NativeArray<int> na2(a, 3, kReference);
EXPECT_THAT(na, Eq(na2));
- const int b1[] = { 0, 1, 1 };
- const int b2[] = { 0, 1, 2, 3 };
- EXPECT_THAT(na, Not(Eq(NativeArray<int>(b1, kReference))));
- EXPECT_THAT(na, Not(Eq(NativeArray<int>(b2, kCopy))));
+ const int b1[3] = { 0, 1, 1 };
+ const int b2[4] = { 0, 1, 2, 3 };
+ EXPECT_THAT(na, Not(Eq(NativeArray<int>(b1, 3, kReference))));
+ EXPECT_THAT(na, Not(Eq(NativeArray<int>(b2, 4, kCopy))));
}
TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
const char a[2][3] = { "hi", "lo" };
- NativeArray<char[3]> na(a, kReference);
+ NativeArray<char[3]> na(a, 2, kReference);
ASSERT_EQ(2, na.size());
EXPECT_EQ(a, na.begin());
}
diff --git a/test/gmock-nice-strict_test.cc b/test/gmock-nice-strict_test.cc
index 955961c5..15984a55 100644
--- a/test/gmock-nice-strict_test.cc
+++ b/test/gmock-nice-strict_test.cc
@@ -36,6 +36,13 @@
#include <gtest/gtest.h>
#include <gtest/gtest-spi.h>
+// This must not be defined inside the ::testing namespace, or it will
+// clash with ::testing::Mock.
+class Mock {
+ public:
+ MOCK_METHOD0(DoThis, void());
+};
+
namespace testing {
namespace gmock_nice_strict_test {
@@ -166,6 +173,17 @@ TEST(NiceMockTest, NonDefaultConstructor10) {
nice_bar.That(5, true);
}
+// Tests that NiceMock<Mock> compiles where Mock is a user-defined
+// class (as opposed to ::testing::Mock). We had to workaround an
+// MSVC 8.0 bug that caused the symbol Mock used in the definition of
+// NiceMock to be looked up in the wrong context, and this test
+// ensures that our fix works.
+TEST(NiceMockTest, AcceptsClassNamedMock) {
+ NiceMock< ::Mock> nice;
+ EXPECT_CALL(nice, DoThis());
+ nice.DoThis();
+}
+
// Tests that a strict mock allows expected calls.
TEST(StrictMockTest, AllowsExpectedCall) {
StrictMock<MockFoo> strict_foo;
@@ -224,5 +242,16 @@ TEST(StrictMockTest, NonDefaultConstructor10) {
"Uninteresting mock function call");
}
+// Tests that StrictMock<Mock> compiles where Mock is a user-defined
+// class (as opposed to ::testing::Mock). We had to workaround an
+// MSVC 8.0 bug that caused the symbol Mock used in the definition of
+// StrictMock to be looked up in the wrong context, and this test
+// ensures that our fix works.
+TEST(StrictMockTest, AcceptsClassNamedMock) {
+ StrictMock< ::Mock> nice;
+ EXPECT_CALL(nice, DoThis());
+ nice.DoThis();
+}
+
} // namespace gmock_nice_strict_test
} // namespace testing
diff --git a/test/gmock-printers_test.cc b/test/gmock-printers_test.cc
index af2e83c0..0eb8e094 100644
--- a/test/gmock-printers_test.cc
+++ b/test/gmock-printers_test.cc
@@ -790,14 +790,14 @@ TEST(PrintStlContainerTest, NestedContainer) {
}
TEST(PrintStlContainerTest, OneDimensionalNativeArray) {
- const int a[] = { 1, 2, 3 };
- NativeArray<int> b(a, kReference);
+ const int a[3] = { 1, 2, 3 };
+ NativeArray<int> b(a, 3, kReference);
EXPECT_EQ("{ 1, 2, 3 }", Print(b));
}
TEST(PrintStlContainerTest, TwoDimensionalNativeArray) {
- const int a[][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
- NativeArray<int[3]> b(a, kReference);
+ const int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
+ NativeArray<int[3]> b(a, 2, kReference);
EXPECT_EQ("{ { 1, 2, 3 }, { 4, 5, 6 } }", Print(b));
}