Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest.cc File Reference
#include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h"
#include "gtest/gtest-spi.h"
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <ostream>
#include <sstream>
#include <vector>
#include <sys/time.h>
#include <unistd.h>
#include "src/gtest-internal-inl.h"
Include dependency graph for gtest.cc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  testing::internal::PrettyUnitTestResultPrinter
 
class  testing::internal::TestEventRepeater
 
class  testing::internal::XmlUnitTestResultPrinter
 
class  testing::internal::JsonUnitTestResultPrinter
 
class  testing::internal::ScopedPrematureExitFile
 
class  testing::internal::TestCaseNameIs
 

Namespaces

namespace  testing
 
namespace  testing::internal
 
namespace  testing::internal::edit_distance
 

Macros

#define GTEST_HAS_GETTIMEOFDAY_   1
 
#define GTEST_IMPL_CMP_HELPER_(op_name, op)
 
#define GTEST_REPEATER_METHOD_(Name, Type)
 
#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)
 

Enumerations

enum  testing::internal::GTestColor { testing::internal::COLOR_DEFAULT , testing::internal::COLOR_RED , testing::internal::COLOR_GREEN , testing::internal::COLOR_YELLOW }
 

Functions

 testing::GTEST_DEFINE_bool_ (also_run_disabled_tests, internal::BoolFromGTestEnv("also_run_disabled_tests", false), "Run disabled tests too, in addition to the tests normally being run.")
 
 testing::GTEST_DEFINE_bool_ (break_on_failure, internal::BoolFromGTestEnv("break_on_failure", false), "True iff a failed assertion should be a debugger break-point.")
 
 testing::GTEST_DEFINE_bool_ (catch_exceptions, internal::BoolFromGTestEnv("catch_exceptions", true), "True iff " GTEST_NAME_ " should catch exceptions and treat them as test failures.")
 
 testing::GTEST_DEFINE_string_ (color, internal::StringFromGTestEnv("color", "auto"), "Whether to use colors in the output. Valid values: yes, no, " "and auto. 'auto' means to use colors if the output is " "being sent to a terminal and the TERM environment variable " "is set to a terminal type that supports colors.")
 
 testing::GTEST_DEFINE_string_ (filter, internal::StringFromGTestEnv("filter", GetDefaultFilter()), "A colon-separated list of glob (not regex) patterns " "for filtering the tests to run, optionally followed by a " "'-' and a : separated list of negative patterns (tests to " "exclude). A test is run if it matches one of the positive " "patterns and does not match any of the negative patterns.")
 
 testing::GTEST_DEFINE_bool_ (list_tests, false, "List all tests without running them.")
 
 testing::GTEST_DEFINE_string_ (output, internal::StringFromGTestEnv("output", internal::OutputFlagAlsoCheckEnvVar().c_str()), "A format (defaults to \"xml\" but can be specified to be \"json\"), " "optionally followed by a colon and an output file name or directory. " "A directory is indicated by a trailing pathname separator. " "Examples: \"xml:filename.xml\", \"xml::directoryname/\". " "If a directory is specified, output files will be created " "within that directory, with file-names based on the test " "executable's name and, if necessary, made unique by adding " "digits.")
 
 testing::GTEST_DEFINE_bool_ (print_time, internal::BoolFromGTestEnv("print_time", true), "True iff " GTEST_NAME_ " should display elapsed time in text output.")
 
 testing::GTEST_DEFINE_bool_ (print_utf8, internal::BoolFromGTestEnv("print_utf8", true), "True iff " GTEST_NAME_ " prints UTF8 characters as text.")
 
 testing::GTEST_DEFINE_int32_ (random_seed, internal::Int32FromGTestEnv("random_seed", 0), "Random number seed to use when shuffling test orders. Must be in range " "[1, 99999], or 0 to use a seed based on the current time.")
 
 testing::GTEST_DEFINE_int32_ (repeat, internal::Int32FromGTestEnv("repeat", 1), "How many times to repeat each test. Specify a negative number " "for repeating forever. Useful for shaking out flaky tests.")
 
 testing::GTEST_DEFINE_bool_ (show_internal_stack_frames, false, "True iff " GTEST_NAME_ " should include internal stack frames when " "printing test failure stack traces.")
 
 testing::GTEST_DEFINE_bool_ (shuffle, internal::BoolFromGTestEnv("shuffle", false), "True iff " GTEST_NAME_ " should randomize tests' order on every run.")
 
 testing::GTEST_DEFINE_int32_ (stack_trace_depth, internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth), "The maximum number of stack frames to print when an " "assertion fails. The valid range is 0 through 100, inclusive.")
 
 testing::GTEST_DEFINE_string_ (stream_result_to, internal::StringFromGTestEnv("stream_result_to", ""), "This flag specifies the host name and the port number on which to stream " "test results. Example: \"localhost:555\". The flag is effective only on " "Linux.")
 
 testing::GTEST_DEFINE_bool_ (throw_on_failure, internal::BoolFromGTestEnv("throw_on_failure", false), "When this flag is specified, a failed assertion will throw an exception " "if exceptions are enabled or exit the program with a non-zero code " "otherwise. For use with an external test framework.")
 
