Unverified Commit 4d50ab75 authored by Ryan Yee's avatar Ryan Yee Committed by GitHub
Browse files

Merge branch 'master' into typo

parents a83429f5 658c6390
...@@ -62,9 +62,6 @@ using std::pair; ...@@ -62,9 +62,6 @@ using std::pair;
using std::set; using std::set;
using std::stringstream; using std::stringstream;
using std::vector; using std::vector;
using testing::get;
using testing::make_tuple;
using testing::tuple;
using testing::_; using testing::_;
using testing::AllOf; using testing::AllOf;
using testing::AnyOf; using testing::AnyOf;
...@@ -118,20 +115,20 @@ std::string Explain(const MatcherType& m, const Value& x) { ...@@ -118,20 +115,20 @@ std::string Explain(const MatcherType& m, const Value& x) {
// Tests Args<k0, ..., kn>(m). // Tests Args<k0, ..., kn>(m).
TEST(ArgsTest, AcceptsZeroTemplateArg) { TEST(ArgsTest, AcceptsZeroTemplateArg) {
const tuple<int, bool> t(5, true); const std::tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<>(Eq(tuple<>()))); EXPECT_THAT(t, Args<>(Eq(std::tuple<>())));
EXPECT_THAT(t, Not(Args<>(Ne(tuple<>())))); EXPECT_THAT(t, Not(Args<>(Ne(std::tuple<>()))));
} }
TEST(ArgsTest, AcceptsOneTemplateArg) { TEST(ArgsTest, AcceptsOneTemplateArg) {
const tuple<int, bool> t(5, true); const std::tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<0>(Eq(make_tuple(5)))); EXPECT_THAT(t, Args<0>(Eq(std::make_tuple(5))));
EXPECT_THAT(t, Args<1>(Eq(make_tuple(true)))); EXPECT_THAT(t, Args<1>(Eq(std::make_tuple(true))));
EXPECT_THAT(t, Not(Args<1>(Eq(make_tuple(false))))); EXPECT_THAT(t, Not(Args<1>(Eq(std::make_tuple(false)))));
} }
TEST(ArgsTest, AcceptsTwoTemplateArgs) { TEST(ArgsTest, AcceptsTwoTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt()))); EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt()))); EXPECT_THAT(t, (Args<1, 2>(Lt())));
...@@ -139,13 +136,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) { ...@@ -139,13 +136,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
} }
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) { TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq()))); EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne()))); EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
} }
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt()))); EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt()))); EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
} }
...@@ -161,29 +158,29 @@ TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { ...@@ -161,29 +158,29 @@ TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
#endif #endif
MATCHER(SumIsZero, "") { MATCHER(SumIsZero, "") {
return get<0>(arg) + get<1>(arg) + get<2>(arg) == 0; return std::get<0>(arg) + std::get<1>(arg) + std::get<2>(arg) == 0;
} }
TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) { TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
EXPECT_THAT(make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero()))); EXPECT_THAT(std::make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));
EXPECT_THAT(make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero()))); EXPECT_THAT(std::make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));
} }
TEST(ArgsTest, CanBeNested) { TEST(ArgsTest, CanBeNested) {
const tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT const std::tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq())))); EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt())))); EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
} }
TEST(ArgsTest, CanMatchTupleByValue) { TEST(ArgsTest, CanMatchTupleByValue) {
typedef tuple<char, int, int> Tuple3; typedef std::tuple<char, int, int> Tuple3;
const Matcher<Tuple3> m = Args<1, 2>(Lt()); const Matcher<Tuple3> m = Args<1, 2>(Lt());
EXPECT_TRUE(m.Matches(Tuple3('a', 1, 2))); EXPECT_TRUE(m.Matches(Tuple3('a', 1, 2)));
EXPECT_FALSE(m.Matches(Tuple3('b', 2, 2))); EXPECT_FALSE(m.Matches(Tuple3('b', 2, 2)));
} }
TEST(ArgsTest, CanMatchTupleByReference) { TEST(ArgsTest, CanMatchTupleByReference) {
typedef tuple<char, char, int> Tuple3; typedef std::tuple<char, char, int> Tuple3;
const Matcher<const Tuple3&> m = Args<0, 1>(Lt()); const Matcher<const Tuple3&> m = Args<0, 1>(Lt());
EXPECT_TRUE(m.Matches(Tuple3('a', 'b', 2))); EXPECT_TRUE(m.Matches(Tuple3('a', 'b', 2)));
EXPECT_FALSE(m.Matches(Tuple3('b', 'b', 2))); EXPECT_FALSE(m.Matches(Tuple3('b', 'b', 2)));
...@@ -195,23 +192,23 @@ MATCHER_P(PrintsAs, str, "") { ...@@ -195,23 +192,23 @@ MATCHER_P(PrintsAs, str, "") {
} }
TEST(ArgsTest, AcceptsTenTemplateArgs) { TEST(ArgsTest, AcceptsTenTemplateArgs) {
EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9), EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>( (Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
PrintsAs("(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)")))); PrintsAs("(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9), EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>( Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
PrintsAs("(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)")))); PrintsAs("(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
} }
TEST(ArgsTest, DescirbesSelfCorrectly) { TEST(ArgsTest, DescirbesSelfCorrectly) {
const Matcher<tuple<int, bool, char> > m = Args<2, 0>(Lt()); const Matcher<std::tuple<int, bool, char> > m = Args<2, 0>(Lt());
EXPECT_EQ("are a tuple whose fields (#2, #0) are a pair where " EXPECT_EQ("are a tuple whose fields (#2, #0) are a pair where "
"the first < the second", "the first < the second",
Describe(m)); Describe(m));
} }
TEST(ArgsTest, DescirbesNestedArgsCorrectly) { TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
const Matcher<const tuple<int, bool, char, int>&> m = const Matcher<const std::tuple<int, bool, char, int>&> m =
Args<0, 2, 3>(Args<2, 0>(Lt())); Args<0, 2, 3>(Args<2, 0>(Lt()));
EXPECT_EQ("are a tuple whose fields (#0, #2, #3) are a tuple " EXPECT_EQ("are a tuple whose fields (#0, #2, #3) are a tuple "
"whose fields (#2, #0) are a pair where the first < the second", "whose fields (#2, #0) are a pair where the first < the second",
...@@ -219,28 +216,28 @@ TEST(ArgsTest, DescirbesNestedArgsCorrectly) { ...@@ -219,28 +216,28 @@ TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
} }
TEST(ArgsTest, DescribesNegationCorrectly) { TEST(ArgsTest, DescribesNegationCorrectly) {
const Matcher<tuple<int, char> > m = Args<1, 0>(Gt()); const Matcher<std::tuple<int, char> > m = Args<1, 0>(Gt());
EXPECT_EQ("are a tuple whose fields (#1, #0) aren't a pair " EXPECT_EQ("are a tuple whose fields (#1, #0) aren't a pair "
"where the first > the second", "where the first > the second",
DescribeNegation(m)); DescribeNegation(m));
} }
TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) { TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
const Matcher<tuple<bool, int, int> > m = Args<1, 2>(Eq()); const Matcher<std::tuple<bool, int, int> > m = Args<1, 2>(Eq());
EXPECT_EQ("whose fields (#1, #2) are (42, 42)", EXPECT_EQ("whose fields (#1, #2) are (42, 42)",
Explain(m, make_tuple(false, 42, 42))); Explain(m, std::make_tuple(false, 42, 42)));
EXPECT_EQ("whose fields (#1, #2) are (42, 43)", EXPECT_EQ("whose fields (#1, #2) are (42, 43)",
Explain(m, make_tuple(false, 42, 43))); Explain(m, std::make_tuple(false, 42, 43)));
} }
// For testing Args<>'s explanation. // For testing Args<>'s explanation.
class LessThanMatcher : public MatcherInterface<tuple<char, int> > { class LessThanMatcher : public MatcherInterface<std::tuple<char, int> > {
public: public:
virtual void DescribeTo(::std::ostream* os) const {} virtual void DescribeTo(::std::ostream* os) const {}
virtual bool MatchAndExplain(tuple<char, int> value, virtual bool MatchAndExplain(std::tuple<char, int> value,
MatchResultListener* listener) const { MatchResultListener* listener) const {
const int diff = get<0>(value) - get<1>(value); const int diff = std::get<0>(value) - std::get<1>(value);
if (diff > 0) { if (diff > 0) {
*listener << "where the first value is " << diff *listener << "where the first value is " << diff
<< " more than the second"; << " more than the second";
...@@ -249,17 +246,18 @@ class LessThanMatcher : public MatcherInterface<tuple<char, int> > { ...@@ -249,17 +246,18 @@ class LessThanMatcher : public MatcherInterface<tuple<char, int> > {
} }
}; };
Matcher<tuple<char, int> > LessThan() { Matcher<std::tuple<char, int> > LessThan() {
return MakeMatcher(new LessThanMatcher); return MakeMatcher(new LessThanMatcher);
} }
TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) { TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {
const Matcher<tuple<char, int, int> > m = Args<0, 2>(LessThan()); const Matcher<std::tuple<char, int, int> > m = Args<0, 2>(LessThan());
EXPECT_EQ("whose fields (#0, #2) are ('a' (97, 0x61), 42), " EXPECT_EQ(
"whose fields (#0, #2) are ('a' (97, 0x61), 42), "
"where the first value is 55 more than the second", "where the first value is 55 more than the second",
Explain(m, make_tuple('a', 42, 42))); Explain(m, std::make_tuple('a', 42, 42)));
EXPECT_EQ("whose fields (#0, #2) are ('\\0', 43)", EXPECT_EQ("whose fields (#0, #2) are ('\\0', 43)",
Explain(m, make_tuple('\0', 42, 43))); Explain(m, std::make_tuple('\0', 42, 43)));
} }
// For testing ExplainMatchResultTo(). // For testing ExplainMatchResultTo().
...@@ -517,7 +515,7 @@ class NativeArrayPassedAsPointerAndSize { ...@@ -517,7 +515,7 @@ class NativeArrayPassedAsPointerAndSize {
TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) { TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {
int array[] = { 0, 1 }; int array[] = { 0, 1 };
::testing::tuple<int*, size_t> array_as_tuple(array, 2); ::std::tuple<int*, size_t> array_as_tuple(array, 2);
EXPECT_THAT(array_as_tuple, ElementsAre(0, 1)); EXPECT_THAT(array_as_tuple, ElementsAre(0, 1));
EXPECT_THAT(array_as_tuple, Not(ElementsAre(0))); EXPECT_THAT(array_as_tuple, Not(ElementsAre(0)));
...@@ -571,7 +569,7 @@ TEST(ElementsAreTest, MakesCopyOfArguments) { ...@@ -571,7 +569,7 @@ TEST(ElementsAreTest, MakesCopyOfArguments) {
int x = 1; int x = 1;
int y = 2; int y = 2;
// This should make a copy of x and y. // This should make a copy of x and y.
::testing::internal::ElementsAreMatcher<testing::tuple<int, int> > ::testing::internal::ElementsAreMatcher<std::tuple<int, int> >
polymorphic_matcher = ElementsAre(x, y); polymorphic_matcher = ElementsAre(x, y);
// Changing x and y now shouldn't affect the meaning of the above matcher. // Changing x and y now shouldn't affect the meaning of the above matcher.
x = y = 0; x = y = 0;
...@@ -1235,8 +1233,8 @@ TEST(ContainsTest, AcceptsMatcher) { ...@@ -1235,8 +1233,8 @@ TEST(ContainsTest, AcceptsMatcher) {
TEST(ContainsTest, WorksForNativeArrayAsTuple) { TEST(ContainsTest, WorksForNativeArrayAsTuple) {
const int a[] = { 1, 2 }; const int a[] = { 1, 2 };
const int* const pointer = a; const int* const pointer = a;
EXPECT_THAT(make_tuple(pointer, 2), Contains(1)); EXPECT_THAT(std::make_tuple(pointer, 2), Contains(1));
EXPECT_THAT(make_tuple(pointer, 2), Not(Contains(Gt(3)))); EXPECT_THAT(std::make_tuple(pointer, 2), Not(Contains(Gt(3))));
} }
TEST(ContainsTest, WorksForTwoDimensionalNativeArray) { TEST(ContainsTest, WorksForTwoDimensionalNativeArray) {
......
...@@ -308,26 +308,23 @@ TEST(LosslessArithmeticConvertibleTest, FloatingPointToFloatingPoint) { ...@@ -308,26 +308,23 @@ TEST(LosslessArithmeticConvertibleTest, FloatingPointToFloatingPoint) {
// Tests the TupleMatches() template function. // Tests the TupleMatches() template function.
TEST(TupleMatchesTest, WorksForSize0) { TEST(TupleMatchesTest, WorksForSize0) {
tuple<> matchers; std::tuple<> matchers;
tuple<> values; std::tuple<> values;
EXPECT_TRUE(TupleMatches(matchers, values)); EXPECT_TRUE(TupleMatches(matchers, values));
} }
TEST(TupleMatchesTest, WorksForSize1) { TEST(TupleMatchesTest, WorksForSize1) {
tuple<Matcher<int> > matchers(Eq(1)); std::tuple<Matcher<int> > matchers(Eq(1));
tuple<int> values1(1), std::tuple<int> values1(1), values2(2);
values2(2);
EXPECT_TRUE(TupleMatches(matchers, values1)); EXPECT_TRUE(TupleMatches(matchers, values1));
EXPECT_FALSE(TupleMatches(matchers, values2)); EXPECT_FALSE(TupleMatches(matchers, values2));
} }
TEST(TupleMatchesTest, WorksForSize2) { TEST(TupleMatchesTest, WorksForSize2) {
tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a')); std::tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a'));
tuple<int, char> values1(1, 'a'), std::tuple<int, char> values1(1, 'a'), values2(1, 'b'), values3(2, 'a'),
values2(1, 'b'),
values3(2, 'a'),
values4(2, 'b'); values4(2, 'b');
EXPECT_TRUE(TupleMatches(matchers, values1)); EXPECT_TRUE(TupleMatches(matchers, values1));
...@@ -337,10 +334,11 @@ TEST(TupleMatchesTest, WorksForSize2) { ...@@ -337,10 +334,11 @@ TEST(TupleMatchesTest, WorksForSize2) {
} }
TEST(TupleMatchesTest, WorksForSize5) { TEST(TupleMatchesTest, WorksForSize5) {
tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<long>, // NOLINT std::tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
Matcher<long>, // NOLINT
Matcher<std::string> > Matcher<std::string> >
matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi")); matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi"));
tuple<int, char, bool, long, std::string> // NOLINT std::tuple<int, char, bool, long, std::string> // NOLINT
values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"), values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"),
values3(2, 'a', true, 2L, "hi"); values3(2, 'a', true, 2L, "hi");
...@@ -686,22 +684,25 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) { ...@@ -686,22 +684,25 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) {
TEST(StlContainerViewTest, WorksForDynamicNativeArray) { TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
StaticAssertTypeEq<NativeArray<int>, StaticAssertTypeEq<NativeArray<int>,
StlContainerView<tuple<const int*, size_t> >::type>(); StlContainerView<std::tuple<const int*, size_t> >::type>();
StaticAssertTypeEq<NativeArray<double>, StaticAssertTypeEq<
StlContainerView<tuple<linked_ptr<double>, int> >::type>(); NativeArray<double>,
StlContainerView<std::tuple<linked_ptr<double>, int> >::type>();
StaticAssertTypeEq<const NativeArray<int>, StaticAssertTypeEq<
StlContainerView<tuple<const int*, int> >::const_reference>(); const NativeArray<int>,
StlContainerView<std::tuple<const int*, int> >::const_reference>();
int a1[3] = { 0, 1, 2 }; int a1[3] = { 0, 1, 2 };
const int* const p1 = a1; const int* const p1 = a1;
NativeArray<int> a2 = StlContainerView<tuple<const int*, int> >:: NativeArray<int> a2 =
ConstReference(make_tuple(p1, 3)); StlContainerView<std::tuple<const int*, int> >::ConstReference(
std::make_tuple(p1, 3));
EXPECT_EQ(3U, a2.size()); EXPECT_EQ(3U, a2.size());
EXPECT_EQ(a1, a2.begin()); EXPECT_EQ(a1, a2.begin());
const NativeArray<int> a3 = StlContainerView<tuple<int*, size_t> >:: const NativeArray<int> a3 = StlContainerView<std::tuple<int*, size_t> >::Copy(
Copy(make_tuple(static_cast<int*>(a1), 3)); std::make_tuple(static_cast<int*>(a1), 3));
ASSERT_EQ(3U, a3.size()); ASSERT_EQ(3U, a3.size());
EXPECT_EQ(0, a3.begin()[0]); EXPECT_EQ(0, a3.begin()[0]);
EXPECT_EQ(1, a3.begin()[1]); EXPECT_EQ(1, a3.begin()[1]);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -148,7 +148,6 @@ macro(config_compiler_and_linker) ...@@ -148,7 +148,6 @@ macro(config_compiler_and_linker)
"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}") "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
set(cxx_default "${cxx_exception}") set(cxx_default "${cxx_exception}")
set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}") set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}")
set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
# For building the gtest libraries. # For building the gtest libraries.
set(cxx_strict "${cxx_default} ${cxx_strict_flags}") set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment