summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny007-MKD <Jonny007-MKD@users.noreply.github.com>2018-09-14 20:39:45 (GMT)
committerGitHub <noreply@github.com>2018-09-14 20:39:45 (GMT)
commit631e3a58389a21bec310470b7788b30dfa17a217 (patch)
tree4aee2a3d4206bf44197f60b051fd8700030dbbe3
parent1b2da360eddeb98f4ee45efabb0056cc28590760 (diff)
parentbc2d0935b74917be0821bfd834472ed9cc4a3b5b (diff)
downloadgoogletest-631e3a58389a21bec310470b7788b30dfa17a217.zip
googletest-631e3a58389a21bec310470b7788b30dfa17a217.tar.gz
googletest-631e3a58389a21bec310470b7788b30dfa17a217.tar.bz2
Merge branch 'master' into master
-rw-r--r--.travis.yml11
-rw-r--r--googlemock/include/gmock/gmock-matchers.h14
-rw-r--r--googlemock/test/gmock-matchers_test.cc39
-rw-r--r--googletest/test/gtest_unittest.cc11
4 files changed, 31 insertions, 44 deletions
diff --git a/.travis.yml b/.travis.yml
index 4e7413a..4ec239f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,25 +32,14 @@ matrix:
- os: linux
group: deprecated-2017Q4
compiler: clang
- env: BUILD_TYPE=Debug VERBOSE=1
- - os: linux
- group: deprecated-2017Q4
- compiler: clang
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
- os: linux
compiler: clang
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON
- os: osx
compiler: gcc
- env: BUILD_TYPE=Debug VERBOSE=1
- - os: osx
- compiler: gcc
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
- os: osx
- compiler: clang
- env: BUILD_TYPE=Debug VERBOSE=1
- if: type != pull_request
- - os: osx
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11
if: type != pull_request
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index a7bcfc8..fa26bf9 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -1307,9 +1307,6 @@ class StrEqualityMatcher {
#if GTEST_HAS_ABSL
bool MatchAndExplain(const absl::string_view& s,
MatchResultListener* listener) const {
- if (s.data() == NULL) {
- return !expect_eq_;
- }
// This should fail to compile if absl::string_view is used with wide
// strings.
const StringType& str = string(s);
@@ -1380,9 +1377,6 @@ class HasSubstrMatcher {
#if GTEST_HAS_ABSL
bool MatchAndExplain(const absl::string_view& s,
MatchResultListener* listener) const {
- if (s.data() == NULL) {
- return false;
- }
// This should fail to compile if absl::string_view is used with wide
// strings.
const StringType& str = string(s);
@@ -1440,9 +1434,6 @@ class StartsWithMatcher {
#if GTEST_HAS_ABSL
bool MatchAndExplain(const absl::string_view& s,
MatchResultListener* listener) const {
- if (s.data() == NULL) {
- return false;
- }
// This should fail to compile if absl::string_view is used with wide
// strings.
const StringType& str = string(s);
@@ -1499,9 +1490,6 @@ class EndsWithMatcher {
#if GTEST_HAS_ABSL
bool MatchAndExplain(const absl::string_view& s,
MatchResultListener* listener) const {
- if (s.data() == NULL) {
- return false;
- }
// This should fail to compile if absl::string_view is used with wide
// strings.
const StringType& str = string(s);
@@ -1558,7 +1546,7 @@ class MatchesRegexMatcher {
#if GTEST_HAS_ABSL
bool MatchAndExplain(const absl::string_view& s,
MatchResultListener* listener) const {
- return s.data() && MatchAndExplain(string(s), listener);
+ return MatchAndExplain(string(s), listener);
}
#endif // GTEST_HAS_ABSL
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index 4697f0b..79eb552 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -1335,6 +1335,11 @@ TEST(StrEqTest, MatchesEqualString) {
EXPECT_TRUE(m3.Matches(absl::string_view("Hello")));
EXPECT_FALSE(m3.Matches(absl::string_view("hello")));
EXPECT_FALSE(m3.Matches(absl::string_view()));
+
+ Matcher<const absl::string_view&> m_empty = StrEq("");
+ EXPECT_TRUE(m_empty.Matches(absl::string_view("")));
+ EXPECT_TRUE(m_empty.Matches(absl::string_view()));
+ EXPECT_FALSE(m_empty.Matches(absl::string_view("hello")));
#endif // GTEST_HAS_ABSL
}
@@ -1459,6 +1464,10 @@ TEST(HasSubstrTest, WorksForStringClasses) {
const Matcher<const std::string&> m2 = HasSubstr("foo");
EXPECT_TRUE(m2.Matches(std::string("I love food.")));
EXPECT_FALSE(m2.Matches(std::string("tofo")));
+
+ const Matcher<std::string> m_empty = HasSubstr("");
+ EXPECT_TRUE(m_empty.Matches(std::string()));
+ EXPECT_TRUE(m_empty.Matches(std::string("not empty")));
}
// Tests that HasSubstr() works for matching C-string-typed values.
@@ -1472,6 +1481,11 @@ TEST(HasSubstrTest, WorksForCStrings) {
EXPECT_TRUE(m2.Matches("I love food."));
EXPECT_FALSE(m2.Matches("tofo"));
EXPECT_FALSE(m2.Matches(NULL));
+
+ const Matcher<const char*> m_empty = HasSubstr("");
+ EXPECT_TRUE(m_empty.Matches("not empty"));
+ EXPECT_TRUE(m_empty.Matches(""));
+ EXPECT_FALSE(m_empty.Matches(NULL));
}
#if GTEST_HAS_ABSL
@@ -1489,7 +1503,8 @@ TEST(HasSubstrTest, WorksForStringViewClasses) {
const Matcher<const absl::string_view&> m3 = HasSubstr("");
EXPECT_TRUE(m3.Matches(absl::string_view("foo")));
- EXPECT_FALSE(m3.Matches(absl::string_view()));
+ EXPECT_TRUE(m3.Matches(absl::string_view("")));
+ EXPECT_TRUE(m3.Matches(absl::string_view()));
}
#endif // GTEST_HAS_ABSL
@@ -1713,6 +1728,13 @@ TEST(StartsWithTest, MatchesStringWithGivenPrefix) {
EXPECT_TRUE(m2.Matches("High"));
EXPECT_FALSE(m2.Matches("H"));
EXPECT_FALSE(m2.Matches(" Hi"));
+
+#if GTEST_HAS_ABSL
+ const Matcher<absl::string_view> m_empty = StartsWith("");
+ EXPECT_TRUE(m_empty.Matches(absl::string_view()));
+ EXPECT_TRUE(m_empty.Matches(absl::string_view("")));
+ EXPECT_TRUE(m_empty.Matches(absl::string_view("not empty")));
+#endif // GTEST_HAS_ABSL
}
TEST(StartsWithTest, CanDescribeSelf) {
@@ -1748,9 +1770,8 @@ TEST(EndsWithTest, MatchesStringWithGivenSuffix) {
const Matcher<const absl::string_view&> m4 = EndsWith("");
EXPECT_TRUE(m4.Matches("Hi"));
EXPECT_TRUE(m4.Matches(""));
- // Default-constructed absl::string_view should not match anything, in order
- // to distinguish it from an empty string.
- EXPECT_FALSE(m4.Matches(absl::string_view()));
+ EXPECT_TRUE(m4.Matches(absl::string_view()));
+ EXPECT_TRUE(m4.Matches(absl::string_view("")));
#endif // GTEST_HAS_ABSL
}
@@ -1777,11 +1798,10 @@ TEST(MatchesRegexTest, MatchesStringMatchingGivenRegex) {
EXPECT_TRUE(m3.Matches(absl::string_view("az")));
EXPECT_TRUE(m3.Matches(absl::string_view("abcz")));
EXPECT_FALSE(m3.Matches(absl::string_view("1az")));
- // Default-constructed absl::string_view should not match anything, in order
- // to distinguish it from an empty string.
EXPECT_FALSE(m3.Matches(absl::string_view()));
const Matcher<const absl::string_view&> m4 = MatchesRegex("");
- EXPECT_FALSE(m4.Matches(absl::string_view()));
+ EXPECT_TRUE(m4.Matches(absl::string_view("")));
+ EXPECT_TRUE(m4.Matches(absl::string_view()));
#endif // GTEST_HAS_ABSL
}
@@ -1816,11 +1836,10 @@ TEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {
EXPECT_TRUE(m3.Matches(absl::string_view("azbz")));
EXPECT_TRUE(m3.Matches(absl::string_view("az1")));
EXPECT_FALSE(m3.Matches(absl::string_view("1a")));
- // Default-constructed absl::string_view should not match anything, in order
- // to distinguish it from an empty string.
EXPECT_FALSE(m3.Matches(absl::string_view()));
const Matcher<const absl::string_view&> m4 = ContainsRegex("");
- EXPECT_FALSE(m4.Matches(absl::string_view()));
+ EXPECT_TRUE(m4.Matches(absl::string_view("")));
+ EXPECT_TRUE(m4.Matches(absl::string_view()));
#endif // GTEST_HAS_ABSL
}
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index de19449..bd1117b 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -63,9 +63,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <map>
#include <vector>
#include <ostream>
-#if GTEST_LANG_CXX11
#include <unordered_set>
-#endif // GTEST_LANG_CXX11
#include "gtest/gtest-spi.h"
#include "src/gtest-internal-inl.h"
@@ -5165,8 +5163,7 @@ TEST(AssertionResultTest, CanStreamOstreamManipulators) {
EXPECT_STREQ("Data\n\\0Will be visible", r.message());
}
-// The next test uses explicit conversion operators -- a C++11 feature.
-#if GTEST_LANG_CXX11
+// The next test uses explicit conversion operators
TEST(AssertionResultTest, ConstructibleFromContextuallyConvertibleToBool) {
struct ExplicitlyConvertibleToBool {
@@ -5179,8 +5176,6 @@ TEST(AssertionResultTest, ConstructibleFromContextuallyConvertibleToBool) {
EXPECT_TRUE(v2);
}
-#endif // GTEST_LANG_CXX11
-
struct ConvertibleToAssertionResult {
operator AssertionResult() const { return AssertionResult(true); }
};
@@ -7564,7 +7559,6 @@ TEST(IsContainerTestTest, WorksForContainer) {
sizeof(IsContainerTest<std::map<int, double> >(0)));
}
-#if GTEST_LANG_CXX11
struct ConstOnlyContainerWithPointerIterator {
using const_iterator = int*;
const_iterator begin() const;
@@ -7586,7 +7580,6 @@ TEST(IsContainerTestTest, ConstOnlyContainer) {
EXPECT_EQ(sizeof(IsContainer),
sizeof(IsContainerTest<ConstOnlyContainerWithClassIterator>(0)));
}
-#endif // GTEST_LANG_CXX11
// Tests IsHashTable.
struct AHashTable {
@@ -7599,10 +7592,8 @@ struct NotReallyAHashTable {
TEST(IsHashTable, Basic) {
EXPECT_TRUE(testing::internal::IsHashTable<AHashTable>::value);
EXPECT_FALSE(testing::internal::IsHashTable<NotReallyAHashTable>::value);
-#if GTEST_LANG_CXX11
EXPECT_FALSE(testing::internal::IsHashTable<std::vector<int>>::value);
EXPECT_TRUE(testing::internal::IsHashTable<std::unordered_set<int>>::value);
-#endif // GTEST_LANG_CXX11
#if GTEST_HAS_HASH_SET_
EXPECT_TRUE(testing::internal::IsHashTable<__gnu_cxx::hash_set<int>>::value);
#endif // GTEST_HAS_HASH_SET_