Namespaces
Records
-
class Action -
class Action -
class ActionInterface -
class AssertionException -
class AssertionResult -
class Cardinality -
class CardinalityInterface -
class DefaultValue -
class DefaultValue -
class DefaultValue -
class EmptyTestEventListener -
class Environment -
class ExitedWithCode -
class Expectation -
class ExpectationSet -
class InSequence -
class IsFalseMatcher -
class IsTrueMatcher -
class KilledBySignal -
class MatchResultListener -
class Matcher -
class Matcher -
class Matcher -
class Matcher -
class Matcher -
class MatcherDescriberInterface -
class MatcherInterface -
class Message -
class Mock -
class MockFunction -
class NaggyMock -
class NiceMock -
class OnceAction -
class OnceAction -
class PolymorphicAction -
class PolymorphicMatcher -
class PrintToStringParamName -
class RuntimeDirHelper -
class ScopedFakeTestPartResultReporter -
class ScopedTrace -
class Sequence -
class StrictMock -
class StringMatchResultListener -
class Test -
class TestEventListener -
class TestEventListeners -
class TestInfo -
class TestParamInfo -
class TestPartResult -
class TestPartResultArray -
class TestPartResultReporterInterface -
class TestProperty -
class TestResult -
class TestSuite -
class TestWithParam -
class UnitTest -
class UserMemory -
class WithParamInterface
Functions
-
Cardinality AnyNumber ()Creates a cardinality that allows any number of calls.
-
template <typename Pred, typename T1>AssertionResult AssertPred1Helper (const char * pred_text, const char * e1, Pred pred, const T1 & v1)Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use
this in your code.
Defined at line 87 of file ../../third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
-
template <typename Pred, typename T1, typename T2>AssertionResult AssertPred2Helper (const char * pred_text, const char * e1, const char * e2, Pred pred, const T1 & v1, const T2 & v2)Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use
this in your code.
Defined at line 118 of file ../../third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
-
template <typename Pred, typename T1, typename T2, typename T3>AssertionResult AssertPred3Helper (const char * pred_text, const char * e1, const char * e2, const char * e3, Pred pred, const T1 & v1, const T2 & v2, const T3 & v3)Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use
this in your code.
Defined at line 155 of file ../../third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
-
template <typename Pred, typename T1, typename T2, typename T3, typename T4>AssertionResult AssertPred4Helper (const char * pred_text, const char * e1, const char * e2, const char * e3, const char * e4, Pred pred, const T1 & v1, const T2 & v2, const T3 & v3, const T4 & v4)Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use
this in your code.
Defined at line 194 of file ../../third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
-
template <typename Pred, typename T1, typename T2, typename T3, typename T4, typename T5>AssertionResult AssertPred5Helper (const char * pred_text, const char * e1, const char * e2, const char * e3, const char * e4, const char * e5, Pred pred, const T1 & v1, const T2 & v2, const T3 & v3, const T4 & v4, const T5 & v5)Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use
this in your code.
Defined at line 236 of file ../../third_party/googletest/src/googletest/include/gtest/gtest_pred_impl.h
-
template <typename T>::std::string PrintToString (const T & value)Defined at line 1223 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-printers.h
-
template <typename T>Matcher<T> An ()Creates a matcher that matches any value of the given type T.
Defined at line 4474 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename... Args>internal::AllOfMatcher<typename std::decay<const Args &>::type...> AllOf (const Args &... matchers)Define variadic matcher versions.
Defined at line 5383 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename... Args>internal::AnyOfMatcher<typename std::decay<const Args &>::type...> AnyOf (const Args &... matchers)Defined at line 5390 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Iter>internal::AnyOfArrayMatcher<typename ::std::iterator_traits<Iter>::value_type> AnyOfArray (Iter first, Iter last)AnyOfArray(array)
AnyOfArray(pointer, count)
AnyOfArray(container)
AnyOfArray({ e1, e2, ..., en })
AnyOfArray(iterator_first, iterator_last)
AnyOfArray() verifies whether a given value matches any member of a
collection of matchers.
AllOfArray(array)
AllOfArray(pointer, count)
AllOfArray(container)
AllOfArray({ e1, e2, ..., en })
AllOfArray(iterator_first, iterator_last)
AllOfArray() verifies whether a given value matches all members of a
collection of matchers.
The matchers can be specified as an array, a pointer and count, a container,
an initializer list, or an STL iterator range. In each of these cases, the
underlying matchers can be either values or matchers.
Defined at line 5419 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Iter>internal::AllOfArrayMatcher<typename ::std::iterator_traits<Iter>::value_type> AllOfArray (Iter first, Iter last)Defined at line 5427 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::AnyOfArrayMatcher<T> AnyOfArray (const T * ptr, size_t count)Defined at line 5435 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::AllOfArrayMatcher<T> AllOfArray (const T * ptr, size_t count)Defined at line 5440 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, size_t N>internal::AnyOfArrayMatcher<T> AnyOfArray (const T (&)[N] array)Defined at line 5445 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, size_t N>internal::AllOfArrayMatcher<T> AllOfArray (const T (&)[N] array)Defined at line 5450 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>internal::AnyOfArrayMatcher<typename Container::value_type> AnyOfArray (const Container & container)Defined at line 5455 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>internal::AllOfArrayMatcher<typename Container::value_type> AllOfArray (const Container & container)Defined at line 5461 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::AnyOfArrayMatcher<T> AnyOfArray (::std::initializer_list<T> xs)Defined at line 5467 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::AllOfArrayMatcher<T> AllOfArray (::std::initializer_list<T> xs)Defined at line 5473 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <size_t... k, typename InnerMatcher>internal::ArgsMatcher<typename std::decay<InnerMatcher>::type, k...> Args (InnerMatcher && matcher)Args
<N1
, N2, ..., Nk>(a_matcher) matches a tuple if the selected
fields of it matches a_matcher. C++ doesn't support default
arguments for function templates, so we have to overload it.
Defined at line 5482 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename InnerMatcher>InnerMatcher AllArgs (const InnerMatcher & matcher)AllArgs(m) is a synonym of m. This is useful in
EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
which is easier to read than
EXPECT_CALL(foo, Bar(_, _)).With(Eq());
Defined at line 5496 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>PolymorphicMatcher<internal::any_cast_matcher::AnyCastMatcher<T>> AnyWith (const Matcher<const T &> & matcher)Returns a matcher that matches the value of a absl::any type variable.
Defined at line 5517 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
void InitGoogleMock (int * argc, char ** argv)Initializes Google Mock. This must be called before running the
tests. In particular, it parses the command line for the flags
that Google Mock recognizes. Whenever a Google Mock flag is seen,
it is removed from argv, and *argc is decremented.
No value is returned. Instead, the Google Mock flag variables are
updated.
Since Google Test is needed for Google Mock to work, this function
also initializes Google Test and parses its flags, if that hasn't
been done.
-
void InitGoogleMock (int * argc, wchar_t ** argv)This overloaded version can be used in Windows programs compiled in
UNICODE mode.
-
void InitGoogleMock ()This overloaded version can be used on Arduino/embedded platforms where
there is no argc/argv.
-
std::ostream & operator<< (std::ostream & os, const TestPartResult & result)Prints a TestPartResult object.
-
Cardinality AtLeast (int n)Creates a cardinality that allows at least n calls.
-
Cardinality AtMost (int n)Creates a cardinality that allows at most n calls.
-
Cardinality Between (int min, int max)Creates a cardinality that allows between min and max calls.
-
Cardinality Exactly (int n)Creates a cardinality that allows exactly n calls.
-
AssertionResult AssertionSuccess ()Makes a successful assertion result.
-
AssertionResult AssertionFailure ()Makes a failed assertion result.
-
AssertionResult AssertionFailure (const Message & msg)Makes a failed assertion result with the given failure message.
Deprecated; use AssertionFailure()
<
<
msg.
-
PolymorphicMatcher<internal::IsEmptyMatcher> IsEmpty ()Creates a polymorphic matcher that matches an empty container or C-style
string. The container must support both size() and empty(), which all
STL-like containers provide.
Defined at line 93 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-more-matchers.h
-
IsTrueMatcher IsTrue ()Define a matcher that matches a value that evaluates in boolean
context to true. Useful for types that define "explicit operator
bool" operators and so can't be compared for equality with true
and false.
Defined at line 101 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-more-matchers.h
-
IsFalseMatcher IsFalse ()Define a matcher that matches a value that evaluates in boolean
context to false. Useful for types that define "explicit operator
bool" operators and so can't be compared for equality with true
and false.
Defined at line 109 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-more-matchers.h
-
Cardinality MakeCardinality (const CardinalityInterface * c)Creates a cardinality from its implementation.
Defined at line 151 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-cardinalities.h
-
template <typename T, typename IncrementT>internal::ParamGenerator<T> Range (T start, T end, IncrementT step)Range() returns generators providing sequences of values in a range.
Synopsis:
Range(start, end)
- returns a generator producing a sequence of values {start, start+1,
start+2, ..., }.
Range(start, end, step)
- returns a generator producing a sequence of values {start, start+step,
start+step+step, ..., }.
Notes:
* The generated sequences never include end. For example, Range(1, 5)
returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
returns a generator producing {1, 3, 5, 7}.
* start and end must have the same type. That type may be any integral or
floating-point type or a user defined type satisfying these conditions:
* It must be assignable (have operator=() defined).
* It must have operator+() (operator+(int-compatible type) for
two-operand version).
* It must have operator
<
() defined.
Elements in the resulting sequences will also have that type.
* Condition start
<
end must be satisfied in order for resulting sequences
to contain any elements.
Defined at line 230 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
std::ostream & operator<< (std::ostream & os, const Message & sb)Streams a Message to an ostream.
Defined at line 231 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-message.h
-
template <typename T>internal::ParamGenerator<T> Range (T start, T end)Defined at line 236 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <typename ForwardIterator>internal::ParamGenerator<typename std::iterator_traits<ForwardIterator>::value_type> ValuesIn (ForwardIterator begin, ForwardIterator end)ValuesIn() function allows generation of tests with parameters coming from
a container.
Synopsis:
ValuesIn(const T (
&array
)[N])
- returns a generator producing sequences with elements from
a C-style array.
ValuesIn(const Container
&
container)
- returns a generator producing sequences with elements from
an STL-style container.
ValuesIn(Iterator begin, Iterator end)
- returns a generator producing sequences with elements from
a range [begin, end) defined by a pair of STL-style iterators. These
iterators can also be plain C pointers.
Please note that ValuesIn copies the values from the containers
passed in and keeps them to generate tests in RUN_ALL_TESTS().
Examples:
This instantiates tests from test suite StringTest
each with C-string values of "foo", "bar", and "baz":
const char* strings[] = {"foo", "bar", "baz"};
INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings));
This instantiates tests from test suite StlStringTest
each with STL strings with values "a" and "b":
::std::vector
<
::std::string> GetParameterStrings() {
::std::vector
<
::std::string> v;
v.push_back("a");
v.push_back("b");
return v;
}
INSTANTIATE_TEST_SUITE_P(CharSequence,
StlStringTest,
ValuesIn(GetParameterStrings()));
This will also instantiate tests from CharTest
each with parameter values 'a' and 'b':
::std::list
<char
> GetParameterChars() {
::std::list
<char
> list;
list.push_back('a');
list.push_back('b');
return list;
}
::std::list
<char
> l = GetParameterChars();
INSTANTIATE_TEST_SUITE_P(CharSequence2,
CharTest,
ValuesIn(l.begin(), l.end()));
Defined at line 296 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <typename T, size_t N>internal::ParamGenerator<T> ValuesIn (const T (&)[N] array)Defined at line 305 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <class Container>internal::ParamGenerator<typename Container::value_type> ValuesIn (const Container & container)Forward declarations of ValuesIn(), which is implemented in
include/gtest/gtest-param-test.h.
Defined at line 310 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <typename... T>internal::ValueArray<T...> Values (T... v)Values() allows generating tests from explicitly specified list of
parameters.
Synopsis:
Values(T v1, T v2, ..., T vN)
- returns a generator producing sequences with elements v1, v2, ..., vN.
For example, this instantiates tests from test suite BarTest each
with values "one", "two", and "three":
INSTANTIATE_TEST_SUITE_P(NumSequence,
BarTest,
Values("one", "two", "three"));
This instantiates tests from test suite BazTest each with values 1, 2, 3.5.
The exact type of values will depend on the type of parameter in BazTest.
INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
Defined at line 336 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
internal::ParamGenerator<bool> Bool ()Bool() allows generating tests with parameters in a set of (false, true).
Synopsis:
Bool()
- returns a generator producing sequences with elements {false, true}.
It is useful when testing code that depends on Boolean flags. Combinations
of multiple flags can be tested when several Bool()'s are combined using
Combine() function.
In the following example all tests in the test suite FlagDependentTest
will be instantiated twice with parameters false and true.
class FlagDependentTest : public testing::TestWithParam
<bool
> {
virtual void SetUp() {
external_flag = GetParam();
}
}
INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
Defined at line 360 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <typename... Generator>internal::CartesianProductHolder<Generator...> Combine (const Generator &... g)Combine() allows the user to combine two or more sequences to produce
values of a Cartesian product of those sequences' elements.
Synopsis:
Combine(gen1, gen2, ..., genN)
- returns a generator producing sequences with elements coming from
the Cartesian product of elements from the sequences generated by
gen1, gen2, ..., genN. The sequence elements will have a type of
std::tuple
<T1
, T2, ..., TN> where T1, T2, ..., TN are the types
of elements from sequences produces by gen1, gen2, ..., genN.
Example:
This will instantiate tests in test suite AnimalTest each one with
the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
tuple("dog", BLACK), and tuple("dog", WHITE):
enum Color { BLACK, GRAY, WHITE };
class AnimalTest
: public testing::TestWithParam
<std
::tuple
<const
char*, Color> > {...};
TEST_P(AnimalTest, AnimalLooksNice) {...}
INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
Combine(Values("cat", "dog"),
Values(BLACK, WHITE)));
This will instantiate tests in FlagDependentTest with all variations of two
Boolean flags:
class FlagDependentTest
: public testing::TestWithParam
<std
::tuple
<bool
, bool> > {
virtual void SetUp() {
// Assigns external_flag_1 and external_flag_2 values from the tuple.
std::tie(external_flag_1, external_flag_2) = GetParam();
}
};
TEST_P(FlagDependentTest, TestFeature1) {
// Test your code using external_flag_1 and external_flag_2 here.
}
INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest,
Combine(Bool(), Bool()));
Defined at line 407 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <typename RequestedT>internal::ParamConverterGenerator<RequestedT> ConvertGenerator (internal::ParamGenerator<RequestedT> gen)ConvertGenerator() wraps a parameter generator in order to cast each produced
value through a known type before supplying it to the test suite
Synopsis:
ConvertGenerator
<T
>(gen)
- returns a generator producing the same elements as generated by gen, but
each T-typed element is static_cast to a type deduced from the interface
that accepts this generator, and then returned
It is useful when using the Combine() function to get the generated
parameters in a custom type instead of std::tuple
Example:
This will instantiate tests in test suite AnimalTest each one with
the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
tuple("dog", BLACK), and tuple("dog", WHITE):
enum Color { BLACK, GRAY, WHITE };
struct ParamType {
using TupleT = std::tuple
<const
char*, Color>;
std::string animal;
Color color;
ParamType(TupleT t) : animal(std::get
<
0>(t)), color(std::get
<
1>(t)) {}
};
class AnimalTest
: public testing::TestWithParam
<ParamType
> {...};
TEST_P(AnimalTest, AnimalLooksNice) {...}
INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
ConvertGenerator
<ParamType
::TupleT>(
Combine(Values("cat", "dog"),
Values(BLACK, WHITE))));
Defined at line 447 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <typename T, int&... ExplicitArgumentBarrier, typename Gen, typename Func, typename StdFunction = decltype(std::function(std::declval<Func>()))>internal::ParamConverterGenerator<T, StdFunction> ConvertGenerator (Gen && gen, Func && f)As above, but takes a callable as a second argument. The callable converts
the generated parameter to the test fixture's parameter type. This allows you
to use a parameter type that does not have a converting constructor from the
generated type.
Example:
This will instantiate tests in test suite AnimalTest each one with
the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
tuple("dog", BLACK), and tuple("dog", WHITE):
enum Color { BLACK, GRAY, WHITE };
struct ParamType {
std::string animal;
Color color;
};
class AnimalTest
: public testing::TestWithParam
<ParamType
> {...};
TEST_P(AnimalTest, AnimalLooksNice) {...}
INSTANTIATE_TEST_SUITE_P(
AnimalVariations, AnimalTest,
ConvertGenerator(Combine(Values("cat", "dog"), Values(BLACK, WHITE)),
[](std::tuple
<std
::string, Color> t) {
return ParamType{.animal = std::get
<
0>(t),
.color = std::get
<
1>(t)};
}));
Defined at line 484 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
template <int&... ExplicitArgumentBarrier, typename Gen, typename Func, typename StdFunction = decltype(std::function(std::declval<Func>()))>auto ConvertGenerator (Gen && gen, Func && f)As above, but infers the T from the supplied std::function instead of
having the caller specify it.
Defined at line 494 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-param-test.h
-
void InitGoogleTest (int * argc, char ** argv)Initializes Google Test. This must be called before calling
RUN_ALL_TESTS(). In particular, it parses a command line for the
flags that Google Test recognizes. Whenever a Google Test flag is
seen, it is removed from argv, and *argc is decremented.
No value is returned. Instead, the Google Test flag variables are
updated.
Calling the function for the second time has no user-visible effect.
-
void InitGoogleTest (int * argc, wchar_t ** argv)This overloaded version can be used in Windows programs compiled in
UNICODE mode.
-
void InitGoogleTest ()This overloaded version can be used on Arduino/embedded platforms where
there is no argc/argv.
-
AssertionResult IsSubstring (const char * needle_expr, const char * haystack_expr, const char * needle, const char * haystack)IsSubstring() and IsNotSubstring() are intended to be used as the
first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by
themselves. They check whether needle is a substring of haystack
(NULL is considered a substring of itself only), and return an
appropriate error message when they fail.
The {needle,haystack}_expr arguments are the stringified
expressions that generated the two real arguments.
-
AssertionResult IsSubstring (const char * needle_expr, const char * haystack_expr, const wchar_t * needle, const wchar_t * haystack) -
AssertionResult IsNotSubstring (const char * needle_expr, const char * haystack_expr, const char * needle, const char * haystack) -
AssertionResult IsNotSubstring (const char * needle_expr, const char * haystack_expr, const wchar_t * needle, const wchar_t * haystack) -
AssertionResult IsNotSubstring (const char * needle_expr, const char * haystack_expr, const ::std::string & needle, const ::std::string & haystack) -
AssertionResult IsSubstring (const char * needle_expr, const char * haystack_expr, const ::std::wstring & needle, const ::std::wstring & haystack) -
AssertionResult IsNotSubstring (const char * needle_expr, const char * haystack_expr, const ::std::wstring & needle, const ::std::wstring & haystack) -
AssertionResult FloatLE (const char * expr1, const char * expr2, float val1, float val2)Asserts that val1 is less than, or almost equal to, val2. Fails
otherwise. In particular, it fails if either val1 or val2 is NaN.
-
AssertionResult DoubleLE (const char * expr1, const char * expr2, double val1, double val2) -
template <typename T, typename M>Matcher<T> MatcherCast (const M & matcher)In order to be safe and clear, casting between different matcher
types is done explicitly via MatcherCast
<T
>(m), which takes a
matcher m and returns a Matcher
<T
>. It compiles only when T can be
statically converted to the argument type of m.
Defined at line 523 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename M>Matcher<T> SafeMatcherCast (const M & polymorphic_matcher_or_value)This overload handles polymorphic matchers and values only since
monomorphic matchers are handled by the next one.
Defined at line 530 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename U>Matcher<T> SafeMatcherCast (const Matcher<U> & matcher)This overload handles monomorphic matchers.
In general, if type T can be implicitly converted to type U, we can
safely convert a Matcher
<U
> to a Matcher
<T
> (i.e. Matcher is
contravariant): just keep a copy of the original Matcher
<U
>, convert the
argument from type T to U, and then pass it to the underlying Matcher
<U
>.
The only exception is when U is a non-const reference and T is not, as the
underlying Matcher
<U
> may be interested in the argument's address, which
cannot be preserved in the conversion from T to U (since a copy of the input
T argument would be required to provide a non-const reference U).
Defined at line 545 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>std::ostream & operator<< (std::ostream & os, const Matcher<T> & matcher)Prints a matcher in a human-readable format.
Defined at line 599 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <std::size_t index, typename... Params>internal::InvokeArgumentAction<index, typename std::decay<Params>::type...> InvokeArgument (Params &&... params)The InvokeArgument
<N
>(a1, a2, ..., a_k) action invokes the N-th
(0-based) argument, which must be a k-ary callable, of the mock
function, with arguments a1, a2, ..., a_k.
Notes:
1. The arguments are passed by value by default. If you need to
pass an argument by reference, wrap it inside std::ref(). For
example,
InvokeArgument
<
1>(5, string("Hello"), std::ref(foo))
passes 5 and string("Hello") by value, and passes foo by
reference.
2. If the callable takes an argument by reference but std::ref() is
not used, it will receive the reference to a copy of the value,
instead of the original value. For example, when the 0-th
argument of the mock function takes a const string
&
, the action
InvokeArgument
<
0>(string("Hello"))
makes a copy of the temporary string("Hello") object and passes a
reference of the copy, instead of the original temporary object,
to the callable. This makes it easy for a user to define an
InvokeArgument action from temporary values and have it performed
later.
Defined at line 649 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-more-actions.h
-
AssertionResult IsSubstring (const char * needle_expr, const char * haystack_expr, const ::std::string & needle, const ::std::string & haystack) -
template <typename T>Matcher<T> MakeMatcher (const MatcherInterface<T> * impl)Creates a matcher from its implementation.
DEPRECATED: Especially in the generic code, prefer:
Matcher
<T
>(new MyMatcherImpl
<const
T
&
>(...));
MakeMatcher may create a Matcher that accepts its argument by value, which
leads to unnecessary copies
&
lack of support for non-copyable types.
Defined at line 664 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <class Impl>PolymorphicMatcher<Impl> MakePolymorphicMatcher (const Impl & impl)Creates a polymorphic matcher from its implementation. This is
easier to use than the PolymorphicMatcher
<Impl
> constructor as it
doesn't require you to explicitly write the template argument, e.g.
MakePolymorphicMatcher(foo);
vs
PolymorphicMatcher
<TypeOfFoo
>(foo);
Defined at line 676 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex (const internal::RE * regex)Matches a string that fully matches regular expression 'regex'.
The matcher takes ownership of 'regex'.
Defined at line 836 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex (const internal::StringLike<T> & regex)Defined at line 841 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex (const internal::RE * regex)Matches a string that contains regular expression 'regex'.
The matcher takes ownership of 'regex'.
Defined at line 848 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex (const internal::StringLike<T> & regex)Defined at line 853 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename T>internal::EqMatcher<T> Eq (T x)Creates a polymorphic matcher that matches anything equal to x.
Note: if the parameter of Eq() were declared as const T
&
, Eq("foo")
wouldn't compile.
Defined at line 862 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename Lhs, typename Rhs>Matcher<Lhs> TypedEq (const Rhs & rhs)Creates a monomorphic matcher that matches anything with type Lhs
and equal to rhs. A user may need to use this instead of Eq(...)
in order to resolve an overloading ambiguity.
TypedEq
<T
>(x) is just a convenient short-hand for Matcher
<T
>(Eq(x))
or Matcher
<T
>(x), but more readable than the latter.
We could define similar monomorphic matchers for other comparison
operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
it yet as those are used much less than Eq() in practice. A user
can always write Matcher
<T
>(Lt(5)) to be explicit about the type,
for example.
Defined at line 886 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename Rhs>internal::GeMatcher<Rhs> Ge (Rhs x)Creates a polymorphic matcher that matches anything >= x.
Defined at line 892 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename Rhs>internal::GtMatcher<Rhs> Gt (Rhs x)Creates a polymorphic matcher that matches anything > x.
Defined at line 898 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename F>Action<F> MakeAction (ActionInterface<F> * impl)Creates an Action from its implementation and returns it. The
created Action object owns the implementation.
Defined at line 904 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename Rhs>internal::LeMatcher<Rhs> Le (Rhs x)Creates a polymorphic matcher that matches anything
<
= x.
Defined at line 904 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename Rhs>internal::LtMatcher<Rhs> Lt (Rhs x)Creates a polymorphic matcher that matches anything
<
x.
Defined at line 910 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
template <typename Impl>PolymorphicAction<Impl> MakePolymorphicAction (const Impl & impl)Creates a polymorphic action from its implementation. This is
easier to use than the PolymorphicAction
<Impl
> constructor as it
doesn't require you to explicitly write the template argument, e.g.
MakePolymorphicAction(foo);
vs
PolymorphicAction
<TypeOfFoo
>(foo);
Defined at line 916 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename Rhs>internal::NeMatcher<Rhs> Ne (Rhs x)Creates a polymorphic matcher that matches anything != x.
Defined at line 916 of file ../../third_party/googletest/src/googletest/include/gtest/gtest-matchers.h
-
Environment * AddGlobalTestEnvironment (Environment * env)A convenient wrapper for adding an environment for the test
program.
You should call this before RUN_ALL_TESTS() is called, probably in
main(). If you use gtest_main, you need to call this before main()
starts for it to take effect. For example, you can define a global
variable like this:
testing::Environment* const foo_env =
testing::AddGlobalTestEnvironment(new FooEnvironment);
However, we strongly recommend you to write your own main() and
call AddGlobalTestEnvironment() there, as relying on initialization
of global variables makes the code harder to read and may cause
problems when you register multiple environments from different
translation units and the environments have dependencies among them
(remember that the compiler doesn't guarantee the order in which
global variables from different translation units are initialized).
Defined at line 1345 of file ../../third_party/googletest/src/googletest/include/gtest/gtest.h
-
template <typename... Action>internal::DoAllAction<typename std::decay<Action>::type...> DoAll (Action &&... action)Creates an action that does actions a1, a2, ..., sequentially in
each invocation. All but the last action will have a readonly view of the
arguments.
Defined at line 1873 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, typename InnerAction>internal::WithArgsAction<typename std::decay<InnerAction>::type, k> WithArg (InnerAction && action)WithArg
<k
>(an_action) creates an action that passes the k-th
(0-based) argument of the mock function to an_action and performs
it. It adapts an action accepting one argument to one that accepts
multiple arguments. For convenience, we also provide
WithArgs
<k
>(an_action) (defined below) as a synonym.
Defined at line 1885 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, size_t... ks, typename InnerAction>internal::WithArgsAction<typename std::decay<InnerAction>::type, k, ks...> WithArgs (InnerAction && action)WithArgs
<N1
, N2, ..., Nk>(an_action) creates an action that passes
the selected arguments of the mock function to an_action and
performs it. It serves as an adaptor between actions with
different argument lists.
Defined at line 1895 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename InnerAction>internal::WithArgsAction<typename std::decay<InnerAction>::type> WithoutArgs (InnerAction && action)WithoutArgs(inner_action) can be used in a mock function with a
non-empty argument list to perform inner_action, which takes no
argument. In other words, it adapts an action accepting no
argument to one that accepts (and ignores) arguments.
Defined at line 1905 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename R>internal::ReturnAction<R> Return (R value)Creates an action that returns a value.
The returned type can be used with a mock function returning a non-void,
non-reference type U as follows:
* If R is convertible to U and U is move-constructible, then the action can
be used with WillOnce.
* If const R
&
is convertible to U and U is copy-constructible, then the
action can be used with both WillOnce and WillRepeatedly.
The mock expectation contains the R value from which the U return value is
constructed (a move/copy of the argument to Return). This means that the R
value will survive at least until the mock object's expectations are cleared
or the mock object is destroyed, meaning that U can safely be a
reference-like type such as std::string_view:
// The mock function returns a view of a copy of the string fed to
// Return. The view is valid even after the action is performed.
MockFunction
<std
::string_view()> mock;
EXPECT_CALL(mock, Call).WillOnce(Return(std::string("taco")));
const std::string_view result = mock.AsStdFunction()();
EXPECT_EQ("taco", result);
Defined at line 1935 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
PolymorphicAction<internal::ReturnNullAction> ReturnNull ()Creates an action that returns NULL.
Defined at line 1940 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
PolymorphicAction<internal::ReturnVoidAction> Return ()Creates an action that returns from a void function.
Defined at line 1945 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename R>internal::ReturnRefAction<R> ReturnRef (R & x)Creates an action that returns the reference to a variable.
Defined at line 1951 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename R, R* = nullptr>internal::ReturnRefAction<R> ReturnRef (R && )Prevent using ReturnRef on reference to temporary.
Defined at line 1957 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename R>internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy (const R & x)Creates an action that returns the reference to a copy of the
argument. The copy is created when the action is constructed and
lives as long as the action.
Defined at line 1963 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename R>internal::ByMoveWrapper<R> ByMove (R x)DEPRECATED: use Return(x) directly with WillOnce.
Modifies the parent action (a Return() action) to perform a move of the
argument instead of a copy.
Return(ByMove()) actions can only be executed once and will assert this
invariant.
Defined at line 1974 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T>internal::ReturnRoundRobinAction<T> ReturnRoundRobin (std::vector<T> vals)Creates an action that returns an element of `vals`. Calling this action will
repeatedly return the next value from `vals` until it reaches the end and
will restart from the beginning.
Defined at line 1982 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T>internal::ReturnRoundRobinAction<T> ReturnRoundRobin (std::initializer_list<T> vals)Creates an action that returns an element of `vals`. Calling this action will
repeatedly return the next value from `vals` until it reaches the end and
will restart from the beginning.
Defined at line 1990 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
internal::DoDefaultAction DoDefault ()Creates an action that does the default action for the give mock function.
Defined at line 1996 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t N, typename T>internal::SetArgumentPointeeAction<N, T> SetArgPointee (T value)Creates an action that sets the variable pointed by the N-th
(0-based) function argument to 'value'.
Defined at line 2003 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t N, typename T>internal::SetArgumentPointeeAction<N, T> SetArgumentPointee (T value)The following version is DEPRECATED.
Defined at line 2009 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T1, typename T2>PolymorphicAction<internal::AssignAction<T1, T2>> Assign (T1 * ptr, T2 val)Creates an action that sets a pointer referent to a given value.
Defined at line 2015 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T>PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn (int errval, T result)Creates an action that sets errno and returns the appropriate error.
Defined at line 2023 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename FunctionImpl>typename std::decay<FunctionImpl>::type Invoke (FunctionImpl && function_impl)Legacy function.
Actions can now be implicitly constructed from callables. No need to create
wrapper objects.
This function exists for backwards compatibility.
Defined at line 2038 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <class Class, typename MethodPtr>internal::InvokeMethodAction<Class, MethodPtr> Invoke (Class * obj_ptr, MethodPtr method_ptr)Creates an action that invokes the given method on the given object
with the mock function's arguments.
Defined at line 2045 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename FunctionImpl>internal::InvokeWithoutArgsAction<typename std::decay<FunctionImpl>::type> InvokeWithoutArgs (FunctionImpl function_impl)Creates an action that invokes 'function_impl' with no argument.
Defined at line 2052 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <class Class, typename MethodPtr>internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> InvokeWithoutArgs (Class * obj_ptr, MethodPtr method_ptr)Creates an action that invokes the given method on the given object
with no argument.
Defined at line 2060 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T>const T & Const (const T & x)Const(x) is a convenient function for obtaining a const reference
to x. This is useful for setting expectations on an overloaded
const mock method, e.g.
class MockFoo : public FooInterface {
public:
MOCK_METHOD0(Bar, int());
MOCK_CONST_METHOD0(Bar, int
&
());
};
MockFoo foo;
// Expects a call to non-const MockFoo::Bar().
EXPECT_CALL(foo, Bar());
// Expects a call to const MockFoo::Bar().
EXPECT_CALL(Const(foo), Bar());
Defined at line 2061 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-spec-builders.h
-
template <typename A>internal::IgnoreResultAction<A> IgnoreResult (const A & an_action)Creates an action that performs an_action and throws away its
result. In other words, it changes the return type of an_action to
void. an_action MUST NOT return void, or the code won't compile.
Defined at line 2069 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T>::std::reference_wrapper<T> ByRef (T & l_value)Creates a reference wrapper for the given L-value. If necessary,
you can explicitly specify the type of the reference. For example,
suppose 'derived' is an object of type Derived, ByRef(derived)
would wrap a Derived
&
. If you want to wrap a const Base
&
instead,
where Base is a base class of Derived, just write:
ByRef
<const
Base>(derived)
N.B. ByRef is redundant with std::ref, std::cref and std::reference_wrapper.
However, it may still be used for consistency with ByMove().
Defined at line 2084 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename T, typename... Params>internal::ReturnNewAction<T, typename std::decay<Params>::type...> ReturnNew (Params &&... params)The ReturnNew
<T
>(a1, a2, ..., a_k) action returns a pointer to a new
instance of type T, constructed on the heap with constructor arguments
a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
Defined at line 2092 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k>internal::ReturnArgAction<k> ReturnArg ()Action ReturnArg
<k
>() returns the k-th argument of the mock function.
Defined at line 2099 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, typename Ptr>internal::SaveArgAction<k, Ptr> SaveArg (Ptr pointer)Action SaveArg
<k
>(pointer) saves the k-th (0-based) argument of the
mock function to *pointer.
Defined at line 2106 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, typename Ptr>internal::SaveArgByMoveAction<k, Ptr> SaveArgByMove (Ptr pointer)Action SaveArgByMove
<k
>(pointer) moves the k-th (0-based) argument of the
mock function into *pointer.
Defined at line 2113 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, typename Ptr>internal::SaveArgPointeeAction<k, Ptr> SaveArgPointee (Ptr pointer)Action SaveArgPointee
<k
>(pointer) saves the value pointed to
by the k-th (0-based) argument of the mock function to *pointer.
Defined at line 2120 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, typename T>internal::SetArgRefereeAction<k, typename std::decay<T>::type> SetArgReferee (T && value)Action SetArgReferee
<k
>(value) assigns 'value' to the variable
referenced by the k-th (0-based) argument of the mock function.
Defined at line 2127 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k, typename I1, typename I2>internal::SetArrayArgumentAction<k, I1, I2> SetArrayArgument (I1 first, I2 last)Action SetArrayArgument
<k
>(first, last) copies the elements in
source range [first, last) to the array pointed to by the k-th
(0-based) argument, which can be either a pointer or an
iterator. The action does not take ownership of the elements in the
source range.
Defined at line 2138 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <size_t k>internal::DeleteArgAction<k> DeleteArg ()Action DeleteArg
<k
>() deletes the k-th (0-based) argument of the mock
function.
Defined at line 2146 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <typename Ptr>internal::ReturnPointeeAction<Ptr> ReturnPointee (Ptr pointer)This action returns the value pointed to by 'pointer'.
Defined at line 2152 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h
-
template <int&... ExplicitParameterBarrier, typename Factory>TestInfo * RegisterTest (const char * test_suite_name, const char * test_name, const char * type_param, const char * value_param, const char * file, int line, Factory factory)Dynamically registers a test with the framework.
This is an advanced API only to be used when the `TEST` macros are
insufficient. The macros should be preferred when possible, as they avoid
most of the complexity of calling this function.
The `factory` argument is a factory callable (move-constructible) object or
function pointer that creates a new instance of the Test object. It
handles ownership to the caller. The signature of the callable is
`Fixture*()`, where `Fixture` is the test fixture class for the test. All
tests registered with the same `test_suite_name` must return the same
fixture type. This is checked at runtime.
The framework will infer the fixture class from the factory and will call
the `SetUpTestSuite` and `TearDownTestSuite` for it.
Must be called before `RUN_ALL_TESTS()` is invoked, otherwise behavior is
undefined.
Use case example:
class MyFixture : public ::testing::Test {
public:
// All of these optional, just like in regular macro usage.
static void SetUpTestSuite() { ... }
static void TearDownTestSuite() { ... }
void SetUp() override { ... }
void TearDown() override { ... }
};
class MyTest : public MyFixture {
public:
explicit MyTest(int data) : data_(data) {}
void TestBody() override { ... }
private:
int data_;
};
void RegisterMyTests(const std::vector
<int
>
&
values) {
for (int v : values) {
::testing::RegisterTest(
"MyFixture", ("Test" + std::to_string(v)).c_str(), nullptr,
std::to_string(v).c_str(),
__FILE__, __LINE__,
// Important to use the fixture type as the return type here.
[=]() -> MyFixture* { return new MyTest(v); });
}
}
...
int main(int argc, char** argv) {
::testing::InitGoogleTest(
&argc
, argv);
std::vector
<int
> values_to_test = LoadValuesFromConfig();
RegisterMyTests(values_to_test);
...
return RUN_ALL_TESTS();
}
Defined at line 2299 of file ../../third_party/googletest/src/googletest/include/gtest/gtest.h
-
template <typename Iter>internal::ElementsAreArrayMatcher<typename ::std::iterator_traits<Iter>::value_type> ElementsAreArray (Iter first, Iter last)ElementsAreArray(iterator_first, iterator_last)
ElementsAreArray(pointer, count)
ElementsAreArray(array)
ElementsAreArray(container)
ElementsAreArray({ e1, e2, ..., en })
The ElementsAreArray() functions are like ElementsAre(...), except
that they are given a homogeneous sequence rather than taking each
element as a function argument. The sequence can be specified as an
array, a pointer and count, a vector, an initializer list, or an
STL iterator range. In each of these cases, the underlying sequence
can be either a sequence of values or a sequence of matchers.
All forms of ElementsAreArray() make a copy of the input matcher sequence.
Defined at line 4378 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>decltype(ElementsAreArray(pointer, pointer + count)) ElementsAreArray (const T * pointer, size_t count)Defined at line 4386 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, size_t N>decltype(ElementsAreArray(array, N)) ElementsAreArray (const T (&)[N] array)Defined at line 4392 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>decltype(ElementsAreArray(container.begin(), container.end())) ElementsAreArray (const Container & container)Defined at line 4398 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>decltype(ElementsAreArray(xs.begin(), xs.end())) ElementsAreArray (::std::initializer_list<T> xs)Defined at line 4404 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
std::string TempDir ()Returns a path to a temporary directory, which should be writable. It is
implementation-dependent whether or not the path is terminated by the
directory-separator character.
-
std::string SrcDir ()Returns a path to a directory that contains ancillary data files that might
be used by tests. It is implementation dependent whether or not the path is
terminated by the directory-separator character. The directory and the files
in it should be considered read-only.
-
template <typename T1, typename T2>bool StaticAssertTypeEq ()Compile-time assertion for type equality.
StaticAssertTypeEq
<type1
, type2>() compiles if and only if type1 and type2
are the same type. The value it returns is not interesting.
Instead of making StaticAssertTypeEq a class template, we make it a
function template that invokes a helper class template. This
prevents a user from misusing StaticAssertTypeEq
<T1
, T2> by
defining objects of that type.
CAVEAT:
When used inside a method of a class template,
StaticAssertTypeEq
<T1
, T2>() is effective ONLY IF the method is
instantiated. For example, given:
template
<typename
T> class Foo {
public:
void Bar() { testing::StaticAssertTypeEq
<int
, T>(); }
};
the code:
void Test1() { Foo
<bool
> foo; }
will NOT generate a compiler error, as Foo
<bool
>::Bar() is never
actually instantiated. Instead, you need:
void Test2() { Foo
<bool
> foo; foo.Bar(); }
to cause a compiler error.
Defined at line 2155 of file ../../third_party/googletest/src/googletest/include/gtest/gtest.h
-
template <typename Iter>internal::UnorderedElementsAreArrayMatcher<typename ::std::iterator_traits<Iter>::value_type> UnorderedElementsAreArray (Iter first, Iter last)UnorderedElementsAreArray(iterator_first, iterator_last)
UnorderedElementsAreArray(pointer, count)
UnorderedElementsAreArray(array)
UnorderedElementsAreArray(container)
UnorderedElementsAreArray({ e1, e2, ..., en })
UnorderedElementsAreArray() verifies that a bijective mapping onto a
collection of matchers exists.
The matchers can be specified as an array, a pointer and count, a container,
an initializer list, or an STL iterator range. In each of these cases, the
underlying matchers can be either values or matchers.
Defined at line 4423 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::UnorderedElementsAreArrayMatcher<T> UnorderedElementsAreArray (const T * pointer, size_t count)Defined at line 4432 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, size_t N>internal::UnorderedElementsAreArrayMatcher<T> UnorderedElementsAreArray (const T (&)[N] array)Defined at line 4438 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>internal::UnorderedElementsAreArrayMatcher<typename Container::value_type> UnorderedElementsAreArray (const Container & container)Defined at line 4444 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::UnorderedElementsAreArrayMatcher<T> UnorderedElementsAreArray (::std::initializer_list<T> xs)Defined at line 4451 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>Matcher<T> A ()A
<T
>() returns a matcher that matches any value of type T.
Defined at line 4468 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::IsNullMatcher> IsNull ()Creates a polymorphic matcher that matches any NULL pointer.
Defined at line 4486 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::NotNullMatcher> NotNull ()Creates a polymorphic matcher that matches any non-NULL pointer.
This is convenient as Not(NULL) doesn't compile (the compiler
thinks that that expression is comparing a pointer with an integer).
Defined at line 4493 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::RefMatcher<T &> Ref (T & x)Creates a polymorphic matcher that matches any argument that
references variable x.
Defined at line 4500 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::IsNanMatcher> IsNan ()Creates a polymorphic matcher that matches any NaN floating point.
Defined at line 4505 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<double> DoubleEq (double rhs)Creates a matcher that matches any double argument approximately
equal to rhs, where two NANs are considered unequal.
Defined at line 4511 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<double> NanSensitiveDoubleEq (double rhs)Creates a matcher that matches any double argument approximately
equal to rhs, including NaN values when rhs is NaN.
Defined at line 4517 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<double> DoubleNear (double rhs, double max_abs_error)Creates a matcher that matches any double argument approximately equal to
rhs, up to the specified max absolute error bound, where two NANs are
considered unequal. The max absolute error bound must be non-negative.
Defined at line 4524 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename GetDistance, typename DistanceMatcher>internal::DistanceFromMatcher<T, GetDistance, DistanceMatcher> DistanceFrom (T target, GetDistance get_distance, DistanceMatcher distance_matcher)The DistanceFrom(target, get_distance, m) and DistanceFrom(target, m)
matchers work on arbitrary types that have the "distance" concept. What they
do:
1. compute the distance between the value and the target using
get_distance(value, target) if get_distance is provided; otherwise compute
the distance as abs(value - target).
2. match the distance against the user-provided matcher m; if the match
succeeds, the DistanceFrom() match succeeds.
Examples:
// 0.5's distance from 0.6 should be
<
= 0.2.
EXPECT_THAT(0.5, DistanceFrom(0.6, Le(0.2)));
Vector2D v1(3.0, 4.0), v2(3.2, 6.0);
// v1's distance from v2, as computed by EuclideanDistance(v1, v2),
// should be >= 1.0.
EXPECT_THAT(v1, DistanceFrom(v2, EuclideanDistance, Ge(1.0)));
Defined at line 4550 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename DistanceMatcher>internal::DistanceFromMatcher<T, internal::DefaultGetDistance, DistanceMatcher> DistanceFrom (T target, DistanceMatcher distance_matcher)Defined at line 4558 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<double> NanSensitiveDoubleNear (double rhs, double max_abs_error)Creates a matcher that matches any double argument approximately equal to
rhs, up to the specified max absolute error bound, including NaN values when
rhs is NaN. The max absolute error bound must be non-negative.
Defined at line 4568 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<float> FloatEq (float rhs)Creates a matcher that matches any float argument approximately
equal to rhs, where two NANs are considered unequal.
Defined at line 4575 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<float> NanSensitiveFloatEq (float rhs)Creates a matcher that matches any float argument approximately
equal to rhs, including NaN values when rhs is NaN.
Defined at line 4581 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<float> FloatNear (float rhs, float max_abs_error)Creates a matcher that matches any float argument approximately equal to
rhs, up to the specified max absolute error bound, where two NANs are
considered unequal. The max absolute error bound must be non-negative.
Defined at line 4588 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEqMatcher<float> NanSensitiveFloatNear (float rhs, float max_abs_error)Creates a matcher that matches any float argument approximately equal to
rhs, up to the specified max absolute error bound, including NaN values when
rhs is NaN. The max absolute error bound must be non-negative.
Defined at line 4596 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename InnerMatcher>internal::PointeeMatcher<InnerMatcher> Pointee (const InnerMatcher & inner_matcher)Creates a matcher that matches a pointer (raw or smart) that points
to a value that matches inner_matcher.
Defined at line 4604 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename To>PolymorphicMatcher<internal::WhenDynamicCastToMatcher<To>> WhenDynamicCastTo (const Matcher<To> & inner_matcher)Creates a matcher that matches a pointer or reference that matches
inner_matcher when dynamic_cast
<To
> is applied.
The result of dynamic_cast
<To
> is forwarded to the inner matcher.
If To is a pointer and the cast fails, the inner matcher will receive NULL.
If To is a reference and the cast fails, this matcher returns false
immediately.
Defined at line 4617 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Class, typename FieldType, typename FieldMatcher>PolymorphicMatcher<internal::FieldMatcher<Class, FieldType>> Field (FieldType Class::* field, const FieldMatcher & matcher)Creates a matcher that matches an object whose given field matches
'matcher'. For example,
Field(
&Foo
::number, Ge(5))
matches a Foo object x if and only if x.number >= 5.
Defined at line 4629 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Class, typename FieldType, typename FieldMatcher>PolymorphicMatcher<internal::FieldMatcher<Class, FieldType>> Field (const std::string & field_name, FieldType Class::* field, const FieldMatcher & matcher)Same as Field() but also takes the name of the field to provide better error
messages.
Defined at line 4642 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Class, typename PropertyType, typename PropertyMatcher>PolymorphicMatcher<internal::PropertyMatcher<Class, PropertyType, PropertyType (Class::*)() const>> Property (PropertyType (Class::*)() const property, const PropertyMatcher & matcher)Creates a matcher that matches an object whose given property
matches 'matcher'. For example,
Property(
&Foo
::str, StartsWith("hi"))
matches a Foo object x if and only if x.str() starts with "hi".
Warning: Don't use `Property()` against member functions that you do not
own, because taking addresses of functions is fragile and generally not part
of the contract of the function.
Defined at line 4658 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Class, typename PropertyType, typename PropertyMatcher>PolymorphicMatcher<internal::PropertyMatcher<Class, PropertyType, PropertyType (Class::*)() const>> Property (const std::string & property_name, PropertyType (Class::*)() const property, const PropertyMatcher & matcher)Same as Property() above, but also takes the name of the property to provide
better error messages.
Defined at line 4675 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Callable, typename InnerMatcher>internal::ResultOfMatcher<Callable, InnerMatcher> ResultOf (Callable callable, InnerMatcher matcher)Creates a matcher that matches an object if and only if the result of
applying a callable to x matches 'matcher'. For example,
ResultOf(f, StartsWith("hi"))
matches a Foo object x if and only if f(x) starts with "hi".
`callable` parameter can be a function, function pointer, or a functor. It is
required to keep no state affecting the results of the calls on it and make
no assumptions about how many calls will be made. Any state it keeps must be
protected from the concurrent access.
Defined at line 4720 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Callable, typename InnerMatcher>internal::ResultOfMatcher<Callable, InnerMatcher> ResultOf (const std::string & result_description, Callable callable, InnerMatcher matcher)Same as ResultOf() above, but also takes a description of the `callable`
result to provide better error messages.
Defined at line 4729 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::StrEqualityMatcher<std::string>> StrEq (const internal::StringLike<T> & str)Matches a string equal to str.
Defined at line 4740 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::StrEqualityMatcher<std::string>> StrNe (const internal::StringLike<T> & str)Matches a string not equal to str.
Defined at line 4748 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::StrEqualityMatcher<std::string>> StrCaseEq (const internal::StringLike<T> & str)Matches a string equal to str, ignoring case.
Defined at line 4756 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::StrEqualityMatcher<std::string>> StrCaseNe (const internal::StringLike<T> & str)Matches a string not equal to str, ignoring case.
Defined at line 4764 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::HasSubstrMatcher<std::string>> HasSubstr (const internal::StringLike<T> & substring)Creates a matcher that matches any string, std::string, or C string
that contains the given substring.
Defined at line 4773 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::StartsWithMatcher<std::string>> StartsWith (const internal::StringLike<T> & prefix)Matches a string that starts with 'prefix' (case-sensitive).
Defined at line 4781 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T = std::string>PolymorphicMatcher<internal::EndsWithMatcher<std::string>> EndsWith (const internal::StringLike<T> & suffix)Matches a string that ends with 'suffix' (case-sensitive).
Defined at line 4789 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring>> StrEq (const std::wstring & str)Matches a string equal to str.
Defined at line 4799 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring>> StrNe (const std::wstring & str)Matches a string not equal to str.
Defined at line 4806 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring>> StrCaseEq (const std::wstring & str)Matches a string equal to str, ignoring case.
Defined at line 4813 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring>> StrCaseNe (const std::wstring & str)Matches a string not equal to str, ignoring case.
Defined at line 4820 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::HasSubstrMatcher<std::wstring>> HasSubstr (const std::wstring & substring)Creates a matcher that matches any ::wstring, std::wstring, or C wide string
that contains the given substring.
Defined at line 4828 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::StartsWithMatcher<std::wstring>> StartsWith (const std::wstring & prefix)Matches a string that starts with 'prefix' (case-sensitive).
Defined at line 4835 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
PolymorphicMatcher<internal::EndsWithMatcher<std::wstring>> EndsWith (const std::wstring & suffix)Matches a string that ends with 'suffix' (case-sensitive).
Defined at line 4842 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::Eq2Matcher Eq ()Creates a polymorphic matcher that matches a 2-tuple where the
first field == the second field.
Defined at line 4852 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::Ge2Matcher Ge ()Creates a polymorphic matcher that matches a 2-tuple where the
first field >= the second field.
Defined at line 4856 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::Gt2Matcher Gt ()Creates a polymorphic matcher that matches a 2-tuple where the
first field > the second field.
Defined at line 4860 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::Le2Matcher Le ()Creates a polymorphic matcher that matches a 2-tuple where the
first field
<
= the second field.
Defined at line 4864 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::Lt2Matcher Lt ()Creates a polymorphic matcher that matches a 2-tuple where the
first field
<
the second field.
Defined at line 4868 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::Ne2Matcher Ne ()Creates a polymorphic matcher that matches a 2-tuple where the
first field != the second field.
Defined at line 4872 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<float> FloatEq ()Creates a polymorphic matcher that matches a 2-tuple where
FloatEq(first field) matches the second field.
Defined at line 4876 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<double> DoubleEq ()Creates a polymorphic matcher that matches a 2-tuple where
DoubleEq(first field) matches the second field.
Defined at line 4882 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<float> NanSensitiveFloatEq ()Creates a polymorphic matcher that matches a 2-tuple where
FloatEq(first field) matches the second field with NaN equality.
Defined at line 4888 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<double> NanSensitiveDoubleEq ()Creates a polymorphic matcher that matches a 2-tuple where
DoubleEq(first field) matches the second field with NaN equality.
Defined at line 4894 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<float> FloatNear (float max_abs_error)Creates a polymorphic matcher that matches a 2-tuple where
FloatNear(first field, max_abs_error) matches the second field.
Defined at line 4900 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<double> DoubleNear (double max_abs_error)Creates a polymorphic matcher that matches a 2-tuple where
DoubleNear(first field, max_abs_error) matches the second field.
Defined at line 4906 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<float> NanSensitiveFloatNear (float max_abs_error)Creates a polymorphic matcher that matches a 2-tuple where
FloatNear(first field, max_abs_error) matches the second field with NaN
equality.
Defined at line 4913 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
internal::FloatingEq2Matcher<double> NanSensitiveDoubleNear (double max_abs_error)Creates a polymorphic matcher that matches a 2-tuple where
DoubleNear(first field, max_abs_error) matches the second field with NaN
equality.
Defined at line 4921 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename InnerMatcher>internal::NotMatcher<InnerMatcher> Not (InnerMatcher m)Creates a matcher that matches any value of type T that m doesn't
match.
Defined at line 4929 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Predicate>PolymorphicMatcher<internal::TrulyMatcher<Predicate>> Truly (Predicate pred)Returns a matcher that matches anything that satisfies the given
predicate. The predicate can be any unary function or functor
whose return type can be implicitly converted to bool.
Defined at line 4937 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename SizeMatcher>internal::SizeIsMatcher<SizeMatcher> SizeIs (const SizeMatcher & size_matcher)Returns a matcher that matches the container size. The container must
support both size() and size_type which all STL-like containers provide.
Note that the parameter 'size' can be a value of type size_type as well as
matcher. For instance:
EXPECT_THAT(container, SizeIs(2)); // Checks container has 2 elements.
EXPECT_THAT(container, SizeIs(Le(2)); // Checks container has at most 2.
Defined at line 4949 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename DistanceMatcher>internal::BeginEndDistanceIsMatcher<DistanceMatcher> BeginEndDistanceIs (const DistanceMatcher & distance_matcher)Returns a matcher that matches the distance between the container's begin()
iterator and its end() iterator, i.e. the size of the container. This matcher
can be used instead of SizeIs with containers such as std::forward_list which
do not implement size(). The container must provide const_iterator (with
valid iterator_traits), begin() and end().
Defined at line 4960 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>PolymorphicMatcher<internal::ContainerEqMatcher<typename std::remove_const<Container>::type>> ContainerEq (const Container & rhs)Returns a matcher that matches an equal container.
This matcher behaves like Eq(), but in the event of mismatch lists the
values that are included in one container but not the other. (Duplicate
values and order differences are not explained.)
Defined at line 4970 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Comparator, typename ContainerMatcher>internal::WhenSortedByMatcher<Comparator, ContainerMatcher> WhenSortedBy (const Comparator & comparator, const ContainerMatcher & container_matcher)Returns a matcher that matches a container that, when sorted using
the given comparator, matches container_matcher.
Defined at line 4979 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename ContainerMatcher>internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher> WhenSorted (const ContainerMatcher & container_matcher)Returns a matcher that matches a container that, when sorted using
the
<
operator, matches container_matcher.
Defined at line 4988 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename TupleMatcher, typename Container>internal::PointwiseMatcher<TupleMatcher, typename std::remove_const<Container>::type> Pointwise (const TupleMatcher & tuple_matcher, const Container & rhs)Matches an STL-style container or a native array that contains the
same number of elements as in rhs, where its i-th element and rhs's
i-th element (as a pair) satisfy the given pair matcher, for all i.
TupleMatcher must be able to be safely cast to Matcher
<std
::tuple
<const
T1
&
, const T2
&
> >, where T1 and T2 are the types of elements in the
LHS container and the RHS container respectively.
Defined at line 5002 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename TupleMatcher, typename T>internal::PointwiseMatcher<TupleMatcher, std::vector<std::remove_const_t<T>>> Pointwise (const TupleMatcher & tuple_matcher, std::initializer_list<T> rhs)Supports the Pointwise(m, {a, b, c}) syntax.
Defined at line 5011 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Tuple2Matcher, typename RhsContainer>internal::UnorderedElementsAreArrayMatcher<typename internal::BoundSecondMatcher<Tuple2Matcher, typename internal::StlContainerView<typename std::remove_const<RhsContainer>::type>::type::value_type>> UnorderedPointwise (const Tuple2Matcher & tuple2_matcher, const RhsContainer & rhs_container)UnorderedPointwise(pair_matcher, rhs) matches an STL-style
container or a native array that contains the same number of
elements as in rhs, where in some permutation of the container, its
i-th element and rhs's i-th element (as a pair) satisfy the given
pair matcher, for all i. Tuple2Matcher must be able to be safely
cast to Matcher
<std
::tuple
<const
T1
&
, const T2
&
> >, where T1 and T2 are
the types of elements in the LHS container and the RHS container
respectively.
This is like Pointwise(pair_matcher, rhs), except that the element
order doesn't matter.
Defined at line 5029 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Tuple2Matcher, typename T>internal::UnorderedElementsAreArrayMatcher<typename internal::BoundSecondMatcher<Tuple2Matcher, T>> UnorderedPointwise (const Tuple2Matcher & tuple2_matcher, std::initializer_list<T> rhs)Supports the UnorderedPointwise(m, {a, b, c}) syntax.
Defined at line 5057 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename M>internal::ContainsMatcher<M> Contains (M matcher)Matches an STL-style container or a native array that contains at
least one element matching the given value or matcher.
Examples:
::std::set
<int
> page_ids;
page_ids.insert(3);
page_ids.insert(1);
EXPECT_THAT(page_ids, Contains(1));
EXPECT_THAT(page_ids, Contains(Gt(2)));
EXPECT_THAT(page_ids, Not(Contains(4))); // See below for Times(0)
::std::map
<int
, size_t> page_lengths;
page_lengths[1] = 100;
EXPECT_THAT(page_lengths,
Contains(::std::pair
<const
int, size_t>(1, 100)));
const char* user_ids[] = { "joe", "mike", "tom" };
EXPECT_THAT(user_ids, Contains(Eq(::std::string("tom"))));
The matcher supports a modifier `Times` that allows to check for arbitrary
occurrences including testing for absence with Times(0).
Examples:
::std::vector
<int
> ids;
ids.insert(1);
ids.insert(1);
ids.insert(3);
EXPECT_THAT(ids, Contains(1).Times(2)); // 1 occurs 2 times
EXPECT_THAT(ids, Contains(2).Times(0)); // 2 is not present
EXPECT_THAT(ids, Contains(3).Times(Ge(1))); // 3 occurs at least once
Defined at line 5096 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Iter>internal::UnorderedElementsAreArrayMatcher<typename ::std::iterator_traits<Iter>::value_type> IsSupersetOf (Iter first, Iter last)IsSupersetOf(iterator_first, iterator_last)
IsSupersetOf(pointer, count)
IsSupersetOf(array)
IsSupersetOf(container)
IsSupersetOf({e1, e2, ..., en})
IsSupersetOf() verifies that a surjective partial mapping onto a collection
of matchers exists. In other words, a container matches
IsSupersetOf({e1, ..., en}) if and only if there is a permutation
{y1, ..., yn} of some of the container's elements where y1 matches e1,
..., and yn matches en. Obviously, the size of the container must be >= n
in order to have a match. Examples:
- {1, 2, 3} matches IsSupersetOf({Ge(3), Ne(0)}), as 3 matches Ge(3) and
1 matches Ne(0).
- {1, 2} doesn't match IsSupersetOf({Eq(1), Lt(2)}), even though 1 matches
both Eq(1) and Lt(2). The reason is that different matchers must be used
for elements in different slots of the container.
- {1, 1, 2} matches IsSupersetOf({Eq(1), Lt(2)}), as (the first) 1 matches
Eq(1) and (the second) 1 matches Lt(2).
- {1, 2, 3} matches IsSupersetOf(Gt(1), Gt(1)), as 2 matches (the first)
Gt(1) and 3 matches (the second) Gt(1).
The matchers can be specified as an array, a pointer and count, a container,
an initializer list, or an STL iterator range. In each of these cases, the
underlying matchers can be either values or matchers.
Defined at line 5128 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf (const T * pointer, size_t count)Defined at line 5137 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, size_t N>internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf (const T (&)[N] array)Defined at line 5143 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>internal::UnorderedElementsAreArrayMatcher<typename Container::value_type> IsSupersetOf (const Container & container)Defined at line 5149 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf (::std::initializer_list<T> xs)Defined at line 5156 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Iter>internal::UnorderedElementsAreArrayMatcher<typename ::std::iterator_traits<Iter>::value_type> IsSubsetOf (Iter first, Iter last)IsSubsetOf(iterator_first, iterator_last)
IsSubsetOf(pointer, count)
IsSubsetOf(array)
IsSubsetOf(container)
IsSubsetOf({e1, e2, ..., en})
IsSubsetOf() verifies that an injective mapping onto a collection of matchers
exists. In other words, a container matches IsSubsetOf({e1, ..., en}) if and
only if there is a subset of matchers {m1, ..., mk} which would match the
container using UnorderedElementsAre. Obviously, the size of the container
must be
<
= n in order to have a match. Examples:
- {1} matches IsSubsetOf({Gt(0), Lt(0)}), as 1 matches Gt(0).
- {1, -1} matches IsSubsetOf({Lt(0), Gt(0)}), as 1 matches Gt(0) and -1
matches Lt(0).
- {1, 2} doesn't match IsSubsetOf({Gt(0), Lt(0)}), even though 1 and 2 both
match Gt(0). The reason is that different matchers must be used for
elements in different slots of the container.
The matchers can be specified as an array, a pointer and count, a container,
an initializer list, or an STL iterator range. In each of these cases, the
underlying matchers can be either values or matchers.
Defined at line 5185 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf (const T * pointer, size_t count)Defined at line 5194 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, size_t N>internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf (const T (&)[N] array)Defined at line 5200 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename Container>internal::UnorderedElementsAreArrayMatcher<typename Container::value_type> IsSubsetOf (const Container & container)Defined at line 5206 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf (::std::initializer_list<T> xs)Defined at line 5213 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename M>internal::EachMatcher<M> Each (M matcher)Matches an STL-style container or a native array that contains only
elements matching the given value or matcher.
Each(m) is semantically equivalent to `Not(Contains(Not(m)))`. Only
the messages are different.
Examples:
::std::set
<int
> page_ids;
// Each(m) matches an empty container, regardless of what m is.
EXPECT_THAT(page_ids, Each(Eq(1)));
EXPECT_THAT(page_ids, Each(Eq(77)));
page_ids.insert(3);
EXPECT_THAT(page_ids, Each(Gt(0)));
EXPECT_THAT(page_ids, Not(Each(Gt(4))));
page_ids.insert(1);
EXPECT_THAT(page_ids, Not(Each(Lt(2))));
::std::map
<int
, size_t> page_lengths;
page_lengths[1] = 100;
page_lengths[2] = 200;
page_lengths[3] = 300;
EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));
EXPECT_THAT(page_lengths, Each(Key(Le(3))));
const char* user_ids[] = { "joe", "mike", "tom" };
EXPECT_THAT(user_ids, Not(Each(Eq(::std::string("tom")))));
Defined at line 5246 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename M>internal::KeyMatcher<M> Key (M inner_matcher)Key(inner_matcher) matches an std::pair whose 'first' field matches
inner_matcher. For example, Contains(Key(Ge(5))) can be used to match an
std::map that contains at least one element whose key is >= 5.
Defined at line 5254 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename FirstMatcher, typename SecondMatcher>internal::PairMatcher<FirstMatcher, SecondMatcher> Pair (FirstMatcher first_matcher, SecondMatcher second_matcher)Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field
matches first_matcher and whose 'second' field matches second_matcher. For
example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), "foo"))) can be used
to match a std::map
<int
, string> that contains exactly one element whose key
is >= 5 and whose value equals "foo".
Defined at line 5264 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename M>internal::MatcherAsPredicate<M> Matches (M matcher)Returns a predicate that is satisfied by anything that matches the
given matcher.
Defined at line 5322 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename M>bool Value (const T & value, M matcher)Returns true if and only if the value matches the matcher.
Defined at line 5328 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename M>bool ExplainMatchResult (M matcher, const T & value, MatchResultListener * listener)Matches the value against the given matcher and explains the match
result to listener.
Defined at line 5335 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T, typename M>std::string DescribeMatcher (const M & matcher, bool negation)Returns a string representation of the given matcher. Useful for description
strings of matchers defined using MATCHER_P* macros that accept matchers as
their arguments. For example:
MATCHER_P(XAndYThat, matcher,
"X that " + DescribeMatcher
<int
>(matcher, negation) +
(negation ? " or" : " and") + " Y that " +
DescribeMatcher
<double
>(matcher, negation)) {
return ExplainMatchResult(matcher, arg.x(), result_listener)
&
&
ExplainMatchResult(matcher, arg.y(), result_listener);
}
Defined at line 5352 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename... Args>internal::ElementsAreMatcher<std::tuple<typename std::decay<const Args &>::type...>> ElementsAre (const Args &... matchers)Defined at line 5364 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename... Args>internal::UnorderedElementsAreMatcher<std::tuple<typename std::decay<const Args &>::type...>> UnorderedElementsAre (const Args &... matchers)Defined at line 5373 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename ValueMatcher>internal::OptionalMatcher<ValueMatcher> Optional (const ValueMatcher & value_matcher)Returns a matcher that matches the value of an optional
<
> type variable.
The matcher implementation only uses '!arg' (or 'arg.has_value()' if '!arg`
isn't a valid expression) and requires that the optional
<
> type has a
'value_type' member type and that '*arg' is of type 'value_type' and is
printable using 'PrintToString'. It is compatible with
std::optional/std::experimental::optional.
Note that to compare an optional type variable against nullopt you should
use Eq(nullopt) and not Eq(Optional(nullopt)). The latter implies that the
optional value contains an optional itself.
Defined at line 5510 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
-
template <typename T>PolymorphicMatcher<internal::variant_matcher::VariantMatcher<T>> VariantWith (const Matcher<const T &> & matcher)Returns a matcher that matches the value of a variant
<
> type variable.
The matcher implementation uses ADL to find the holds_alternative and get
functions.
It is compatible with std::variant.
Defined at line 5528 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-matchers.h
Variables
bool FLAGS_gmock_catch_leaked_mocks
int32_t FLAGS_gmock_default_mock_behavior
::std::string FLAGS_gmock_verbose
bool FLAGS_gtest_also_run_disabled_tests
bool FLAGS_gtest_break_on_failure
bool FLAGS_gtest_brief
bool FLAGS_gtest_catch_exceptions
::std::string FLAGS_gtest_color
::std::string FLAGS_gtest_death_test_style
bool FLAGS_gtest_fail_fast
::std::string FLAGS_gtest_filter
::std::string FLAGS_gtest_flagfile
bool FLAGS_gtest_install_failure_signal_handler
::std::string FLAGS_gtest_internal_run_death_test
bool FLAGS_gtest_list_tests
::std::string FLAGS_gtest_output
bool FLAGS_gtest_print_time
bool FLAGS_gtest_print_utf8
std::int32_t FLAGS_gtest_random_seed
bool FLAGS_gtest_recreate_environments_when_repeating
std::int32_t FLAGS_gtest_repeat
bool FLAGS_gtest_show_internal_stack_frames
bool FLAGS_gtest_shuffle
std::int32_t FLAGS_gtest_stack_trace_depth
::std::string FLAGS_gtest_stream_result_to
bool FLAGS_gtest_throw_on_failure