Merge branch 'master' into fix-printers
This commit is contained in:
commit
823f139bc7
|
@ -3614,10 +3614,6 @@ BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond(
|
||||||
return BoundSecondMatcher<Tuple2Matcher, Second>(tm, second);
|
return BoundSecondMatcher<Tuple2Matcher, Second>(tm, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joins a vector of strings as if they are fields of a tuple; returns
|
|
||||||
// the joined string. This function is exported for testing.
|
|
||||||
GTEST_API_ string JoinAsTuple(const Strings& fields);
|
|
||||||
|
|
||||||
// Returns the description for a matcher defined using the MATCHER*()
|
// Returns the description for a matcher defined using the MATCHER*()
|
||||||
// macro where the user-supplied description string is "", if
|
// macro where the user-supplied description string is "", if
|
||||||
// 'negation' is false; otherwise returns the description of the
|
// 'negation' is false; otherwise returns the description of the
|
||||||
|
|
|
@ -47,6 +47,25 @@
|
||||||
namespace testing {
|
namespace testing {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
// Joins a vector of strings as if they are fields of a tuple; returns
|
||||||
|
// the joined string.
|
||||||
|
GTEST_API_ std::string JoinAsTuple(const Strings& fields) {
|
||||||
|
switch (fields.size()) {
|
||||||
|
case 0:
|
||||||
|
return "";
|
||||||
|
case 1:
|
||||||
|
return fields[0];
|
||||||
|
default:
|
||||||
|
std::string result = "(" + fields[0];
|
||||||
|
for (size_t i = 1; i < fields.size(); i++) {
|
||||||
|
result += ", ";
|
||||||
|
result += fields[i];
|
||||||
|
}
|
||||||
|
result += ")";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Converts an identifier name to a space-separated list of lower-case
|
// Converts an identifier name to a space-separated list of lower-case
|
||||||
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
|
// words. Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
|
||||||
// treated as one word. For example, both "FooBar123" and
|
// treated as one word. For example, both "FooBar123" and
|
||||||
|
|
|
@ -100,25 +100,6 @@ Matcher<StringPiece>::Matcher(StringPiece s) {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Joins a vector of strings as if they are fields of a tuple; returns
|
|
||||||
// the joined string.
|
|
||||||
GTEST_API_ string JoinAsTuple(const Strings& fields) {
|
|
||||||
switch (fields.size()) {
|
|
||||||
case 0:
|
|
||||||
return "";
|
|
||||||
case 1:
|
|
||||||
return fields[0];
|
|
||||||
default:
|
|
||||||
string result = "(" + fields[0];
|
|
||||||
for (size_t i = 1; i < fields.size(); i++) {
|
|
||||||
result += ", ";
|
|
||||||
result += fields[i];
|
|
||||||
}
|
|
||||||
result += ")";
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the description for a matcher defined using the MATCHER*()
|
// Returns the description for a matcher defined using the MATCHER*()
|
||||||
// macro where the user-supplied description string is "", if
|
// macro where the user-supplied description string is "", if
|
||||||
// 'negation' is false; otherwise returns the description of the
|
// 'negation' is false; otherwise returns the description of the
|
||||||
|
|
|
@ -146,7 +146,6 @@ using testing::internal::ExplainMatchFailureTupleTo;
|
||||||
using testing::internal::FloatingEqMatcher;
|
using testing::internal::FloatingEqMatcher;
|
||||||
using testing::internal::FormatMatcherDescription;
|
using testing::internal::FormatMatcherDescription;
|
||||||
using testing::internal::IsReadableTypeName;
|
using testing::internal::IsReadableTypeName;
|
||||||
using testing::internal::JoinAsTuple;
|
|
||||||
using testing::internal::linked_ptr;
|
using testing::internal::linked_ptr;
|
||||||
using testing::internal::MatchMatrix;
|
using testing::internal::MatchMatrix;
|
||||||
using testing::internal::RE;
|
using testing::internal::RE;
|
||||||
|
@ -5268,28 +5267,6 @@ TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
|
||||||
EXPECT_FALSE(IsReadableTypeName("void (&)(int, bool, char, float)"));
|
EXPECT_FALSE(IsReadableTypeName("void (&)(int, bool, char, float)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests JoinAsTuple().
|
|
||||||
|
|
||||||
TEST(JoinAsTupleTest, JoinsEmptyTuple) {
|
|
||||||
EXPECT_EQ("", JoinAsTuple(Strings()));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(JoinAsTupleTest, JoinsOneTuple) {
|
|
||||||
const char* fields[] = {"1"};
|
|
||||||
EXPECT_EQ("1", JoinAsTuple(Strings(fields, fields + 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(JoinAsTupleTest, JoinsTwoTuple) {
|
|
||||||
const char* fields[] = {"1", "a"};
|
|
||||||
EXPECT_EQ("(1, a)", JoinAsTuple(Strings(fields, fields + 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(JoinAsTupleTest, JoinsTenTuple) {
|
|
||||||
const char* fields[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
|
|
||||||
EXPECT_EQ("(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)",
|
|
||||||
JoinAsTuple(Strings(fields, fields + 10)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tests FormatMatcherDescription().
|
// Tests FormatMatcherDescription().
|
||||||
|
|
||||||
TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {
|
TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
# include <string>
|
# include <string>
|
||||||
# include <vector>
|
# include <vector>
|
||||||
# include "src/gtest-internal-inl.h" // for UnitTestOptions
|
|
||||||
|
|
||||||
|
# include "src/gtest-internal-inl.h" // for UnitTestOptions
|
||||||
# include "test/gtest-param-test_test.h"
|
# include "test/gtest-param-test_test.h"
|
||||||
|
|
||||||
using ::std::vector;
|
using ::std::vector;
|
||||||
|
@ -536,6 +536,51 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
|
||||||
VerifyGenerator(gen, expected_values);
|
VerifyGenerator(gen, expected_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GTEST_LANG_CXX11
|
||||||
|
|
||||||
|
class NonDefaultConstructAssignString {
|
||||||
|
public:
|
||||||
|
NonDefaultConstructAssignString(const std::string& s) : str_(s) {}
|
||||||
|
|
||||||
|
const std::string& str() const { return str_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string str_;
|
||||||
|
|
||||||
|
// Not default constructible
|
||||||
|
NonDefaultConstructAssignString();
|
||||||
|
// Not assignable
|
||||||
|
void operator=(const NonDefaultConstructAssignString&);
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(CombineTest, NonDefaultConstructAssign) {
|
||||||
|
const ParamGenerator<tuple<int, NonDefaultConstructAssignString> > gen =
|
||||||
|
Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"),
|
||||||
|
NonDefaultConstructAssignString("B")));
|
||||||
|
|
||||||
|
ParamGenerator<tuple<int, NonDefaultConstructAssignString> >::iterator it =
|
||||||
|
gen.begin();
|
||||||
|
|
||||||
|
EXPECT_EQ(0, std::get<0>(*it));
|
||||||
|
EXPECT_EQ("A", std::get<1>(*it).str());
|
||||||
|
++it;
|
||||||
|
|
||||||
|
EXPECT_EQ(0, std::get<0>(*it));
|
||||||
|
EXPECT_EQ("B", std::get<1>(*it).str());
|
||||||
|
++it;
|
||||||
|
|
||||||
|
EXPECT_EQ(1, std::get<0>(*it));
|
||||||
|
EXPECT_EQ("A", std::get<1>(*it).str());
|
||||||
|
++it;
|
||||||
|
|
||||||
|
EXPECT_EQ(1, std::get<0>(*it));
|
||||||
|
EXPECT_EQ("B", std::get<1>(*it).str());
|
||||||
|
++it;
|
||||||
|
|
||||||
|
EXPECT_TRUE(it == gen.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GTEST_LANG_CXX11
|
||||||
# endif // GTEST_HAS_COMBINE
|
# endif // GTEST_HAS_COMBINE
|
||||||
|
|
||||||
// Tests that an generator produces correct sequence after being
|
// Tests that an generator produces correct sequence after being
|
||||||
|
@ -811,8 +856,8 @@ class CustomFunctorNamingTest : public TestWithParam<std::string> {};
|
||||||
TEST_P(CustomFunctorNamingTest, CustomTestNames) {}
|
TEST_P(CustomFunctorNamingTest, CustomTestNames) {}
|
||||||
|
|
||||||
struct CustomParamNameFunctor {
|
struct CustomParamNameFunctor {
|
||||||
std::string operator()(const ::testing::TestParamInfo<std::string>& info) {
|
std::string operator()(const ::testing::TestParamInfo<std::string>& inf) {
|
||||||
return info.param;
|
return inf.param;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -829,8 +874,8 @@ INSTANTIATE_TEST_CASE_P(AllAllowedCharacters,
|
||||||
CustomParamNameFunctor());
|
CustomParamNameFunctor());
|
||||||
|
|
||||||
inline std::string CustomParamNameFunction(
|
inline std::string CustomParamNameFunction(
|
||||||
const ::testing::TestParamInfo<std::string>& info) {
|
const ::testing::TestParamInfo<std::string>& inf) {
|
||||||
return info.param;
|
return inf.param;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomFunctionNamingTest : public TestWithParam<std::string> {};
|
class CustomFunctionNamingTest : public TestWithParam<std::string> {};
|
||||||
|
@ -848,11 +893,10 @@ INSTANTIATE_TEST_CASE_P(CustomParamNameFunction,
|
||||||
class CustomLambdaNamingTest : public TestWithParam<std::string> {};
|
class CustomLambdaNamingTest : public TestWithParam<std::string> {};
|
||||||
TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
|
TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(CustomParamNameLambda,
|
INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest,
|
||||||
CustomLambdaNamingTest,
|
|
||||||
Values(std::string("LambdaName")),
|
Values(std::string("LambdaName")),
|
||||||
[](const ::testing::TestParamInfo<std::string>& tpinfo) {
|
[](const ::testing::TestParamInfo<std::string>& inf) {
|
||||||
return tpinfo.param;
|
return inf.param;
|
||||||
});
|
});
|
||||||
|
|
||||||
#endif // GTEST_LANG_CXX11
|
#endif // GTEST_LANG_CXX11
|
||||||
|
@ -1019,6 +1063,7 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
|
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
// Used in TestGenerationTest test case.
|
// Used in TestGenerationTest test case.
|
||||||
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
|
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
|
||||||
|
|
|
@ -33,15 +33,15 @@
|
||||||
//
|
//
|
||||||
// Sometimes it's desirable to build most of Google Test's own tests
|
// Sometimes it's desirable to build most of Google Test's own tests
|
||||||
// by compiling a single file. This file serves this purpose.
|
// by compiling a single file. This file serves this purpose.
|
||||||
#include "test/gtest-filepath_test.cc"
|
#include "gtest-filepath_test.cc"
|
||||||
#include "test/gtest-linked_ptr_test.cc"
|
#include "gtest-linked_ptr_test.cc"
|
||||||
#include "test/gtest-message_test.cc"
|
#include "gtest-message_test.cc"
|
||||||
#include "test/gtest-options_test.cc"
|
#include "gtest-options_test.cc"
|
||||||
#include "test/gtest-port_test.cc"
|
#include "gtest-port_test.cc"
|
||||||
#include "test/gtest_pred_impl_unittest.cc"
|
#include "gtest_pred_impl_unittest.cc"
|
||||||
#include "test/gtest_prod_test.cc"
|
#include "gtest_prod_test.cc"
|
||||||
#include "test/gtest-test-part_test.cc"
|
#include "gtest-test-part_test.cc"
|
||||||
#include "test/gtest-typed-test_test.cc"
|
#include "gtest-typed-test_test.cc"
|
||||||
#include "test/gtest-typed-test2_test.cc"
|
#include "gtest-typed-test2_test.cc"
|
||||||
#include "test/gtest_unittest.cc"
|
#include "gtest_unittest.cc"
|
||||||
#include "test/production.cc"
|
#include "production.cc"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user