GTEST_API_ testing::internal::GTEST_DEFINE_STATIC_MUTEX_ (g_linked_ptr_mutex)
 
GTEST_API_ std::vector< std::string > testing::internal::GetArgvs ()
 
GTEST_API_ FilePath testing::internal::GetCurrentExecutableName ()
 
GTEST_API_ TypeId testing::internal::GetTestTypeId ()
 
GTEST_API_ TimeInMillis testing::internal::GetTimeInMillis ()
 
void testing::internal::SplitString (const ::std::string &str, char delimiter, ::std::vector< ::std::string > *dest)
 
GTEST_API_ AssertionResult testing::AssertionSuccess ()
 
GTEST_API_ AssertionResult testing::AssertionFailure ()
 
GTEST_API_ AssertionResult testing::AssertionFailure (const Message &msg)
 
GTEST_API_ std::vector< EditTypetesting::internal::edit_distance::CalculateOptimalEdits (const std::vector< size_t > &left, const std::vector< size_t > &right)
 
GTEST_API_ std::vector< EditTypetesting::internal::edit_distance::CalculateOptimalEdits (const std::vector< std::string > &left, const std::vector< std::string > &right)
 
GTEST_API_ std::string testing::internal::edit_distance::CreateUnifiedDiff (const std::vector< std::string > &left, const std::vector< std::string > &right, size_t context=2)
 
GTEST_API_ AssertionResult testing::internal::EqFailure (const char *expected_expression, const char *actual_expression, const std::string &expected_value, const std::string &actual_value, bool ignoring_case)
 
GTEST_API_ std::string testing::internal::GetBoolAssertionFailureMessage (const AssertionResult &assertion_result, const char *expression_text, const char *actual_predicate_value, const char *expected_predicate_value)
 
GTEST_API_ AssertionResult testing::internal::DoubleNearPredFormat (const char *expr1, const char *expr2, const char *abs_error_expr, double val1, double val2, double abs_error)
 
template<typename RawType >
AssertionResult testing::internal::FloatingPointLE (const char *expr1, const char *expr2, RawType val1, RawType val2)
 
GTEST_API_ AssertionResult testing::FloatLE (const char *expr1, const char *expr2, float val1, float val2)
 
