Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest-internal.h File Reference
#include "gtest/internal/gtest-port.h"
#include <ctype.h>
#include <float.h>
#include <string.h>
#include <iomanip>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-type-util.h"
Include dependency graph for gtest-internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  testing::internal::FloatingPoint< RawType >
 
class  testing::internal::TypeIdHelper< T >
 
class  testing::internal::TestFactoryBase
 
class  testing::internal::TestFactoryImpl< TestClass >
 
struct  testing::internal::CodeLocation
 
struct  testing::internal::ConstCharPtr
 
class  testing::internal::Random
 
struct  testing::internal::CompileAssertTypesEqual< T, T >
 
struct  testing::internal::RemoveReference< T >
 
struct  testing::internal::RemoveReference< T & >
 
struct  testing::internal::RemoveConst< T >
 
struct  testing::internal::RemoveConst< const T >
 
struct  testing::internal::RemoveConst< const T[N]>
 
class  testing::internal::ImplicitlyConvertible< From, To >
 
struct  testing::internal::IsAProtocolMessage< T >
 
struct  testing::internal::IsHashTable< T >
 
struct  testing::internal::VoidT< T >
 
struct  testing::internal::HasValueType< T, typename >
 
struct  testing::internal::HasValueType< T, VoidT< typename T::value_type > >
 
struct  testing::internal::IsRecursiveContainerImpl< C, false, HV >
 
struct  testing::internal::IsRecursiveContainerImpl< C, true, false >
 
struct  testing::internal::IsRecursiveContainerImpl< C, true, true >
 
struct  testing::internal::IsRecursiveContainer< C >
 
struct  testing::internal::EnableIf< true >
 
struct  testing::internal::RelationToSourceReference
 
struct  testing::internal::RelationToSourceCopy
 
class  testing::internal::NativeArray< Element >
 

Namespaces

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

Macros

#define GTEST_CONCAT_TOKEN_(foo, bar)
 
#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
 
#define GTEST_STRINGIFY_(name)
 
#define GTEST_IS_NULL_LITERAL_(x)
 
#define GTEST_REMOVE_REFERENCE_(T)
 
#define GTEST_REMOVE_CONST_(T)
 
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)
 
#define GTEST_MESSAGE_AT_(file, line, message, result_type)
 
#define GTEST_MESSAGE_(message, result_type)
 
#define GTEST_FATAL_FAILURE_(message)
 
#define GTEST_NONFATAL_FAILURE_(message)
 
#define GTEST_SUCCESS_(message)
 
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
 
#define GTEST_TEST_THROW_(statement, expected_exception, fail)
 
#define GTEST_TEST_NO_THROW_(statement, fail)
 
#define GTEST_TEST_ANY_THROW_(statement, fail)
 
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail)
 
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail)
 
#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name)
 
#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)
 

Typedefs

typedef FloatingPoint< float > testing::internal::Float
 
typedef FloatingPoint< double > testing::internal::Double
 
typedef const void * testing::internal::TypeId
 
typedef void(* testing::internal::SetUpTestCaseFunc) ()
 
typedef void(* testing::internal::TearDownTestCaseFunc) ()
 
typedef int testing::internal::IsContainer
 
typedef char testing::internal::IsNotContainer
 

Enumerations

enum  testing::internal::edit_distance::EditType { testing::internal::edit_distance::kMatch , testing::internal::edit_distance::kAdd , testing::internal::edit_distance::kRemove , testing::internal::edit_distance::kReplace }
 

Functions

template<typename T >
::std::string testing::PrintToString (const T &value)
 
char testing::internal::IsNullLiteralHelper (Secret *p)
 
char(& testing::internal::IsNullLiteralHelper (...))[2]
 
GTEST_API_ std::string testing::internal::AppendUserMessage (const std::string &gtest_msg, const Message &user_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_ std::string testing::internal::DiffStrings (const std::string &left, const std::string &right, size_t *total_line_count)
 
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)
 
template<typename T >
TypeId testing::internal::GetTypeId ()
 
GTEST_API_ TypeId testing::internal::GetTestTypeId ()
 
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_ bool testing::internal::SkipPrefix (const char *prefix, const char **pstr)
 
GTEST_API_ std::string testing::internal::GetCurrentOsStackTraceExceptTop (UnitTest *unit_test, int skip_count)
 
GTEST_API_ bool testing::internal::AlwaysTrue ()
 
bool testing::internal::AlwaysFalse ()
 
template<class C >
IsContainer testing::internal::IsContainerTest (int, typename C::iterator *=NULL, typename C::const_iterator *=NULL)
 
template<class C >
IsNotContainer testing::internal::IsContainerTest (long)
 
template<typename T , typename U >
bool testing::internal::ArrayEq (const T *lhs, size_t size, const U *rhs)
 
template<typename T , typename U >
bool testing::internal::ArrayEq (const T &lhs, const U &rhs)
 
template<typename T , typename U , size_t N>
bool testing::internal::ArrayEq (const T(&lhs)[N], const U(&rhs)[N])
 
template<typename Iter , typename Element >
Iter testing::internal::ArrayAwareFind (Iter begin, Iter end, const Element &elem)
 
template<typename T , typename U >
void testing::internal::CopyArray (const T *from, size_t size, U *to)
 
template<typename T , typename U >
void testing::internal::CopyArray (const T &from, U *to)
 
template<typename T , typename U , size_t N>
void testing::internal::CopyArray (const T(&from)[N], U(*to)[N])
 

Variables

GTEST_API_ const char testing::internal::kStackTraceMarker [] = "\nStack trace:\n"
 

Macro Definition Documentation

◆ GTEST_CONCAT_TOKEN_

#define GTEST_CONCAT_TOKEN_ ( foo,
bar )
Value:

Definition at line 75 of file gtest-internal.h.

◆ GTEST_CONCAT_TOKEN_IMPL_

#define GTEST_CONCAT_TOKEN_IMPL_ ( foo,
bar )
Value:
foo ## bar

Definition at line 76 of file gtest-internal.h.

◆ GTEST_FATAL_FAILURE_

#define GTEST_FATAL_FAILURE_ ( message)
Value:
#define GTEST_MESSAGE_(message, result_type)

Definition at line 1149 of file gtest-internal.h.

1149#define GTEST_FATAL_FAILURE_(message) \
1150 return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)

◆ GTEST_IS_NULL_LITERAL_

#define GTEST_IS_NULL_LITERAL_ ( x)
Value:
char IsNullLiteralHelper(Secret *p)

Definition at line 133 of file gtest-internal.h.

133# define GTEST_IS_NULL_LITERAL_(x) \
134 (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)

◆ GTEST_MESSAGE_

#define GTEST_MESSAGE_ ( message,
result_type )
Value:
GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
#define GTEST_MESSAGE_AT_(file, line, message, result_type)

Definition at line 1146 of file gtest-internal.h.

1146#define GTEST_MESSAGE_(message, result_type) \
1147 GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)

◆ GTEST_MESSAGE_AT_

#define GTEST_MESSAGE_AT_ ( file,
line,
message,
result_type )
Value:

Definition at line 1142 of file gtest-internal.h.

1142#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
1143 ::testing::internal::AssertHelper(result_type, file, line, message) \
1144 = ::testing::Message()

◆ GTEST_NONFATAL_FAILURE_

#define GTEST_NONFATAL_FAILURE_ ( message)
Value:

Definition at line 1152 of file gtest-internal.h.

1152#define GTEST_NONFATAL_FAILURE_(message) \
1153 GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)

◆ GTEST_REMOVE_CONST_

#define GTEST_REMOVE_CONST_ ( T)
Value:
typename ::testing::internal::RemoveConst<T>::type

