summaryrefslogtreecommitdiffstats
path: root/googlemock/test
diff options
context:
space:
mode:
authorTanzinul Islam <t_17_7@hotmail.com>2018-08-01 21:48:05 (GMT)
committerTanzinul Islam <t_17_7@hotmail.com>2018-08-01 21:48:05 (GMT)
commit1cd979a80701a6c8c370f3a69048ba5cbec62a28 (patch)
tree5358fa1f0e6726c0b9a77b985d26f7b431b663b9 /googlemock/test
parent3280099951c51b7d2745bd840f2dd9d967cffcda (diff)
parente5e2ef7cd27cc089c1d8302a11970ef870554294 (diff)
downloadgoogletest-1cd979a80701a6c8c370f3a69048ba5cbec62a28.zip
googletest-1cd979a80701a6c8c370f3a69048ba5cbec62a28.tar.gz
googletest-1cd979a80701a6c8c370f3a69048ba5cbec62a28.tar.bz2
Merge branch 'master' into fix_death_test_child_mingw_wer_issue1116
Diffstat (limited to 'googlemock/test')
-rw-r--r--googlemock/test/gmock-actions_test.cc202
-rw-r--r--googlemock/test/gmock-matchers_test.cc33
-rw-r--r--googlemock/test/gmock_ex_test.cc6
-rwxr-xr-xgooglemock/test/gmock_leak_test.py2
-rw-r--r--googlemock/test/gmock_link2_test.cc2
-rw-r--r--googlemock/test/gmock_link_test.cc2
-rwxr-xr-xgooglemock/test/gmock_output_test.py1
-rw-r--r--googlemock/test/gmock_stress_test.cc3
-rwxr-xr-xgooglemock/test/gmock_test_utils.py2
9 files changed, 33 insertions, 220 deletions
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index 7fbb50d..e8bdbee 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -88,10 +88,6 @@ using testing::tuple_element;
using testing::SetErrnoAndReturn;
#endif
-#if GTEST_HAS_PROTOBUF_
-using testing::internal::TestMessage;
-#endif // GTEST_HAS_PROTOBUF_
-
// Tests that BuiltInDefaultValue<T*>::Get() returns NULL.
TEST(BuiltInDefaultValueTest, IsNullForPointerTypes) {
EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL);
@@ -895,105 +891,6 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
# endif
}
-#if GTEST_HAS_PROTOBUF_
-
-// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
-// variable pointed to by the N-th (0-based) argument to proto_buffer.
-TEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferType) {
- TestMessage* const msg = new TestMessage;
- msg->set_member("yes");
- TestMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, TestMessage*)> a = SetArgPointee<1>(*msg);
- // SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
- // s.t. the action works even when the original proto_buffer has
- // died. We ensure this behavior by deleting msg before using the
- // action.
- delete msg;
-
- TestMessage dest;
- EXPECT_FALSE(orig_msg.Equals(dest));
- a.Perform(make_tuple(true, &dest));
- EXPECT_TRUE(orig_msg.Equals(dest));
-}
-
-// Tests that SetArgPointee<N>(proto_buffer) sets the
-// ::ProtocolMessage variable pointed to by the N-th (0-based)
-// argument to proto_buffer.
-TEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {
- TestMessage* const msg = new TestMessage;
- msg->set_member("yes");
- TestMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, ::ProtocolMessage*)> a = SetArgPointee<1>(*msg);
- // SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
- // s.t. the action works even when the original proto_buffer has
- // died. We ensure this behavior by deleting msg before using the
- // action.
- delete msg;
-
- TestMessage dest;
- ::ProtocolMessage* const dest_base = &dest;
- EXPECT_FALSE(orig_msg.Equals(dest));
- a.Perform(make_tuple(true, dest_base));
- EXPECT_TRUE(orig_msg.Equals(dest));
-}
-
-// Tests that SetArgPointee<N>(proto2_buffer) sets the v2
-// protobuf variable pointed to by the N-th (0-based) argument to
-// proto2_buffer.
-TEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferType) {
- using testing::internal::FooMessage;
- FooMessage* const msg = new FooMessage;
- msg->set_int_field(2);
- msg->set_string_field("hi");
- FooMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, FooMessage*)> a = SetArgPointee<1>(*msg);
- // SetArgPointee<N>(proto2_buffer) makes a copy of
- // proto2_buffer s.t. the action works even when the original
- // proto2_buffer has died. We ensure this behavior by deleting msg
- // before using the action.
- delete msg;
-
- FooMessage dest;
- dest.set_int_field(0);
- a.Perform(make_tuple(true, &dest));
- EXPECT_EQ(2, dest.int_field());
- EXPECT_EQ("hi", dest.string_field());
-}
-
-// Tests that SetArgPointee<N>(proto2_buffer) sets the
-// proto2::Message variable pointed to by the N-th (0-based) argument
-// to proto2_buffer.
-TEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {
- using testing::internal::FooMessage;
- FooMessage* const msg = new FooMessage;
- msg->set_int_field(2);
- msg->set_string_field("hi");
- FooMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, ::proto2::Message*)> a = SetArgPointee<1>(*msg);
- // SetArgPointee<N>(proto2_buffer) makes a copy of
- // proto2_buffer s.t. the action works even when the original
- // proto2_buffer has died. We ensure this behavior by deleting msg
- // before using the action.
- delete msg;
-
- FooMessage dest;
- dest.set_int_field(0);
- ::proto2::Message* const dest_base = &dest;
- a.Perform(make_tuple(true, dest_base));
- EXPECT_EQ(2, dest.int_field());
- EXPECT_EQ("hi", dest.string_field());
-}
-
-#endif // GTEST_HAS_PROTOBUF_
-
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
// the N-th (0-based) argument to v.
TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
@@ -1014,105 +911,6 @@ TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
EXPECT_EQ('a', ch);
}
-#if GTEST_HAS_PROTOBUF_
-
-// Tests that SetArgumentPointee<N>(proto_buffer) sets the v1 protobuf
-// variable pointed to by the N-th (0-based) argument to proto_buffer.
-TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferType) {
- TestMessage* const msg = new TestMessage;
- msg->set_member("yes");
- TestMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, TestMessage*)> a = SetArgumentPointee<1>(*msg);
- // SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer
- // s.t. the action works even when the original proto_buffer has
- // died. We ensure this behavior by deleting msg before using the
- // action.
- delete msg;
-
- TestMessage dest;
- EXPECT_FALSE(orig_msg.Equals(dest));
- a.Perform(make_tuple(true, &dest));
- EXPECT_TRUE(orig_msg.Equals(dest));
-}
-
-// Tests that SetArgumentPointee<N>(proto_buffer) sets the
-// ::ProtocolMessage variable pointed to by the N-th (0-based)
-// argument to proto_buffer.
-TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {
- TestMessage* const msg = new TestMessage;
- msg->set_member("yes");
- TestMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, ::ProtocolMessage*)> a = SetArgumentPointee<1>(*msg);
- // SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer
- // s.t. the action works even when the original proto_buffer has
- // died. We ensure this behavior by deleting msg before using the
- // action.
- delete msg;
-
- TestMessage dest;
- ::ProtocolMessage* const dest_base = &dest;
- EXPECT_FALSE(orig_msg.Equals(dest));
- a.Perform(make_tuple(true, dest_base));
- EXPECT_TRUE(orig_msg.Equals(dest));
-}
-
-// Tests that SetArgumentPointee<N>(proto2_buffer) sets the v2
-// protobuf variable pointed to by the N-th (0-based) argument to
-// proto2_buffer.
-TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferType) {
- using testing::internal::FooMessage;
- FooMessage* const msg = new FooMessage;
- msg->set_int_field(2);
- msg->set_string_field("hi");
- FooMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, FooMessage*)> a = SetArgumentPointee<1>(*msg);
- // SetArgumentPointee<N>(proto2_buffer) makes a copy of
- // proto2_buffer s.t. the action works even when the original
- // proto2_buffer has died. We ensure this behavior by deleting msg
- // before using the action.
- delete msg;
-
- FooMessage dest;
- dest.set_int_field(0);
- a.Perform(make_tuple(true, &dest));
- EXPECT_EQ(2, dest.int_field());
- EXPECT_EQ("hi", dest.string_field());
-}
-
-// Tests that SetArgumentPointee<N>(proto2_buffer) sets the
-// proto2::Message variable pointed to by the N-th (0-based) argument
-// to proto2_buffer.
-TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {
- using testing::internal::FooMessage;
- FooMessage* const msg = new FooMessage;
- msg->set_int_field(2);
- msg->set_string_field("hi");
- FooMessage orig_msg;
- orig_msg.CopyFrom(*msg);
-
- Action<void(bool, ::proto2::Message*)> a = SetArgumentPointee<1>(*msg);
- // SetArgumentPointee<N>(proto2_buffer) makes a copy of
- // proto2_buffer s.t. the action works even when the original
- // proto2_buffer has died. We ensure this behavior by deleting msg
- // before using the action.
- delete msg;
-
- FooMessage dest;
- dest.set_int_field(0);
- ::proto2::Message* const dest_base = &dest;
- a.Perform(make_tuple(true, dest_base));
- EXPECT_EQ(2, dest.int_field());
- EXPECT_EQ("hi", dest.string_field());
-}
-
-#endif // GTEST_HAS_PROTOBUF_
-
// Sample functions and functors for testing Invoke() and etc.
int Nullary() { return 1; }
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index b422465..9f1a547 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
}
// Helper to allow easy testing of AnyOf matchers with num parameters.
-void AnyOfMatches(int num, const Matcher<int>& m) {
+static void AnyOfMatches(int num, const Matcher<int>& m) {
SCOPED_TRACE(Describe(m));
EXPECT_FALSE(m.Matches(0));
for (int i = 1; i <= num; ++i) {
@@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
EXPECT_FALSE(m.Matches(num + 1));
}
+#if GTEST_LANG_CXX11
+static void AnyOfStringMatches(int num, const Matcher<std::string>& m) {
+ SCOPED_TRACE(Describe(m));
+ EXPECT_FALSE(m.Matches(std::to_string(0)));
+
+ for (int i = 1; i <= num; ++i) {
+ EXPECT_TRUE(m.Matches(std::to_string(i)));
+ }
+ EXPECT_FALSE(m.Matches(std::to_string(num + 1)));
+}
+#endif
+
// Tests that AnyOf(m1, ..., mn) matches any value that matches at
// least one of the given matchers.
TEST(AnyOfTest, MatchesWhenAnyMatches) {
@@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
+ AnyOfStringMatches(
+ 50, AnyOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
+ "13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
+ "23", "24", "25", "26", "27", "28", "29", "30", "31", "32",
+ "33", "34", "35", "36", "37", "38", "39", "40", "41", "42",
+ "43", "44", "45", "46", "47", "48", "49", "50"));
}
// Tests the variadic version of the ElementsAreMatcher
@@ -3704,6 +3722,7 @@ MATCHER_P(FieldIIs, inner_matcher, "") {
return ExplainMatchResult(inner_matcher, arg.i, result_listener);
}
+#if GTEST_HAS_RTTI
TEST(WhenDynamicCastToTest, SameType) {
Derived derived;
derived.i = 4;
@@ -3761,12 +3780,8 @@ TEST(WhenDynamicCastToTest, AmbiguousCast) {
TEST(WhenDynamicCastToTest, Describe) {
Matcher<Base*> matcher = WhenDynamicCastTo<Derived*>(Pointee(_));
-#if GTEST_HAS_RTTI
const std::string prefix =
"when dynamic_cast to " + internal::GetTypeName<Derived*>() + ", ";
-#else // GTEST_HAS_RTTI
- const std::string prefix = "when dynamic_cast, ";
-#endif // GTEST_HAS_RTTI
EXPECT_EQ(prefix + "points to a value that is anything", Describe(matcher));
EXPECT_EQ(prefix + "does not point to a value that is anything",
DescribeNegation(matcher));
@@ -3799,6 +3814,7 @@ TEST(WhenDynamicCastToTest, BadReference) {
Base& as_base_ref = derived;
EXPECT_THAT(as_base_ref, Not(WhenDynamicCastTo<const OtherDerived&>(_)));
}
+#endif // GTEST_HAS_RTTI
// Minimal const-propagating pointer.
template <typename T>
@@ -4222,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) {
// ref-qualified.
TEST(PropertyTest, WorksForRefQualifiedProperty) {
Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi"));
+ Matcher<const AClass&> m_with_name =
+ Property("s", &AClass::s_ref, StartsWith("hi"));
AClass a;
a.set_s("hill");
EXPECT_TRUE(m.Matches(a));
+ EXPECT_TRUE(m_with_name.Matches(a));
a.set_s("hole");
EXPECT_FALSE(m.Matches(a));
+ EXPECT_FALSE(m_with_name.Matches(a));
}
#endif
@@ -4572,7 +4592,7 @@ TEST(ResultOfTest, WorksForFunctors) {
}
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
-// functor with more then one operator() defined. ResultOf() must work
+// functor with more than one operator() defined. ResultOf() must work
// for each defined operator().
struct PolymorphicFunctor {
typedef int result_type;
@@ -6766,4 +6786,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
} // namespace gmock_matchers_test
} // namespace testing
-
diff --git a/googlemock/test/gmock_ex_test.cc b/googlemock/test/gmock_ex_test.cc
index 3afed86..b03de82 100644
--- a/googlemock/test/gmock_ex_test.cc
+++ b/googlemock/test/gmock_ex_test.cc
@@ -34,9 +34,11 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#if GTEST_HAS_EXCEPTIONS
namespace {
using testing::HasSubstr;
+
using testing::internal::GoogleTestFailureException;
// A type that cannot be default constructed.
@@ -52,8 +54,6 @@ class MockFoo {
MOCK_METHOD0(GetNonDefaultConstructible, NonDefaultConstructible());
};
-#if GTEST_HAS_EXCEPTIONS
-
TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
MockFoo mock;
try {
@@ -76,6 +76,6 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
}
}
-#endif
} // unnamed namespace
+#endif
diff --git a/googlemock/test/gmock_leak_test.py b/googlemock/test/gmock_leak_test.py
index 997680c..a2fee4b 100755
--- a/googlemock/test/gmock_leak_test.py
+++ b/googlemock/test/gmock_leak_test.py
@@ -33,10 +33,8 @@
__author__ = 'wan@google.com (Zhanyong Wan)'
-
import gmock_test_utils
-
PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_leak_test_')
TEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']
TEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*']
diff --git a/googlemock/test/gmock_link2_test.cc b/googlemock/test/gmock_link2_test.cc
index 4c310c3..2b48395 100644
--- a/googlemock/test/gmock_link2_test.cc
+++ b/googlemock/test/gmock_link2_test.cc
@@ -37,4 +37,4 @@
#define LinkTest LinkTest2
-#include "test/gmock_link_test.h"
+#include "test/gmock_link_test.h"
diff --git a/googlemock/test/gmock_link_test.cc b/googlemock/test/gmock_link_test.cc
index 61e97d1..ef041be 100644
--- a/googlemock/test/gmock_link_test.cc
+++ b/googlemock/test/gmock_link_test.cc
@@ -37,4 +37,4 @@
#define LinkTest LinkTest1
-#include "test/gmock_link_test.h"
+#include "test/gmock_link_test.h"
diff --git a/googlemock/test/gmock_output_test.py b/googlemock/test/gmock_output_test.py
index 9d73d57..8f57d46 100755
--- a/googlemock/test/gmock_output_test.py
+++ b/googlemock/test/gmock_output_test.py
@@ -43,7 +43,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import os
import re
import sys
-
import gmock_test_utils
diff --git a/googlemock/test/gmock_stress_test.cc b/googlemock/test/gmock_stress_test.cc
index b9fdc45..e4e61f0 100644
--- a/googlemock/test/gmock_stress_test.cc
+++ b/googlemock/test/gmock_stress_test.cc
@@ -33,13 +33,12 @@
// threads concurrently.
#include "gmock/gmock.h"
-
#include "gtest/gtest.h"
namespace testing {
namespace {
-// From "gtest/internal/gtest-port.h".
+// From gtest-port.h.
using ::testing::internal::ThreadWithParam;
// The maximum number of test threads (not including helper threads)
diff --git a/googlemock/test/gmock_test_utils.py b/googlemock/test/gmock_test_utils.py
index b513000..92b1ac1 100755
--- a/googlemock/test/gmock_test_utils.py
+++ b/googlemock/test/gmock_test_utils.py
@@ -38,7 +38,7 @@ import sys
SCRIPT_DIR = os.path.dirname(__file__) or '.'
# isdir resolves symbolic links.
-gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../googletest/test')
+gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../../googletest/test')
if os.path.isdir(gtest_tests_util_dir):
GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir
else: