35#include "gtest/gtest.h"
40TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
41 bool dummy = testing::GTEST_FLAG(also_run_disabled_tests)
42 || testing::GTEST_FLAG(break_on_failure)
43 || testing::GTEST_FLAG(catch_exceptions)
44 || testing::GTEST_FLAG(color) !=
"unknown"
45 || testing::GTEST_FLAG(filter) !=
"unknown"
46 || testing::GTEST_FLAG(list_tests)
47 || testing::GTEST_FLAG(output) !=
"unknown"
48 || testing::GTEST_FLAG(print_time)
49 || testing::GTEST_FLAG(random_seed)
50 || testing::GTEST_FLAG(repeat) > 0
51 || testing::GTEST_FLAG(show_internal_stack_frames)
52 || testing::GTEST_FLAG(shuffle)
53 || testing::GTEST_FLAG(stack_trace_depth) > 0
54 || testing::GTEST_FLAG(stream_result_to) !=
"unknown"
55 || testing::GTEST_FLAG(throw_on_failure);
68#include "gtest/gtest-spi.h"
75#define GTEST_IMPLEMENTATION_ 1
76#include "src/gtest-internal-inl.h"
77#undef GTEST_IMPLEMENTATION_
82#if GTEST_CAN_STREAM_RESULTS_
84class StreamingListenerTest :
public Test {
86 class FakeSocketWriter :
public StreamingListener::AbstractSocketWriter {
89 virtual void Send(
const string& message) { output_ += message; }
94 StreamingListenerTest()
95 : fake_sock_writer_(
new FakeSocketWriter),
96 streamer_(fake_sock_writer_),
97 test_info_obj_(
"FooTest",
"Bar", NULL, NULL,
98 CodeLocation(__FILE__, __LINE__), 0, NULL) {}
101 string* output() {
return &(fake_sock_writer_->output_); }
103 FakeSocketWriter*
const fake_sock_writer_;
104 StreamingListener streamer_;
109TEST_F(StreamingListenerTest, OnTestProgramEnd) {
111 streamer_.OnTestProgramEnd(unit_test_);
112 EXPECT_EQ(
"event=TestProgramEnd&passed=1\n", *output());
115TEST_F(StreamingListenerTest, OnTestIterationEnd) {
117 streamer_.OnTestIterationEnd(unit_test_, 42);
118 EXPECT_EQ(
"event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
121TEST_F(StreamingListenerTest, OnTestCaseStart) {
123 streamer_.OnTestCaseStart(
TestCase(
"FooTest",
"Bar", NULL, NULL));
124 EXPECT_EQ(
"event=TestCaseStart&name=FooTest\n", *output());
127TEST_F(StreamingListenerTest, OnTestCaseEnd) {
129 streamer_.OnTestCaseEnd(
TestCase(
"FooTest",
"Bar", NULL, NULL));
130 EXPECT_EQ(
"event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
133TEST_F(StreamingListenerTest, OnTestStart) {
135 streamer_.OnTestStart(test_info_obj_);
136 EXPECT_EQ(
"event=TestStart&name=Bar\n", *output());
139TEST_F(StreamingListenerTest, OnTestEnd) {
141 streamer_.OnTestEnd(test_info_obj_);
142 EXPECT_EQ(
"event=TestEnd&passed=1&elapsed_time=0ms\n", *output());
145TEST_F(StreamingListenerTest, OnTestPartResult) {
152 "event=TestPartResult&file=foo.cc&line=42&message=failed%3D%0A%26%25\n",
206using testing::GTEST_FLAG(also_run_disabled_tests);
207using testing::GTEST_FLAG(break_on_failure);
208using testing::GTEST_FLAG(catch_exceptions);
209using testing::GTEST_FLAG(color);
210using testing::GTEST_FLAG(death_test_use_fork);
211using testing::GTEST_FLAG(filter);
212using testing::GTEST_FLAG(list_tests);
213using testing::GTEST_FLAG(output);
214using testing::GTEST_FLAG(print_time);
215using testing::GTEST_FLAG(random_seed);
216using testing::GTEST_FLAG(repeat);
217using testing::GTEST_FLAG(show_internal_stack_frames);
218using testing::GTEST_FLAG(shuffle);
219using testing::GTEST_FLAG(stack_trace_depth);
220using testing::GTEST_FLAG(stream_result_to);
221using testing::GTEST_FLAG(throw_on_failure);
293#if GTEST_HAS_STREAM_REDIRECTION
294using testing::internal::CaptureStdout;
295using testing::internal::GetCapturedStdout;
298#if GTEST_IS_THREADSAFE
299using testing::internal::ThreadWithParam;
308 for (
size_t i = 0;
i <
vector.size();
i++) {
318TEST(GetRandomSeedFromFlagTest, HandlesZero) {
324TEST(GetRandomSeedFromFlagTest, PreservesValidSeed) {
332TEST(GetRandomSeedFromFlagTest, NormalizesInvalidSeed) {
342TEST(GetNextRandomSeedTest, WorksForValidInput) {
355static void ClearCurrentTestPartResults() {
362TEST(GetTypeIdTest, ReturnsSameValueForSameType) {
367class SubClassOfTest :
public Test {};
368class AnotherSubClassOfTest :
public Test {};
370TEST(GetTypeIdTest, ReturnsDifferentValuesForDifferentTypes) {
381TEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {
387TEST(FormatTimeInMillisAsSecondsTest, FormatsZero) {
391TEST(FormatTimeInMillisAsSecondsTest, FormatsPositiveNumber) {
399TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
413class FormatEpochTimeInMillisAsIso8601Test :
public Test {
421 virtual void SetUp() {
426 saved_tz_ = strdup(getenv(
"TZ"));
432 SetTimeZone(
"UTC+00");
435 virtual
void TearDown() {
436 SetTimeZone(saved_tz_);
437 free(
const_cast<char*
>(saved_tz_));
441 static void SetTimeZone(
const char* time_zone) {
448 const std::string env_var =
449 std::string(
"TZ=") + (time_zone ? time_zone :
"");
450 _putenv(env_var.c_str());
456 setenv((
"TZ"), time_zone, 1);
464 const char* saved_tz_;
467const TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec;
469TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsTwoDigitSegments) {
474TEST_F(FormatEpochTimeInMillisAsIso8601Test, MillisecondsDoNotAffectResult) {
476 "2011-10-31T18:52:42",
480TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsLeadingZeroes) {
485TEST_F(FormatEpochTimeInMillisAsIso8601Test, Prints24HourTime) {
490TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
494#if GTEST_CAN_COMPARE_NULL
498# pragma option push -w-ccc -w-rch
503TEST(NullLiteralTest, IsTrueForNullLiterals) {
512TEST(NullLiteralTest, IsFalseForNonNullLiterals) {
529TEST(CodePointToUtf8Test, CanEncodeNul) {
534TEST(CodePointToUtf8Test, CanEncodeAscii) {
543TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
557TEST(CodePointToUtf8Test, CanEncode12To16Bits) {
567#if !GTEST_WIDE_STRING_USES_UTF16_
574TEST(CodePointToUtf8Test, CanEncode17To21Bits) {
586TEST(CodePointToUtf8Test, CanEncodeInvalidCodePoint) {
595TEST(WideStringToUtf8Test, CanEncodeNul) {
601TEST(WideStringToUtf8Test, CanEncodeAscii) {
610TEST(WideStringToUtf8Test, CanEncode8To11Bits) {
616 const wchar_t s[] = { 0x576,
'\0' };
623TEST(WideStringToUtf8Test, CanEncode12To16Bits) {
625 const wchar_t s1[] = { 0x8D3,
'\0' };
630 const wchar_t s2[] = { 0xC74D,
'\0' };
636TEST(WideStringToUtf8Test, StopsOnNulCharacter) {
642TEST(WideStringToUtf8Test, StopsWhenLengthLimitReached) {
646#if !GTEST_WIDE_STRING_USES_UTF16_
650TEST(WideStringToUtf8Test, CanEncode17To21Bits) {
661TEST(WideStringToUtf8Test, CanEncodeInvalidCodePoint) {
668TEST(WideStringToUtf8Test, CanEncodeValidUtf16SUrrogatePairs) {
669 const wchar_t s[] = { 0xD801, 0xDC00,
'\0' };
675TEST(WideStringToUtf8Test, CanEncodeInvalidUtf16SurrogatePair) {
677 const wchar_t s1[] = { 0xD800,
'\0' };
680 const wchar_t s2[] = { 0xD800,
'M',
'\0' };
683 const wchar_t s3[] = { 0xDC00,
'P',
'Q',
'R',
'\0' };
689#if !GTEST_WIDE_STRING_USES_UTF16_
690TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {
691 const wchar_t s[] = { 0x108634, 0xC74D,
'\n', 0x576, 0x8D3, 0x108634,
'\0'};
702TEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {
703 const wchar_t s[] = { 0xC74D,
'\n', 0x576, 0x8D3,
'\0'};
705 "\xEC\x9D\x8D" "\n" "\xD5\xB6" "\xE0\xA3\x93",
712TEST(RandomDeathTest, GeneratesCrashesOnInvalidRange) {
713 testing::internal::Random
random(42);
716 "Cannot generate a number in the range \\[0, 0\\)");
719 "Generation of a number in \\[0, 2147483649\\) was requested, "
720 "but this can only generate numbers in \\[0, 2147483648\\)");
723TEST(RandomTest, GeneratesNumbersWithinRange) {
724 const UInt32 kRange = 10000;
725 testing::internal::Random
random(12345);
726 for (
int i = 0;
i < 10;
i++) {
731 for (
int i = 0;
i < 10;
i++) {
732 EXPECT_LT(random2.Generate(kRange), kRange) <<
" for iteration " <<
i;
736TEST(RandomTest, RepeatsWhenReseeded) {
737 const int kSeed = 123;
738 const int kArraySize = 10;
739 const UInt32 kRange = 10000;
740 UInt32 values[kArraySize];
742 testing::internal::Random
random(kSeed);
743 for (
int i = 0;
i < kArraySize;
i++) {
744 values[
i] =
random.Generate(kRange);
748 for (
int i = 0;
i < kArraySize;
i++) {
757static bool IsPositive(
int n) {
return n > 0; }
776static void Accumulate(
int n) { g_sum += n; }
814 testing::internal::Random
random(1);
818 "Invalid shuffle range start -1: must be in range \\[0, 3\\]");
821 "Invalid shuffle range start 4: must be in range \\[0, 3\\]");
824 "Invalid shuffle range finish 2: must be in range \\[3, 3\\]");
827 "Invalid shuffle range finish 4: must be in range \\[3, 3\\]");
830class VectorShuffleTest :
public Test {
832 static const int kVectorSize = 20;
834 VectorShuffleTest() : random_(1) {
835 for (
int i = 0;
i < kVectorSize;
i++) {
836 vector_.push_back(i);
840 static bool VectorIsCorrupt(
const TestingVector& vector) {
841 if (kVectorSize !=
static_cast<int>(vector.size())) {
845 bool found_in_vector[kVectorSize] = {
false };
846 for (
size_t i = 0;
i < vector.size();
i++) {
847 const int e = vector[
i];
848 if (e < 0 || e >= kVectorSize || found_in_vector[e]) {
851 found_in_vector[
e] =
true;
859 static bool VectorIsNotCorrupt(
const TestingVector& vector) {
860 return !VectorIsCorrupt(vector);
863 static bool RangeIsShuffled(
const TestingVector& vector,
int begin,
int end) {
864 for (
int i = begin;
i < end;
i++) {
865 if (i != vector[i]) {
872 static bool RangeIsUnshuffled(
873 const TestingVector& vector,
int begin,
int end) {
874 return !RangeIsShuffled(vector, begin, end);
877 static bool VectorIsShuffled(
const TestingVector& vector) {
878 return RangeIsShuffled(vector, 0,
static_cast<int>(vector.size()));
881 static bool VectorIsUnshuffled(
const TestingVector& vector) {
882 return !VectorIsShuffled(vector);
885 testing::internal::Random random_;
886 TestingVector vector_;
889const int VectorShuffleTest::kVectorSize;
891TEST_F(VectorShuffleTest, HandlesEmptyRange) {
898 ShuffleRange(&random_, kVectorSize/2, kVectorSize/2, &vector_);
903 ShuffleRange(&random_, kVectorSize - 1, kVectorSize - 1, &vector_);
908 ShuffleRange(&random_, kVectorSize, kVectorSize, &vector_);
913TEST_F(VectorShuffleTest, HandlesRangeOfSizeOne) {
920 ShuffleRange(&random_, kVectorSize/2, kVectorSize/2 + 1, &vector_);
925 ShuffleRange(&random_, kVectorSize - 1, kVectorSize, &vector_);
933TEST_F(VectorShuffleTest, ShufflesEntireVector) {
941 EXPECT_NE(kVectorSize - 1, vector_[kVectorSize - 1]);
944TEST_F(VectorShuffleTest, ShufflesStartOfVector) {
945 const int kRangeSize = kVectorSize/2;
951 EXPECT_PRED3(RangeIsUnshuffled, vector_, kRangeSize, kVectorSize);
954TEST_F(VectorShuffleTest, ShufflesEndOfVector) {
955 const int kRangeSize = kVectorSize / 2;
956 ShuffleRange(&random_, kRangeSize, kVectorSize, &vector_);
959 EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize);
960 EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, kVectorSize);
963TEST_F(VectorShuffleTest, ShufflesMiddleOfVector) {
964 int kRangeSize = kVectorSize/3;
965 ShuffleRange(&random_, kRangeSize, 2*kRangeSize, &vector_);
968 EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize);
969 EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, 2*kRangeSize);
970 EXPECT_PRED3(RangeIsUnshuffled, vector_, 2*kRangeSize, kVectorSize);
973TEST_F(VectorShuffleTest, ShufflesRepeatably) {
974 TestingVector vector2;
975 for (
int i = 0;
i < kVectorSize;
i++) {
976 vector2.push_back(i);
979 random_.Reseed(1234);
981 random_.Reseed(1234);
987 for (
int i = 0;
i < kVectorSize;
i++) {
988 EXPECT_EQ(vector_[i], vector2[i]) <<
" where i is " <<
i;
994TEST(AssertHelperTest, AssertHelperIsSmall) {
997 EXPECT_LE(
sizeof(testing::internal::AssertHelper),
sizeof(
void*));
1001TEST(StringTest, EndsWithCaseInsensitive) {
1015static const wchar_t*
const kNull = NULL;
1018TEST(StringTest, CaseInsensitiveWideCStringEquals) {
1032TEST(StringTest, ShowWideCString) {
1039# if GTEST_OS_WINDOWS_MOBILE
1040TEST(StringTest, AnsiAndUtf16Null) {
1041 EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));
1042 EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));
1045TEST(StringTest, AnsiAndUtf16ConvertBasic) {
1046 const char* ansi = String::Utf16ToAnsi(
L"str");
1049 const WCHAR*
utf16 = String::AnsiToUtf16(
"str");
1054TEST(StringTest, AnsiAndUtf16ConvertPathChars) {
1055 const char* ansi = String::Utf16ToAnsi(
L".:\\ \"*?");
1058 const WCHAR*
utf16 = String::AnsiToUtf16(
".:\\ \"*?");
1067TEST(TestPropertyTest, StringValue) {
1068 TestProperty property(
"key",
"1");
1074TEST(TestPropertyTest, ReplaceStringValue) {
1075 TestProperty property(
"key",
"1");
1077 property.SetValue(
"2");
1084static void AddFatalFailure() {
1085 FAIL() <<
"Expected fatal failure.";
1088static void AddNonfatalFailure() {
1092class ScopedFakeTestPartResultReporterTest :
public Test {
1098 static void AddFailure(FailureMode failure) {
1099 if (failure == FATAL_FAILURE) {
1102 AddNonfatalFailure();
1109TEST_F(ScopedFakeTestPartResultReporterTest, InterceptsTestFailures) {
1110 TestPartResultArray results;
1112 ScopedFakeTestPartResultReporter reporter(
1115 AddFailure(NONFATAL_FAILURE);
1116 AddFailure(FATAL_FAILURE);
1124TEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) {
1125 TestPartResultArray results;
1128 ScopedFakeTestPartResultReporter reporter(&results);
1129 AddFailure(NONFATAL_FAILURE);
1134#if GTEST_IS_THREADSAFE
1136class ScopedFakeTestPartResultReporterWithThreadsTest
1137 :
public ScopedFakeTestPartResultReporterTest {
1139 static void AddFailureInOtherThread(FailureMode failure) {
1140 ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL);
1145TEST_F(ScopedFakeTestPartResultReporterWithThreadsTest,
1146 InterceptsTestFailuresInAllThreads) {
1147 TestPartResultArray results;
1149 ScopedFakeTestPartResultReporter reporter(
1151 AddFailure(NONFATAL_FAILURE);
1152 AddFailure(FATAL_FAILURE);
1153 AddFailureInOtherThread(NONFATAL_FAILURE);
1154 AddFailureInOtherThread(FATAL_FAILURE);
1170typedef ScopedFakeTestPartResultReporterTest ExpectFatalFailureTest;
1172TEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) {
1176#if GTEST_HAS_GLOBAL_STRING
1177TEST_F(ExpectFatalFailureTest, AcceptsStringObject) {
1182TEST_F(ExpectFatalFailureTest, AcceptsStdStringObject) {
1184 ::std::string(
"Expected fatal failure."));
1187TEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) {
1191 "Expected fatal failure.");
1196# pragma option push -w-ccc
1202int NonVoidFunction() {
1208TEST_F(ExpectFatalFailureTest, CanBeUsedInNonVoidFunction) {
1215void DoesNotAbortHelper(
bool* aborted) {
1227TEST_F(ExpectFatalFailureTest, DoesNotAbort) {
1228 bool aborted =
true;
1229 DoesNotAbortHelper(&aborted);
1237static int global_var = 0;
1238#define GTEST_USE_UNPROTECTED_COMMA_ global_var++, global_var++
1240TEST_F(ExpectFatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {
1257typedef ScopedFakeTestPartResultReporterTest ExpectNonfatalFailureTest;
1259TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) {
1261 "Expected non-fatal failure.");
1264#if GTEST_HAS_GLOBAL_STRING
1265TEST_F(ExpectNonfatalFailureTest, AcceptsStringObject) {
1267 ::string(
"Expected non-fatal failure."));
1271TEST_F(ExpectNonfatalFailureTest, AcceptsStdStringObject) {
1273 ::std::string(
"Expected non-fatal failure."));
1276TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailureOnAllThreads) {
1280 "Expected non-fatal failure.");
1286TEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {
1289 AddNonfatalFailure();
1294 AddNonfatalFailure();
1298#if GTEST_IS_THREADSAFE
1300typedef ScopedFakeTestPartResultReporterWithThreadsTest
1301 ExpectFailureWithThreadsTest;
1303TEST_F(ExpectFailureWithThreadsTest, ExpectFatalFailureOnAllThreads) {
1305 "Expected fatal failure.");
1308TEST_F(ExpectFailureWithThreadsTest, ExpectNonFatalFailureOnAllThreads) {
1310 AddFailureInOtherThread(NONFATAL_FAILURE),
"Expected non-fatal failure.");
1317TEST(TestPropertyTest, ConstructorWorks) {
1318 const TestProperty property(
"key",
"value");
1323TEST(TestPropertyTest, SetValue) {
1324 TestProperty property(
"key",
"value_1");
1326 property.SetValue(
"value_2");
1334class TestResultTest :
public Test {
1336 typedef std::vector<TestPartResult> TPRVector;
1339 TestPartResult * pr1, * pr2;
1342 TestResult * r0, * r1, * r2;
1344 virtual void SetUp() {
1358 r0 =
new TestResult();
1359 r1 =
new TestResult();
1360 r2 =
new TestResult();
1367 TPRVector* results1 =
const_cast<TPRVector*
>(
1369 TPRVector* results2 =
const_cast<TPRVector*
>(
1375 results1->push_back(*pr1);
1378 results2->push_back(*pr1);
1379 results2->push_back(*pr2);
1382 virtual void TearDown() {
1392 static void CompareTestPartResult(
const TestPartResult& expected,
1393 const TestPartResult& actual) {
1407TEST_F(TestResultTest, total_part_count) {
1414TEST_F(TestResultTest, Passed) {
1421TEST_F(TestResultTest, Failed) {
1429typedef TestResultTest TestResultDeathTest;
1431TEST_F(TestResultDeathTest, GetTestPartResult) {
1439TEST(TestResultPropertyTest, NoPropertiesFoundWhenNoneAreAdded) {
1440 TestResult test_result;
1445TEST(TestResultPropertyTest, OnePropertyFoundWhenAdded) {
1446 TestResult test_result;
1447 TestProperty property(
"key_1",
"1");
1456TEST(TestResultPropertyTest, MultiplePropertiesFoundWhenAdded) {
1457 TestResult test_result;
1458 TestProperty property_1(
"key_1",
"1");
1459 TestProperty property_2(
"key_2",
"2");
1463 const TestProperty& actual_property_1 = test_result.
GetTestProperty(0);
1467 const TestProperty& actual_property_2 = test_result.
GetTestProperty(1);
1473TEST(TestResultPropertyTest, OverridesValuesForDuplicateKeys) {
1474 TestResult test_result;
1475 TestProperty property_1_1(
"key_1",
"1");
1476 TestProperty property_2_1(
"key_2",
"2");
1477 TestProperty property_1_2(
"key_1",
"12");
1478 TestProperty property_2_2(
"key_2",
"22");
1485 const TestProperty& actual_property_1 = test_result.
GetTestProperty(0);
1489 const TestProperty& actual_property_2 = test_result.
GetTestProperty(1);
1495TEST(TestResultPropertyTest, GetTestProperty) {
1496 TestResult test_result;
1497 TestProperty property_1(
"key_1",
"1");
1498 TestProperty property_2(
"key_2",
"2");
1499 TestProperty property_3(
"key_3",
"3");
1504 const TestProperty& fetched_property_1 = test_result.
GetTestProperty(0);
1505 const TestProperty& fetched_property_2 = test_result.
GetTestProperty(1);
1506 const TestProperty& fetched_property_3 = test_result.
GetTestProperty(2);
1533class GTestFlagSaverTest :
public Test {
1538 static void SetUpTestCase() {
1539 saver_ =
new GTestFlagSaver;
1560 static void TearDownTestCase() {
1567 void VerifyAndModifyFlags() {
1597 GTEST_FLAG(stream_result_to) =
"localhost:1234";
1603 static GTestFlagSaver* saver_;
1606GTestFlagSaver* GTestFlagSaverTest::saver_ = NULL;
1612TEST_F(GTestFlagSaverTest, ModifyGTestFlags) {
1613 VerifyAndModifyFlags();
1618TEST_F(GTestFlagSaverTest, VerifyGTestFlags) {
1619 VerifyAndModifyFlags();
1625static void SetEnv(
const char*
name,
const char*
value) {
1626#if GTEST_OS_WINDOWS_MOBILE
1629#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
1633 static std::map<std::string, std::string*> added_env;
1637 std::string *prev_env = NULL;
1638 if (added_env.find(
name) != added_env.end()) {
1639 prev_env = added_env[
name];
1641 added_env[
name] =
new std::string(
1642 (Message() <<
name <<
"=" <<
value).GetString());
1647 putenv(
const_cast<char*
>(added_env[
name]->c_str()));
1649#elif GTEST_OS_WINDOWS
1650 _putenv((Message() <<
name <<
"=" <<
value).GetString().c_str());
1652 if (*
value ==
'\0') {
1660#if !GTEST_OS_WINDOWS_MOBILE
1669TEST(Int32FromGTestEnvTest, ReturnsDefaultWhenVariableIsNotSet) {
1674# if !defined(GTEST_GET_INT32_FROM_ENV_)
1678TEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueOverflows) {
1679 printf(
"(expecting 2 warnings)\n");
1690TEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueIsInvalid) {
1691 printf(
"(expecting 2 warnings)\n");
1705TEST(Int32FromGTestEnvTest, ParsesAndReturnsValidValue) {
1718TEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {
1729TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {
1730 printf(
"(expecting 2 warnings)\n");
1743TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {
1744 printf(
"(expecting 2 warnings)\n");
1757TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {
1770#if !GTEST_OS_WINDOWS_MOBILE
1771TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {
1782TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
1791TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {
1800TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) {
1808class ShouldShardTest :
public testing::Test {
1810 virtual void SetUp() {
1815 virtual void TearDown() {
1816 SetEnv(index_var_,
"");
1817 SetEnv(total_var_,
"");
1820 const char* index_var_;
1821 const char* total_var_;
1826TEST_F(ShouldShardTest, ReturnsFalseWhenNeitherEnvVarIsSet) {
1827 SetEnv(index_var_,
"");
1828 SetEnv(total_var_,
"");
1835TEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) {
1836 SetEnv(index_var_,
"0");
1837 SetEnv(total_var_,
"1");
1845#if !GTEST_OS_WINDOWS_MOBILE
1846TEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) {
1847 SetEnv(index_var_,
"4");
1848 SetEnv(total_var_,
"22");
1852 SetEnv(index_var_,
"8");
1853 SetEnv(total_var_,
"9");
1857 SetEnv(index_var_,
"0");
1858 SetEnv(total_var_,
"9");
1866typedef ShouldShardTest ShouldShardDeathTest;
1868TEST_F(ShouldShardDeathTest, AbortsWhenShardingEnvVarsAreInvalid) {
1869 SetEnv(index_var_,
"4");
1870 SetEnv(total_var_,
"4");
1873 SetEnv(index_var_,
"4");
1874 SetEnv(total_var_,
"-2");
1877 SetEnv(index_var_,
"5");
1878 SetEnv(total_var_,
"");
1881 SetEnv(index_var_,
"");
1882 SetEnv(total_var_,
"5");
1888TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {
1890 const int num_tests = 17;
1891 const int num_shards = 5;
1894 for (
int test_id = 0; test_id < num_tests; test_id++) {
1895 int prev_selected_shard_index = -1;
1896 for (
int shard_index = 0; shard_index < num_shards; shard_index++) {
1898 if (prev_selected_shard_index < 0) {
1899 prev_selected_shard_index = shard_index;
1901 ADD_FAILURE() <<
"Shard " << prev_selected_shard_index <<
" and "
1902 << shard_index <<
" are both selected to run test " << test_id;
1910 for (
int shard_index = 0; shard_index < num_shards; shard_index++) {
1911 int num_tests_on_shard = 0;
1912 for (
int test_id = 0; test_id < num_tests; test_id++) {
1913 num_tests_on_shard +=
1916 EXPECT_GE(num_tests_on_shard, num_tests / num_shards);
1930TEST(UnitTestTest, CanGetOriginalWorkingDir) {
1935TEST(UnitTestTest, ReturnsPlausibleTimestamp) {
1943void ExpectNonFatalFailureRecordingPropertyWithReservedKey(
1944 const TestResult& test_result,
const char*
key) {
1947 <<
"' recorded unexpectedly.";
1950void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
1954 ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->
result(),
1958void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
1962 ExpectNonFatalFailureRecordingPropertyWithReservedKey(
1966void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
1968 ExpectNonFatalFailureRecordingPropertyWithReservedKey(
1975class UnitTestRecordPropertyTest :
1976 public testing::internal::UnitTestRecordPropertyTestHelper {
1978 static void SetUpTestCase() {
1979 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
1981 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
1983 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
1985 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
1987 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
1989 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
2005TEST_F(UnitTestRecordPropertyTest, OnePropertyFoundWhenAdded) {
2006 UnitTestRecordProperty(
"key_1",
"1");
2008 ASSERT_EQ(1, unit_test_.ad_hoc_test_result().test_property_count());
2011 unit_test_.ad_hoc_test_result().GetTestProperty(0).key());
2013 unit_test_.ad_hoc_test_result().GetTestProperty(0).value());
2017TEST_F(UnitTestRecordPropertyTest, MultiplePropertiesFoundWhenAdded) {
2018 UnitTestRecordProperty(
"key_1",
"1");
2019 UnitTestRecordProperty(
"key_2",
"2");
2021 ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());
2024 unit_test_.ad_hoc_test_result().GetTestProperty(0).key());
2025 EXPECT_STREQ(
"1", unit_test_.ad_hoc_test_result().GetTestProperty(0).value());
2028 unit_test_.ad_hoc_test_result().GetTestProperty(1).key());
2029 EXPECT_STREQ(
"2", unit_test_.ad_hoc_test_result().GetTestProperty(1).value());
2033TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {
2034 UnitTestRecordProperty(
"key_1",
"1");
2035 UnitTestRecordProperty(
"key_2",
"2");
2036 UnitTestRecordProperty(
"key_1",
"12");
2037 UnitTestRecordProperty(
"key_2",
"22");
2039 ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());
2042 unit_test_.ad_hoc_test_result().GetTestProperty(0).key());
2044 unit_test_.ad_hoc_test_result().GetTestProperty(0).value());
2047 unit_test_.ad_hoc_test_result().GetTestProperty(1).key());
2049 unit_test_.ad_hoc_test_result().GetTestProperty(1).value());
2052TEST_F(UnitTestRecordPropertyTest,
2053 AddFailureInsideTestsWhenUsingTestCaseReservedKeys) {
2054 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
2056 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
2058 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
2060 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
2062 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
2064 ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
2068TEST_F(UnitTestRecordPropertyTest,
2069 AddRecordWithReservedKeysGeneratesCorrectPropertyList) {
2072 "'classname', 'name', 'status', 'time', 'type_param', and 'value_param'"
2076class UnitTestRecordPropertyTestEnvironment :
public Environment {
2078 virtual void TearDown() {
2079 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2081 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2083 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2085 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2087 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2089 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2091 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2093 ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
2099static Environment* record_property_env =
2112 return (n % 2) == 0;
2116struct IsEvenFunctor {
2117 bool operator()(
int n) {
return IsEven(n); }
2122AssertionResult AssertIsEven(
const char* expr,
int n) {
2128 msg << expr <<
" evaluates to " << n <<
", which is not even.";
2134AssertionResult ResultIsEven(
int n) {
2144AssertionResult ResultIsEvenNoExplanation(
int n) {
2153struct AssertIsEvenFunctor {
2154 AssertionResult operator()(
const char* expr,
int n) {
2155 return AssertIsEven(expr, n);
2160bool SumIsEven2(
int n1,
int n2) {
2161 return IsEven(n1 + n2);
2166struct SumIsEven3Functor {
2167 bool operator()(
int n1,
int n2,
int n3) {
2168 return IsEven(n1 + n2 + n3);
2174AssertionResult AssertSumIsEven4(
2175 const char* e1,
const char* e2,
const char* e3,
const char* e4,
2176 int n1,
int n2,
int n3,
int n4) {
2177 const int sum = n1 + n2 + n3 + n4;
2183 msg << e1 <<
" + " << e2 <<
" + " << e3 <<
" + " << e4
2184 <<
" (" << n1 <<
" + " << n2 <<
" + " << n3 <<
" + " << n4
2185 <<
") evaluates to " << sum <<
", which is not even.";
2191struct AssertSumIsEven5Functor {
2192 AssertionResult operator()(
2193 const char* e1,
const char* e2,
const char* e3,
const char* e4,
2194 const char* e5,
int n1,
int n2,
int n3,
int n4,
int n5) {
2195 const int sum = n1 + n2 + n3 + n4 + n5;
2201 msg << e1 <<
" + " << e2 <<
" + " << e3 <<
" + " << e4 <<
" + " << e5
2203 << n1 <<
" + " << n2 <<
" + " << n3 <<
" + " << n4 <<
" + " << n5
2204 <<
") evaluates to " << sum <<
", which is not even.";
2213TEST(Pred1Test, WithoutFormat) {
2215 EXPECT_PRED1(IsEvenFunctor(), 2) <<
"This failure is UNEXPECTED!";
2220 EXPECT_PRED1(IsEven, 5) <<
"This failure is expected.";
2221 },
"This failure is expected.");
2223 "evaluates to false");
2227TEST(Pred1Test, WithFormat) {
2231 <<
"This failure is UNEXPECTED!";
2236 "n evaluates to 5, which is not even.");
2239 },
"This failure is expected.");
2244TEST(Pred1Test, SingleEvaluationOnFailure) {
2248 EXPECT_EQ(1, n) <<
"The argument is not evaluated exactly once.";
2253 <<
"This failure is expected.";
2254 },
"This failure is expected.");
2255 EXPECT_EQ(2, n) <<
"The argument is not evaluated exactly once.";
2262TEST(PredTest, WithoutFormat) {
2264 ASSERT_PRED2(SumIsEven2, 2, 4) <<
"This failure is UNEXPECTED!";
2271 EXPECT_PRED2(SumIsEven2, n1, n2) <<
"This failure is expected.";
2272 },
"This failure is expected.");
2275 },
"evaluates to false");
2279TEST(PredTest, WithFormat) {
2282 "This failure is UNEXPECTED!";
2292 },
"evaluates to 13, which is not even.");
2295 <<
"This failure is expected.";
2296 },
"This failure is expected.");
2301TEST(PredTest, SingleEvaluationOnFailure) {
2306 EXPECT_EQ(1, n1) <<
"Argument 1 is not evaluated exactly once.";
2307 EXPECT_EQ(1, n2) <<
"Argument 2 is not evaluated exactly once.";
2315 n1++, n2++, n3++, n4++, n5++)
2316 <<
"This failure is UNEXPECTED!";
2317 EXPECT_EQ(1, n1) <<
"Argument 1 is not evaluated exactly once.";
2318 EXPECT_EQ(1, n2) <<
"Argument 2 is not evaluated exactly once.";
2319 EXPECT_EQ(1, n3) <<
"Argument 3 is not evaluated exactly once.";
2320 EXPECT_EQ(1, n4) <<
"Argument 4 is not evaluated exactly once.";
2321 EXPECT_EQ(1, n5) <<
"Argument 5 is not evaluated exactly once.";
2327 <<
"This failure is expected.";
2328 },
"This failure is expected.");
2329 EXPECT_EQ(1, n1) <<
"Argument 1 is not evaluated exactly once.";
2330 EXPECT_EQ(1, n2) <<
"Argument 2 is not evaluated exactly once.";
2331 EXPECT_EQ(1, n3) <<
"Argument 3 is not evaluated exactly once.";
2334 n1 = n2 = n3 = n4 = 0;
2337 },
"evaluates to 1, which is not even.");
2338 EXPECT_EQ(1, n1) <<
"Argument 1 is not evaluated exactly once.";
2339 EXPECT_EQ(1, n2) <<
"Argument 2 is not evaluated exactly once.";
2340 EXPECT_EQ(1, n3) <<
"Argument 3 is not evaluated exactly once.";
2341 EXPECT_EQ(1, n4) <<
"Argument 4 is not evaluated exactly once.";
2352template <
typename T>
2353bool IsNegative(
T x) {
2357template <
typename T1,
typename T2>
2364TEST(PredicateAssertionTest, AcceptsOverloadedFunction) {
2372TEST(PredicateAssertionTest, AcceptsTemplateFunction) {
2383AssertionResult IsPositiveFormat(
const char* ,
int n) {
2388AssertionResult IsPositiveFormat(
const char* ,
double x) {
2393template <
typename T>
2394AssertionResult IsNegativeFormat(
const char* ,
T x) {
2399template <
typename T1,
typename T2>
2400AssertionResult EqualsFormat(
const char* ,
const char* ,
2401 const T1& x1,
const T2& x2) {
2408TEST(PredicateFormatAssertionTest, AcceptsOverloadedFunction) {
2415TEST(PredicateFormatAssertionTest, AcceptsTemplateFunction) {
2425 const char *
const p1 =
"good";
2429 const char p2[] =
"good";
2433 "Expected: \"bad\"");
2437TEST(StringAssertionTest, ASSERT_STREQ_Null) {
2444TEST(StringAssertionTest, ASSERT_STREQ_Null2) {
2459 "\"Hi\" vs \"Hi\"");
2486TEST(StringAssertionTest, STREQ_Wide) {
2488 ASSERT_STREQ(
static_cast<const wchar_t *
>(NULL), NULL);
2511 },
"Expected failure");
2515TEST(StringAssertionTest, STRNE_Wide) {
2518 EXPECT_STRNE(
static_cast<const wchar_t *
>(NULL), NULL);
2540 ASSERT_STRNE(
L"abc\x8119",
L"abc\x8120") <<
"This shouldn't happen";
2547TEST(IsSubstringTest, ReturnsCorrectResultForCString) {
2558TEST(IsSubstringTest, ReturnsCorrectResultForWideCString) {
2569TEST(IsSubstringTest, GeneratesCorrectMessageForCString) {
2571 " Actual: \"needle\"\n"
2572 "Expected: a substring of haystack_expr\n"
2573 "Which is: \"haystack\"",
2575 "needle",
"haystack").failure_message());
2580TEST(IsSubstringTest, ReturnsCorrectResultsForStdString) {
2585#if GTEST_HAS_STD_WSTRING
2588TEST(IsSubstringTest, ReturnsCorrectResultForStdWstring) {
2595TEST(IsSubstringTest, GeneratesCorrectMessageForWstring) {
2597 " Actual: L\"needle\"\n"
2598 "Expected: a substring of haystack_expr\n"
2599 "Which is: L\"haystack\"",
2601 "needle_expr",
"haystack_expr",
2602 ::std::wstring(
L"needle"),
L"haystack").failure_message());
2611TEST(IsNotSubstringTest, ReturnsCorrectResultForCString) {
2618TEST(IsNotSubstringTest, ReturnsCorrectResultForWideCString) {
2625TEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {
2627 " Actual: L\"needle\"\n"
2628 "Expected: not a substring of haystack_expr\n"
2629 "Which is: L\"two needles\"",
2631 "needle_expr",
"haystack_expr",
2632 L"needle",
L"two needles").failure_message());
2637TEST(IsNotSubstringTest, ReturnsCorrectResultsForStdString) {
2644TEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {
2646 " Actual: \"needle\"\n"
2647 "Expected: not a substring of haystack_expr\n"
2648 "Which is: \"two needles\"",
2650 "needle_expr",
"haystack_expr",
2651 ::std::string(
"needle"),
"two needles").failure_message());
2654#if GTEST_HAS_STD_WSTRING
2658TEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) {
2668template <
typename RawType>
2669class FloatingPointTest :
public Test {
2673 RawType close_to_positive_zero;
2674 RawType close_to_negative_zero;
2675 RawType further_from_negative_zero;
2677 RawType close_to_one;
2678 RawType further_from_one;
2681 RawType close_to_infinity;
2682 RawType further_from_infinity;
2688 typedef typename testing::internal::FloatingPoint<RawType> Floating;
2689 typedef typename Floating::Bits Bits;
2691 virtual void SetUp() {
2692 const size_t max_ulps = Floating::kMaxUlps;
2695 const Bits zero_bits = Floating(0).bits();
2698 values_.close_to_positive_zero = Floating::ReinterpretBits(
2699 zero_bits + max_ulps/2);
2700 values_.close_to_negative_zero = -Floating::ReinterpretBits(
2701 zero_bits + max_ulps - max_ulps/2);
2702 values_.further_from_negative_zero = -Floating::ReinterpretBits(
2703 zero_bits + max_ulps + 1 - max_ulps/2);
2706 const Bits one_bits = Floating(1).bits();
2709 values_.close_to_one = Floating::ReinterpretBits(one_bits + max_ulps);
2710 values_.further_from_one = Floating::ReinterpretBits(
2711 one_bits + max_ulps + 1);
2714 values_.infinity = Floating::Infinity();
2717 const Bits infinity_bits = Floating(values_.infinity).bits();
2720 values_.close_to_infinity = Floating::ReinterpretBits(
2721 infinity_bits - max_ulps);
2722 values_.further_from_infinity = Floating::ReinterpretBits(
2723 infinity_bits - max_ulps - 1);
2728 values_.nan1 = Floating::ReinterpretBits(Floating::kExponentBitMask
2729 | (
static_cast<Bits
>(1) << (Floating::kFractionBitCount - 1)) | 1);
2730 values_.nan2 = Floating::ReinterpretBits(Floating::kExponentBitMask
2731 | (
static_cast<Bits
>(1) << (Floating::kFractionBitCount - 1)) | 200);
2735 EXPECT_EQ(
sizeof(RawType),
sizeof(Bits));
2738 static TestValues values_;
2741template <
typename RawType>
2742typename FloatingPointTest<RawType>::TestValues
2743 FloatingPointTest<RawType>::values_;
2746typedef FloatingPointTest<float>
FloatTest;
2754TEST_F(FloatTest, Zeros) {
2767TEST_F(FloatTest, AlmostZeros) {
2774 static const FloatTest::TestValues& v = this->values_;
2782 v.further_from_negative_zero);
2783 },
"v.further_from_negative_zero");
2787TEST_F(FloatTest, SmallDiff) {
2790 "values_.further_from_one");
2794TEST_F(FloatTest, LargeDiff) {
2803TEST_F(FloatTest, Infinity) {
2806#if !GTEST_OS_SYMBIAN
2809 "-values_.infinity");
2820#if !GTEST_OS_SYMBIAN
2829 static const FloatTest::TestValues& v = this->values_;
2844TEST_F(FloatTest, Reflexive) {
2851TEST_F(FloatTest, Commutative) {
2865 "The difference between 1.0f and 1.5f is 0.5, "
2866 "which exceeds 0.25f");
2876 "The difference between 1.0f and 1.5f is 0.5, "
2877 "which exceeds 0.25f");
2883TEST_F(FloatTest, FloatLESucceeds) {
2892TEST_F(FloatTest, FloatLEFails) {
2895 "(2.0f) <= (1.0f)");
2900 },
"(values_.further_from_one) <= (1.0f)");
2902#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
2908 },
"(values_.nan1) <= (values_.infinity)");
2911 },
"(-values_.infinity) <= (values_.nan1)");
2914 },
"(values_.nan1) <= (values_.nan1)");
2922TEST_F(DoubleTest, Size) {
2927TEST_F(DoubleTest, Zeros) {
2940TEST_F(DoubleTest, AlmostZeros) {
2947 static const DoubleTest::TestValues& v = this->values_;
2955 v.further_from_negative_zero);
2956 },
"v.further_from_negative_zero");
2960TEST_F(DoubleTest, SmallDiff) {
2963 "values_.further_from_one");
2967TEST_F(DoubleTest, LargeDiff) {
2976TEST_F(DoubleTest, Infinity) {
2979#if !GTEST_OS_SYMBIAN
2982 "-values_.infinity");
2993#if !GTEST_OS_SYMBIAN
3000 static const DoubleTest::TestValues& v = this->values_;
3013TEST_F(DoubleTest, Reflexive) {
3016#if !GTEST_OS_SYMBIAN
3023TEST_F(DoubleTest, Commutative) {
3037 "The difference between 1.0 and 1.5 is 0.5, "
3038 "which exceeds 0.25");
3048 "The difference between 1.0 and 1.5 is 0.5, "
3049 "which exceeds 0.25");
3055TEST_F(DoubleTest, DoubleLESucceeds) {
3064TEST_F(DoubleTest, DoubleLEFails) {
3072 },
"(values_.further_from_one) <= (1.0)");
3074#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
3080 },
"(values_.nan1) <= (values_.infinity)");
3083 },
" (-values_.infinity) <= (values_.nan1)");
3086 },
"(values_.nan1) <= (values_.nan1)");
3096TEST(DisabledTest, DISABLED_TestShouldNotRun) {
3097 FAIL() <<
"Unexpected failure: Disabled test should not be run.";
3102TEST(DisabledTest, NotDISABLED_TestShouldRun) {
3108TEST(DISABLED_TestCase, TestShouldNotRun) {
3109 FAIL() <<
"Unexpected failure: Test in disabled test case should not be run.";
3114TEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) {
3115 FAIL() <<
"Unexpected failure: Test in disabled test case should not be run.";
3120class DisabledTestsTest :
public Test {
3122 static void SetUpTestCase() {
3123 FAIL() <<
"Unexpected failure: All tests disabled in test case. "
3124 "SetupTestCase() should not be called.";
3127 static void TearDownTestCase() {
3128 FAIL() <<
"Unexpected failure: All tests disabled in test case. "
3129 "TearDownTestCase() should not be called.";
3133TEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_1) {
3134 FAIL() <<
"Unexpected failure: Disabled test should not be run.";
3137TEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_2) {
3138 FAIL() <<
"Unexpected failure: Disabled test should not be run.";
3143#if GTEST_HAS_TYPED_TEST
3145template <
typename T>
3146class TypedTest :
public Test {
3149typedef testing::Types<int, double> NumericTypes;
3152TYPED_TEST(TypedTest, DISABLED_ShouldNotRun) {
3153 FAIL() <<
"Unexpected failure: Disabled typed test should not run.";
3156template <
typename T>
3157class DISABLED_TypedTest :
public Test {
3162TYPED_TEST(DISABLED_TypedTest, ShouldNotRun) {
3163 FAIL() <<
"Unexpected failure: Disabled typed test should not run.";
3170#if GTEST_HAS_TYPED_TEST_P
3172template <
typename T>
3173class TypedTestP :
public Test {
3179 FAIL() <<
"Unexpected failure: "
3180 <<
"Disabled type-parameterized test should not run.";
3187template <
typename T>
3188class DISABLED_TypedTestP :
public Test {
3194 FAIL() <<
"Unexpected failure: "
3195 <<
"Disabled type-parameterized test should not run.";
3206class SingleEvaluationTest :
public Test {
3211 static void CompareAndIncrementCharPtrs() {
3217 static void CompareAndIncrementInts() {
3222 SingleEvaluationTest() {
3229 static const char*
const s1_;
3230 static const char*
const s2_;
3231 static const char* p1_;
3232 static const char* p2_;
3238const char*
const SingleEvaluationTest::s1_ =
"01234";
3239const char*
const SingleEvaluationTest::s2_ =
"abcde";
3240const char* SingleEvaluationTest::p1_;
3241const char* SingleEvaluationTest::p2_;
3242int SingleEvaluationTest::a_;
3243int SingleEvaluationTest::b_;
3247TEST_F(SingleEvaluationTest, FailedASSERT_STREQ) {
3255TEST_F(SingleEvaluationTest, ASSERT_STR) {
3270TEST_F(SingleEvaluationTest, FailedASSERT_NE) {
3272 "(a_++) != (b_++)");
3278TEST_F(SingleEvaluationTest, OtherCases) {
3307#if GTEST_HAS_EXCEPTIONS
3309void ThrowAnInteger() {
3314TEST_F(SingleEvaluationTest, ExceptionTests) {
3326 },
bool),
"throws a different type");
3359class NoFatalFailureTest :
public Test {
3362 void FailsNonFatal() {
3366 FAIL() <<
"some fatal failure";
3369 void DoAssertNoFatalFailureOnFails() {
3374 void DoExpectNoFatalFailureOnFails() {
3380TEST_F(NoFatalFailureTest, NoFailure) {
3385TEST_F(NoFatalFailureTest, NonFatalIsNoFailure) {
3388 "some non-fatal failure");
3391 "some non-fatal failure");
3394TEST_F(NoFatalFailureTest, AssertNoFatalFailureOnFatalFailure) {
3395 TestPartResultArray gtest_failures;
3397 ScopedFakeTestPartResultReporter gtest_reporter(>est_failures);
3398 DoAssertNoFatalFailureOnFails();
3411TEST_F(NoFatalFailureTest, ExpectNoFatalFailureOnFatalFailure) {
3412 TestPartResultArray gtest_failures;
3414 ScopedFakeTestPartResultReporter gtest_reporter(>est_failures);
3415 DoExpectNoFatalFailureOnFails();
3432TEST_F(NoFatalFailureTest, MessageIsStreamable) {
3433 TestPartResultArray gtest_failures;
3435 ScopedFakeTestPartResultReporter gtest_reporter(>est_failures);
3451std::string EditsToString(
const std::vector<EditType>& edits) {
3453 for (
size_t i = 0;
i < edits.size(); ++
i) {
3454 static const char kEdits[] =
" +-/";
3455 out.append(1, kEdits[edits[i]]);
3460std::vector<size_t> CharsToIndices(
const std::string&
str) {
3461 std::vector<size_t>
out;
3462 for (
size_t i = 0;
i <
str.size(); ++
i) {
3468std::vector<std::string> CharsToLines(
const std::string&
str) {
3469 std::vector<std::string>
out;
3470 for (
size_t i = 0;
i <
str.size(); ++
i) {
3471 out.push_back(
str.substr(i, 1));
3476TEST(EditDistance, TestCases) {
3481 const char* expected_edits;
3482 const char* expected_diff;
3484 static const Case kCases[] = {
3486 {__LINE__,
"A",
"A",
" ",
""},
3487 {__LINE__,
"ABCDE",
"ABCDE",
" ",
""},
3489 {__LINE__,
"X",
"XA",
" +",
"@@ +1,2 @@\n X\n+A\n"},
3490 {__LINE__,
"X",
"XABCD",
" ++++",
"@@ +1,5 @@\n X\n+A\n+B\n+C\n+D\n"},
3492 {__LINE__,
"XA",
"X",
" -",
"@@ -1,2 @@\n X\n-A\n"},
3493 {__LINE__,
"XABCD",
"X",
" ----",
"@@ -1,5 @@\n X\n-A\n-B\n-C\n-D\n"},
3495 {__LINE__,
"A",
"a",
"/",
"@@ -1,1 +1,1 @@\n-A\n+a\n"},
3496 {__LINE__,
"ABCD",
"abcd",
"////",
3497 "@@ -1,4 +1,4 @@\n-A\n-B\n-C\n-D\n+a\n+b\n+c\n+d\n"},
3499 {__LINE__,
"ABCDEFGH",
"ABXEGH1",
" -/ - +",
3500 "@@ -1,8 +1,7 @@\n A\n B\n-C\n-D\n+X\n E\n-F\n G\n H\n+1\n"},
3501 {__LINE__,
"AAAABCCCC",
"ABABCDCDC",
"- / + / ",
3502 "@@ -1,9 +1,9 @@\n-A\n A\n-A\n+B\n A\n B\n C\n+D\n C\n-C\n+D\n C\n"},
3503 {__LINE__,
"ABCDE",
"BCDCD",
"- +/",
3504 "@@ -1,5 +1,5 @@\n-A\n B\n C\n D\n-E\n+C\n+D\n"},
3505 {__LINE__,
"ABCDEFGHIJKL",
"BCDCDEFGJKLJK",
"- ++ -- ++",
3506 "@@ -1,4 +1,5 @@\n-A\n B\n+C\n+D\n C\n D\n"
3507 "@@ -6,7 +7,7 @@\n F\n G\n-H\n-I\n J\n K\n L\n+J\n+K\n"},
3509 for (
const Case* c = kCases;
c->left; ++
c) {
3512 CharsToIndices(
c->right))))
3513 <<
"Left <" <<
c->left <<
"> Right <" <<
c->right <<
"> Edits <"
3515 CharsToIndices(
c->left), CharsToIndices(
c->right))) <<
">";
3517 CharsToLines(
c->right)))
3518 <<
"Left <" <<
c->left <<
"> Right <" <<
c->right <<
"> Diff <"
3526 const std::string foo_val(
"5"), bar_val(
"6");
3527 const std::string msg1(
3528 EqFailure(
"foo",
"bar", foo_val, bar_val,
false)
3529 .failure_message());
3533 "To be equal to: bar\n"
3537 const std::string msg2(
3538 EqFailure(
"foo",
"6", foo_val, bar_val,
false)
3539 .failure_message());
3543 "To be equal to: 6",
3546 const std::string msg3(
3547 EqFailure(
"5",
"bar", foo_val, bar_val,
false)
3548 .failure_message());
3551 "To be equal to: bar\n"
3555 const std::string msg4(
3556 EqFailure(
"5",
"6", foo_val, bar_val,
false).failure_message());
3559 "To be equal to: 6",
3562 const std::string msg5(
3564 std::string(
"\"x\""), std::string(
"\"y\""),
3565 true).failure_message());
3568 " Which is: \"x\"\n"
3569 "To be equal to: bar\n"
3570 " Which is: \"y\"\n"
3575TEST(AssertionTest, EqFailureWithDiff) {
3576 const std::string left(
3577 "1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15");
3578 const std::string right(
3579 "1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14");
3580 const std::string msg1(
3581 EqFailure(
"left",
"right", left, right,
false).failure_message());
3585 "1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15\n"
3586 "To be equal to: right\n"
3587 " Which is: 1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14\n"
3588 "With diff:\n@@ -1,5 +1,6 @@\n 1\n-2XXX\n+2\n 3\n+4\n 5\n 6\n"
3589 "@@ -7,8 +8,6 @@\n 8\n 9\n-10\n 11\n-12XXX\n+12\n 13\n 14\n-15\n",
3595 const std::string
foo(
"foo");
3608# pragma option push -w-ccc -w-rch
3619TEST(AssertionTest, AssertTrueWithAssertionResult) {
3624 "Value of: ResultIsEven(3)\n"
3625 " Actual: false (3 is odd)\n"
3630 "Value of: ResultIsEvenNoExplanation(3)\n"
3631 " Actual: false (3 is odd)\n"
3645TEST(AssertionTest, AssertFalseWithAssertionResult) {
3650 "Value of: ResultIsEven(2)\n"
3651 " Actual: true (2 is even)\n"
3656 "Value of: ResultIsEvenNoExplanation(2)\n"
3669TEST(ExpectTest, ASSERT_EQ_Double) {
3683 "To be equal to: 2*3\n"
3688#if GTEST_CAN_COMPARE_NULL
3689TEST(AssertionTest, ASSERT_EQ_NULL) {
3691 const char*
p = NULL;
3701 "To be equal to: &n\n");
3709TEST(ExpectTest, ASSERT_EQ_0) {
3724 "Expected: ('a') != ('a'), "
3725 "actual: 'a' (97, 0x61) vs 'a' (97, 0x61)");
3733 "Expected: (2) <= (0), actual: 2 vs 0");
3740 "Expected: (2) < (2), actual: 2 vs 2");
3748 "Expected: (2) >= (3), actual: 2 vs 3");
3755 "Expected: (2) > (2), actual: 2 vs 2");
3758#if GTEST_HAS_EXCEPTIONS
3760void ThrowNothing() {}
3766# ifndef __BORLANDC__
3771 "Expected: ThrowAnInteger() throws an exception of type bool.\n"
3772 " Actual: it throws a different type.");
3777 "Expected: ThrowNothing() throws an exception of type bool.\n"
3778 " Actual: it throws nothing.");
3785 "Expected: ThrowAnInteger() doesn't throw an exception."
3786 "\n Actual: it throws.");
3794 "Expected: ThrowNothing() throws an exception.\n"
3795 " Actual: it doesn't.");
3802TEST(AssertionTest, AssertPrecedence) {
3804 bool false_value =
false;
3814TEST(AssertionTest, NonFixtureSubroutine) {
3816 "To be equal to: x");
3822 explicit Uncopyable(
int a_value) : value_(a_value) {}
3824 int value()
const {
return value_; }
3825 bool operator==(
const Uncopyable& rhs)
const {
3826 return value() == rhs.value();
3831 Uncopyable(
const Uncopyable&);
3836::std::ostream&
operator<<(::std::ostream& os,
const Uncopyable&
value) {
3837 return os <<
value.value();
3841bool IsPositiveUncopyable(
const Uncopyable& x) {
3842 return x.value() > 0;
3846void TestAssertNonPositive() {
3851void TestAssertEqualsUncopyable() {
3858TEST(AssertionTest, AssertWorksWithUncopyableObject) {
3863 "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1");
3865 "Expected: x\n Which is: 5\nTo be equal to: y\n Which is: -1");
3869TEST(AssertionTest, ExpectWorksWithUncopyableObject) {
3874 "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1");
3877 "Expected: x\n Which is: 5\nTo be equal to: y\n Which is: -1");
3885TEST(AssertionTest, NamedEnum) {
3896#if !GTEST_OS_MAC && !defined(__SUNPRO_CC) && !defined(__HP_aCC)
3927 EXPECT_EQ(
static_cast<int>(kCaseA),
static_cast<int>(kCaseB));
3938 "(kCaseA) >= (kCaseB)");
3949# ifndef __BORLANDC__
3953 "To be equal to: kCaseB");
3966static HRESULT UnexpectedHRESULTFailure() {
3967 return E_UNEXPECTED;
3970static HRESULT OkHRESULTSuccess() {
3974static HRESULT FalseHRESULTSuccess() {
3982TEST(HRESULTAssertionTest, EXPECT_HRESULT_SUCCEEDED) {
3983 EXPECT_HRESULT_SUCCEEDED(S_OK);
3984 EXPECT_HRESULT_SUCCEEDED(S_FALSE);
3987 "Expected: (UnexpectedHRESULTFailure()) succeeds.\n"
3988 " Actual: 0x8000FFFF");
3991TEST(HRESULTAssertionTest, ASSERT_HRESULT_SUCCEEDED) {
3992 ASSERT_HRESULT_SUCCEEDED(S_OK);
3993 ASSERT_HRESULT_SUCCEEDED(S_FALSE);
3996 "Expected: (UnexpectedHRESULTFailure()) succeeds.\n"
3997 " Actual: 0x8000FFFF");
4000TEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) {
4001 EXPECT_HRESULT_FAILED(E_UNEXPECTED);
4004 "Expected: (OkHRESULTSuccess()) fails.\n"
4007 "Expected: (FalseHRESULTSuccess()) fails.\n"
4011TEST(HRESULTAssertionTest, ASSERT_HRESULT_FAILED) {
4012 ASSERT_HRESULT_FAILED(E_UNEXPECTED);
4014# ifndef __BORLANDC__
4018 "Expected: (OkHRESULTSuccess()) fails.\n"
4023 "Expected: (FalseHRESULTSuccess()) fails.\n"
4028TEST(HRESULTAssertionTest, Streaming) {
4029 EXPECT_HRESULT_SUCCEEDED(S_OK) <<
"unexpected failure";
4030 ASSERT_HRESULT_SUCCEEDED(S_OK) <<
"unexpected failure";
4031 EXPECT_HRESULT_FAILED(E_UNEXPECTED) <<
"unexpected failure";
4032 ASSERT_HRESULT_FAILED(E_UNEXPECTED) <<
"unexpected failure";
4035 EXPECT_HRESULT_SUCCEEDED(E_UNEXPECTED) <<
"expected failure",
4036 "expected failure");
4038# ifndef __BORLANDC__
4042 ASSERT_HRESULT_SUCCEEDED(E_UNEXPECTED) <<
"expected failure",
4043 "expected failure");
4047 EXPECT_HRESULT_FAILED(S_OK) <<
"expected failure",
4048 "expected failure");
4051 ASSERT_HRESULT_FAILED(S_OK) <<
"expected failure",
4052 "expected failure");
4059# pragma option push -w-ccc -w-rch
4063TEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) {
4065 ASSERT_TRUE(
false) <<
"This should never be executed; "
4066 "It's a compilation test only.";
4082#if GTEST_HAS_EXCEPTIONS
4085TEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {
4097TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
4124TEST(AssertionSyntaxTest, NoFatalFailureAssertionsBehavesLikeSingleStatement) {
4127 <<
"It's a compilation test only.";
4148TEST(AssertionSyntaxTest, WorksWithSwitch) {
4158 EXPECT_FALSE(
false) <<
"EXPECT_FALSE failed in switch case";
4165 ASSERT_EQ(1, 1) <<
"ASSERT_EQ failed in default switch handler";
4173#if GTEST_HAS_EXCEPTIONS
4175void ThrowAString() {
4176 throw "std::string";
4181TEST(AssertionSyntaxTest, WorksWithConst) {
4201TEST(SuccessfulAssertionTest, EXPECT) {
4207TEST(SuccessfulAssertionTest, EXPECT_STR) {
4213TEST(SuccessfulAssertionTest, ASSERT) {
4219TEST(SuccessfulAssertionTest, ASSERT_STR) {
4230TEST(AssertionWithMessageTest, EXPECT) {
4231 EXPECT_EQ(1, 1) <<
"This should succeed.";
4233 "Expected failure #1");
4234 EXPECT_LE(1, 2) <<
"This should succeed.";
4236 "Expected failure #2.");
4237 EXPECT_GE(1, 0) <<
"This should succeed.";
4239 "Expected failure #3.");
4243 "Expected failure #4.");
4246 "Expected failure #5.");
4250 "Expected failure #6.");
4251 EXPECT_NEAR(1, 1.1, 0.2) <<
"This should succeed.";
4254TEST(AssertionWithMessageTest, ASSERT) {
4255 ASSERT_EQ(1, 1) <<
"This should succeed.";
4256 ASSERT_NE(1, 2) <<
"This should succeed.";
4257 ASSERT_LE(1, 2) <<
"This should succeed.";
4258 ASSERT_LT(1, 2) <<
"This should succeed.";
4259 ASSERT_GE(1, 0) <<
"This should succeed.";
4261 "Expected failure.");
4264TEST(AssertionWithMessageTest, ASSERT_STR) {
4269 "Expected failure.");
4272TEST(AssertionWithMessageTest, ASSERT_FLOATING) {
4285 ASSERT_FALSE(
true) <<
"Expected failure: " << 2 <<
" > " << 1
4286 <<
" evaluates to " <<
true;
4287 },
"Expected failure");
4291TEST(AssertionWithMessageTest,
FAIL) {
4298 SUCCEED() <<
"Success == " << 1;
4306 ASSERT_TRUE(
false) <<
static_cast<const char *
>(NULL)
4307 <<
static_cast<char *
>(NULL);
4313TEST(AssertionWithMessageTest, WideStringMessage) {
4315 EXPECT_TRUE(
false) <<
L"This failure is expected.\x8119";
4316 },
"This failure is expected.");
4319 <<
L"expected too.\x8120";
4320 },
"This failure is expected too.");
4328 "Intentional failure #1.");
4330 "Intentional failure #2.");
4341TEST(ExpectTest, ExpectTrueWithAssertionResult) {
4344 "Value of: ResultIsEven(3)\n"
4345 " Actual: false (3 is odd)\n"
4349 "Value of: ResultIsEvenNoExplanation(3)\n"
4350 " Actual: false (3 is odd)\n"
4359 "Intentional failure #1.");
4361 "Intentional failure #2.");
4371TEST(ExpectTest, ExpectFalseWithAssertionResult) {
4374 "Value of: ResultIsEven(2)\n"
4375 " Actual: true (2 is even)\n"
4379 "Value of: ResultIsEvenNoExplanation(2)\n"
4394 "To be equal to: 2*3\n"
4403TEST(ExpectTest, EXPECT_EQ_Double) {
4412#if GTEST_CAN_COMPARE_NULL
4414TEST(ExpectTest, EXPECT_EQ_NULL) {
4416 const char* p = NULL;
4426 "To be equal to: &n\n");
4434TEST(ExpectTest, EXPECT_EQ_0) {
4450 "Expected: ('a') != ('a'), "
4451 "actual: 'a' (97, 0x61) vs 'a' (97, 0x61)");
4454 char*
const p0 = NULL;
4461 void* pv1 = (
void*)0x1234;
4462 char*
const p1 =
reinterpret_cast<char*
>(pv1);
4472 "Expected: (2) <= (0), actual: 2 vs 0");
4481 "Expected: (2) < (2), actual: 2 vs 2");
4491 "Expected: (2) >= (3), actual: 2 vs 3");
4500 "Expected: (2) > (2), actual: 2 vs 2");
4505#if GTEST_HAS_EXCEPTIONS
4511 "Expected: ThrowAnInteger() throws an exception of "
4512 "type bool.\n Actual: it throws a different type.");
4515 "Expected: ThrowNothing() throws an exception of type bool.\n"
4516 " Actual: it throws nothing.");
4523 "Expected: ThrowAnInteger() doesn't throw an "
4524 "exception.\n Actual: it throws.");
4532 "Expected: ThrowNothing() throws an exception.\n"
4533 " Actual: it doesn't.");
4539TEST(ExpectTest, ExpectPrecedence) {
4542 "To be equal to: true && false");
4549TEST(StreamableToStringTest, Scalar) {
4561TEST(StreamableToStringTest, NullPointer) {
4567TEST(StreamableToStringTest, CString) {
4572TEST(StreamableToStringTest, NullCString) {
4580TEST(StreamableTest,
string) {
4581 static const std::string
str(
4582 "This failure message is a std::string, and is expected.");
4589TEST(StreamableTest, stringWithEmbeddedNUL) {
4590 static const char char_array_with_nul[] =
4591 "Here's a NUL\0 and some more string";
4592 static const std::string string_with_nul(char_array_with_nul,
4593 sizeof(char_array_with_nul)
4596 "Here's a NUL\\0 and some more string");
4600TEST(StreamableTest, NULChar) {
4602 FAIL() <<
"A NUL" <<
'\0' <<
" and some more string";
4603 },
"A NUL\\0 and some more string");
4607TEST(StreamableTest,
int) {
4617TEST(StreamableTest, NullCharPtr) {
4624TEST(StreamableTest, BasicIoManip) {
4626 FAIL() <<
"Line 1." << std::endl
4627 <<
"A NUL char " << std::ends << std::flush <<
" in line 2.";
4628 },
"Line 1.\nA NUL char \\0 in line 2.");
4633void AddFailureHelper(
bool* aborted) {
4641 bool aborted =
true;
4643 "Intentional failure.");
4667 "Intentional failure.");
4673 SUCCEED() <<
"Explicit success.";
4687 bool false_value =
false;
4689 },
"To be equal to: true");
4693TEST(EqAssertionTest, Int) {
4700TEST(EqAssertionTest, Time_T) {
4702 static_cast<time_t
>(0));
4704 static_cast<time_t
>(1234)),
4709TEST(EqAssertionTest, Char) {
4711 const char ch =
'b';
4719TEST(EqAssertionTest, WideChar) {
4723 " Expected: L'\0'\n"
4724 " Which is: L'\0' (0, 0x0)\n"
4725 "To be equal to: L'x'\n"
4726 " Which is: L'x' (120, 0x78)");
4728 static wchar_t wchar;
4734 "To be equal to: wchar");
4738TEST(EqAssertionTest, StdString) {
4741 ASSERT_EQ(
"Test", ::std::string(
"Test"));
4744 static const ::std::string
str1(
"A * in the middle");
4745 static const ::std::string
str2(
str1);
4754 char*
const p1 =
const_cast<char*
>(
"foo");
4760 static ::std::string str3(
str1);
4763 "To be equal to: str3\n"
4764 " Which is: \"A \\0 in the middle\"");
4767#if GTEST_HAS_STD_WSTRING
4770TEST(EqAssertionTest, StdWideString) {
4772 const ::std::wstring wstr1(
L"A * in the middle");
4773 const ::std::wstring wstr2(wstr1);
4778 const wchar_t kTestX8119[] = {
'T',
'e',
's',
't', 0x8119,
'\0' };
4779 EXPECT_EQ(::std::wstring(kTestX8119), kTestX8119);
4783 const wchar_t kTestX8120[] = {
'T',
'e',
's',
't', 0x8120,
'\0' };
4785 EXPECT_EQ(::std::wstring(kTestX8119), kTestX8120);
4790 ::std::wstring wstr3(wstr1);
4791 wstr3.at(2) =
L'\0';
4798 ASSERT_EQ(
const_cast<wchar_t*
>(
L"foo"), ::std::wstring(
L"bar"));
4804#if GTEST_HAS_GLOBAL_STRING
4806TEST(EqAssertionTest, GlobalString) {
4811 const ::string
str1(
"A * in the middle");
4821 ::string str3(
str1);
4828 ASSERT_EQ(::string(
"bar"),
const_cast<char*
>(
"foo"));
4834#if GTEST_HAS_GLOBAL_WSTRING
4837TEST(EqAssertionTest, GlobalWideString) {
4839 static const ::wstring wstr1(
L"A * in the middle");
4840 static const ::wstring wstr2(wstr1);
4844 const wchar_t kTestX8119[] = {
'T',
'e',
's',
't', 0x8119,
'\0' };
4845 ASSERT_EQ(kTestX8119, ::wstring(kTestX8119));
4849 const wchar_t kTestX8120[] = {
'T',
'e',
's',
't', 0x8120,
'\0' };
4851 EXPECT_EQ(kTestX8120, ::wstring(kTestX8119));
4855 wchar_t*
const p1 =
const_cast<wchar_t*
>(
L"foo");
4861 static ::wstring wstr3;
4863 wstr3.at(2) =
L'\0';
4871TEST(EqAssertionTest, CharPointer) {
4872 char*
const p0 = NULL;
4877 void* pv1 = (
void*)0x1234;
4878 void* pv2 = (
void*)0xABC0;
4879 char*
const p1 =
reinterpret_cast<char*
>(pv1);
4880 char*
const p2 =
reinterpret_cast<char*
>(pv2);
4884 "To be equal to: p2");
4888 reinterpret_cast<char*
>(0xABC0)),
4893TEST(EqAssertionTest, WideCharPointer) {
4894 wchar_t*
const p0 = NULL;
4899 void* pv1 = (
void*)0x1234;
4900 void* pv2 = (
void*)0xABC0;
4901 wchar_t*
const p1 =
reinterpret_cast<wchar_t*
>(pv1);
4902 wchar_t*
const p2 =
reinterpret_cast<wchar_t*
>(pv2);
4906 "To be equal to: p2");
4909 void* pv3 = (
void*)0x1234;
4910 void* pv4 = (
void*)0xABC0;
4911 const wchar_t* p3 =
reinterpret_cast<const wchar_t*
>(pv3);
4912 const wchar_t* p4 =
reinterpret_cast<const wchar_t*
>(pv4);
4918TEST(EqAssertionTest, OtherPointer) {
4919 ASSERT_EQ(
static_cast<const int*
>(NULL),
4920 static_cast<const int*
>(NULL));
4922 reinterpret_cast<const int*
>(0x1234)),
4927class UnprintableChar {
4929 explicit UnprintableChar(
char ch) : char_(ch) {}
4931 bool operator==(
const UnprintableChar& rhs)
const {
4932 return char_ == rhs.char_;
4934 bool operator!=(
const UnprintableChar& rhs)
const {
4935 return char_ != rhs.char_;
4937 bool operator<(
const UnprintableChar& rhs)
const {
4938 return char_ < rhs.char_;
4940 bool operator<=(
const UnprintableChar& rhs)
const {
4941 return char_ <= rhs.char_;
4943 bool operator>(
const UnprintableChar& rhs)
const {
4944 return char_ > rhs.char_;
4946 bool operator>=(
const UnprintableChar& rhs)
const {
4947 return char_ >= rhs.char_;
4956TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {
4957 const UnprintableChar x(
'x'), y(
'y');
4976 "1-byte object <78>");
4978 "1-byte object <78>");
4981 "1-byte object <79>");
4983 "1-byte object <78>");
4985 "1-byte object <79>");
4997 int Bar()
const {
return 1; }
5012class FRIEND_TEST_Test2 :
public Test {
5029class TestLifeCycleTest :
public Test {
5033 TestLifeCycleTest() { count_++; }
5037 ~TestLifeCycleTest() { count_--; }
5040 int count()
const {
return count_; }
5046int TestLifeCycleTest::count_ = 0;
5049TEST_F(TestLifeCycleTest, Test1) {
5056TEST_F(TestLifeCycleTest, Test2) {
5067TEST(AssertionResultTest, CopyConstructorWorksWhenNotOptimied) {
5077 EXPECT_EQ(
static_cast<bool>(r3),
static_cast<bool>(r1));
5083TEST(AssertionResultTest, ConstructionWorks) {
5106TEST(AssertionResultTest, NegationWorks) {
5116TEST(AssertionResultTest, StreamingWorks) {
5118 r <<
"abc" <<
'd' << 0 <<
true;
5122TEST(AssertionResultTest, CanStreamOstreamManipulators) {
5124 r <<
"Data" << std::endl << std::flush << std::ends <<
"Will be visible";
5131TEST(AssertionResultTest, ConstructibleFromContextuallyConvertibleToBool) {
5132 struct ExplicitlyConvertibleToBool {
5133 explicit operator bool()
const {
return value; }
5136 ExplicitlyConvertibleToBool
v1 = {
false};
5137 ExplicitlyConvertibleToBool
v2 = {
true};
5148TEST(AssertionResultTest, ConstructibleFromImplicitlyConvertible) {
5164 return os << val.x();
5168 return os <<
"(" <<
pointer->x() <<
")";
5171TEST(MessageTest, CanStreamUserTypeInGlobalNameSpace) {
5182class MyTypeInUnnamedNameSpace :
public Base {
5184 explicit MyTypeInUnnamedNameSpace(
int an_x): Base(an_x) {}
5187 const MyTypeInUnnamedNameSpace& val) {
5188 return os << val.x();
5191 const MyTypeInUnnamedNameSpace*
pointer) {
5192 return os <<
"(" <<
pointer->x() <<
")";
5196TEST(MessageTest, CanStreamUserTypeInUnnamedNameSpace) {
5198 MyTypeInUnnamedNameSpace
a(1);
5213 return os << val.x();
5217 return os <<
"(" <<
pointer->x() <<
")";
5221TEST(MessageTest, CanStreamUserTypeInUserNameSpace) {
5239 return os << val.x();
5243 return os <<
"(" <<
pointer->x() <<
")";
5246TEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) {
5257 char*
const p1 = NULL;
5258 unsigned char*
const p2 = NULL;
5264 msg << p1 << p2 << p3 << p4 << p5 << p6;
5272 const wchar_t* const_wstr = NULL;
5274 (
Message() << const_wstr).GetString().c_str());
5277 wchar_t* wstr = NULL;
5279 (
Message() << wstr).GetString().c_str());
5282 const_wstr =
L"abc\x8119";
5284 (
Message() << const_wstr).GetString().c_str());
5287 wstr =
const_cast<wchar_t*
>(const_wstr);
5289 (
Message() << wstr).GetString().c_str());
5302 GetTestCase(
"TestInfoTest",
"", NULL, NULL);
5306 if (strcmp(test_name, test_info->
name()) == 0)
5314 return test_info->
result();
5320 const TestInfo*
const test_info = GetTestInfo(
"Names");
5328 const TestInfo*
const test_info = GetTestInfo(
"result");
5331 ASSERT_EQ(0, GetTestResult(test_info)->total_part_count());
5334 ASSERT_EQ(0, GetTestResult(test_info)->total_part_count());
5337#define VERIFY_CODE_LOCATION \
5338 const int expected_line = __LINE__ - 1; \
5339 const TestInfo* const test_info = GetUnitTestImpl()->current_test_info(); \
5340 ASSERT_TRUE(test_info); \
5341 EXPECT_STREQ(__FILE__, test_info->file()); \
5342 EXPECT_EQ(expected_line, test_info->line())
5364template <
typename T>
5374template <
typename T>
5388#undef VERIFY_CODE_LOCATION
5397 printf(
"Setting up the test case . . .\n");
5414 printf(
"Tearing down the test case . . .\n");
5626 template <
typename CharType>
5628 size_t size2, CharType** array2) {
5629 ASSERT_EQ(size1, size2) <<
" Array sizes different.";
5631 for (
size_t i = 0; i != size1; i++) {
5632 ASSERT_STREQ(array1[i], array2[i]) <<
" where i == " << i;
5659 template <
typename CharType>
5661 int argc2,
const CharType** argv2,
5662 const Flags& expected,
bool should_print_help) {
5666#if GTEST_HAS_STREAM_REDIRECTION
5673#if GTEST_HAS_STREAM_REDIRECTION
5674 const std::string captured_stdout = GetCapturedStdout();
5688#if GTEST_HAS_STREAM_REDIRECTION
5689 const char*
const expected_help_fragment =
5690 "This program contains tests written using";
5691 if (should_print_help) {
5695 expected_help_fragment, captured_stdout);
5705#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
5706 TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
5707 sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
5708 expected, should_print_help)
5713 const char* argv[] = {
5717 const char* argv2[] = {
5726 const char* argv[] = {
5731 const char* argv2[] = {
5741 const char* argv[] = {
5747 const char* argv2[] = {
5758 const char* argv[] = {
5764 const char* argv2[] = {
5774 const char* argv[] = {
5776 "--gtest_filter=abc",
5780 const char* argv2[] = {
5790 const char* argv[] = {
5792 "--gtest_break_on_failure",
5796 const char* argv2[] = {
5806 const char* argv[] = {
5808 "--gtest_break_on_failure=0",
5812 const char* argv2[] = {
5822 const char* argv[] = {
5824 "--gtest_break_on_failure=f",
5828 const char* argv2[] = {
5838 const char* argv[] = {
5840 "--gtest_break_on_failure=F",
5844 const char* argv2[] = {
5855 const char* argv[] = {
5857 "--gtest_break_on_failure=1",
5861 const char* argv2[] = {
5871 const char* argv[] = {
5873 "--gtest_catch_exceptions",
5877 const char* argv2[] = {
5887 const char* argv[] = {
5889 "--gtest_death_test_use_fork",
5893 const char* argv2[] = {
5904 const char* argv[] = {
5911 const char* argv2[] = {
5921 const char* argv[] = {
5923 "--gtest_break_on_failure",
5929 const char* argv2[] = {
5936 flags.break_on_failure =
true;
5943 const char* argv[] = {
5945 "--gtest_list_tests",
5949 const char* argv2[] = {
5959 const char* argv[] = {
5961 "--gtest_list_tests=1",
5965 const char* argv2[] = {
5975 const char* argv[] = {
5977 "--gtest_list_tests=0",
5981 const char* argv2[] = {
5991 const char* argv[] = {
5993 "--gtest_list_tests=f",
5997 const char* argv2[] = {
6007 const char* argv[] = {
6009 "--gtest_list_tests=F",
6013 const char* argv2[] = {
6023 const char* argv[] = {
6029 const char* argv2[] = {
6040 const char* argv[] = {
6042 "--gtest_output=xml",
6046 const char* argv2[] = {
6056 const char* argv[] = {
6058 "--gtest_output=xml:file",
6062 const char* argv2[] = {
6072 const char* argv[] = {
6074 "--gtest_output=xml:directory/path/",
6078 const char* argv2[] = {
6089 const char* argv[] = {
6091 "--gtest_print_time",
6095 const char* argv2[] = {
6105 const char* argv[] = {
6107 "--gtest_print_time=1",
6111 const char* argv2[] = {
6121 const char* argv[] = {
6123 "--gtest_print_time=0",
6127 const char* argv2[] = {
6137 const char* argv[] = {
6139 "--gtest_print_time=f",
6143 const char* argv2[] = {
6153 const char* argv[] = {
6155 "--gtest_print_time=F",
6159 const char* argv2[] = {
6169 const char* argv[] = {
6171 "--gtest_random_seed=1000",
6175 const char* argv2[] = {
6185 const char* argv[] = {
6187 "--gtest_repeat=1000",
6191 const char* argv2[] = {
6201 const char* argv[] = {
6203 "--gtest_also_run_disabled_tests",
6207 const char* argv2[] = {
6218 const char* argv[] = {
6220 "--gtest_also_run_disabled_tests=1",
6224 const char* argv2[] = {
6235 const char* argv[] = {
6237 "--gtest_also_run_disabled_tests=0",
6241 const char* argv2[] = {
6252 const char* argv[] = {
6258 const char* argv2[] = {
6268 const char* argv[] = {
6270 "--gtest_shuffle=0",
6274 const char* argv2[] = {
6285 const char* argv[] = {
6287 "--gtest_shuffle=1",
6291 const char* argv2[] = {
6301 const char* argv[] = {
6303 "--gtest_stack_trace_depth=5",
6307 const char* argv2[] = {
6316 const char* argv[] = {
6318 "--gtest_stream_result_to=localhost:1234",
6322 const char* argv2[] = {
6333 const char* argv[] = {
6335 "--gtest_throw_on_failure",
6339 const char* argv2[] = {
6349 const char* argv[] = {
6351 "--gtest_throw_on_failure=0",
6355 const char* argv2[] = {
6366 const char* argv[] = {
6368 "--gtest_throw_on_failure=1",
6372 const char* argv2[] = {
6382TEST_F(InitGoogleTestTest, WideStrings) {
6383 const wchar_t* argv[] = {
6385 L"--gtest_filter=Foo*",
6386 L"--gtest_list_tests=1",
6387 L"--gtest_break_on_failure",
6388 L"--non_gtest_flag",
6392 const wchar_t* argv2[] = {
6394 L"--non_gtest_flag",
6398 Flags expected_flags;
6400 expected_flags.filter =
"Foo*";
6401 expected_flags.list_tests =
true;
6407#if GTEST_USE_OWN_FLAGFILE_FLAG_
6410 virtual void SetUp() {
6411 InitGoogleTestTest::SetUp();
6413 testdata_path_.Set(internal::FilePath(
6414 internal::TempDir() + internal::GetCurrentExecutableName().
string() +
6420 virtual void TearDown() {
6422 InitGoogleTestTest::TearDown();
6425 internal::FilePath CreateFlagfile(
const char* contents) {
6426 internal::FilePath file_path(internal::FilePath::GenerateUniqueFileName(
6427 testdata_path_, internal::FilePath(
"unique"),
"txt"));
6429 fprintf(f,
"%s", contents);
6435 internal::FilePath testdata_path_;
6439TEST_F(FlagfileTest, Empty) {
6441 std::string flagfile_flag =
6444 const char* argv[] = {
6446 flagfile_flag.c_str(),
6450 const char* argv2[] = {
6459TEST_F(FlagfileTest, FilterNonEmpty) {
6462 std::string flagfile_flag =
6465 const char* argv[] = {
6467 flagfile_flag.c_str(),
6471 const char* argv2[] = {
6480TEST_F(FlagfileTest, SeveralFlags) {
6485 std::string flagfile_flag =
6488 const char* argv[] = {
6490 flagfile_flag.c_str(),
6494 const char* argv2[] = {
6499 Flags expected_flags;
6501 expected_flags.filter =
"abc";
6502 expected_flags.list_tests =
true;
6518 <<
"There should be no tests running at this point.";
6527 <<
"There should be no tests running at this point.";
6537 <<
"There is a test running so we should have a valid TestInfo.";
6539 <<
"Expected the name of the currently running test case.";
6541 <<
"Expected the name of the currently running test.";
6552 <<
"There is a test running so we should have a valid TestInfo.";
6554 <<
"Expected the name of the currently running test case.";
6556 <<
"Expected the name of the currently running test.";
6580TEST(NestedTestingNamespaceTest, Success) {
6581 EXPECT_EQ(1, 1) <<
"This shouldn't fail.";
6585TEST(NestedTestingNamespaceTest, Failure) {
6587 "This failure is expected.");
6609TEST(StreamingAssertionsTest, Unconditional) {
6610 SUCCEED() <<
"expected success";
6612 "expected failure");
6614 "expected failure");
6619# pragma option push -w-ccc -w-rch
6622TEST(StreamingAssertionsTest, Truth) {
6626 "expected failure");
6628 "expected failure");
6631TEST(StreamingAssertionsTest, Truth2) {
6635 "expected failure");
6637 "expected failure");
6645TEST(StreamingAssertionsTest, IntegerEquals) {
6646 EXPECT_EQ(1, 1) <<
"unexpected failure";
6647 ASSERT_EQ(1, 1) <<
"unexpected failure";
6649 "expected failure");
6651 "expected failure");
6654TEST(StreamingAssertionsTest, IntegerLessThan) {
6655 EXPECT_LT(1, 2) <<
"unexpected failure";
6656 ASSERT_LT(1, 2) <<
"unexpected failure";
6658 "expected failure");
6660 "expected failure");
6663TEST(StreamingAssertionsTest, StringsEqual) {
6667 "expected failure");
6669 "expected failure");
6672TEST(StreamingAssertionsTest, StringsNotEqual) {
6676 "expected failure");
6678 "expected failure");
6681TEST(StreamingAssertionsTest, StringsEqualIgnoringCase) {
6685 "expected failure");
6687 "expected failure");
6690TEST(StreamingAssertionsTest, StringNotEqualIgnoringCase) {
6694 "expected failure");
6696 "expected failure");
6699TEST(StreamingAssertionsTest, FloatingPointEquals) {
6703 "expected failure");
6705 "expected failure");
6708#if GTEST_HAS_EXCEPTIONS
6710TEST(StreamingAssertionsTest, Throw) {
6711 EXPECT_THROW(ThrowAnInteger(),
int) <<
"unexpected failure";
6712 ASSERT_THROW(ThrowAnInteger(),
int) <<
"unexpected failure";
6714 "expected failure",
"expected failure");
6716 "expected failure",
"expected failure");
6719TEST(StreamingAssertionsTest, NoThrow) {
6723 "expected failure",
"expected failure");
6725 "expected failure",
"expected failure");
6728TEST(StreamingAssertionsTest, AnyThrow) {
6732 "expected failure",
"expected failure");
6734 "expected failure",
"expected failure");
6741TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) {
6744 SetEnv(
"TERM",
"xterm");
6748 SetEnv(
"TERM",
"dumb");
6753TEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes) {
6754 SetEnv(
"TERM",
"dumb");
6766TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) {
6769 SetEnv(
"TERM",
"xterm");
6773 SetEnv(
"TERM",
"dumb");
6778TEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid) {
6779 SetEnv(
"TERM",
"xterm");
6791TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {
6794 SetEnv(
"TERM",
"xterm");
6799TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
6805 SetEnv(
"TERM",
"dumb");
6811 SetEnv(
"TERM",
"xterm");
6817 SetEnv(
"TERM",
"dumb");
6820 SetEnv(
"TERM",
"emacs");
6823 SetEnv(
"TERM",
"vt100");
6826 SetEnv(
"TERM",
"xterm-mono");
6829 SetEnv(
"TERM",
"xterm");
6832 SetEnv(
"TERM",
"xterm-color");
6835 SetEnv(
"TERM",
"xterm-256color");
6838 SetEnv(
"TERM",
"screen");
6841 SetEnv(
"TERM",
"screen-256color");
6844 SetEnv(
"TERM",
"tmux");
6847 SetEnv(
"TERM",
"tmux-256color");
6850 SetEnv(
"TERM",
"rxvt-unicode");
6853 SetEnv(
"TERM",
"rxvt-unicode-256color");
6856 SetEnv(
"TERM",
"linux");
6859 SetEnv(
"TERM",
"cygwin");
6872template <
typename T>
6878TEST(StaticAssertTypeEqTest, WorksInClass) {
6886TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {
6891TEST(GetCurrentOsStackTraceExceptTopTest, ReturnsTheStackTrace) {
6899TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) {
6905TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsOnlyFatalFailure) {
6907 const bool has_nonfatal_failure = HasNonfatalFailure();
6908 ClearCurrentTestPartResults();
6912TEST(HasNonfatalFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) {
6914 const bool has_nonfatal_failure = HasNonfatalFailure();
6915 ClearCurrentTestPartResults();
6919TEST(HasNonfatalFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) {
6922 const bool has_nonfatal_failure = HasNonfatalFailure();
6923 ClearCurrentTestPartResults();
6932TEST(HasNonfatalFailureTest, WorksOutsideOfTestBody) {
6936TEST(HasNonfatalFailureTest, WorksOutsideOfTestBody2) {
6939 ClearCurrentTestPartResults();
6943TEST(HasFailureTest, ReturnsFalseWhenThereIsNoFailure) {
6947TEST(HasFailureTest, ReturnsTrueWhenThereIsFatalFailure) {
6949 const bool has_failure = HasFailure();
6950 ClearCurrentTestPartResults();
6954TEST(HasFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) {
6956 const bool has_failure = HasFailure();
6957 ClearCurrentTestPartResults();
6961TEST(HasFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) {
6964 const bool has_failure = HasFailure();
6965 ClearCurrentTestPartResults();
6972TEST(HasFailureTest, WorksOutsideOfTestBody) {
6976TEST(HasFailureTest, WorksOutsideOfTestBody2) {
6979 ClearCurrentTestPartResults();
6998 (*on_start_counter_)++;
7007TEST(TestEventListenersTest, ConstructionWorks) {
7017TEST(TestEventListenersTest, DestructionWorks) {
7018 bool default_result_printer_is_destroyed =
false;
7019 bool default_xml_printer_is_destroyed =
false;
7020 bool extra_listener_is_destroyed =
false;
7022 NULL, &default_result_printer_is_destroyed);
7024 NULL, &default_xml_printer_is_destroyed);
7026 NULL, &extra_listener_is_destroyed);
7031 default_result_printer);
7033 default_xml_printer);
7034 listeners.
Append(extra_listener);
7043TEST(TestEventListenersTest, Append) {
7044 int on_start_counter = 0;
7045 bool is_destroyed =
false;
7049 listeners.
Append(listener);
7087 message <<
id_ <<
"." << method;
7088 return message.GetString();
7097TEST(EventListenerTest, AppendKeepsOrder) {
7098 std::vector<std::string> vec;
7107 EXPECT_STREQ(
"1st.OnTestProgramStart", vec[0].c_str());
7108 EXPECT_STREQ(
"2nd.OnTestProgramStart", vec[1].c_str());
7109 EXPECT_STREQ(
"3rd.OnTestProgramStart", vec[2].c_str());
7123 EXPECT_STREQ(
"1st.OnTestIterationStart", vec[0].c_str());
7124 EXPECT_STREQ(
"2nd.OnTestIterationStart", vec[1].c_str());
7125 EXPECT_STREQ(
"3rd.OnTestIterationStart", vec[2].c_str());
7131 EXPECT_STREQ(
"3rd.OnTestIterationEnd", vec[0].c_str());
7132 EXPECT_STREQ(
"2nd.OnTestIterationEnd", vec[1].c_str());
7133 EXPECT_STREQ(
"1st.OnTestIterationEnd", vec[2].c_str());
7138TEST(TestEventListenersTest, Release) {
7139 int on_start_counter = 0;
7140 bool is_destroyed =
false;
7147 listeners.
Append(listener);
7159TEST(EventListenerTest, SuppressEventForwarding) {
7160 int on_start_counter = 0;
7164 listeners.
Append(listener);
7175TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) {
7179 "expected failure");
7185TEST(EventListenerTest, default_result_printer) {
7186 int on_start_counter = 0;
7187 bool is_destroyed =
false;
7216TEST(EventListenerTest, RemovingDefaultResultPrinterWorks) {
7217 int on_start_counter = 0;
7218 bool is_destroyed =
false;
7244TEST(EventListenerTest, default_xml_generator) {
7245 int on_start_counter = 0;
7246 bool is_destroyed =
false;
7275TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) {
7276 int on_start_counter = 0;
7277 bool is_destroyed =
false;
7310 "An expected failure");
7316 "An expected failure");
7318 "An expected failure");
7323 "An expected failure");
7328 "An expected failure");
7332 "An expected failure");
7334 "An expected failure");
7339 "An expected failure");
7343 "An expected failure");
7345 "An expected failure");
7356TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {
7364TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {
7371TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {
7384TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) {
7390TEST(RemoveReferenceTest, RemovesReference) {
7397template <
typename T1,
typename T2>
7402TEST(RemoveReferenceTest, MacroVersion) {
7409TEST(RemoveConstTest, DoesNotAffectNonConstType) {
7415TEST(RemoveConstTest, RemovesConst) {
7423template <
typename T1,
typename T2>
7428TEST(RemoveConstTest, MacroVersion) {
7436template <
typename T1,
typename T2>
7441TEST(RemoveReferenceToConstTest, Works) {
7450TEST(AddReferenceTest, DoesNotAffectReferenceType) {
7456TEST(AddReferenceTest, AddsReference) {
7463template <
typename T1,
typename T2>
7468TEST(AddReferenceTest, MacroVersion) {
7475template <
typename T1,
typename T2>
7480TEST(GTestReferenceToConstTest, Works) {
7488TEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) {
7496TEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) {
7509TEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) {
7521TEST(IsContainerTestTest, WorksForNonContainer) {
7527TEST(IsContainerTestTest, WorksForContainer) {
7536TEST(ArrayEqTest, WorksForDegeneratedArrays) {
7541TEST(ArrayEqTest, WorksForOneDimensionalArrays) {
7543 const int a[] = { 0, 1 };
7544 long b[] = { 0, 1 };
7553TEST(ArrayEqTest, WorksForTwoDimensionalArrays) {
7554 const char a[][3] = {
"hi",
"lo" };
7555 const char b[][3] = {
"hi",
"lo" };
7556 const char c[][3] = {
"hi",
"li" };
7567TEST(ArrayAwareFindTest, WorksForOneDimensionalArray) {
7568 const char a[] =
"hello";
7573TEST(ArrayAwareFindTest, WorksForTwoDimensionalArray) {
7574 int a[][2] = { { 0, 1 }, { 2, 3 }, { 4, 5 } };
7575 const int b[2] = { 2, 3 };
7578 const int c[2] = { 6, 7 };
7584TEST(CopyArrayTest, WorksForDegeneratedArrays) {
7590TEST(CopyArrayTest, WorksForOneDimensionalArrays) {
7591 const char a[3] =
"hi";
7603TEST(CopyArrayTest, WorksForTwoDimensionalArrays) {
7604 const int a[2][3] = { { 0, 1, 2 }, { 3, 4, 5 } };
7618TEST(NativeArrayTest, ConstructorFromArrayWorks) {
7619 const int a[3] = { 0, 1, 2 };
7625TEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) {
7626 typedef int Array[2];
7627 Array*
a =
new Array[1];
7640TEST(NativeArrayTest, TypeMembersAreCorrect) {
7648TEST(NativeArrayTest, MethodsWork) {
7649 const int a[3] = { 0, 1, 2 };
7668 const int b1[3] = { 0, 1, 1 };
7669 const int b2[4] = { 0, 1, 2, 3 };
7674TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
7675 const char a[2][3] = {
"hi",
"lo" };
7683TEST(SkipPrefixTest, SkipsWhenPrefixMatches) {
7684 const char*
const str =
"hello";
7686 const char* p =
str;
7695TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
7696 const char*
const str =
"world";
7698 const char* p =
str;
#define s(x, c)
Definition aesb.c:47
#define v1(p)
Definition aesb.c:117
#define v2(p)
Definition aesb.c:118
cryptonote::block b
Definition block.cpp:40
Base(int an_x)
Definition gtest_unittest.cc:5157
int x_
Definition gtest_unittest.cc:5160
int x() const
Definition gtest_unittest.cc:5158
Definition gtest_unittest.cc:7352
Definition gtest_unittest.cc:7353
static const bool value
Definition gtest-internal.h:891
const Element * const_iterator
Definition gtest-internal.h:1039
Definition gtest_unittest.cc:7519
Definition gtest_unittest.cc:6597
virtual void SetUp()
Definition gtest_unittest.cc:6599
virtual void TearDown()
Definition gtest_unittest.cc:6602
Definition gtest_unittest.cc:7060
virtual void OnTestProgramStart(const UnitTest &)
Definition gtest_unittest.cc:7066
virtual void OnTestIterationStart(const UnitTest &, int)
Definition gtest_unittest.cc:7074
GTEST_DISALLOW_COPY_AND_ASSIGN_(SequenceTestingListener)
virtual void OnTestIterationEnd(const UnitTest &, int)
Definition gtest_unittest.cc:7079
std::vector< std::string > * vector_
Definition gtest_unittest.cc:7091
virtual void OnTestProgramEnd(const UnitTest &)
Definition gtest_unittest.cc:7070
SequenceTestingListener(std::vector< std::string > *vector, const char *id)
Definition gtest_unittest.cc:7062
std::string GetEventDescription(const char *method)
Definition gtest_unittest.cc:7085
const char *const id_
Definition gtest_unittest.cc:7092
Definition gtest_unittest.cc:6873
StaticAssertTypeEqTestHelper()
Definition gtest_unittest.cc:6875
virtual void OnTestIterationEnd(const UnitTest &unit_test, int iteration)=0
virtual void OnTestProgramStart(const UnitTest &unit_test)=0
virtual void OnTestIterationStart(const UnitTest &unit_test, int iteration)=0
virtual void OnTestProgramEnd(const UnitTest &unit_test)=0
static bool EventForwardingEnabled(const TestEventListeners &listeners)
Definition gtest_unittest.cc:175
static TestEventListener * GetRepeater(TestEventListeners *listeners)
Definition gtest_unittest.cc:162
static void SetDefaultXmlGenerator(TestEventListeners *listeners, TestEventListener *listener)
Definition gtest_unittest.cc:170
static void SuppressEventForwarding(TestEventListeners *listeners)
Definition gtest_unittest.cc:179
static void SetDefaultResultPrinter(TestEventListeners *listeners, TestEventListener *listener)
Definition gtest_unittest.cc:166
Definition gtest_unittest.cc:6983
virtual void OnTestProgramStart(const UnitTest &)
Definition gtest_unittest.cc:6996
bool * is_destroyed_
Definition gtest_unittest.cc:7003
TestListener(int *on_start_counter, bool *is_destroyed)
Definition gtest_unittest.cc:6986
int * on_start_counter_
Definition gtest_unittest.cc:7002
TestListener()
Definition gtest_unittest.cc:6985
virtual ~TestListener()
Definition gtest_unittest.cc:6990
@ kSuccess
Definition gtest-test-part.h:52
@ kFatalFailure
Definition gtest-test-part.h:54
static void ClearTestPartResults(TestResult *test_result)
Definition gtest-internal-inl.h:1022
static const std::vector< testing::TestPartResult > & test_part_results(const TestResult &test_result)
Definition gtest-internal-inl.h:1026
static void RecordProperty(const std::string &key, const std::string &value)
Definition gtest.cc:2237
Definition gtest_unittest.cc:302
static UnitTest * GetInstance()
Definition gtest.cc:3972
Definition gtest_unittest.cc:6577
Definition gtest_unittest.cc:6572
Definition gtest_unittest.cc:6568
Definition gtest_unittest.cc:5207
MyTypeInNameSpace1(int an_x)
Definition gtest_unittest.cc:5209
Definition gtest_unittest.cc:5232
MyTypeInNameSpace2(int an_x)
Definition gtest_unittest.cc:5234
const char * message() const
Definition gtest.h:297
Definition gtest_unittest.cc:5348
Definition gtest_unittest.cc:5355
Definition gtest_unittest.cc:5375
Definition gtest_unittest.cc:5365
Definition gtest_unittest.cc:6509
static void SetUpTestCase()
Definition gtest_unittest.cc:6513
static void TearDownTestCase()
Definition gtest_unittest.cc:6523
Definition gtest_unittest.cc:5605
virtual void SetUp()
Definition gtest_unittest.cc:5608
static void CheckFlags(const Flags &expected)
Definition gtest_unittest.cc:5637
static void TestParsingFlags(int argc1, const CharType **argv1, int argc2, const CharType **argv2, const Flags &expected, bool should_print_help)
Definition gtest_unittest.cc:5660
static void AssertStringArrayEq(size_t size1, CharType **array1, size_t size2, CharType **array2)
Definition gtest_unittest.cc:5627
Definition gtest-message.h:85
std::string GetString() const
Definition gtest.cc:981
Definition gtest-spi.h:52
@ INTERCEPT_ALL_THREADS
Definition gtest-spi.h:57
@ INTERCEPT_ONLY_CURRENT_THREAD
Definition gtest-spi.h:56
Definition gtest_unittest.cc:5392
virtual void SetUp()
Definition gtest_unittest.cc:5427
static void SetUpTestCase()
Definition gtest_unittest.cc:5396
static int counter_
Definition gtest_unittest.cc:5434
static const char * shared_resource_
Definition gtest_unittest.cc:5437
static void TearDownTestCase()
Definition gtest_unittest.cc:5413
const TestInfo * GetTestInfo(int i) const
Definition gtest.cc:2739
const TestResult & ad_hoc_test_result() const
Definition gtest.h:849
int total_test_count() const
Definition gtest.cc:2707
TestEventListener * Release(TestEventListener *listener)
Definition gtest.cc:3909
void Append(TestEventListener *listener)
Definition gtest.cc:3902
void SetDefaultXmlGenerator(TestEventListener *listener)
Definition gtest.cc:3942
void SuppressEventForwarding()
Definition gtest.cc:3959
TestEventListener * default_result_printer() const
Definition gtest.h:1084
bool EventForwardingEnabled() const
Definition gtest.cc:3955
TestEventListener * repeater()
Definition gtest.cc:3919
TestEventListener * default_xml_generator() const
Definition gtest.h:1095
void SetDefaultResultPrinter(TestEventListener *listener)
Definition gtest.cc:3926
Definition gtest_unittest.cc:5298
static const TestResult * GetTestResult(const TestInfo *test_info)
Definition gtest_unittest.cc:5312
static const TestInfo * GetTestInfo(const char *test_name)
Definition gtest_unittest.cc:5300
const char * name() const
Definition gtest.h:654
const TestResult * result() const
Definition gtest.h:705
const char * test_case_name() const
Definition gtest.h:651
Definition gtest-test-part.h:126
int size() const
Definition gtest-test-part.cc:83
const TestPartResult & GetTestPartResult(int index) const
Definition gtest-test-part.cc:73
Definition gtest-test-part.h:47
const char * message() const
Definition gtest-test-part.h:88
const char * summary() const
Definition gtest-test-part.h:85
const char * file_name() const
Definition gtest-test-part.h:76
bool nonfatally_failed() const
Definition gtest-test-part.h:97
@ kFatalFailure
Definition gtest-test-part.h:54
@ kNonFatalFailure
Definition gtest-test-part.h:53
bool fatally_failed() const
Definition gtest-test-part.h:100
bool failed() const
Definition gtest-test-part.h:94
Type type() const
Definition gtest-test-part.h:72
bool passed() const
Definition gtest-test-part.h:91
int line_number() const
Definition gtest-test-part.h:82
const char * value() const
Definition gtest.h:501
const char * key() const
Definition gtest.h:496
int total_part_count() const
Definition gtest.cc:2200
const TestProperty & GetTestProperty(int i) const
Definition gtest.cc:2038
const TestPartResult & GetTestPartResult(int i) const
Definition gtest.cc:2029
bool Passed() const
Definition gtest.h:539
bool Failed() const
Definition gtest.cc:2170
int test_property_count() const
Definition gtest.cc:2205
virtual void TearDown()
Definition gtest.cc:2233
static bool HasNonfatalFailure()
Definition gtest.cc:2492
virtual void SetUp()
Definition gtest.cc:2227
Test()
Definition gtest.cc:2214
static bool HasFailure()
Definition gtest.h:407
static void RecordProperty(const std::string &key, const std::string &value)
Definition gtest.cc:2237
friend class TestInfo
Definition gtest.h:373
const TestInfo * current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_)
Definition gtest.cc:4279
static UnitTest * GetInstance()
Definition gtest.cc:3972
const TestCase * current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_)
Definition gtest.cc:4271
Definition gtest-filepath.h:59
Definition gtest-internal.h:262
Definition gtest-internal-inl.h:162
Definition gtest-internal.h:855
Definition gtest-internal.h:1034
const_iterator begin() const
Definition gtest-internal.h:1063
const_iterator end() const
Definition gtest-internal.h:1064
size_t size() const
Definition gtest-internal.h:1062
static const UInt32 kMaxRange
Definition gtest-internal.h:754
Definition gtest-string.h:58
static bool CaseInsensitiveWideCStringEquals(const wchar_t *lhs, const wchar_t *rhs)
Definition gtest.cc:1925
static bool EndsWithCaseInsensitive(const std::string &str, const std::string &suffix)
Definition gtest.cc:1949
static std::string ShowWideCString(const wchar_t *wide_c_str)
Definition gtest.cc:1848
Definition gtest_unittest.cc:160
static bool EventForwardingEnabled(const TestEventListeners &listeners)
Definition gtest_unittest.cc:175
static TestEventListener * GetRepeater(TestEventListeners *listeners)
Definition gtest_unittest.cc:162
static void SetDefaultXmlGenerator(TestEventListeners *listeners, TestEventListener *listener)
Definition gtest_unittest.cc:170
static void SuppressEventForwarding(TestEventListeners *listeners)
Definition gtest_unittest.cc:179
static void SetDefaultResultPrinter(TestEventListeners *listeners, TestEventListener *listener)
Definition gtest_unittest.cc:166
Definition gtest-internal-inl.h:1014
static void RecordProperty(TestResult *test_result, const std::string &xml_element, const TestProperty &property)
Definition gtest-internal-inl.h:1016
UnitTest unit_test_
Definition gtest_unittest.cc:193
void UnitTestRecordProperty(const char *key, const std::string &value)
Definition gtest_unittest.cc:189
UnitTestRecordPropertyTestHelper()
Definition gtest_unittest.cc:186
const uint8_t seed[32]
Definition code-generator.cpp:37
bool operator!=(expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
Definition expect.h:423
bool operator==(expect< T > const &lhs, expect< U > const &rhs) noexcept(noexcept(lhs.equal(rhs)))
Definition expect.h:402
GenericPointer< Value, CrtAllocator > Pointer
Definition fwd.h:128
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)
Definition gtest-death-test.h:286
#define EXPECT_FATAL_FAILURE(statement, substr)
Definition gtest-spi.h:138
#define EXPECT_NONFATAL_FAILURE(statement, substr)
Definition gtest-spi.h:204
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr)
Definition gtest-spi.h:218
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr)
Definition gtest-spi.h:155
#define EXPECT_NO_FATAL_FAILURE(statement)
Definition gtest.h:2101
#define EXPECT_STRCASENE(s1, s2)
Definition gtest.h:2001
#define GTEST_ASSERT_GT(val1, val2)
Definition gtest.h:1949
#define TEST_F(test_fixture, test_name)
Definition gtest.h:2216
#define ASSERT_GT(val1, val2)
Definition gtest.h:1976
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
#define GTEST_SUCCEED()
Definition gtest.h:1826
#define EXPECT_NO_THROW(statement)
Definition gtest.h:1845
#define ASSERT_STRNE(s1, s2)
Definition gtest.h:2006
#define FAIL()
Definition gtest.h:1822
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1922
#define ADD_FAILURE_AT(file, line)
Definition gtest.h:1812
#define ASSERT_FLOAT_EQ(val1, val2)
Definition gtest.h:2035
#define ASSERT_NO_FATAL_FAILURE(statement)
Definition gtest.h:2099
#define GTEST_ASSERT_GE(val1, val2)
Definition gtest.h:1947
#define ASSERT_STRCASEEQ(s1, s2)
Definition gtest.h:2008
#define GTEST_ASSERT_LT(val1, val2)
Definition gtest.h:1945
#define GTEST_FAIL()
Definition gtest.h:1817
#define ASSERT_DOUBLE_EQ(val1, val2)
Definition gtest.h:2039
#define EXPECT_NE(val1, val2)
Definition gtest.h:1926
#define GTEST_ASSERT_NE(val1, val2)
Definition gtest.h:1941
#define GTEST_TEST(test_case_name, test_name)
Definition gtest.h:2180
#define ASSERT_NEAR(val1, val2, abs_error)
Definition gtest.h:2047
#define EXPECT_STRCASEEQ(s1, s2)
Definition gtest.h:1999
#define ASSERT_STREQ(s1, s2)
Definition gtest.h:2004
#define SUCCEED()
Definition gtest.h:1831
#define ASSERT_LE(val1, val2)
Definition gtest.h:1964
#define EXPECT_THROW(statement, expected_exception)
Definition gtest.h:1843
#define ASSERT_FALSE(condition)
Definition gtest.h:1868
#define EXPECT_NEAR(val1, val2, abs_error)
Definition gtest.h:2043
#define ASSERT_NO_THROW(statement)
Definition gtest.h:1851
#define GTEST_ASSERT_EQ(val1, val2)
Definition gtest.h:1937
#define EXPECT_FLOAT_EQ(val1, val2)
Definition gtest.h:2027
#define EXPECT_ANY_THROW(statement)
Definition gtest.h:1847
#define ASSERT_NE(val1, val2)
Definition gtest.h:1960
#define EXPECT_GT(val1, val2)
Definition gtest.h:1934
#define EXPECT_DOUBLE_EQ(val1, val2)
Definition gtest.h:2031
#define EXPECT_GE(val1, val2)
Definition gtest.h:1932
#define GTEST_ASSERT_LE(val1, val2)
Definition gtest.h:1943
#define EXPECT_TRUE(condition)
Definition gtest.h:1859
#define ASSERT_STRCASENE(s1, s2)
Definition gtest.h:2010
#define EXPECT_STREQ(s1, s2)
Definition gtest.h:1995
#define TEST(test_case_name, test_name)
Definition gtest.h:2187
#define ADD_FAILURE()
Definition gtest.h:1808
#define EXPECT_LE(val1, val2)
Definition gtest.h:1928
#define ASSERT_TRUE(condition)
Definition gtest.h:1865
#define EXPECT_FALSE(condition)
Definition gtest.h:1862
#define ASSERT_THROW(statement, expected_exception)
Definition gtest.h:1849
#define EXPECT_STRNE(s1, s2)
Definition gtest.h:1997
#define EXPECT_LT(val1, val2)
Definition gtest.h:1930
#define ASSERT_GE(val1, val2)
Definition gtest.h:1972
#define ASSERT_ANY_THROW(statement)
Definition gtest.h:1853
#define ASSERT_LT(val1, val2)
Definition gtest.h:1968
#define EXPECT_PRED_FORMAT1(pred_format, v1)
Definition gtest_pred_impl.h:113
#define EXPECT_PRED3(pred, v1, v2, v3)
Definition gtest_pred_impl.h:218
#define EXPECT_PRED2(pred, v1, v2)
Definition gtest_pred_impl.h:163
#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4)
Definition gtest_pred_impl.h:282
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4)
Definition gtest_pred_impl.h:278
#define ASSERT_PRED_FORMAT1(pred_format, v1)
Definition gtest_pred_impl.h:117
#define ASSERT_PRED2(pred, v1, v2)
Definition gtest_pred_impl.h:167
#define EXPECT_PRED1(pred, v1)
Definition gtest_pred_impl.h:115
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5)
Definition gtest_pred_impl.h:347
#define ASSERT_PRED1(pred, v1)
Definition gtest_pred_impl.h:119
#define ASSERT_PRED3(pred, v1, v2, v3)
Definition gtest_pred_impl.h:222
#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5)
Definition gtest_pred_impl.h:351
#define ASSERT_PRED_FORMAT2(pred_format, v1, v2)
Definition gtest_pred_impl.h:165
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)
Definition gtest_pred_impl.h:161
#define FRIEND_TEST(test_case_name, test_name)
Definition gtest_prod.h:55
#define GTEST_IS_NULL_LITERAL_(x)
Definition gtest-internal.h:132
#define GTEST_ATTRIBUTE_UNUSED_
Definition gtest-port.h:864
#define GTEST_FLAG_PREFIX_
Definition gtest-port.h:286
#define GTEST_FLAG_PREFIX_UPPER_
Definition gtest-port.h:288
#define GTEST_FLAG(name)
Definition gtest-port.h:2504
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
Definition gtest-port.h:317
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition gtest-port.h:318
#define GTEST_CHECK_(condition)
Definition gtest-port.h:1295
#define GTEST_COMPILE_ASSERT_(expr, msg)
Definition gtest-port.h:1032
Environment * AddGlobalTestEnvironment(Environment *env)
Definition gtest.h:1350
AnonymousEnum
Definition gtest-printers_test.cc:68
REGISTER_TYPED_TEST_CASE_P(TypeParamTest, TestA, TestB)
TYPED_TEST(TypedTest, TestA)
Definition gtest_list_tests_unittest_.cc:129
TYPED_TEST_CASE(TypedTest, MyTypes)
TYPED_TEST_CASE_P(TypeParamTest)
TYPED_TEST_P(TypeParamTest, TestA)
Definition gtest_list_tests_unittest_.cc:143
INSTANTIATE_TYPED_TEST_CASE_P(My, TypeParamTest, MyTypes)
void TestEq1(int x)
Definition gtest_output_test_.cc:65
void TestGTestReferenceToConst()
Definition gtest_unittest.cc:7476
GTEST_API_ std::string WideStringToUtf8(const wchar_t *str, int num_chars)
Definition gtest.cc:1823
GTEST_API_ AssertionResult EqFailure(const char *expected_expression, const char *actual_expression, const std::string &expected_value, const std::string &actual_value, bool ignoring_case)
Definition gtest.cc:1312
GTEST_API_ std::string CodePointToUtf8(UInt32 code_point)
Definition gtest.cc:1759
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help)
Definition gtest_unittest.cc:5705
void ShuffleRange(internal::Random *random, int begin, int end, std::vector< E > *v)
Definition gtest-internal-inl.h:312
GTEST_API_ bool ShouldShard(const char *total_shards_str, const char *shard_index_str, bool in_subprocess_for_death_test)
Definition gtest.cc:4715
int CountIf(const Container &c, Predicate predicate)
Definition gtest-internal-inl.h:283
GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition gtest.cc:1618
GTEST_API_ bool SkipPrefix(const char *prefix, const char **pstr)
Definition gtest.cc:5001
GTEST_API_ std::vector< EditType > CalculateOptimalEdits(const std::vector< size_t > &left, const std::vector< size_t > &right)
Definition gtest.cc:1028
GTEST_API_ AssertionResult FloatLE(const char *expr1, const char *expr2, float val1, float val2)
Definition gtest.cc:1421
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition gtest.cc:1606
static void FailFatally()
Definition gtest_unittest.cc:6903
const int kMaxRandomSeed
Definition gtest-internal-inl.h:106
GTEST_API_ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id)
Definition gtest.cc:4778
bool AlwaysFalse()
Definition gtest-internal.h:736
void ForEach(const Container &c, Functor functor)
Definition gtest-internal-inl.h:296
GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms)
Definition gtest.cc:3574
bool StaticAssertTypeEq()
Definition gtest.h:2150
TypeId GetTypeId()
Definition gtest-internal.h:447
int GetNextRandomSeed(int seed)
Definition gtest-internal-inl.h:152
E GetElementOr(const std::vector< E > &v, int i, E default_value)
Definition gtest-internal-inl.h:303
GTEST_API_ AssertionResult AssertionFailure()
Definition gtest.cc:1015
#define VERIFY_CODE_LOCATION
Definition gtest_unittest.cc:5337
int IntAlias
Definition gtest_unittest.cc:6884
GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms)
Definition gtest.cc:3550
void Shuffle(internal::Random *random, std::vector< E > *v)
Definition gtest-internal-inl.h:333
GTEST_API_ bool AlwaysTrue()
Definition gtest.cc:4988
void TestGTestRemoveConst()
Definition gtest_unittest.cc:7424
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
Definition gtest-internal.h:983
class UnitTestImpl * GetUnitTestImpl()
Definition gtest-internal-inl.h:927
void TestGTestAddReference()
Definition gtest_unittest.cc:7464
GTEST_API_ Int32 Int32FromEnvOrDie(const char *env_var, Int32 default_val)
Definition gtest.cc:4760
std::string StreamableToString(const T &streamable)
Definition gtest-message.h:243
::std::ostream & operator<<(::std::ostream &os, const TestingVector &vector)
Definition gtest_unittest.cc:305
GTEST_API_ AssertionResult AssertionSuccess()
Definition gtest.cc:1010
GTEST_API_ bool ShouldUseColor(bool stdout_is_tty)
Definition gtest.cc:2916
GTEST_API_ std::string CreateUnifiedDiff(const std::vector< std::string > &left, const std::vector< std::string > &right, size_t context=2)
Definition gtest.cc:1203
static bool HasNonfatalFailureHelper()
Definition gtest_unittest.cc:6928
GTEST_API_ const TypeId kTestTypeIdInGoogleTest
Definition gtest.cc:626
IsContainer IsContainerTest(int, typename C::iterator *=NULL, typename C::const_iterator *=NULL)
Definition gtest-internal.h:932
GTEST_API_ TypeId GetTestTypeId()
Definition gtest.cc:620
#define GTEST_USE_UNPROTECTED_COMMA_
Definition gtest_unittest.cc:1238
static bool HasFailureHelper()
Definition gtest_unittest.cc:6970
void TestGTestRemoveReference()
Definition gtest_unittest.cc:7398
GTEST_API_ AssertionResult DoubleLE(const char *expr1, const char *expr2, double val1, double val2)
Definition gtest.cc:1428
GTEST_API_ bool ParseInt32Flag(const char *str, const char *flag, Int32 *value)
Definition gtest.cc:5070
GTEST_API_ std::string AppendUserMessage(const std::string >est_msg, const Message &user_msg)
Definition gtest.cc:2001
const int kMaxStackTraceDepth
Definition gtest.h:147
GTEST_API_ TimeInMillis GetTimeInMillis()
Definition gtest.cc:806
int GetRandomSeedFromFlag(Int32 random_seed_flag)
Definition gtest-internal-inl.h:136
GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(UnitTest *unit_test, int skip_count)
Definition gtest.cc:4973
bool ArrayEq(const T *lhs, size_t size, const U *rhs)
Definition gtest-internal.h:972
void TestGTestRemoveReferenceAndConst()
Definition gtest_unittest.cc:7437
void CopyArray(const T *from, size_t size, U *to)
Definition gtest-internal.h:1012
const char * key
Definition hmac_keccak.cpp:40
static std::string utf16(const unsigned char *data, uint32_t len)
Definition i18n.cpp:92
static void Verify(void(*f)(T, char *), char *(*g)(T, char *))
Definition itoatest.cpp:70
#define L(m0, m1, m2, m3, m4, m5, m6, m7)
Definition jh.c:116
static int flags
Definition mdb_load.c:31
line
Definition check.py:23
int bool
Definition hash.h:36
bool operator<=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:117
bool operator>=(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:121
bool operator>(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:119
bool operator<(const ipv4_network_address &lhs, const ipv4_network_address &rhs) noexcept
Definition net_utils_base.h:115
Definition gtest-printers_test.cc:126
TestCase
Definition gmock_test_utils.py:101
Definition document.h:406
mdb_size_t count(MDB_cursor *cur)
Definition value_stream.cpp:40
@ out
Definition message_store.h:75
Definition gtest_unittest.cc:6563
Definition gtest_unittest.cc:5206
std::ostream & operator<<(std::ostream &os, const MyTypeInNameSpace1 &val)
Definition gtest_unittest.cc:5211
Definition gtest_unittest.cc:5231
c
Definition pymoduletest.py:79
int i
Definition pymoduletest.py:23
e
Definition pymoduletest.py:79
int
Definition pymoduletest.py:17
p
Definition pymoduletest.py:75
FloatingPointTest< float > FloatTest
Definition gmock-matchers_test.cc:2896
const int foo
Definition gmock-matchers_test.cc:2448
Matcher< int > GreaterThan(int n)
Definition gmock-matchers_test.cc:188
int IsPositive(double x)
Definition gmock-matchers_test.cc:2431
FloatingPointTest< double > DoubleTest
Definition gmock-matchers_test.cc:3011
GTEST_API_ std::vector< EditType > CalculateOptimalEdits(const std::vector< size_t > &left, const std::vector< size_t > &right)
Definition gtest.cc:1028
GTEST_API_ std::string CreateUnifiedDiff(const std::vector< std::string > &left, const std::vector< std::string > &right, size_t context=2)
Definition gtest.cc:1203
EditType
Definition gtest-internal.h:180
int RmDir(const char *dir)
Definition gtest-port.h:2347
FILE * FOpen(const char *path, const char *mode)
Definition gtest-port.h:2367
GTEST_API_ std::string WideStringToUtf8(const wchar_t *str, int num_chars)
Definition gtest.cc:1823
GTEST_API_ AssertionResult EqFailure(const char *expected_expression, const char *actual_expression, const std::string &expected_value, const std::string &actual_value, bool ignoring_case)
Definition gtest.cc:1312
GTEST_API_ std::string CodePointToUtf8(UInt32 code_point)
Definition gtest.cc:1759
void ShuffleRange(internal::Random *random, int begin, int end, std::vector< E > *v)
Definition gtest-internal-inl.h:312
GTEST_API_ Int32 Int32FromGTestEnv(const char *flag, Int32 default_val)
Definition gtest-port.cc:1204
GTEST_API_ bool ShouldShard(const char *total_shards_str, const char *shard_index_str, bool in_subprocess_for_death_test)
Definition gtest.cc:4715
int CountIf(const Container &c, Predicate predicate)
Definition gtest-internal-inl.h:283
GTEST_API_ bool SkipPrefix(const char *prefix, const char **pstr)
Definition gtest.cc:5001
const int kMaxRandomSeed
Definition gtest-internal-inl.h:106
TypeWithSize< 4 >::UInt UInt32
Definition gtest-port.h:2495
GTEST_API_ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id)
Definition gtest.cc:4778
GTEST_API_ void ParseGoogleTestFlagsOnly(int *argc, char **argv)
Definition gtest.cc:5332
bool AlwaysFalse()
Definition gtest-internal.h:736
void ForEach(const Container &c, Functor functor)
Definition gtest-internal-inl.h:296
GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms)
Definition gtest.cc:3574
TypeId GetTypeId()
Definition gtest-internal.h:447
int GetNextRandomSeed(int seed)
Definition gtest-internal-inl.h:152
E GetElementOr(const std::vector< E > &v, int i, E default_value)
Definition gtest-internal-inl.h:303
GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms)
Definition gtest.cc:3550
void Shuffle(internal::Random *random, std::vector< E > *v)
Definition gtest-internal-inl.h:333
GTEST_API_ bool AlwaysTrue()
Definition gtest.cc:4988
GTEST_API_ bool g_help_flag
Definition gtest.cc:188
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)
Definition gtest-internal.h:983
class UnitTestImpl * GetUnitTestImpl()
Definition gtest-internal-inl.h:927
const bool ImplicitlyConvertible< From, To >::value
Definition gtest-internal.h:897
GTEST_API_ Int32 Int32FromEnvOrDie(const char *env_var, Int32 default_val)
Definition gtest.cc:4760
std::string StreamableToString(const T &streamable)
Definition gtest-message.h:243
char IsNotContainer
Definition gtest-internal.h:938
GTEST_API_ bool ShouldUseColor(bool stdout_is_tty)
Definition gtest.cc:2916
GTEST_API_ const TypeId kTestTypeIdInGoogleTest
Definition gtest.cc:626
IsContainer IsContainerTest(int, typename C::iterator *=NULL, typename C::const_iterator *=NULL)
Definition gtest-internal.h:932
GTEST_API_ TypeId GetTestTypeId()
Definition gtest.cc:620
int IsContainer
Definition gtest-internal.h:930
const BiggestInt kMaxBiggestInt
Definition gtest-port.h:2439
GTEST_API_ bool ParseInt32Flag(const char *str, const char *flag, Int32 *value)
Definition gtest.cc:5070
GTEST_API_ std::string AppendUserMessage(const std::string >est_msg, const Message &user_msg)
Definition gtest.cc:2001
GTEST_API_ TimeInMillis GetTimeInMillis()
Definition gtest.cc:806
int GetRandomSeedFromFlag(Int32 random_seed_flag)
Definition gtest-internal-inl.h:136
GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(UnitTest *unit_test, int skip_count)
Definition gtest.cc:4973
bool ArrayEq(const T *lhs, size_t size, const U *rhs)
Definition gtest-internal.h:972
TypeWithSize< 4 >::Int Int32
Definition gtest-port.h:2494
void CopyArray(const T *from, size_t size, U *to)
Definition gtest-internal.h:1012
Definition gmock-actions.h:53
INSTANTIATE_TYPED_TEST_CASE_P(My, CodeLocationForTYPEDTESTP, int)
GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition gtest.cc:1618
GTEST_API_ AssertionResult FloatLE(const char *expr1, const char *expr2, float val1, float val2)
Definition gtest.cc:1421
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition gtest.cc:1606
TYPED_TEST_P(CodeLocationForTYPEDTESTP, Verify)
Definition gtest_unittest.cc:5380
TYPED_TEST(CodeLocationForTYPEDTEST, Verify)
Definition gtest_unittest.cc:5370
TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP)
INSTANTIATE_TEST_CASE_P(, CodeLocationForTESTP, Values(0))
bool StaticAssertTypeEq()
Definition gtest.h:2150
GTEST_API_ AssertionResult AssertionFailure()
Definition gtest.cc:1015
internal::TimeInMillis TimeInMillis
Definition gtest.h:480
class UnitTestImpl * GetUnitTestImpl()
Definition gtest-internal-inl.h:927
REGISTER_TYPED_TEST_CASE_P(CodeLocationForTYPEDTESTP, Verify)
GTEST_API_ AssertionResult AssertionSuccess()
Definition gtest.cc:1010
GTEST_API_ AssertionResult DoubleLE(const char *expr1, const char *expr2, double val1, double val2)
Definition gtest.cc:1428
const int kMaxStackTraceDepth
Definition gtest.h:147
TYPED_TEST_CASE(CodeLocationForTYPEDTEST, int)
TEST_P(CodeLocationForTESTP, Verify)
Definition gtest_unittest.cc:5358
Definition unit_tests_utils.h:37
const char * name
Definition options.c:30
enum upnpconfigoptions id
Definition options.c:29
const GenericPointer< typename T::ValueType > T2 value
Definition pointer.h:1225
const GenericPointer< typename T::ValueType > & pointer
Definition pointer.h:1124
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
const char *const str
Definition portlistingparse.c:23
tools::wallet2::message_signature_result_t result
Definition signature.cpp:62
if(!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
Definition signature.cpp:53
Definition gtest_pred_impl_unittest.cc:56
Definition gtest_unittest.cc:5144
Definition fwdtest.cpp:28
Foo()
Definition fwdtest.cpp:106
Definition gtest_unittest.cc:5456
bool catch_exceptions
Definition gtest_unittest.cc:5590
static Flags StackTraceDepth(Int32 stack_trace_depth)
Definition gtest_unittest.cc:5565
static Flags Repeat(Int32 repeat)
Definition gtest_unittest.cc:5549
static Flags Shuffle(bool shuffle)
Definition gtest_unittest.cc:5557
Int32 stack_trace_depth
Definition gtest_unittest.cc:5599
static Flags CatchExceptions(bool catch_exceptions)
Definition gtest_unittest.cc:5493
bool list_tests
Definition gtest_unittest.cc:5593
Flags()
Definition gtest_unittest.cc:5458
static Flags DeathTestUseFork(bool death_test_use_fork)
Definition gtest_unittest.cc:5501
Int32 random_seed
Definition gtest_unittest.cc:5596
static Flags Output(const char *output)
Definition gtest_unittest.cc:5525
bool shuffle
Definition gtest_unittest.cc:5598
Int32 repeat
Definition gtest_unittest.cc:5597
static Flags BreakOnFailure(bool break_on_failure)
Definition gtest_unittest.cc:5485
static Flags RandomSeed(Int32 random_seed)
Definition gtest_unittest.cc:5541
bool death_test_use_fork
Definition gtest_unittest.cc:5591
static Flags ListTests(bool list_tests)
Definition gtest_unittest.cc:5517
bool print_time
Definition gtest_unittest.cc:5595
static Flags AlsoRunDisabledTests(bool also_run_disabled_tests)
Definition gtest_unittest.cc:5477
const char * output
Definition gtest_unittest.cc:5594
bool also_run_disabled_tests
Definition gtest_unittest.cc:5588
static Flags StreamResultTo(const char *stream_result_to)
Definition gtest_unittest.cc:5573
const char * filter
Definition gtest_unittest.cc:5592
const char * stream_result_to
Definition gtest_unittest.cc:5600
bool throw_on_failure
Definition gtest_unittest.cc:5601
bool break_on_failure
Definition gtest_unittest.cc:5589
static Flags ThrowOnFailure(bool throw_on_failure)
Definition gtest_unittest.cc:5581
static Flags PrintTime(bool print_time)
Definition gtest_unittest.cc:5533
static Flags Filter(const char *filter)
Definition gtest_unittest.cc:5509
Definition gtest-internal.h:830
Definition gtest-internal.h:772
Definition gtest-internal.h:906
Definition gtest-internal.h:1023
Definition gtest-internal.h:1022
Definition gtest-internal.h:795
Definition gtest-internal.h:782
static const bool value
Definition gtest-port.h:2205
const char * str1
Definition testupnpdescgen.c:131
const char * str2
Definition testupnpdescgen.c:132
uint64_t random(const uint64_t max_value)
Definition transactions_flow_test.cpp:53