Definition at line 802 of file gtest-internal.h.

802#define GTEST_REMOVE_CONST_(T) \
803 typename ::testing::internal::RemoveConst<T>::type

◆ GTEST_REMOVE_REFERENCE_

#define GTEST_REMOVE_REFERENCE_ ( T)
Value:
typename ::testing::internal::RemoveReference<T>::type

Definition at line 771 of file gtest-internal.h.

771#define GTEST_REMOVE_REFERENCE_(T) \
772 typename ::testing::internal::RemoveReference<T>::type

◆ GTEST_REMOVE_REFERENCE_AND_CONST_

#define GTEST_REMOVE_REFERENCE_AND_CONST_ ( T)
Value:
#define GTEST_REMOVE_CONST_(T)
#define GTEST_REMOVE_REFERENCE_(T)
#define T(meth, val, expected)

Definition at line 806 of file gtest-internal.h.

806#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
807 GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))

◆ GTEST_STRINGIFY_

#define GTEST_STRINGIFY_ ( name)
Value:
#name

Definition at line 79 of file gtest-internal.h.

◆ GTEST_SUCCESS_

#define GTEST_SUCCESS_ ( message)
Value:

Definition at line 1155 of file gtest-internal.h.

1155#define GTEST_SUCCESS_(message) \
1156 GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)

◆ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_

#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ ( statement)
Value:
if (::testing::internal::AlwaysTrue()) { statement; }
GTEST_API_ bool AlwaysTrue()
Definition gtest.cc:5406

Definition at line 1161 of file gtest-internal.h.

1161#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
1162 if (::testing::internal::AlwaysTrue()) { statement; }

◆ GTEST_TEST_

#define GTEST_TEST_ ( test_case_name,
test_name,
parent_class,
parent_id )
Value:
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
public:\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
private:\
virtual void TestBody();\
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
};\
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
::test_info_ =\
::testing::internal::MakeAndRegisterTestInfo(\
#test_case_name, #test_name, NULL, NULL, \
::testing::internal::CodeLocation(__FILE__, __LINE__), \
(parent_id), \
parent_class::SetUpTestCase, \
parent_class::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()
#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name)
#define GTEST_ATTRIBUTE_UNUSED_
Definition gtest-port.h:883

Definition at line 1254 of file gtest-internal.h.

1254#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\
1255class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
1256 public:\
1257 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
1258 private:\
1259 virtual void TestBody();\
1260 static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
1261 GTEST_DISALLOW_COPY_AND_ASSIGN_(\
1262 GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
1263};\
1264\
1265::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
1266 ::test_info_ =\
1267 ::testing::internal::MakeAndRegisterTestInfo(\
1268 #test_case_name, #test_name, NULL, NULL, \
1269 ::testing::internal::CodeLocation(__FILE__, __LINE__), \
1270 (parent_id), \
1271 parent_class::SetUpTestCase, \
1272 parent_class::TearDownTestCase, \
1273 new ::testing::internal::TestFactoryImpl<\
1274 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
1275void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()

◆ GTEST_TEST_ANY_THROW_

#define GTEST_TEST_ANY_THROW_ ( statement,
fail )
Value:
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
bool gtest_caught_any = false; \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (...) { \
gtest_caught_any = true; \
} \
if (!gtest_caught_any) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
fail("Expected: " #statement " throws an exception.\n" \
" Actual: it doesn't.")
#define GTEST_CONCAT_TOKEN_(foo, bar)

Definition at line 1204 of file gtest-internal.h.

1204#define GTEST_TEST_ANY_THROW_(statement, fail) \
1205 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1206 if (::testing::internal::AlwaysTrue()) { \
1207 bool gtest_caught_any = false; \
1208 try { \
1209 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
1210 } \
1211 catch (...) { \
1212 gtest_caught_any = true; \
1213 } \
1214 if (!gtest_caught_any) { \
1215 goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
1216 } \
1217 } else \
1218 GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
1219 fail("Expected: " #statement " throws an exception.\n" \
1220 " Actual: it doesn't.")

◆ GTEST_TEST_BOOLEAN_

#define GTEST_TEST_BOOLEAN_ ( expression,
text,
actual,
expected,
fail )
Value:
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const ::testing::AssertionResult gtest_ar_ = \
; \
else \
gtest_ar_, text, #actual, #expected).c_str())
GTEST_API_ std::string GetBoolAssertionFailureMessage(const AssertionResult &assertion_result, const char *expression_text, const char *actual_predicate_value, const char *expected_predicate_value)
Definition gtest.cc:1361