GTEST_API_ AssertionResult testing::DoubleLE (const char *expr1, const char *expr2, double val1, double val2)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperEQ (const char *lhs_expression, const char *rhs_expression, BiggestInt lhs, BiggestInt rhs)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperSTREQ (const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperSTRCASEEQ (const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperSTRNE (const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperSTRCASENE (const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
 
GTEST_API_ AssertionResult testing::IsSubstring (const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
 
GTEST_API_ AssertionResult testing::IsSubstring (const char *needle_expr, const char *haystack_expr, const wchar_t *needle, const wchar_t *haystack)
 
GTEST_API_ AssertionResult testing::IsNotSubstring (const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
 
GTEST_API_ AssertionResult testing::IsNotSubstring (const char *needle_expr, const char *haystack_expr, const wchar_t *needle, const wchar_t *haystack)
 
GTEST_API_ AssertionResult testing::IsSubstring (const char *needle_expr, const char *haystack_expr, const ::std::string &needle, const ::std::string &haystack)
 
GTEST_API_ AssertionResult testing::IsNotSubstring (const char *needle_expr, const char *haystack_expr, const ::std::string &needle, const ::std::string &haystack)
 
UInt32 testing::internal::ChopLowBits (UInt32 *bits, int n)
 
GTEST_API_ std::string testing::internal::CodePointToUtf8 (UInt32 code_point)
 
bool testing::internal::IsUtf16SurrogatePair (wchar_t first, wchar_t second)
 
UInt32 testing::internal::CreateCodePointFromUtf16SurrogatePair (wchar_t first, wchar_t second)
 
GTEST_API_ std::string testing::internal::WideStringToUtf8 (const wchar_t *str, int num_chars)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperSTREQ (const char *s1_expression, const char *s2_expression, const wchar_t *s1, const wchar_t *s2)
 
GTEST_API_ AssertionResult testing::internal::CmpHelperSTRNE (const char *s1_expression, const char *s2_expression, const wchar_t *s1, const wchar_t *s2)
 
GTEST_API_ std::string testing::internal::StringStreamToString (::std::stringstream *stream)
 
GTEST_API_ std::string testing::internal::AppendUserMessage (const std::string &gtest_msg, const Message &user_msg)
 
template<int kSize>
std::vector< std::string > testing::ArrayAsVector (const char *const (&array)[kSize])
 
void testing::internal::ReportFailureInUnknownLocation (TestPartResult::Type result_type, const std::string &message)
 
template<class T , typename Result >
Result testing::internal::HandleSehExceptionsInMethodIfSupported (T *object, Result(T::*method)(), const char *location)
 
template<class T , typename Result >
Result testing::internal::HandleExceptionsInMethodIfSupported (T *object, Result(T::*method)(), const char *location)
 
GTEST_API_ TestInfotesting::internal::MakeAndRegisterTestInfo (const char *test_case_name, const char *name, const char *type_param, const char *value_param, CodeLocation code_location, TypeId fixture_class_id, SetUpTestCaseFunc set_up_tc, TearDownTestCaseFunc tear_down_tc, TestFactoryBase *factory)
 
GTEST_API_ void testing::internal::ReportInvalidTestCaseType (const char *test_case_name, CodeLocation code_location)
 
GTEST_API_ bool testing::internal::ShouldUseColor (bool stdout_is_tty)
 
GTEST_API_ std::string testing::internal::FormatTimeInMillisAsSeconds (TimeInMillis ms)
 
GTEST_API_ std::string testing::internal::FormatEpochTimeInMillisAsIso8601 (TimeInMillis ms)
 
void testing::internal::WriteToShardStatusFileIfNeeded ()
 
GTEST_API_ bool testing::internal::ShouldShard (const char *total_shards_str, const char *shard_index_str, bool in_subprocess_for_death_test)
 
GTEST_API_ Int32 testing::internal::Int32FromEnvOrDie (const char *env_var, Int32 default_val)
 
GTEST_API_ bool testing::internal::ShouldRunTestOnShard (int total_shards, int shard_index, int test_id)
 
GTEST_API_ std::string testing::internal::GetCurrentOsStackTraceExceptTop (UnitTest *unit_test, int skip_count)
 
GTEST_API_ bool testing::internal::IsTrue (bool condition)
 
GTEST_API_ bool testing::internal::AlwaysTrue ()
 
GTEST_API_ bool testing::internal::SkipPrefix (const char *prefix, const char **pstr)
 
GTEST_API_ bool testing::internal::ParseInt32Flag (const char *str, const char *flag, Int32 *value)
 
template<typename CharType >
void testing::internal::ParseGoogleTestFlagsOnlyImpl (int *argc, CharType **argv)
 
GTEST_API_ void testing::internal::ParseGoogleTestFlagsOnly (int *argc, char **argv)
 
GTEST_API_ void testing::internal::ParseGoogleTestFlagsOnly (int *argc, wchar_t **argv)
 
template<typename CharType >
void testing::internal::InitGoogleTestImpl (int *argc, CharType **argv)
 
GTEST_API_ void testing::InitGoogleTest (int *argc, char **argv)
 
GTEST_API_ void testing::InitGoogleTest (int *argc, wchar_t **argv)
 
GTEST_API_ std::string testing::TempDir ()
 

Variables

::std::vector< std::string > testing::internal::g_argvs
 
const UInt32 testing::internal::kMaxCodePoint1 = (static_cast<UInt32>(1) << 7) - 1
 
const UInt32 testing::internal::kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1
 
const UInt32 testing::internal::kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1
 
const UInt32 testing::internal::kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1
 

Macro Definition Documentation

◆ GTEST_HAS_GETTIMEOFDAY_

#define GTEST_HAS_GETTIMEOFDAY_   1

Definition at line 116 of file gtest.cc.

◆ GTEST_IMPL_CMP_HELPER_

#define GTEST_IMPL_CMP_HELPER_ ( op_name,
op )
Value:
AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
BiggestInt val1, BiggestInt val2) {\
if (val1 op val2) {\
return AssertionSuccess();\
} else {\
return AssertionFailure() \
<< "Expected: (" << expr1 << ") " #op " (" << expr2\
<< "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
<< " vs " << FormatForComparisonFailureMessage(val2, val1);\
}\
}

Definition at line 1470 of file gtest.cc.

1470#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
1471AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
1472 BiggestInt val1, BiggestInt val2) {\
1473 if (val1 op val2) {\
1474 return AssertionSuccess();\
1475 } else {\
1476 return AssertionFailure() \
1477 << "Expected: (" << expr1 << ") " #op " (" << expr2\
1478 << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
1479 << " vs " << FormatForComparisonFailureMessage(val2, val1);\
1480 }\
1481}

◆ GTEST_REPEATER_METHOD_

#define GTEST_REPEATER_METHOD_ ( Name,
Type )
Value:
void TestEventRepeater::Name(const Type& parameter) { \
if (forwarding_enabled_) { \
for (size_t i = 0; i < listeners_.size(); i++) { \
listeners_[i]->Name(parameter); \
} \
} \
}
#define parameter
Definition pkcs11.h:165
Type
Type of JSON value.
Definition rapidjson.h:644

Definition at line 3337 of file gtest.cc.

3337#define GTEST_REPEATER_METHOD_(Name, Type) \
3338void TestEventRepeater::Name(const Type& parameter) { \
3339 if (forwarding_enabled_) { \
3340 for (size_t i = 0; i < listeners_.size(); i++) { \
3341 listeners_[i]->Name(parameter); \
3342 } \
3343 } \
3344}

◆ GTEST_REVERSE_REPEATER_METHOD_

#define GTEST_REVERSE_REPEATER_METHOD_ ( Name,
Type )
Value:
void TestEventRepeater::Name(const Type& parameter) { \
if (forwarding_enabled_) { \
for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \
listeners_[i]->Name(parameter); \
} \
} \
}

Definition at line 3347 of file gtest.cc.

3347#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
3348void TestEventRepeater::Name(const Type& parameter) { \
3349 if (forwarding_enabled_) { \
3350 for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \
3351 listeners_[i]->Name(parameter); \
3352 } \
3353 } \
3354}