37 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ 38 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ 44 #include <sys/types.h> 47 #endif // GTEST_OS_LINUX 67 #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar) 68 #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar 104 class AssertionResult;
108 class TestPartResult;
150 #ifdef GTEST_ELLIPSIS_NEEDS_POD_ 153 #define GTEST_IS_NULL_LITERAL_(x) false 155 #define GTEST_IS_NULL_LITERAL_(x) \ 156 (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1) 157 #endif // GTEST_ELLIPSIS_NEEDS_POD_ 189 template <
typename T>
194 #ifdef GTEST_NEEDS_IS_POINTER_ 204 template <
typename T>
210 template <
typename T>
216 template <
typename T>
218 return FormatValueForFailureMessage(
228 template <
typename T>
235 template <
typename T>
240 #endif // GTEST_NEEDS_IS_POINTER_ 251 #define GTEST_FORMAT_IMPL_(operand2_type, operand1_printer)\ 252 inline String FormatForComparisonFailureMessage(\ 253 operand2_type::value_type* str, const operand2_type& ) {\ 254 return operand1_printer(str);\ 256 inline String FormatForComparisonFailureMessage(\ 257 const operand2_type::value_type* str, const operand2_type& ) {\ 258 return operand1_printer(str);\ 262 #if GTEST_HAS_STD_WSTRING 264 #endif // GTEST_HAS_STD_WSTRING 266 #if GTEST_HAS_GLOBAL_STRING 268 #endif // GTEST_HAS_GLOBAL_STRING 269 #if GTEST_HAS_GLOBAL_WSTRING 271 #endif // GTEST_HAS_GLOBAL_WSTRING 273 #undef GTEST_FORMAT_IMPL_ 291 const char* actual_expression,
292 const String& expected_value,
293 const String& actual_value,
298 const AssertionResult& assertion_result,
299 const char* expression_text,
300 const char* actual_predicate_value,
301 const char* expected_predicate_value);
332 template <
typename RawType>
342 static const size_t kBitCount = 8*
sizeof(RawType);
345 static const size_t kFractionBitCount =
346 std::numeric_limits<RawType>::digits - 1;
349 static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;
352 static const Bits kSignBitMask =
static_cast<Bits
>(1) << (kBitCount - 1);
355 static const Bits kFractionBitMask =
356 ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
359 static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);
373 static const size_t kMaxUlps = 4;
396 return ReinterpretBits(kExponentBitMask);
402 const Bits &
bits()
const {
return u_.bits_; }
411 Bits
sign_bit()
const {
return kSignBitMask & u_.bits_; }
417 return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
429 if (is_nan() || rhs.
is_nan())
return false;
431 return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
437 union FloatingPointUnion {
457 static Bits SignAndMagnitudeToBiased(
const Bits &sam) {
458 if (kSignBitMask & sam) {
463 return kSignBitMask | sam;
469 static Bits DistanceBetweenSignAndMagnitudeNumbers(
const Bits &sam1,
471 const Bits biased1 = SignAndMagnitudeToBiased(sam1);
472 const Bits biased2 = SignAndMagnitudeToBiased(sam2);
473 return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
476 FloatingPointUnion u_;
492 template <
typename T>
501 template <
typename T>
507 template <
typename T>
513 return &(TypeIdHelper<T>::dummy_);
531 virtual Test* CreateTest() = 0;
542 template <
class TestClass>
559 #endif // GTEST_OS_WINDOWS 564 const char*
const file_name = file ==
NULL ?
"unknown file" :
file;
597 const char* test_case_name,
const char*
name,
598 const char* test_case_comment,
const char* comment,
599 TypeId fixture_class_id,
609 #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P 614 TypedTestCasePState() : registered_(
false) {}
619 bool AddTestName(
const char*
file,
int line,
const char* case_name,
620 const char* test_name) {
622 fprintf(
stderr,
"%s Test %s must be defined before " 623 "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n",
628 defined_test_names_.insert(test_name);
635 const char* VerifyRegisteredTestNames(
636 const char* file,
int line,
const char* registered_tests);
640 ::std::set<const char*> defined_test_names_;
645 inline const char* SkipComma(
const char*
str) {
646 const char* comma =
strchr(str,
',');
650 while (isspace(*(++comma))) {}
656 inline String GetPrefixUntilComma(
const char* str) {
657 const char* comma =
strchr(str,
',');
658 return comma ==
NULL ?
String(str) : String(str, comma - str);
668 template <GTEST_TEMPLATE_ Fixture,
class TestSel,
typename Types>
669 class TypeParameterizedTest {
675 static bool Register(
const char*
prefix,
const char* case_name,
676 const char* test_names,
int index) {
677 typedef typename Types::Head
Type;
678 typedef Fixture<Type> FixtureClass;
679 typedef typename GTEST_BIND_(TestSel, Type) TestClass;
685 case_name, index).c_str(),
686 GetPrefixUntilComma(test_names).c_str(),
687 String::Format(
"TypeParam = %s", GetTypeName<Type>().c_str()).c_str(),
689 GetTypeId<FixtureClass>(),
690 TestClass::SetUpTestCase,
691 TestClass::TearDownTestCase,
695 return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>
696 ::Register(prefix, case_name, test_names, index + 1);
701 template <GTEST_TEMPLATE_ Fixture,
class TestSel>
702 class TypeParameterizedTest<Fixture, TestSel, Types0> {
704 static bool Register(
const char* ,
const char* ,
705 const char* ,
int ) {
714 template <GTEST_TEMPLATE_ Fixture,
typename Tests,
typename Types>
715 class TypeParameterizedTestCase {
717 static bool Register(
const char* prefix,
const char* case_name,
718 const char* test_names) {
719 typedef typename Tests::Head Head;
722 TypeParameterizedTest<Fixture, Head, Types>::Register(
723 prefix, case_name, test_names, 0);
726 return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>
727 ::Register(prefix, case_name, SkipComma(test_names));
732 template <GTEST_TEMPLATE_ Fixture,
typename Types>
733 class TypeParameterizedTestCase<Fixture, Templates0, Types> {
735 static bool Register(
const char* ,
const char* ,
741 #endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P 790 #define GTEST_MESSAGE_(message, result_type) \ 791 ::testing::internal::AssertHelper(result_type, __FILE__, __LINE__, message) \ 792 = ::testing::Message() 794 #define GTEST_FATAL_FAILURE_(message) \ 795 return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure) 797 #define GTEST_NONFATAL_FAILURE_(message) \ 798 GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure) 800 #define GTEST_SUCCESS_(message) \ 801 GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess) 806 #define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \ 807 if (::testing::internal::AlwaysTrue()) { statement; } 809 #define GTEST_TEST_THROW_(statement, expected_exception, fail) \ 810 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 811 if (const char* gtest_msg = "") { \ 812 bool gtest_caught_expected = false; \ 814 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ 816 catch (expected_exception const&) { \ 817 gtest_caught_expected = true; \ 820 gtest_msg = "Expected: " #statement " throws an exception of type " \ 821 #expected_exception ".\n Actual: it throws a different " \ 823 goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ 825 if (!gtest_caught_expected) { \ 826 gtest_msg = "Expected: " #statement " throws an exception of type " \ 827 #expected_exception ".\n Actual: it throws nothing."; \ 828 goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ 831 GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ 834 #define GTEST_TEST_NO_THROW_(statement, fail) \ 835 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 836 if (const char* gtest_msg = "") { \ 838 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ 841 gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \ 842 " Actual: it throws."; \ 843 goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ 846 GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \ 849 #define GTEST_TEST_ANY_THROW_(statement, fail) \ 850 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 851 if (const char* gtest_msg = "") { \ 852 bool gtest_caught_any = false; \ 854 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ 857 gtest_caught_any = true; \ 859 if (!gtest_caught_any) { \ 860 gtest_msg = "Expected: " #statement " throws an exception.\n" \ 861 " Actual: it doesn't."; \ 862 goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \ 865 GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \ 872 #define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ 873 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 874 if (const ::testing::AssertionResult gtest_ar_ = \ 875 ::testing::AssertionResult(expression)) \ 878 fail(::testing::internal::GetBoolAssertionFailureMessage(\ 879 gtest_ar_, text, #actual, #expected).c_str()) 881 #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ 882 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ 883 if (const char* gtest_msg = "") { \ 884 ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \ 885 GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ 886 if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ 887 gtest_msg = "Expected: " #statement " doesn't generate new fatal " \ 888 "failures in the current thread.\n" \ 889 " Actual: it does."; \ 890 goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ 893 GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \ 897 #define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ 898 test_case_name##_##test_name##_Test 901 #define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\ 902 class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\ 904 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ 906 virtual void TestBody();\ 907 static ::testing::TestInfo* const test_info_;\ 908 GTEST_DISALLOW_COPY_AND_ASSIGN_(\ 909 GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ 912 ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ 914 ::testing::internal::MakeAndRegisterTestInfo(\ 915 #test_case_name, #test_name, "", "", \ 917 parent_class::SetUpTestCase, \ 918 parent_class::TearDownTestCase, \ 919 new ::testing::internal::TestFactoryImpl<\ 920 GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ 921 void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() 923 #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ GTEST_API_ String FormatForFailureMessage(const ::std::string &str)
Definition: gtest.h:1210
static RawType ReinterpretBits(const Bits bits)
Definition: gtest-internal.h:388
OPENSSL_EXPORT ASN1_BIT_STRING * bits
Definition: x509v3.h:532
line
Definition: buildtests.py:37
TypeId GetTypeId()
Definition: gtest-internal.h:508
Definition: testutils.h:40
virtual Test * CreateTest()
Definition: gtest-internal.h:545
Definition: gtest-internal.h:543
TestFactoryBase()
Definition: gtest-internal.h:534
DOMString p
Definition: WebCryptoAPI.idl:116
GTEST_API_ String AppendUserMessage(const String >est_msg, const Message &user_msg)
Definition: gtest.cc:1776
GTEST_API_ String GetCurrentOsStackTraceExceptTop(UnitTest *unit_test, int skip_count)
Definition: gtest.cc:4332
class GTEST_API_ testing::internal::ScopedTrace GTEST_ATTRIBUTE_UNUSED_
long seed
Definition: float-mm.c:84
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:398
Definition: gtest-internal.h:333
FloatingPoint(const RawType &x)
Definition: gtest-internal.h:381
static String ShowCStringQuoted(const char *c_str)
Definition: gtest.cc:800
const CTYPE * strchr(const CTYPE *str, const CTYPE *chs)
Definition: stringutils.h:145
bool SkipPrefix(const char *prefix, const char **pstr)
Definition: gtest.cc:4360
Definition: gtest-internal.h:493
#define GTEST_API_
Definition: gtest-port.h:615
Message
Definition: peerconnection_unittest.cc:105
String FormatFileLocation(const char *file, int line)
Definition: gtest-internal.h:563
TypeWithSize< 4 >::UInt UInt32
Definition: gtest-port.h:1491
const void * TypeId
Definition: gtest-internal.h:490
void
Definition: AVFoundationCFSoftLinking.h:81
VoEFile * file
Definition: voe_cmd_test.cc:59
stderr
Definition: barcode_decoder.py:21
Bits fraction_bits() const
Definition: gtest-internal.h:408
Definition: messagequeue.h:156
GTEST_API_ TypeId GetTestTypeId()
Definition: gtest.cc:570
Bits sign_bit() const
Definition: gtest-internal.h:411
TestSubObjConstructor T
Definition: TestTypedefs.idl:84
FloatingPoint< float > Float
Definition: gtest-internal.h:481
FloatingPoint< double > Double
Definition: gtest-internal.h:482
EGLSurface EGLint x
Definition: eglext.h:950
rtc::scoped_refptr< PeerConnectionFactoryInterface > factory(webrtc::CreatePeerConnectionFactory(network_thread.get(), worker_thread.get(), signaling_thread.get(), nullptr, encoder_factory, decoder_factory))
Definition: peerconnection_jni.cc:1838
GLuint index
Definition: gl2.h:383
EGLAttrib * value
Definition: eglext.h:120
#define GTEST_FORMAT_IMPL_(operand2_type, operand1_printer)
Definition: gtest-internal.h:251
TypeWithSize< sizeof(RawType)>::UInt Bits
Definition: gtest-internal.h:337
GTEST_API_ bool AlwaysTrue()
Definition: gtest.cc:4347
bool AlwaysFalse()
Definition: gtest-internal.h:763
void(* SetUpTestCaseFunc)()
Definition: gtest-internal.h:576
Definition: gtest-string.h:81
void(* TearDownTestCaseFunc)()
Definition: gtest-internal.h:577
void Reseed(UInt32 seed)
Definition: gtest-internal.h:776
Definition: gtest-internal.h:164
EGLImageKHR EGLint * name
Definition: eglext.h:851
static String ShowWideCStringQuoted(const wchar_t *wide_c_str)
Definition: gtest.cc:1559
Definition: xmlparse.c:154
Definition: gtest-port.h:1457
Bits exponent_bits() const
Definition: gtest-internal.h:405
GLenum void ** pointer
Definition: gl2.h:460
virtual ~TestFactoryBase()
Definition: gtest-internal.h:527
Definition: gtest-port.h:1273
GTEST_API_ TestInfo * MakeAndRegisterTestInfo(const char *test_case_name, const char *name, const char *test_case_comment, const char *comment, TypeId fixture_class_id, SetUpTestCaseFunc set_up_tc, TearDownTestCaseFunc tear_down_tc, TestFactoryBase *factory)
Definition: gtest.cc:2157
static bool dummy_
Definition: gtest-internal.h:498
GTEST_API_ const char kStackTraceMarker[]
Definition: gtest.cc:170
str
Definition: make-dist.py:305
GLsizei const GLchar *const * string
Definition: gl2.h:479
Definition: document.h:393
int g_init_gtest_count
Definition: gtest.cc:297
const Bits & bits() const
Definition: gtest-internal.h:402
Definition: bn_test.cc:620
GTEST_API_ AssertionResult EqFailure(const char *expected_expression, const char *actual_expression, const String &expected_value, const String &actual_value, bool ignoring_case)
Definition: gtest.cc:1013
#define false
Definition: float-mm.c:5
static RawType Infinity()
Definition: gtest-internal.h:395
void Abort()
Definition: gtest-port.h:1423
#define NULL
Definition: common_types.h:41
bool AlmostEquals(const FloatingPoint &rhs) const
Definition: gtest-internal.h:426
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: gtest-port.h:573
GTEST_API_ String GetBoolAssertionFailureMessage(const AssertionResult &assertion_result, const char *expression_text, const char *actual_predicate_value, const char *expected_predicate_value)
Definition: gtest.cc:1036
Random(UInt32 seed)
Definition: gtest-internal.h:774
if(WebKit_Nightly_Survey::responded()) hr
Definition: nightly-start.php:185
Definition: gtest-internal.h:525
Type
Type of JSON value.
Definition: rapidjson.h:616
char IsNullLiteralHelper(Secret *p)
GLuint GLsizei const GLchar * message
Definition: gl2ext.h:137
GLuint GLsizei GLsizei GLfloat * val
Definition: gl2ext.h:3301
Definition: gtest-internal.h:770
void GTestStreamToHelper(std::ostream *os, const T &val)
Definition: gtest-internal.h:96
String StreamableToString(const T &streamable)
Definition: gtest.h:169
static String Format(const char *format,...)
Definition: gtest.cc:1723
GLenum GLint * range
Definition: gl2.h:450
bool is_nan() const
Definition: gtest-internal.h:414