Definition at line 1226 of file gtest-internal.h.

1226#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
1227 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1228 if (const ::testing::AssertionResult gtest_ar_ = \
1229 ::testing::AssertionResult(expression)) \
1230 ; \
1231 else \
1232 fail(::testing::internal::GetBoolAssertionFailureMessage(\
1233 gtest_ar_, text, #actual, #expected).c_str())

◆ GTEST_TEST_CLASS_NAME_

#define GTEST_TEST_CLASS_NAME_ ( test_case_name,
test_name )
Value:
test_case_name##_##test_name##_Test

Definition at line 1250 of file gtest-internal.h.

1250#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
1251 test_case_name##_##test_name##_Test

◆ GTEST_TEST_NO_FATAL_FAILURE_

#define GTEST_TEST_NO_FATAL_FAILURE_ ( statement,
fail )
Value:
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
fail("Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \
" Actual: it does.")

Definition at line 1235 of file gtest-internal.h.

1235#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
1236 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1237 if (::testing::internal::AlwaysTrue()) { \
1238 ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
1239 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
1240 if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
1241 goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
1242 } \
1243 } else \
1244 GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
1245 fail("Expected: " #statement " doesn't generate new fatal " \
1246 "failures in the current thread.\n" \
1247 " Actual: it does.")

◆ GTEST_TEST_NO_THROW_

#define GTEST_TEST_NO_THROW_ ( statement,
fail )
Value:
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (...) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
fail("Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws.")

Definition at line 1190 of file gtest-internal.h.

1190#define GTEST_TEST_NO_THROW_(statement, fail) \
1191 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1192 if (::testing::internal::AlwaysTrue()) { \
1193 try { \
1194 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
1195 } \
1196 catch (...) { \
1197 goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
1198 } \
1199 } else \
1200 GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
1201 fail("Expected: " #statement " doesn't throw an exception.\n" \
1202 " Actual: it throws.")

◆ GTEST_TEST_THROW_

#define GTEST_TEST_THROW_ ( statement,
expected_exception,
fail )
Value:
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::ConstCharPtr gtest_msg = "") { \
bool gtest_caught_expected = false; \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (expected_exception const&) { \
gtest_caught_expected = true; \
} \
catch (...) { \
gtest_msg.value = \
"Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws a different type."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
if (!gtest_caught_expected) { \
gtest_msg.value = \
"Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws nothing."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_msg.value)

Definition at line 1164 of file gtest-internal.h.

1164#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
1165 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1166 if (::testing::internal::ConstCharPtr gtest_msg = "") { \
1167 bool gtest_caught_expected = false; \
1168 try { \
1169 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
1170 } \
1171 catch (expected_exception const&) { \
1172 gtest_caught_expected = true; \
1173 } \
1174 catch (...) { \
1175 gtest_msg.value = \
1176 "Expected: " #statement " throws an exception of type " \
1177 #expected_exception ".\n Actual: it throws a different type."; \
1178 goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
1179 } \
1180 if (!gtest_caught_expected) { \
1181 gtest_msg.value = \
1182 "Expected: " #statement " throws an exception of type " \
1183 #expected_exception ".\n Actual: it throws nothing."; \
1184 goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
1185 } \
1186 } else \
1187 GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
1188 fail(gtest_msg.value)