Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
9e712372
Unverified
Commit
9e712372
authored
Mar 18, 2022
by
Brad Messer
Committed by
GitHub
Mar 18, 2022
Browse files
Merge branch 'main' into promote-inclusive-behavior
parents
794da715
b007c54f
Changes
135
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1030 additions
and
1481 deletions
+1030
-1481
googletest/test/googletest-param-test-test.cc
googletest/test/googletest-param-test-test.cc
+60
-69
googletest/test/googletest-param-test-test.h
googletest/test/googletest-param-test-test.h
+2
-4
googletest/test/googletest-param-test2-test.cc
googletest/test/googletest-param-test2-test.cc
+3
-6
googletest/test/googletest-port-test.cc
googletest/test/googletest-port-test.cc
+46
-50
googletest/test/googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+168
-203
googletest/test/googletest-setuptestsuite-test_.cc
googletest/test/googletest-setuptestsuite-test_.cc
+2
-7
googletest/test/googletest-shuffle-test_.cc
googletest/test/googletest-shuffle-test_.cc
+1
-2
googletest/test/googletest-test-part-test.cc
googletest/test/googletest-test-part-test.cc
+6
-16
googletest/test/googletest-throw-on-failure-test_.cc
googletest/test/googletest-throw-on-failure-test_.cc
+5
-5
googletest/test/googletest-uninitialized-test_.cc
googletest/test/googletest-uninitialized-test_.cc
+1
-4
googletest/test/gtest-typed-test2_test.cc
googletest/test/gtest-typed-test2_test.cc
+1
-2
googletest/test/gtest-typed-test_test.cc
googletest/test/gtest-typed-test_test.cc
+20
-35
googletest/test/gtest-typed-test_test.h
googletest/test/gtest-typed-test_test.h
+4
-7
googletest/test/gtest-unittest-api_test.cc
googletest/test/gtest-unittest-api_test.cc
+10
-10
googletest/test/gtest_assert_by_exception_test.cc
googletest/test/gtest_assert_by_exception_test.cc
+10
-14
googletest/test/gtest_environment_test.cc
googletest/test/gtest_environment_test.cc
+6
-11
googletest/test/gtest_help_test_.cc
googletest/test/gtest_help_test_.cc
+0
-1
googletest/test/gtest_json_test_utils.py
googletest/test/gtest_json_test_utils.py
+2
-0
googletest/test/gtest_main_unittest.cc
googletest/test/gtest_main_unittest.cc
+1
-3
googletest/test/gtest_pred_impl_unittest.cc
googletest/test/gtest_pred_impl_unittest.cc
+682
-1032
No files found.
googletest/test/googletest-param-test-test.cc
View file @
9e712372
...
...
@@ -32,21 +32,21 @@
// generators objects produce correct parameter sequences and that
// Google Test runtime instantiates correct tests from those sequences.
#include "
g
test/gtest.h"
#include "test/g
oogletest-param-test-
test.h"
#
include <algorithm>
#
include <iostream>
#
include <list>
#
include <set>
#
include <sstream>
#
include <string>
#
include <vector>
#include <algorithm>
#include <iostream>
#include <list>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#
include "
src/
gtest
-internal-inl.h" // for UnitTestOptions
#
include "
test/googletest-param-test-test.h"
#include "gtest
/gtest.h"
#include "
src/gtest-internal-inl.h" // for UnitTestOptions
using
::
std
::
vector
;
using
::
std
::
sort
;
using
::
std
::
vector
;
using
::
testing
::
AddGlobalTestEnvironment
;
using
::
testing
::
Bool
;
...
...
@@ -85,15 +85,14 @@ void VerifyGenerator(const ParamGenerator<T>& generator,
// We cannot use EXPECT_EQ() here as the values may be tuples,
// which don't support <<.
EXPECT_TRUE
(
expected_values
[
i
]
==
*
it
)
<<
"where i is "
<<
i
<<
", expected_values[i] is "
<<
PrintValue
(
expected_values
[
i
])
<<
", *it is "
<<
PrintValue
(
*
it
)
<<
"where i is "
<<
i
<<
", expected_values[i] is "
<<
PrintValue
(
expected_values
[
i
])
<<
", *it is "
<<
PrintValue
(
*
it
)
<<
", and 'it' is an iterator created with the copy constructor.
\n
"
;
++
it
;
}
EXPECT_TRUE
(
it
==
generator
.
end
())
<<
"At the presumed end of sequence when accessing via an iterator "
<<
"created with the copy constructor.
\n
"
;
<<
"At the presumed end of sequence when accessing via an iterator "
<<
"created with the copy constructor.
\n
"
;
// Test the iterator assignment. The following lines verify that
// the sequence accessed via an iterator initialized via the
...
...
@@ -105,15 +104,14 @@ void VerifyGenerator(const ParamGenerator<T>& generator,
<<
"At element "
<<
i
<<
" when accessing via an iterator "
<<
"created with the assignment operator.
\n
"
;
EXPECT_TRUE
(
expected_values
[
i
]
==
*
it
)
<<
"where i is "
<<
i
<<
", expected_values[i] is "
<<
PrintValue
(
expected_values
[
i
])
<<
", *it is "
<<
PrintValue
(
*
it
)
<<
"where i is "
<<
i
<<
", expected_values[i] is "
<<
PrintValue
(
expected_values
[
i
])
<<
", *it is "
<<
PrintValue
(
*
it
)
<<
", and 'it' is an iterator created with the copy constructor.
\n
"
;
++
it
;
}
EXPECT_TRUE
(
it
==
generator
.
end
())
<<
"At the presumed end of sequence when accessing via an iterator "
<<
"created with the assignment operator.
\n
"
;
<<
"At the presumed end of sequence when accessing via an iterator "
<<
"created with the assignment operator.
\n
"
;
}
template
<
typename
T
>
...
...
@@ -216,8 +214,7 @@ class DogAdder {
DogAdder
(
const
DogAdder
&
other
)
:
value_
(
other
.
value_
.
c_str
())
{}
DogAdder
operator
=
(
const
DogAdder
&
other
)
{
if
(
this
!=
&
other
)
value_
=
other
.
value_
;
if
(
this
!=
&
other
)
value_
=
other
.
value_
;
return
*
this
;
}
DogAdder
operator
+
(
const
DogAdder
&
other
)
const
{
...
...
@@ -225,9 +222,7 @@ class DogAdder {
msg
<<
value_
.
c_str
()
<<
other
.
value_
.
c_str
();
return
DogAdder
(
msg
.
GetString
().
c_str
());
}
bool
operator
<
(
const
DogAdder
&
other
)
const
{
return
value_
<
other
.
value_
;
}
bool
operator
<
(
const
DogAdder
&
other
)
const
{
return
value_
<
other
.
value_
;
}
const
std
::
string
&
value
()
const
{
return
value_
;
}
private:
...
...
@@ -372,19 +367,17 @@ TEST(ValuesTest, ValuesWorksForValuesOfCompatibleTypes) {
}
TEST
(
ValuesTest
,
ValuesWorksForMaxLengthList
)
{
const
ParamGenerator
<
int
>
gen
=
Values
(
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
,
100
,
110
,
120
,
130
,
140
,
150
,
160
,
170
,
180
,
190
,
200
,
210
,
220
,
230
,
240
,
250
,
260
,
270
,
280
,
290
,
300
,
310
,
320
,
330
,
340
,
350
,
360
,
370
,
380
,
390
,
400
,
410
,
420
,
430
,
440
,
450
,
460
,
470
,
480
,
490
,
500
);
const
ParamGenerator
<
int
>
gen
=
Values
(
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
,
100
,
110
,
120
,
130
,
140
,
150
,
160
,
170
,
180
,
190
,
200
,
210
,
220
,
230
,
240
,
250
,
260
,
270
,
280
,
290
,
300
,
310
,
320
,
330
,
340
,
350
,
360
,
370
,
380
,
390
,
400
,
410
,
420
,
430
,
440
,
450
,
460
,
470
,
480
,
490
,
500
);
const
int
expected_values
[]
=
{
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
,
100
,
110
,
120
,
130
,
140
,
150
,
160
,
170
,
180
,
190
,
200
,
210
,
220
,
230
,
240
,
250
,
260
,
270
,
280
,
290
,
300
,
310
,
320
,
330
,
340
,
350
,
360
,
370
,
380
,
390
,
400
,
410
,
420
,
430
,
440
,
450
,
460
,
470
,
480
,
490
,
500
};
10
,
20
,
30
,
40
,
50
,
60
,
70
,
80
,
90
,
100
,
110
,
120
,
130
,
140
,
150
,
160
,
170
,
180
,
190
,
200
,
210
,
220
,
230
,
240
,
250
,
260
,
270
,
280
,
290
,
300
,
310
,
320
,
330
,
340
,
350
,
360
,
370
,
380
,
390
,
400
,
410
,
420
,
430
,
440
,
450
,
460
,
470
,
480
,
490
,
500
};
VerifyGenerator
(
gen
,
expected_values
);
}
...
...
@@ -530,7 +523,6 @@ TEST(CombineTest, NonDefaultConstructAssign) {
EXPECT_TRUE
(
it
==
gen
.
end
());
}
// Tests that an generator produces correct sequence after being
// assigned from another generator.
TEST
(
ParamGeneratorTest
,
AssignmentWorks
)
{
...
...
@@ -573,7 +565,7 @@ class TestGenerationEnvironment : public ::testing::Environment {
Message
msg
;
msg
<<
"TestsExpandedAndRun/"
<<
i
;
if
(
UnitTestOptions
::
FilterMatchesTest
(
"TestExpansionModule/MultipleTestGenerationTest"
,
"TestExpansionModule/MultipleTestGenerationTest"
,
msg
.
GetString
().
c_str
()))
{
perform_check
=
true
;
}
...
...
@@ -595,8 +587,11 @@ class TestGenerationEnvironment : public ::testing::Environment {
}
private:
TestGenerationEnvironment
()
:
fixture_constructor_count_
(
0
),
set_up_count_
(
0
),
tear_down_count_
(
0
),
test_body_count_
(
0
)
{}
TestGenerationEnvironment
()
:
fixture_constructor_count_
(
0
),
set_up_count_
(
0
),
tear_down_count_
(
0
),
test_body_count_
(
0
)
{}
int
fixture_constructor_count_
;
int
set_up_count_
;
...
...
@@ -612,7 +607,7 @@ class TestGenerationTest : public TestWithParam<int> {
public:
enum
{
PARAMETER_COUNT
=
sizeof
(
test_generation_params
)
/
sizeof
(
test_generation_params
[
0
])
sizeof
(
test_generation_params
)
/
sizeof
(
test_generation_params
[
0
])
};
typedef
TestGenerationEnvironment
<
PARAMETER_COUNT
>
Environment
;
...
...
@@ -636,9 +631,9 @@ class TestGenerationTest : public TestWithParam<int> {
for
(
int
i
=
0
;
i
<
PARAMETER_COUNT
;
++
i
)
{
Message
test_name
;
test_name
<<
"TestsExpandedAndRun/"
<<
i
;
if
(
!
UnitTestOptions
::
FilterMatchesTest
(
"TestExpansionModule/MultipleTestGenerationTest"
,
test_name
.
GetString
()))
{
if
(
!
UnitTestOptions
::
FilterMatchesTest
(
"TestExpansionModule/MultipleTestGenerationTest"
,
test_name
.
GetString
()))
{
all_tests_in_test_case_selected
=
false
;
}
}
...
...
@@ -729,8 +724,7 @@ TEST_P(ExternalInstantiationTest, IsMultipleOf33) {
// Tests that a parameterized test case can be instantiated with multiple
// generators.
class
MultipleInstantiationTest
:
public
TestWithParam
<
int
>
{};
TEST_P
(
MultipleInstantiationTest
,
AllowsMultipleInstances
)
{
}
TEST_P
(
MultipleInstantiationTest
,
AllowsMultipleInstances
)
{}
INSTANTIATE_TEST_SUITE_P
(
Sequence1
,
MultipleInstantiationTest
,
Values
(
1
,
2
));
INSTANTIATE_TEST_SUITE_P
(
Sequence2
,
MultipleInstantiationTest
,
Range
(
3
,
5
));
...
...
@@ -780,7 +774,7 @@ class NamingTest : public TestWithParam<int> {};
TEST_P
(
NamingTest
,
TestsReportCorrectNamesAndParameters
)
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"ZeroToFiveSequence/NamingTest"
,
test_info
->
test_suite_name
());
...
...
@@ -801,7 +795,7 @@ class MacroNamingTest : public TestWithParam<int> {};
TEST_P
(
PREFIX_WITH_MACRO
(
NamingTest
),
PREFIX_WITH_FOO
(
SomeTestName
))
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"FortyTwo/MacroNamingTest"
,
test_info
->
test_suite_name
());
EXPECT_STREQ
(
"FooSomeTestName/0"
,
test_info
->
name
());
...
...
@@ -815,7 +809,7 @@ class MacroNamingTestNonParametrized : public ::testing::Test {};
TEST_F
(
PREFIX_WITH_MACRO
(
NamingTestNonParametrized
),
PREFIX_WITH_FOO
(
SomeTestName
))
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_STREQ
(
"MacroNamingTestNonParametrized"
,
test_info
->
test_suite_name
());
EXPECT_STREQ
(
"FooSomeTestName"
,
test_info
->
name
());
...
...
@@ -839,9 +833,8 @@ TEST(MacroNameing, LookupNames) {
EXPECT_NE
(
//
know_suite_names
.
find
(
"FortyTwo/MacroNamingTest"
),
know_suite_names
.
end
());
EXPECT_NE
(
know_suite_names
.
find
(
"MacroNamingTestNonParametrized"
),
know_suite_names
.
end
());
EXPECT_NE
(
know_suite_names
.
find
(
"MacroNamingTestNonParametrized"
),
know_suite_names
.
end
());
// Check that the expected form of the test name actually exists.
EXPECT_NE
(
//
know_test_names
.
find
(
"FortyTwo/MacroNamingTest.FooSomeTestName/0"
),
...
...
@@ -924,7 +917,7 @@ class CustomIntegerNamingTest : public TestWithParam<int> {};
TEST_P
(
CustomIntegerNamingTest
,
TestsReportCorrectNames
)
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
Message
test_name_stream
;
test_name_stream
<<
"TestsReportCorrectNames/"
<<
GetParam
();
EXPECT_STREQ
(
test_name_stream
.
GetString
().
c_str
(),
test_info
->
name
());
...
...
@@ -949,7 +942,7 @@ class CustomStructNamingTest : public TestWithParam<CustomStruct> {};
TEST_P
(
CustomStructNamingTest
,
TestsReportCorrectNames
)
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
Message
test_name_stream
;
test_name_stream
<<
"TestsReportCorrectNames/"
<<
GetParam
();
EXPECT_STREQ
(
test_name_stream
.
GetString
().
c_str
(),
test_info
->
name
());
...
...
@@ -979,7 +972,7 @@ class StatefulNamingTest : public ::testing::TestWithParam<int> {
TEST_P
(
StatefulNamingTest
,
TestsReportCorrectNames
)
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
sum_
+=
GetParam
();
Message
test_name_stream
;
test_name_stream
<<
"TestsReportCorrectNames/"
<<
sum_
;
...
...
@@ -1007,7 +1000,7 @@ class CommentTest : public TestWithParam<Unstreamable> {};
TEST_P
(
CommentTest
,
TestsCorrectlyReportUnstreamableParams
)
{
const
::
testing
::
TestInfo
*
const
test_info
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_EQ
(
::
testing
::
PrintToString
(
GetParam
()),
test_info
->
value_param
());
}
...
...
@@ -1021,7 +1014,8 @@ INSTANTIATE_TEST_SUITE_P(InstantiationWithComments, CommentTest,
// perform simple tests on both.
class
NonParameterizedBaseTest
:
public
::
testing
::
Test
{
public:
NonParameterizedBaseTest
()
:
n_
(
17
)
{
}
NonParameterizedBaseTest
()
:
n_
(
17
)
{}
protected:
int
n_
;
};
...
...
@@ -1029,16 +1023,14 @@ class NonParameterizedBaseTest : public ::testing::Test {
class
ParameterizedDerivedTest
:
public
NonParameterizedBaseTest
,
public
::
testing
::
WithParamInterface
<
int
>
{
protected:
ParameterizedDerivedTest
()
:
count_
(
0
)
{
}
ParameterizedDerivedTest
()
:
count_
(
0
)
{}
int
count_
;
static
int
global_count_
;
};
int
ParameterizedDerivedTest
::
global_count_
=
0
;
TEST_F
(
NonParameterizedBaseTest
,
FixtureIsInitialized
)
{
EXPECT_EQ
(
17
,
n_
);
}
TEST_F
(
NonParameterizedBaseTest
,
FixtureIsInitialized
)
{
EXPECT_EQ
(
17
,
n_
);
}
TEST_P
(
ParameterizedDerivedTest
,
SeesSequence
)
{
EXPECT_EQ
(
17
,
n_
);
...
...
@@ -1046,11 +1038,10 @@ TEST_P(ParameterizedDerivedTest, SeesSequence) {
EXPECT_EQ
(
GetParam
(),
global_count_
++
);
}
class
ParameterizedDeathTest
:
public
::
testing
::
TestWithParam
<
int
>
{
};
class
ParameterizedDeathTest
:
public
::
testing
::
TestWithParam
<
int
>
{};
TEST_F
(
ParameterizedDeathTest
,
GetParamDiesFromTestF
)
{
EXPECT_DEATH_IF_SUPPORTED
(
GetParam
(),
".* value-parameterized test .*"
);
EXPECT_DEATH_IF_SUPPORTED
(
GetParam
(),
".* value-parameterized test .*"
);
}
INSTANTIATE_TEST_SUITE_P
(
RangeZeroToFive
,
ParameterizedDerivedTest
,
...
...
@@ -1084,11 +1075,11 @@ class NotInstantiatedTest : public testing::TestWithParam<int> {};
// ... we mark is as allowed.
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST
(
NotInstantiatedTest
);
TEST_P
(
NotInstantiatedTest
,
Used
)
{
}
TEST_P
(
NotInstantiatedTest
,
Used
)
{}
using
OtherName
=
NotInstantiatedTest
;
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST
(
OtherName
);
TEST_P
(
OtherName
,
Used
)
{
}
TEST_P
(
OtherName
,
Used
)
{}
// Used but not instantiated, this would fail. but...
template
<
typename
T
>
...
...
@@ -1097,11 +1088,11 @@ TYPED_TEST_SUITE_P(NotInstantiatedTypeTest);
// ... we mark is as allowed.
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST
(
NotInstantiatedTypeTest
);
TYPED_TEST_P
(
NotInstantiatedTypeTest
,
Used
)
{
}
TYPED_TEST_P
(
NotInstantiatedTypeTest
,
Used
)
{}
REGISTER_TYPED_TEST_SUITE_P
(
NotInstantiatedTypeTest
,
Used
);
}
// namespace works_here
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
// Used in TestGenerationTest test suite.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
// Used in GeneratorEvaluationTest test suite. Tests that the updated value
...
...
googletest/test/googletest-param-test-test.h
View file @
9e712372
...
...
@@ -39,13 +39,11 @@
// Test fixture for testing definition and instantiation of a test
// in separate translation units.
class
ExternalInstantiationTest
:
public
::
testing
::
TestWithParam
<
int
>
{
};
class
ExternalInstantiationTest
:
public
::
testing
::
TestWithParam
<
int
>
{};
// Test fixture for testing instantiation of a test in multiple
// translation units.
class
InstantiationInMultipleTranslationUnitsTest
:
public
::
testing
::
TestWithParam
<
int
>
{
};
:
public
::
testing
::
TestWithParam
<
int
>
{};
#endif // GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_
googletest/test/googletest-param-test2-test.cc
View file @
9e712372
...
...
@@ -46,8 +46,7 @@ ParamGenerator<int> extern_gen = Values(33);
// and instantiated in another. The test is defined in
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
// defined in gtest-param-test_test.h.
INSTANTIATE_TEST_SUITE_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
INSTANTIATE_TEST_SUITE_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
// Tests that a parameterized test case can be instantiated
...
...
@@ -55,7 +54,5 @@ INSTANTIATE_TEST_SUITE_P(MultiplesOf33,
// in googletest-param-test-test.cc and
// InstantiationInMultipleTranslationUnitsTest fixture is defined in
// gtest-param-test_test.h
INSTANTIATE_TEST_SUITE_P
(
Sequence2
,
InstantiationInMultipleTranslationUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
INSTANTIATE_TEST_SUITE_P
(
Sequence2
,
InstantiationInMultipleTranslationUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
googletest/test/googletest-port-test.cc
View file @
9e712372
...
...
@@ -33,18 +33,18 @@
#include "gtest/internal/gtest-port.h"
#if GTEST_OS_MAC
#
include <time.h>
#include <time.h>
#endif // GTEST_OS_MAC
#include <chrono> // NOLINT
#include <list>
#include <memory>
#include <thread> // NOLINT
#include <thread>
// NOLINT
#include <utility> // For std::pair and std::make_pair.
#include <vector>
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
using
std
::
make_pair
;
...
...
@@ -238,8 +238,8 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
}
switch
(
0
)
case
0
:
GTEST_CHECK_
(
true
)
<<
"Check failed in switch case"
;
case
0
:
GTEST_CHECK_
(
true
)
<<
"Check failed in switch case"
;
}
// Verifies behavior of FormatFileLocation.
...
...
@@ -281,7 +281,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
}
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA || \
GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD ||
\
GTEST_OS_NETBSD || GTEST_OS_OPENBSD || GTEST_OS_GNU_HURD
void
*
ThreadFunc
(
void
*
data
)
{
internal
::
Mutex
*
mutex
=
static_cast
<
internal
::
Mutex
*>
(
data
);
...
...
@@ -357,13 +357,13 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
const
bool
a_false_condition
=
false
;
const
char
regex
[]
=
#ifdef _MSC_VER
"googletest-port-test
\\
.cc
\\
(
\\
d+
\\
):"
"googletest-port-test
\\
.cc
\\
(
\\
d+
\\
):"
#elif GTEST_USES_POSIX_RE
"googletest-port-test
\\
.cc:[0-9]+"
"googletest-port-test
\\
.cc:[0-9]+"
#else
"googletest-port-test
\\
.cc:
\\
d+"
"googletest-port-test
\\
.cc:
\\
d+"
#endif // _MSC_VER
".*a_false_condition.*Extra info.*"
;
".*a_false_condition.*Extra info.*"
;
EXPECT_DEATH_IF_SUPPORTED
(
GTEST_CHECK_
(
a_false_condition
)
<<
"Extra info"
,
regex
);
...
...
@@ -372,10 +372,12 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
#if GTEST_HAS_DEATH_TEST
TEST
(
GtestCheckDeathTest
,
LivesSilentlyOnSuccess
)
{
EXPECT_EXIT
({
GTEST_CHECK_
(
true
)
<<
"Extra info"
;
::
std
::
cerr
<<
"Success
\n
"
;
exit
(
0
);
},
EXPECT_EXIT
(
{
GTEST_CHECK_
(
true
)
<<
"Extra info"
;
::
std
::
cerr
<<
"Success
\n
"
;
exit
(
0
);
},
::
testing
::
ExitedWithCode
(
0
),
"Success"
);
}
...
...
@@ -386,15 +388,15 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {
// For simplicity, we only cover the most important platforms here.
TEST
(
RegexEngineSelectionTest
,
SelectsCorrectRegexEngine
)
{
#if !GTEST_USES_PCRE
#
if GTEST_HAS_POSIX_RE
#if GTEST_HAS_POSIX_RE
EXPECT_TRUE
(
GTEST_USES_POSIX_RE
);
#
else
#else
EXPECT_TRUE
(
GTEST_USES_SIMPLE_RE
);
#
endif
#endif
#endif // !GTEST_USES_PCRE
}
...
...
@@ -423,9 +425,9 @@ TYPED_TEST(RETest, ImplicitConstructorWorks) {
// Tests that RE's constructors reject invalid regular expressions.
TYPED_TEST
(
RETest
,
RejectsInvalidRegex
)
{
EXPECT_NONFATAL_FAILURE
(
{
const
RE
invalid
(
TypeParam
(
"?"
));
},
"
\"
?
\"
is not a valid POSIX Extended regular expression."
);
EXPECT_NONFATAL_FAILURE
(
{
const
RE
invalid
(
TypeParam
(
"?"
));
},
"
\"
?
\"
is not a valid POSIX Extended regular expression."
);
}
// Tests RE::FullMatch().
...
...
@@ -819,8 +821,7 @@ TEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithRepetition) {
EXPECT_TRUE
(
MatchRegexAtHead
(
"a?b"
,
"ab"
));
}
TEST
(
MatchRegexAtHeadTest
,
WorksWhenRegexStartsWithRepetionOfEscapeSequence
)
{
TEST
(
MatchRegexAtHeadTest
,
WorksWhenRegexStartsWithRepetionOfEscapeSequence
)
{
EXPECT_FALSE
(
MatchRegexAtHead
(
"
\\
.+a"
,
"abc"
));
EXPECT_FALSE
(
MatchRegexAtHead
(
"
\\
s?b"
,
" b"
));
...
...
@@ -876,17 +877,14 @@ TEST(RETest, ImplicitConstructorWorks) {
// Tests that RE's constructors reject invalid regular expressions.
TEST
(
RETest
,
RejectsInvalidRegex
)
{
EXPECT_NONFATAL_FAILURE
({
const
RE
normal
(
NULL
);
},
"NULL is not a valid simple regular expression"
);
EXPECT_NONFATAL_FAILURE
({
const
RE
normal
(
NULL
);
},
"NULL is not a valid simple regular expression"
);
EXPECT_NONFATAL_FAILURE
({
const
RE
normal
(
".*(
\\
w+"
);
},
"'(' is unsupported"
);
EXPECT_NONFATAL_FAILURE
({
const
RE
normal
(
".*(
\\
w+"
);
},
"'(' is unsupported"
);
EXPECT_NONFATAL_FAILURE
({
const
RE
invalid
(
"^?"
);
},
"'?' can only follow a repeatable token"
);
EXPECT_NONFATAL_FAILURE
({
const
RE
invalid
(
"^?"
);
},
"'?' can only follow a repeatable token"
);
}
// Tests RE::FullMatch().
...
...
@@ -1028,12 +1026,13 @@ TEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) {
TEST
(
MutexDeathTest
,
AssertHeldShouldAssertWhenNotLocked
)
{
// AssertHeld() is flaky only in the presence of multiple threads accessing
// the lock. In this case, the test is robust.
EXPECT_DEATH_IF_SUPPORTED
({
Mutex
m
;
{
MutexLock
lock
(
&
m
);
}
m
.
AssertHeld
();
},
"thread .*hold"
);
EXPECT_DEATH_IF_SUPPORTED
(
{
Mutex
m
;
{
MutexLock
lock
(
&
m
);
}
m
.
AssertHeld
();
},
"thread .*hold"
);
}
TEST
(
MutexTest
,
AssertHeldShouldNotAssertWhenLocked
)
{
...
...
@@ -1044,8 +1043,8 @@ TEST(MutexTest, AssertHeldShouldNotAssertWhenLocked) {
class
AtomicCounterWithMutex
{
public:
explicit
AtomicCounterWithMutex
(
Mutex
*
mutex
)
:
value_
(
0
),
mutex_
(
mutex
),
random_
(
42
)
{}
explicit
AtomicCounterWithMutex
(
Mutex
*
mutex
)
:
value_
(
0
),
mutex_
(
mutex
),
random_
(
42
)
{}
void
Increment
()
{
MutexLock
lock
(
mutex_
);
...
...
@@ -1076,7 +1075,7 @@ class AtomicCounterWithMutex {
std
::
chrono
::
milliseconds
(
random_
.
Generate
(
30
)));
::
InterlockedIncrement
(
&
dummy
);
#else
#
error "Memory barrier not implemented on this platform."
#error "Memory barrier not implemented on this platform."
#endif // GTEST_HAS_PTHREAD
}
value_
=
temp
+
1
;
...
...
@@ -1086,12 +1085,11 @@ class AtomicCounterWithMutex {
private:
volatile
int
value_
;
Mutex
*
const
mutex_
;
// Protects value_.
Random
random_
;
Random
random_
;
};
void
CountingThreadFunc
(
pair
<
AtomicCounterWithMutex
*
,
int
>
param
)
{
for
(
int
i
=
0
;
i
<
param
.
second
;
++
i
)
param
.
first
->
Increment
();
for
(
int
i
=
0
;
i
<
param
.
second
;
++
i
)
param
.
first
->
Increment
();
}
// Tests that the mutex only lets one thread at a time to lock it.
...
...
@@ -1107,14 +1105,12 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
// Creates and runs kThreadCount threads that increment locked_counter
// kCycleCount times each.
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
{
counting_threads
[
i
].
reset
(
new
ThreadType
(
&
CountingThreadFunc
,
make_pair
(
&
locked_counter
,
kCycleCount
),
&
threads_can_start
));
counting_threads
[
i
].
reset
(
new
ThreadType
(
&
CountingThreadFunc
,
make_pair
(
&
locked_counter
,
kCycleCount
),
&
threads_can_start
));
}
threads_can_start
.
Notify
();
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
counting_threads
[
i
]
->
Join
();
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
counting_threads
[
i
]
->
Join
();
// If the mutex lets more than one thread to increment the counter at a
// time, they are likely to encounter a race condition and have some
...
...
@@ -1124,7 +1120,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
}
template
<
typename
T
>
void
RunFromThread
(
void
(
func
)(
T
),
T
param
)
{
void
RunFromThread
(
void
(
func
)(
T
),
T
param
)
{
ThreadWithParam
<
T
>
thread
(
func
,
param
,
nullptr
);
thread
.
Join
();
}
...
...
googletest/test/googletest-printers-test.cc
View file @
9e712372
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Test - The Google C++ Testing and Mocking Framework
//
// This file tests the universal value printer.
...
...
@@ -56,30 +55,20 @@
// Some user-defined types for testing the universal value printer.
// An anonymous enum type.
enum
AnonymousEnum
{
kAE1
=
-
1
,
kAE2
=
1
};
enum
AnonymousEnum
{
kAE1
=
-
1
,
kAE2
=
1
};
// An enum without a user-defined printer.
enum
EnumWithoutPrinter
{
kEWP1
=
-
2
,
kEWP2
=
42
};
enum
EnumWithoutPrinter
{
kEWP1
=
-
2
,
kEWP2
=
42
};
// An enum with a << operator.
enum
EnumWithStreaming
{
kEWS1
=
10
};
enum
EnumWithStreaming
{
kEWS1
=
10
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
EnumWithStreaming
e
)
{
return
os
<<
(
e
==
kEWS1
?
"kEWS1"
:
"invalid"
);
}
// An enum with a PrintTo() function.
enum
EnumWithPrintTo
{
kEWPT1
=
1
};
enum
EnumWithPrintTo
{
kEWPT1
=
1
};
void
PrintTo
(
EnumWithPrintTo
e
,
std
::
ostream
*
os
)
{
*
os
<<
(
e
==
kEWPT1
?
"kEWPT1"
:
"invalid"
);
...
...
@@ -108,6 +97,7 @@ template <typename T>
class
UnprintableTemplateInGlobal
{
public:
UnprintableTemplateInGlobal
()
:
value_
()
{}
private:
T
value_
;
};
...
...
@@ -133,6 +123,7 @@ class UnprintableInFoo {
public:
UnprintableInFoo
()
:
z_
(
0
)
{
memcpy
(
xy_
,
"
\xEF\x12
\x0\x0
\x34\xAB
\x0\x0"
,
8
);
}
double
z
()
const
{
return
z_
;
}
private:
char
xy_
[
8
];
double
z_
;
...
...
@@ -149,8 +140,7 @@ void PrintTo(const PrintableViaPrintTo& x, ::std::ostream* os) {
}
// A type with a user-defined << for printing its pointer.
struct
PointerPrintable
{
};
struct
PointerPrintable
{};
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PointerPrintable
*
/* x */
)
{
...
...
@@ -164,6 +154,7 @@ class PrintableViaPrintToTemplate {
explicit
PrintableViaPrintToTemplate
(
const
T
&
a_value
)
:
value_
(
a_value
)
{}
const
T
&
value
()
const
{
return
value_
;
}
private:
T
value_
;
};
...
...
@@ -180,6 +171,7 @@ class StreamableTemplateInFoo {
StreamableTemplateInFoo
()
:
value_
()
{}
const
T
&
value
()
const
{
return
value_
;
}
private:
T
value_
;
};
...
...
@@ -255,7 +247,6 @@ class UniversalPrinter<Wrapper<T>> {
};
}
// namespace internal
namespace
gtest_printers_test
{
using
::
std
::
deque
;
...
...
@@ -350,29 +341,21 @@ TEST(PrintCharTest, PlainChar) {
// signed char.
TEST
(
PrintCharTest
,
SignedChar
)
{
EXPECT_EQ
(
"'
\\
0'"
,
Print
(
static_cast
<
signed
char
>
(
'\0'
)));
EXPECT_EQ
(
"'
\\
xCE' (-50)"
,
Print
(
static_cast
<
signed
char
>
(
-
50
)));
EXPECT_EQ
(
"'
\\
xCE' (-50)"
,
Print
(
static_cast
<
signed
char
>
(
-
50
)));
}
// unsigned char.
TEST
(
PrintCharTest
,
UnsignedChar
)
{
EXPECT_EQ
(
"'
\\
0'"
,
Print
(
static_cast
<
unsigned
char
>
(
'\0'
)));
EXPECT_EQ
(
"'b' (98, 0x62)"
,
Print
(
static_cast
<
unsigned
char
>
(
'b'
)));
EXPECT_EQ
(
"'b' (98, 0x62)"
,
Print
(
static_cast
<
unsigned
char
>
(
'b'
)));
}
TEST
(
PrintCharTest
,
Char16
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
u'A'
));
}
TEST
(
PrintCharTest
,
Char16
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
u'A'
));
}
TEST
(
PrintCharTest
,
Char32
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
U'A'
));
}
TEST
(
PrintCharTest
,
Char32
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
U'A'
));
}
#ifdef __cpp_char8_t
TEST
(
PrintCharTest
,
Char8
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
u8'A'
));
}
TEST
(
PrintCharTest
,
Char8
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
u8'A'
));
}
#endif
// Tests printing other simple, built-in types.
...
...
@@ -414,8 +397,8 @@ TEST(PrintTypeSizeTest, Wchar_t) {
TEST
(
PrintBuiltInTypeTest
,
Integer
)
{
EXPECT_EQ
(
"'
\\
xFF' (255)"
,
Print
(
static_cast
<
unsigned
char
>
(
255
)));
// uint8
EXPECT_EQ
(
"'
\\
x80' (-128)"
,
Print
(
static_cast
<
signed
char
>
(
-
128
)));
// int8
EXPECT_EQ
(
"65535"
,
Print
(
std
::
numeric_limits
<
uint16_t
>::
max
()));
// uint16
EXPECT_EQ
(
"-32768"
,
Print
(
std
::
numeric_limits
<
int16_t
>::
min
()));
// int16
EXPECT_EQ
(
"65535"
,
Print
(
std
::
numeric_limits
<
uint16_t
>::
max
()));
// uint16
EXPECT_EQ
(
"-32768"
,
Print
(
std
::
numeric_limits
<
int16_t
>::
min
()));
// int16
EXPECT_EQ
(
"4294967295"
,
Print
(
std
::
numeric_limits
<
uint32_t
>::
max
()));
// uint32
EXPECT_EQ
(
"-2147483648"
,
...
...
@@ -446,7 +429,7 @@ TEST(PrintBuiltInTypeTest, Size_t) {
#if !GTEST_OS_WINDOWS
// Windows has no ssize_t type.
EXPECT_EQ
(
"-2"
,
Print
(
static_cast
<
ssize_t
>
(
-
2
)));
// ssize_t.
#endif // !GTEST_OS_WINDOWS
#endif
// !GTEST_OS_WINDOWS
}
// gcc/clang __{u,}int128_t values.
...
...
@@ -516,8 +499,9 @@ TEST(PrintCStringTest, Null) {
// Tests that C strings are escaped properly.
TEST
(
PrintCStringTest
,
EscapesProperly
)
{
const
char
*
p
=
"'
\"
?
\\\a\b\f\n\r\t\v\x7F\xFF
a"
;
EXPECT_EQ
(
PrintPointer
(
p
)
+
" pointing to
\"
'
\\\"
?
\\\\\\
a
\\
b
\\
f"
"
\\
n
\\
r
\\
t
\\
v
\\
x7F
\\
xFF a
\"
"
,
EXPECT_EQ
(
PrintPointer
(
p
)
+
" pointing to
\"
'
\\\"
?
\\\\\\
a
\\
b
\\
f"
"
\\
n
\\
r
\\
t
\\
v
\\
x7F
\\
xFF a
\"
"
,
Print
(
p
));
}
...
...
@@ -636,10 +620,12 @@ TEST(PrintWideCStringTest, Null) {
// Tests that wide C strings are escaped properly.
TEST
(
PrintWideCStringTest
,
EscapesProperly
)
{
const
wchar_t
s
[]
=
{
'\''
,
'"'
,
'?'
,
'\\'
,
'\a'
,
'\b'
,
'\f'
,
'\n'
,
'\r'
,
'\t'
,
'\v'
,
0xD3
,
0x576
,
0x8D3
,
0xC74D
,
' '
,
'a'
,
'\0'
};
EXPECT_EQ
(
PrintPointer
(
s
)
+
" pointing to L
\"
'
\\\"
?
\\\\\\
a
\\
b
\\
f"
"
\\
n
\\
r
\\
t
\\
v
\\
xD3
\\
x576
\\
x8D3
\\
xC74D a
\"
"
,
const
wchar_t
s
[]
=
{
'\''
,
'"'
,
'?'
,
'\\'
,
'\a'
,
'\b'
,
'\f'
,
'\n'
,
'\r'
,
'\t'
,
'\v'
,
0xD3
,
0x576
,
0x8D3
,
0xC74D
,
' '
,
'a'
,
'\0'
};
EXPECT_EQ
(
PrintPointer
(
s
)
+
" pointing to L
\"
'
\\\"
?
\\\\\\
a
\\
b
\\
f"
"
\\
n
\\
r
\\
t
\\
v
\\
xD3
\\
x576
\\
x8D3
\\
xC74D a
\"
"
,
Print
(
static_cast
<
const
wchar_t
*>
(
s
)));
}
#endif // native wchar_t
...
...
@@ -721,10 +707,9 @@ TEST(PrintPointerTest, NonMemberFunctionPointer) {
// standard disallows casting between pointers to functions and
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce
// this limitation.
EXPECT_EQ
(
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
reinterpret_cast
<
internal
::
BiggestInt
>
(
&
MyFunction
))),
Print
(
&
MyFunction
));
EXPECT_EQ
(
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
reinterpret_cast
<
internal
::
BiggestInt
>
(
&
MyFunction
))),
Print
(
&
MyFunction
));
int
(
*
p
)(
bool
)
=
NULL
;
// NOLINT
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -733,14 +718,13 @@ TEST(PrintPointerTest, NonMemberFunctionPointer) {
// another.
template
<
typename
StringType
>
AssertionResult
HasPrefix
(
const
StringType
&
str
,
const
StringType
&
prefix
)
{
if
(
str
.
find
(
prefix
,
0
)
==
0
)
return
AssertionSuccess
();
if
(
str
.
find
(
prefix
,
0
)
==
0
)
return
AssertionSuccess
();
const
bool
is_wide_string
=
sizeof
(
prefix
[
0
])
>
1
;
const
char
*
const
begin_string_quote
=
is_wide_string
?
"L
\"
"
:
"
\"
"
;
return
AssertionFailure
()
<<
begin_string_quote
<<
prefix
<<
"
\"
is not a prefix of "
<<
begin_string_quote
<<
str
<<
"
\"\n
"
;
<<
begin_string_quote
<<
prefix
<<
"
\"
is not a prefix of "
<<
begin_string_quote
<<
str
<<
"
\"\n
"
;
}
// Tests printing member variable pointers. Although they are called
...
...
@@ -761,8 +745,7 @@ TEST(PrintPointerTest, MemberVariablePointer) {
EXPECT_TRUE
(
HasPrefix
(
Print
(
&
Foo
::
value
),
Print
(
sizeof
(
&
Foo
::
value
))
+
"-byte object "
));
int
Foo
::*
p
=
NULL
;
// NOLINT
EXPECT_TRUE
(
HasPrefix
(
Print
(
p
),
Print
(
sizeof
(
p
))
+
"-byte object "
));
EXPECT_TRUE
(
HasPrefix
(
Print
(
p
),
Print
(
sizeof
(
p
))
+
"-byte object "
));
}
// Tests printing member function pointers. Although they are called
...
...
@@ -776,8 +759,7 @@ TEST(PrintPointerTest, MemberFunctionPointer) {
HasPrefix
(
Print
(
&
Foo
::
MyVirtualMethod
),
Print
(
sizeof
((
&
Foo
::
MyVirtualMethod
)))
+
"-byte object "
));
int
(
Foo
::*
p
)(
char
)
=
NULL
;
// NOLINT
EXPECT_TRUE
(
HasPrefix
(
Print
(
p
),
Print
(
sizeof
(
p
))
+
"-byte object "
));
EXPECT_TRUE
(
HasPrefix
(
Print
(
p
),
Print
(
sizeof
(
p
))
+
"-byte object "
));
}
// Tests printing C arrays.
...
...
@@ -791,29 +773,26 @@ std::string PrintArrayHelper(T (&a)[N]) {
// One-dimensional array.
TEST
(
PrintArrayTest
,
OneDimensionalArray
)
{
int
a
[
5
]
=
{
1
,
2
,
3
,
4
,
5
};
int
a
[
5
]
=
{
1
,
2
,
3
,
4
,
5
};
EXPECT_EQ
(
"{ 1, 2, 3, 4, 5 }"
,
PrintArrayHelper
(
a
));
}
// Two-dimensional array.
TEST
(
PrintArrayTest
,
TwoDimensionalArray
)
{
int
a
[
2
][
5
]
=
{
{
1
,
2
,
3
,
4
,
5
},
{
6
,
7
,
8
,
9
,
0
}
};
int
a
[
2
][
5
]
=
{{
1
,
2
,
3
,
4
,
5
},
{
6
,
7
,
8
,
9
,
0
}};
EXPECT_EQ
(
"{ { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 0 } }"
,
PrintArrayHelper
(
a
));
}
// Array of const elements.
TEST
(
PrintArrayTest
,
ConstArray
)
{
const
bool
a
[
1
]
=
{
false
};
const
bool
a
[
1
]
=
{
false
};
EXPECT_EQ
(
"{ false }"
,
PrintArrayHelper
(
a
));
}
// char array without terminating NUL.
TEST
(
PrintArrayTest
,
CharArrayWithNoTerminatingNul
)
{
// Array a contains '\0' in the middle and doesn't end with '\0'.
char
a
[]
=
{
'H'
,
'\0'
,
'i'
};
char
a
[]
=
{
'H'
,
'\0'
,
'i'
};
EXPECT_EQ
(
"
\"
H
\\
0i
\"
(no terminating NUL)"
,
PrintArrayHelper
(
a
));
}
...
...
@@ -834,9 +813,7 @@ TEST(PrintArrayTest, Char8ArrayWithNoTerminatingNul) {
// char8_t array with terminating NUL.
TEST
(
PrintArrayTest
,
Char8ArrayWithTerminatingNul
)
{
const
char8_t
a
[]
=
u8"
\0
世界"
;
EXPECT_EQ
(
"u8
\"\\
0
\\
xE4
\\
xB8
\\
x96
\\
xE7
\\
x95
\\
x8C
\"
"
,
PrintArrayHelper
(
a
));
EXPECT_EQ
(
"u8
\"\\
0
\\
xE4
\\
xB8
\\
x96
\\
xE7
\\
x95
\\
x8C
\"
"
,
PrintArrayHelper
(
a
));
}
#endif
...
...
@@ -889,7 +866,7 @@ TEST(PrintArrayTest, ObjectArray) {
// Array with many elements.
TEST
(
PrintArrayTest
,
BigArray
)
{
int
a
[
100
]
=
{
1
,
2
,
3
};
int
a
[
100
]
=
{
1
,
2
,
3
};
EXPECT_EQ
(
"{ 1, 2, 3, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0 }"
,
PrintArrayHelper
(
a
));
}
...
...
@@ -909,11 +886,14 @@ TEST(PrintStringTest, StringAmbiguousHex) {
// '\x6', '\x6B', or '\x6BA'.
// a hex escaping sequence following by a decimal digit
EXPECT_EQ
(
"
\"
0
\\
x12
\"
\"
3
\"
"
,
Print
(
::
std
::
string
(
"0
\x12
"
"3"
)));
EXPECT_EQ
(
"
\"
0
\\
x12
\"
\"
3
\"
"
,
Print
(
::
std
::
string
(
"0
\x12
"
"3"
)));
// a hex escaping sequence following by a hex digit (lower-case)
EXPECT_EQ
(
"
\"
mm
\\
x6
\"
\"
bananas
\"
"
,
Print
(
::
std
::
string
(
"mm\x6"
"bananas"
)));
EXPECT_EQ
(
"
\"
mm
\\
x6
\"
\"
bananas
\"
"
,
Print
(
::
std
::
string
(
"mm\x6"
"bananas"
)));
// a hex escaping sequence following by a hex digit (upper-case)
EXPECT_EQ
(
"
\"
NOM
\\
x6
\"
\"
BANANA
\"
"
,
Print
(
::
std
::
string
(
"NOM\x6"
"BANANA"
)));
EXPECT_EQ
(
"
\"
NOM
\\
x6
\"
\"
BANANA
\"
"
,
Print
(
::
std
::
string
(
"NOM\x6"
"BANANA"
)));
// a hex escaping sequence following by a non-xdigit
EXPECT_EQ
(
"
\"
!
\\
x5-!
\"
"
,
Print
(
::
std
::
string
(
"!\x5-!"
)));
}
...
...
@@ -923,19 +903,21 @@ TEST(PrintStringTest, StringAmbiguousHex) {
// ::std::wstring.
TEST
(
PrintWideStringTest
,
StringInStdNamespace
)
{
const
wchar_t
s
[]
=
L"'
\"
?
\\\a\b\f\n\0\r\t\v\xD3\x576\x8D3\xC74D
a"
;
const
::
std
::
wstring
str
(
s
,
sizeof
(
s
)
/
sizeof
(
wchar_t
));
EXPECT_EQ
(
"L
\"
'
\\\"
?
\\\\\\
a
\\
b
\\
f
\\
n
\\
0
\\
r
\\
t
\\
v"
"
\\
xD3
\\
x576
\\
x8D3
\\
xC74D a
\\
0
\"
"
,
Print
(
str
));
const
::
std
::
wstring
str
(
s
,
sizeof
(
s
)
/
sizeof
(
wchar_t
));
EXPECT_EQ
(
"L
\"
'
\\\"
?
\\\\\\
a
\\
b
\\
f
\\
n
\\
0
\\
r
\\
t
\\
v"
"
\\
xD3
\\
x576
\\
x8D3
\\
xC74D a
\\
0
\"
"
,
Print
(
str
));
}
TEST
(
PrintWideStringTest
,
StringAmbiguousHex
)
{
// same for wide strings.
EXPECT_EQ
(
"L
\"
0
\\
x12
\"
L
\"
3
\"
"
,
Print
(
::
std
::
wstring
(
L"0
\x12
"
L"3"
)));
EXPECT_EQ
(
"L
\"
mm
\\
x6
\"
L
\"
bananas
\"
"
,
Print
(
::
std
::
wstring
(
L"mm\x6"
L"bananas"
)));
EXPECT_EQ
(
"L
\"
NOM
\\
x6
\"
L
\"
BANANA
\"
"
,
Print
(
::
std
::
wstring
(
L"NOM\x6"
L"BANANA"
)));
EXPECT_EQ
(
"L
\"
0
\\
x12
\"
L
\"
3
\"
"
,
Print
(
::
std
::
wstring
(
L"0
\x12
"
L"3"
)));
EXPECT_EQ
(
"L
\"
mm
\\
x6
\"
L
\"
bananas
\"
"
,
Print
(
::
std
::
wstring
(
L"mm\x6"
L"bananas"
)));
EXPECT_EQ
(
"L
\"
NOM
\\
x6
\"
L
\"
BANANA
\"
"
,
Print
(
::
std
::
wstring
(
L"NOM\x6"
L"BANANA"
)));
EXPECT_EQ
(
"L
\"
!
\\
x5-!
\"
"
,
Print
(
::
std
::
wstring
(
L"!\x5-!"
)));
}
#endif // GTEST_HAS_STD_WSTRING
...
...
@@ -1049,7 +1031,6 @@ TEST(PrintStlContainerTest, NonEmptyDeque) {
EXPECT_EQ
(
"{ 1, 3 }"
,
Print
(
non_empty
));
}
TEST
(
PrintStlContainerTest
,
OneElementHashMap
)
{
::
std
::
unordered_map
<
int
,
char
>
map1
;
map1
[
1
]
=
'a'
;
...
...
@@ -1065,11 +1046,9 @@ TEST(PrintStlContainerTest, HashMultiMap) {
const
std
::
string
result
=
Print
(
map1
);
EXPECT_TRUE
(
result
==
"{ (5, true), (5, false) }"
||
result
==
"{ (5, false), (5, true) }"
)
<<
" where Print(map1) returns
\"
"
<<
result
<<
"
\"
."
;
<<
" where Print(map1) returns
\"
"
<<
result
<<
"
\"
."
;
}
TEST
(
PrintStlContainerTest
,
HashSet
)
{
::
std
::
unordered_set
<
int
>
set1
;
set1
.
insert
(
1
);
...
...
@@ -1078,7 +1057,7 @@ TEST(PrintStlContainerTest, HashSet) {
TEST
(
PrintStlContainerTest
,
HashMultiSet
)
{
const
int
kSize
=
5
;
int
a
[
kSize
]
=
{
1
,
1
,
2
,
5
,
1
};
int
a
[
kSize
]
=
{
1
,
1
,
2
,
5
,
1
};
::
std
::
unordered_multiset
<
int
>
set1
(
a
,
a
+
kSize
);
// Elements of hash_multiset can be printed in any order.
...
...
@@ -1094,8 +1073,8 @@ TEST(PrintStlContainerTest, HashMultiSet) {
ASSERT_NE
(
isdigit
(
static_cast
<
unsigned
char
>
(
result
[
i
])),
0
);
numbers
.
push_back
(
result
[
i
]
-
'0'
);
}
else
{
EXPECT_EQ
(
expected_pattern
[
i
],
result
[
i
])
<<
" where result is "
<<
result
;
EXPECT_EQ
(
expected_pattern
[
i
],
result
[
i
])
<<
" where result is "
<<
result
;
}
}
...
...
@@ -1105,7 +1084,6 @@ TEST(PrintStlContainerTest, HashMultiSet) {
EXPECT_TRUE
(
std
::
equal
(
a
,
a
+
kSize
,
numbers
.
begin
()));
}
TEST
(
PrintStlContainerTest
,
List
)
{
const
std
::
string
a
[]
=
{
"hello"
,
"world"
};
const
list
<
std
::
string
>
strings
(
a
,
a
+
2
);
...
...
@@ -1135,20 +1113,19 @@ TEST(PrintStlContainerTest, MultiMap) {
}
TEST
(
PrintStlContainerTest
,
Set
)
{
const
unsigned
int
a
[]
=
{
3
,
0
,
5
};
const
unsigned
int
a
[]
=
{
3
,
0
,
5
};
set
<
unsigned
int
>
set1
(
a
,
a
+
3
);
EXPECT_EQ
(
"{ 0, 3, 5 }"
,
Print
(
set1
));
}
TEST
(
PrintStlContainerTest
,
MultiSet
)
{
const
int
a
[]
=
{
1
,
1
,
2
,
5
,
1
};
const
int
a
[]
=
{
1
,
1
,
2
,
5
,
1
};
multiset
<
int
>
set1
(
a
,
a
+
5
);
EXPECT_EQ
(
"{ 1, 1, 1, 2, 5 }"
,
Print
(
set1
));
}
TEST
(
PrintStlContainerTest
,
SinglyLinkedList
)
{
int
a
[]
=
{
9
,
2
,
8
};
int
a
[]
=
{
9
,
2
,
8
};
const
std
::
forward_list
<
int
>
ints
(
a
,
a
+
3
);
EXPECT_EQ
(
"{ 9, 2, 8 }"
,
Print
(
ints
));
}
...
...
@@ -1166,32 +1143,34 @@ TEST(PrintStlContainerTest, Vector) {
}
TEST
(
PrintStlContainerTest
,
LongSequence
)
{
const
int
a
[
100
]
=
{
1
,
2
,
3
};
const
int
a
[
100
]
=
{
1
,
2
,
3
};
const
vector
<
int
>
v
(
a
,
a
+
100
);
EXPECT_EQ
(
"{ 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "
"0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... }"
,
Print
(
v
));
EXPECT_EQ
(
"{ 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "
"0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... }"
,
Print
(
v
));
}
TEST
(
PrintStlContainerTest
,
NestedContainer
)
{
const
int
a1
[]
=
{
1
,
2
};
const
int
a2
[]
=
{
3
,
4
,
5
};
const
int
a1
[]
=
{
1
,
2
};
const
int
a2
[]
=
{
3
,
4
,
5
};
const
list
<
int
>
l1
(
a1
,
a1
+
2
);
const
list
<
int
>
l2
(
a2
,
a2
+
3
);
vector
<
list
<
int
>
>
v
;
vector
<
list
<
int
>>
v
;
v
.
push_back
(
l1
);
v
.
push_back
(
l2
);
EXPECT_EQ
(
"{ { 1, 2 }, { 3, 4, 5 } }"
,
Print
(
v
));
}
TEST
(
PrintStlContainerTest
,
OneDimensionalNativeArray
)
{
const
int
a
[
3
]
=
{
1
,
2
,
3
};
const
int
a
[
3
]
=
{
1
,
2
,
3
};
NativeArray
<
int
>
b
(
a
,
3
,
RelationToSourceReference
());
EXPECT_EQ
(
"{ 1, 2, 3 }"
,
Print
(
b
));
}
TEST
(
PrintStlContainerTest
,
TwoDimensionalNativeArray
)
{
const
int
a
[
2
][
3
]
=
{
{
1
,
2
,
3
},
{
4
,
5
,
6
}
};
const
int
a
[
2
][
3
]
=
{
{
1
,
2
,
3
},
{
4
,
5
,
6
}
};
NativeArray
<
int
[
3
]
>
b
(
a
,
2
,
RelationToSourceReference
());
EXPECT_EQ
(
"{ { 1, 2, 3 }, { 4, 5, 6 } }"
,
Print
(
b
));
}
...
...
@@ -1243,20 +1222,18 @@ TEST(PrintStdTupleTest, VariousSizes) {
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
// NOLINT
nullptr
,
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
Print
(
t10
));
}
// Nested tuples.
TEST
(
PrintStdTupleTest
,
NestedTuple
)
{
::
std
::
tuple
<
::
std
::
tuple
<
int
,
bool
>
,
char
>
nested
(
::
std
::
make_tuple
(
5
,
true
),
'a'
);
::
std
::
tuple
<::
std
::
tuple
<
int
,
bool
>
,
char
>
nested
(
::
std
::
make_tuple
(
5
,
true
),
'a'
);
EXPECT_EQ
(
"((5, true), 'a' (97, 0x61))"
,
Print
(
nested
));
}
TEST
(
PrintNullptrT
,
Basic
)
{
EXPECT_EQ
(
"(nullptr)"
,
Print
(
nullptr
));
}
TEST
(
PrintNullptrT
,
Basic
)
{
EXPECT_EQ
(
"(nullptr)"
,
Print
(
nullptr
));
}
TEST
(
PrintReferenceWrapper
,
Printable
)
{
int
x
=
5
;
...
...
@@ -1280,8 +1257,7 @@ TEST(PrintReferenceWrapper, Unprintable) {
// Unprintable types in the global namespace.
TEST
(
PrintUnprintableTypeTest
,
InGlobalNamespace
)
{
EXPECT_EQ
(
"1-byte object <00>"
,
Print
(
UnprintableTemplateInGlobal
<
char
>
()));
EXPECT_EQ
(
"1-byte object <00>"
,
Print
(
UnprintableTemplateInGlobal
<
char
>
()));
}
// Unprintable types in a user namespace.
...
...
@@ -1298,14 +1274,15 @@ struct Big {
};
TEST
(
PrintUnpritableTypeTest
,
BigObject
)
{
EXPECT_EQ
(
"257-byte object <00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 ... 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00>"
,
Print
(
Big
()));
EXPECT_EQ
(
"257-byte object <00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 ... 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00>"
,
Print
(
Big
()));
}
// Tests printing user-defined streamable types.
...
...
@@ -1348,8 +1325,7 @@ TEST(PrintStreamableTypeTest, PathLikeInUserNamespace) {
// Tests printing user-defined types that have a PrintTo() function.
TEST
(
PrintPrintableTypeTest
,
InUserNamespace
)
{
EXPECT_EQ
(
"PrintableViaPrintTo: 0"
,
Print
(
::
foo
::
PrintableViaPrintTo
()));
EXPECT_EQ
(
"PrintableViaPrintTo: 0"
,
Print
(
::
foo
::
PrintableViaPrintTo
()));
}
// Tests printing a pointer to a user-defined type that has a <<
...
...
@@ -1371,16 +1347,14 @@ TEST(PrintReferenceTest, PrintsAddressAndValue) {
int
n
=
5
;
EXPECT_EQ
(
"@"
+
PrintPointer
(
&
n
)
+
" 5"
,
PrintByRef
(
n
));
int
a
[
2
][
3
]
=
{
{
0
,
1
,
2
},
{
3
,
4
,
5
}
};
int
a
[
2
][
3
]
=
{{
0
,
1
,
2
},
{
3
,
4
,
5
}};
EXPECT_EQ
(
"@"
+
PrintPointer
(
a
)
+
" { { 0, 1, 2 }, { 3, 4, 5 } }"
,
PrintByRef
(
a
));
const
::
foo
::
UnprintableInFoo
x
;
EXPECT_EQ
(
"@"
+
PrintPointer
(
&
x
)
+
" 16-byte object "
"<EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>"
,
EXPECT_EQ
(
"@"
+
PrintPointer
(
&
x
)
+
" 16-byte object "
"<EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>"
,
PrintByRef
(
x
));
}
...
...
@@ -1396,33 +1370,29 @@ TEST(PrintReferenceTest, HandlesFunctionPointer) {
// this limitation.
const
std
::
string
fp_string
=
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
reinterpret_cast
<
internal
::
BiggestInt
>
(
fp
)));
EXPECT_EQ
(
"@"
+
fp_pointer_string
+
" "
+
fp_string
,
PrintByRef
(
fp
));
EXPECT_EQ
(
"@"
+
fp_pointer_string
+
" "
+
fp_string
,
PrintByRef
(
fp
));
}
// Tests that the universal printer prints a member function pointer
// passed by reference.
TEST
(
PrintReferenceTest
,
HandlesMemberFunctionPointer
)
{
int
(
Foo
::*
p
)(
char
ch
)
=
&
Foo
::
MyMethod
;
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p
),
"@"
+
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
&
p
))
+
" "
+
Print
(
sizeof
(
p
))
+
"-byte object "
));
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p
),
"@"
+
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
&
p
))
+
" "
+
Print
(
sizeof
(
p
))
+
"-byte object "
));
char
(
Foo
::*
p2
)(
int
n
)
=
&
Foo
::
MyVirtualMethod
;
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p2
),
"@"
+
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
&
p2
))
+
" "
+
Print
(
sizeof
(
p2
))
+
"-byte object "
));
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p2
),
"@"
+
PrintPointer
(
reinterpret_cast
<
const
void
*>
(
&
p2
))
+
" "
+
Print
(
sizeof
(
p2
))
+
"-byte object "
));
}
// Tests that the universal printer prints a member variable pointer
// passed by reference.
TEST
(
PrintReferenceTest
,
HandlesMemberVariablePointer
)
{
int
Foo
::*
p
=
&
Foo
::
value
;
// NOLINT
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p
),
"@"
+
PrintPointer
(
&
p
)
+
" "
+
Print
(
sizeof
(
p
))
+
"-byte object "
));
EXPECT_TRUE
(
HasPrefix
(
PrintByRef
(
p
),
"@"
+
PrintPointer
(
&
p
)
+
" "
+
Print
(
sizeof
(
p
))
+
"-byte object "
));
}
// Tests that FormatForComparisonFailureMessage(), which is used to print
...
...
@@ -1431,8 +1401,7 @@ TEST(PrintReferenceTest, HandlesMemberVariablePointer) {
// scalar
TEST
(
FormatForComparisonFailureMessageTest
,
WorksForScalar
)
{
EXPECT_STREQ
(
"123"
,
FormatForComparisonFailureMessage
(
123
,
124
).
c_str
());
EXPECT_STREQ
(
"123"
,
FormatForComparisonFailureMessage
(
123
,
124
).
c_str
());
}
// non-char pointer
...
...
@@ -1446,9 +1415,8 @@ TEST(FormatForComparisonFailureMessageTest, WorksForNonCharPointer) {
TEST
(
FormatForComparisonFailureMessageTest
,
FormatsNonCharArrayAsPointer
)
{
// In expression 'array == x', 'array' is compared by pointer.
// Therefore we want to print an array operand as a pointer.
int
n
[]
=
{
1
,
2
,
3
};
EXPECT_EQ
(
PrintPointer
(
n
),
FormatForComparisonFailureMessage
(
n
,
n
).
c_str
());
int
n
[]
=
{
1
,
2
,
3
};
EXPECT_EQ
(
PrintPointer
(
n
),
FormatForComparisonFailureMessage
(
n
,
n
).
c_str
());
}
// Tests formatting a char pointer when it's compared with another pointer.
...
...
@@ -1464,8 +1432,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsPointer) {
// const char*
const
char
*
s
=
"hello"
;
EXPECT_EQ
(
PrintPointer
(
s
),
FormatForComparisonFailureMessage
(
s
,
s
).
c_str
());
EXPECT_EQ
(
PrintPointer
(
s
),
FormatForComparisonFailureMessage
(
s
,
s
).
c_str
());
// char*
char
ch
=
'a'
;
...
...
@@ -1482,8 +1449,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsPointer) {
// const wchar_t*
const
wchar_t
*
s
=
L"hello"
;
EXPECT_EQ
(
PrintPointer
(
s
),
FormatForComparisonFailureMessage
(
s
,
s
).
c_str
());
EXPECT_EQ
(
PrintPointer
(
s
),
FormatForComparisonFailureMessage
(
s
,
s
).
c_str
());
// wchar_t*
wchar_t
ch
=
L'a'
;
...
...
@@ -1580,13 +1546,11 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsStdWString) {
// Useful for testing PrintToString(). We cannot use EXPECT_EQ()
// there as its implementation uses PrintToString(). The caller must
// ensure that 'value' has no side effect.
#define EXPECT_PRINT_TO_STRING_(value, expected_string)
\
EXPECT_TRUE(PrintToString(value) == (expected_string))
\
#define EXPECT_PRINT_TO_STRING_(value, expected_string) \
EXPECT_TRUE(PrintToString(value) == (expected_string)) \
<< " where " #value " prints as " << (PrintToString(value))
TEST
(
PrintToStringTest
,
WorksForScalar
)
{
EXPECT_PRINT_TO_STRING_
(
123
,
"123"
);
}
TEST
(
PrintToStringTest
,
WorksForScalar
)
{
EXPECT_PRINT_TO_STRING_
(
123
,
"123"
);
}
TEST
(
PrintToStringTest
,
WorksForPointerToConstChar
)
{
const
char
*
p
=
"hello"
;
...
...
@@ -1611,7 +1575,7 @@ TEST(PrintToStringTest, EscapesForPointerToNonConstChar) {
}
TEST
(
PrintToStringTest
,
WorksForArray
)
{
int
n
[
3
]
=
{
1
,
2
,
3
};
int
n
[
3
]
=
{
1
,
2
,
3
};
EXPECT_PRINT_TO_STRING_
(
n
,
"{ 1, 2, 3 }"
);
}
...
...
@@ -1628,7 +1592,7 @@ TEST(PrintToStringTest, WorksForCharArrayWithEmbeddedNul) {
EXPECT_PRINT_TO_STRING_
(
mutable_str_with_nul
,
"
\"
hello
\\
0 world
\"
"
);
}
TEST
(
PrintToStringTest
,
ContainsNonLatin
)
{
TEST
(
PrintToStringTest
,
ContainsNonLatin
)
{
// Test with valid UTF-8. Prints both in hex and as text.
std
::
string
non_ascii_str
=
::
std
::
string
(
"오전 4:30"
);
EXPECT_PRINT_TO_STRING_
(
non_ascii_str
,
...
...
@@ -1645,57 +1609,58 @@ TEST(IsValidUTF8Test, IllFormedUTF8) {
// as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is
// expected to fail, thus output does not contain "As Text:".
static
const
char
*
const
kTestdata
[][
2
]
=
{
// 2-byte lead byte followed by a single-byte character.
{
"
\xC3\x74
"
,
"
\"\\
xC3t
\"
"
},
// Valid 2-byte character followed by an orphan trail byte.
{
"
\xC3\x84\xA4
"
,
"
\"\\
xC3
\\
x84
\\
xA4
\"
"
},
// Lead byte without trail byte.
{
"abc
\xC3
"
,
"
\"
abc
\\
xC3
\"
"
},
// 3-byte lead byte, single-byte character, orphan trail byte.
{
"x
\xE2\x70\x94
"
,
"
\"
x
\\
xE2p
\\
x94
\"
"
},
// Truncated 3-byte character.
{
"
\xE2\x80
"
,
"
\"\\
xE2
\\
x80
\"
"
},
// Truncated 3-byte character followed by valid 2-byte char.
{
"
\xE2\x80\xC3\x84
"
,
"
\"\\
xE2
\\
x80
\\
xC3
\\
x84
\"
"
},
// Truncated 3-byte character followed by a single-byte character.
{
"
\xE2\x80\x7A
"
,
"
\"\\
xE2
\\
x80z
\"
"
},
// 3-byte lead byte followed by valid 3-byte character.
{
"
\xE2\xE2\x80\x94
"
,
"
\"\\
xE2
\\
xE2
\\
x80
\\
x94
\"
"
},
// 4-byte lead byte followed by valid 3-byte character.
{
"
\xF0\xE2\x80\x94
"
,
"
\"\\
xF0
\\
xE2
\\
x80
\\
x94
\"
"
},
// Truncated 4-byte character.
{
"
\xF0\xE2\x80
"
,
"
\"\\
xF0
\\
xE2
\\
x80
\"
"
},
// Invalid UTF-8 byte sequences embedded in other chars.
{
"abc
\xE2\x80\x94\xC3\x74
xyc"
,
"
\"
abc
\\
xE2
\\
x80
\\
x94
\\
xC3txyc
\"
"
},
{
"abc
\xC3\x84\xE2\x80\xC3\x84
xyz"
,
"
\"
abc
\\
xC3
\\
x84
\\
xE2
\\
x80
\\
xC3
\\
x84xyz
\"
"
},
// Non-shortest UTF-8 byte sequences are also ill-formed.
// The classics: xC0, xC1 lead byte.
{
"
\xC0\x80
"
,
"
\"\\
xC0
\\
x80
\"
"
},
{
"
\xC1\x81
"
,
"
\"\\
xC1
\\
x81
\"
"
},
// Non-shortest sequences.
{
"
\xE0\x80\x80
"
,
"
\"\\
xE0
\\
x80
\\
x80
\"
"
},
{
"
\xf0\x80\x80\x80
"
,
"
\"\\
xF0
\\
x80
\\
x80
\\
x80
\"
"
},
// Last valid code point before surrogate range, should be printed as text,
// too.
{
"
\xED\x9F\xBF
"
,
"
\"\\
xED
\\
x9F
\\
xBF
\"\n
As Text:
\"
\"
"
},
// Start of surrogate lead. Surrogates are not printed as text.
{
"
\xED\xA0\x80
"
,
"
\"\\
xED
\\
xA0
\\
x80
\"
"
},
// Last non-private surrogate lead.
{
"
\xED\xAD\xBF
"
,
"
\"\\
xED
\\
xAD
\\
xBF
\"
"
},
// First private-use surrogate lead.
{
"
\xED\xAE\x80
"
,
"
\"\\
xED
\\
xAE
\\
x80
\"
"
},
// Last private-use surrogate lead.
{
"
\xED\xAF\xBF
"
,
"
\"\\
xED
\\
xAF
\\
xBF
\"
"
},
// Mid-point of surrogate trail.
{
"
\xED\xB3\xBF
"
,
"
\"\\
xED
\\
xB3
\\
xBF
\"
"
},
// First valid code point after surrogate range, should be printed as text,
// too.
{
"
\xEE\x80\x80
"
,
"
\"\\
xEE
\\
x80
\\
x80
\"\n
As Text:
\"
\"
"
}
};
for
(
int
i
=
0
;
i
<
int
(
sizeof
(
kTestdata
)
/
sizeof
(
kTestdata
[
0
]));
++
i
)
{
static
const
char
*
const
kTestdata
[][
2
]
=
{
// 2-byte lead byte followed by a single-byte character.
{
"
\xC3\x74
"
,
"
\"\\
xC3t
\"
"
},
// Valid 2-byte character followed by an orphan trail byte.
{
"
\xC3\x84\xA4
"
,
"
\"\\
xC3
\\
x84
\\
xA4
\"
"
},
// Lead byte without trail byte.
{
"abc
\xC3
"
,
"
\"
abc
\\
xC3
\"
"
},
// 3-byte lead byte, single-byte character, orphan trail byte.
{
"x
\xE2\x70\x94
"
,
"
\"
x
\\
xE2p
\\
x94
\"
"
},
// Truncated 3-byte character.
{
"
\xE2\x80
"
,
"
\"\\
xE2
\\
x80
\"
"
},
// Truncated 3-byte character followed by valid 2-byte char.
{
"
\xE2\x80\xC3\x84
"
,
"
\"\\
xE2
\\
x80
\\
xC3
\\
x84
\"
"
},
// Truncated 3-byte character followed by a single-byte character.
{
"
\xE2\x80\x7A
"
,
"
\"\\
xE2
\\
x80z
\"
"
},
// 3-byte lead byte followed by valid 3-byte character.
{
"
\xE2\xE2\x80\x94
"
,
"
\"\\
xE2
\\
xE2
\\
x80
\\
x94
\"
"
},
// 4-byte lead byte followed by valid 3-byte character.
{
"
\xF0\xE2\x80\x94
"
,
"
\"\\
xF0
\\
xE2
\\
x80
\\
x94
\"
"
},
// Truncated 4-byte character.
{
"
\xF0\xE2\x80
"
,
"
\"\\
xF0
\\
xE2
\\
x80
\"
"
},
// Invalid UTF-8 byte sequences embedded in other chars.
{
"abc
\xE2\x80\x94\xC3\x74
xyc"
,
"
\"
abc
\\
xE2
\\
x80
\\
x94
\\
xC3txyc
\"
"
},
{
"abc
\xC3\x84\xE2\x80\xC3\x84
xyz"
,
"
\"
abc
\\
xC3
\\
x84
\\
xE2
\\
x80
\\
xC3
\\
x84xyz
\"
"
},
// Non-shortest UTF-8 byte sequences are also ill-formed.
// The classics: xC0, xC1 lead byte.
{
"
\xC0\x80
"
,
"
\"\\
xC0
\\
x80
\"
"
},
{
"
\xC1\x81
"
,
"
\"\\
xC1
\\
x81
\"
"
},
// Non-shortest sequences.
{
"
\xE0\x80\x80
"
,
"
\"\\
xE0
\\
x80
\\
x80
\"
"
},
{
"
\xf0\x80\x80\x80
"
,
"
\"\\
xF0
\\
x80
\\
x80
\\
x80
\"
"
},
// Last valid code point before surrogate range, should be printed as
// text,
// too.
{
"
\xED\x9F\xBF
"
,
"
\"\\
xED
\\
x9F
\\
xBF
\"\n
As Text:
\"
\"
"
},
// Start of surrogate lead. Surrogates are not printed as text.
{
"
\xED\xA0\x80
"
,
"
\"\\
xED
\\
xA0
\\
x80
\"
"
},
// Last non-private surrogate lead.
{
"
\xED\xAD\xBF
"
,
"
\"\\
xED
\\
xAD
\\
xBF
\"
"
},
// First private-use surrogate lead.
{
"
\xED\xAE\x80
"
,
"
\"\\
xED
\\
xAE
\\
x80
\"
"
},
// Last private-use surrogate lead.
{
"
\xED\xAF\xBF
"
,
"
\"\\
xED
\\
xAF
\\
xBF
\"
"
},
// Mid-point of surrogate trail.
{
"
\xED\xB3\xBF
"
,
"
\"\\
xED
\\
xB3
\\
xBF
\"
"
},
// First valid code point after surrogate range, should be printed as
// text,
// too.
{
"
\xEE\x80\x80
"
,
"
\"\\
xEE
\\
x80
\\
x80
\"\n
As Text:
\"
\"
"
}};
for
(
int
i
=
0
;
i
<
int
(
sizeof
(
kTestdata
)
/
sizeof
(
kTestdata
[
0
]));
++
i
)
{
EXPECT_PRINT_TO_STRING_
(
kTestdata
[
i
][
0
],
kTestdata
[
i
][
1
]);
}
}
...
...
@@ -1844,15 +1809,15 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsEmptyTuple) {
}
TEST
(
UniversalTersePrintTupleFieldsToStringsTestWithStd
,
PrintsOneTuple
)
{
Strings
result
=
UniversalTersePrintTupleFieldsToStrings
(
::
std
::
make_tuple
(
1
));
Strings
result
=
UniversalTersePrintTupleFieldsToStrings
(
::
std
::
make_tuple
(
1
));
ASSERT_EQ
(
1u
,
result
.
size
());
EXPECT_EQ
(
"1"
,
result
[
0
]);
}
TEST
(
UniversalTersePrintTupleFieldsToStringsTestWithStd
,
PrintsTwoTuple
)
{
Strings
result
=
UniversalTersePrintTupleFieldsToStrings
(
::
std
::
make_tuple
(
1
,
'a'
));
Strings
result
=
UniversalTersePrintTupleFieldsToStrings
(
::
std
::
make_tuple
(
1
,
'a'
));
ASSERT_EQ
(
2u
,
result
.
size
());
EXPECT_EQ
(
"1"
,
result
[
0
]);
EXPECT_EQ
(
"'a' (97, 0x61)"
,
result
[
1
]);
...
...
googletest/test/googletest-setuptestsuite-test_.cc
View file @
9e712372
...
...
@@ -27,23 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest.h"
class
SetupFailTest
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
ASSERT_EQ
(
""
,
"SET_UP_FAIL"
);
}
static
void
SetUpTestSuite
()
{
ASSERT_EQ
(
""
,
"SET_UP_FAIL"
);
}
};
TEST_F
(
SetupFailTest
,
NoopPassingTest
)
{}
class
TearDownFailTest
:
public
::
testing
::
Test
{
protected:
static
void
TearDownTestSuite
()
{
ASSERT_EQ
(
""
,
"TEAR_DOWN_FAIL"
);
}
static
void
TearDownTestSuite
()
{
ASSERT_EQ
(
""
,
"TEAR_DOWN_FAIL"
);
}
};
TEST_F
(
TearDownFailTest
,
NoopPassingTest
)
{}
googletest/test/googletest-shuffle-test_.cc
View file @
9e712372
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Verifies that test shuffling works.
#include "gtest/gtest.h"
...
...
@@ -88,7 +87,7 @@ class TestNamePrinter : public EmptyTestEventListener {
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
InitGoogleTest
(
&
argc
,
argv
);
// Replaces the default printer with TestNamePrinter, which prints
...
...
googletest/test/googletest-test-part-test.cc
View file @
9e712372
...
...
@@ -28,7 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest-test-part.h"
#include "gtest/gtest.h"
using
testing
::
Message
;
...
...
@@ -52,17 +51,14 @@ class TestPartResultTest : public Test {
TestPartResult
r1_
,
r2_
,
r3_
,
r4_
;
};
TEST_F
(
TestPartResultTest
,
ConstructorWorks
)
{
Message
message
;
message
<<
"something is terribly wrong"
;
message
<<
static_cast
<
const
char
*>
(
testing
::
internal
::
kStackTraceMarker
);
message
<<
"some unimportant stack trace"
;
const
TestPartResult
result
(
TestPartResult
::
kNonFatalFailure
,
"some_file.cc"
,
42
,
message
.
GetString
().
c_str
());
const
TestPartResult
result
(
TestPartResult
::
kNonFatalFailure
,
"some_file.cc"
,
42
,
message
.
GetString
().
c_str
());
EXPECT_EQ
(
TestPartResult
::
kNonFatalFailure
,
result
.
type
());
EXPECT_STREQ
(
"some_file.cc"
,
result
.
file_name
());
...
...
@@ -72,9 +68,7 @@ TEST_F(TestPartResultTest, ConstructorWorks) {
}
TEST_F
(
TestPartResultTest
,
ResultAccessorsWork
)
{
const
TestPartResult
success
(
TestPartResult
::
kSuccess
,
"file.cc"
,
42
,
const
TestPartResult
success
(
TestPartResult
::
kSuccess
,
"file.cc"
,
42
,
"message"
);
EXPECT_TRUE
(
success
.
passed
());
EXPECT_FALSE
(
success
.
failed
());
...
...
@@ -83,19 +77,15 @@ TEST_F(TestPartResultTest, ResultAccessorsWork) {
EXPECT_FALSE
(
success
.
skipped
());
const
TestPartResult
nonfatal_failure
(
TestPartResult
::
kNonFatalFailure
,
"file.cc"
,
42
,
"message"
);
"file.cc"
,
42
,
"message"
);
EXPECT_FALSE
(
nonfatal_failure
.
passed
());
EXPECT_TRUE
(
nonfatal_failure
.
failed
());
EXPECT_TRUE
(
nonfatal_failure
.
nonfatally_failed
());
EXPECT_FALSE
(
nonfatal_failure
.
fatally_failed
());
EXPECT_FALSE
(
nonfatal_failure
.
skipped
());
const
TestPartResult
fatal_failure
(
TestPartResult
::
kFatalFailure
,
"file.cc"
,
42
,
"message"
);
const
TestPartResult
fatal_failure
(
TestPartResult
::
kFatalFailure
,
"file.cc"
,
42
,
"message"
);
EXPECT_FALSE
(
fatal_failure
.
passed
());
EXPECT_TRUE
(
fatal_failure
.
failed
());
EXPECT_FALSE
(
fatal_failure
.
nonfatally_failed
());
...
...
googletest/test/googletest-throw-on-failure-test_.cc
View file @
9e712372
...
...
@@ -27,18 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Tests Google Test's throw-on-failure mode with exceptions disabled.
//
// This program must be compiled with exceptions disabled. It will be
// invoked by googletest-throw-on-failure-test.py, and is expected to exit
// with non-zero in the throw-on-failure mode or 0 otherwise.
#include "gtest/gtest.h"
#include <stdio.h> // for fflush, fprintf, NULL, etc.
#include <stdlib.h> // for exit
#include <
stdio.h> // for fflush, fprintf, NULL, etc.
#include <stdlib.h> // for exit
#include
<exception> // for set_terminate
#include <
exception> // for set_terminate
#include
"gtest/gtest.h"
// This terminate handler aborts the program using exit() rather than abort().
// This avoids showing pop-ups on Windows systems and core dumps on Unix-like
...
...
googletest/test/googletest-uninitialized-test_.cc
View file @
9e712372
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest.h"
TEST
(
DummyTest
,
Dummy
)
{
...
...
@@ -37,6 +36,4 @@ TEST(DummyTest, Dummy) {
// testing::InitGoogleTest() being called first.
}
int
main
()
{
return
RUN_ALL_TESTS
();
}
int
main
()
{
return
RUN_ALL_TESTS
();
}
googletest/test/gtest-typed-test2_test.cc
View file @
9e712372
...
...
@@ -27,11 +27,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include "test/gtest-typed-test_test.h"
#include "gtest/gtest.h"
#include "test/gtest-typed-test_test.h"
// Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together.
...
...
googletest/test/gtest-typed-test_test.cc
View file @
9e712372
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "test/gtest-typed-test_test.h"
#include <set>
...
...
@@ -50,9 +49,7 @@ class CommonTest : public Test {
// For some technical reason, SetUpTestSuite() and TearDownTestSuite()
// must be public.
public:
static
void
SetUpTestSuite
()
{
shared_
=
new
T
(
5
);
}
static
void
SetUpTestSuite
()
{
shared_
=
new
T
(
5
);
}
static
void
TearDownTestSuite
()
{
delete
shared_
;
...
...
@@ -130,8 +127,7 @@ TYPED_TEST(CommonTest, ValuesAreStillCorrect) {
// translation unit.
template
<
typename
T
>
class
TypedTest1
:
public
Test
{
};
class
TypedTest1
:
public
Test
{};
// Verifies that the second argument of TYPED_TEST_SUITE can be a
// single type.
...
...
@@ -139,8 +135,7 @@ TYPED_TEST_SUITE(TypedTest1, int);
TYPED_TEST
(
TypedTest1
,
A
)
{}
template
<
typename
T
>
class
TypedTest2
:
public
Test
{
};
class
TypedTest2
:
public
Test
{};
// Verifies that the second argument of TYPED_TEST_SUITE can be a
// Types<...> type list.
...
...
@@ -155,15 +150,12 @@ TYPED_TEST(TypedTest2, A) {}
namespace
library1
{
template
<
typename
T
>
class
NumericTest
:
public
Test
{
};
class
NumericTest
:
public
Test
{};
typedef
Types
<
int
,
long
>
NumericTypes
;
TYPED_TEST_SUITE
(
NumericTest
,
NumericTypes
);
TYPED_TEST
(
NumericTest
,
DefaultIsZero
)
{
EXPECT_EQ
(
0
,
TypeParam
());
}
TYPED_TEST
(
NumericTest
,
DefaultIsZero
)
{
EXPECT_EQ
(
0
,
TypeParam
());
}
}
// namespace library1
...
...
@@ -265,8 +257,7 @@ TEST_F(TypedTestSuitePStateDeathTest, DetectsTestAfterRegistration) {
// and SetUp()/TearDown() work correctly in type-parameterized tests.
template
<
typename
T
>
class
DerivedTest
:
public
CommonTest
<
T
>
{
};
class
DerivedTest
:
public
CommonTest
<
T
>
{};
TYPED_TEST_SUITE_P
(
DerivedTest
);
...
...
@@ -290,8 +281,8 @@ TYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) {
EXPECT_EQ
(
2
,
this
->
value_
);
}
REGISTER_TYPED_TEST_SUITE_P
(
DerivedTest
,
ValuesAreCorrect
,
ValuesAreStillCorrect
);
REGISTER_TYPED_TEST_SUITE_P
(
DerivedTest
,
ValuesAreCorrect
,
ValuesAreStillCorrect
);
typedef
Types
<
short
,
long
>
MyTwoTypes
;
INSTANTIATE_TYPED_TEST_SUITE_P
(
My
,
DerivedTest
,
MyTwoTypes
);
...
...
@@ -334,14 +325,13 @@ class TypeParametrizedTestNames {
};
INSTANTIATE_TYPED_TEST_SUITE_P
(
CustomName
,
TypeParametrizedTestWithNames
,
TwoTypes
,
TypeParametrizedTestNames
);
TwoTypes
,
TypeParametrizedTestNames
);
// Tests that multiple TYPED_TEST_SUITE_P's can be defined in the same
// translation unit.
template
<
typename
T
>
class
TypedTestP1
:
public
Test
{
};
class
TypedTestP1
:
public
Test
{};
TYPED_TEST_SUITE_P
(
TypedTestP1
);
...
...
@@ -359,8 +349,7 @@ using IntBeforeRegisterTypedTestSuiteP = int;
REGISTER_TYPED_TEST_SUITE_P
(
TypedTestP1
,
A
,
B
);
template
<
typename
T
>
class
TypedTestP2
:
public
Test
{
};
class
TypedTestP2
:
public
Test
{};
TYPED_TEST_SUITE_P
(
TypedTestP2
);
...
...
@@ -396,21 +385,17 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, ContainerTest, MyContainers);
namespace
library2
{
template
<
typename
T
>
class
NumericTest
:
public
Test
{
};
class
NumericTest
:
public
Test
{};
TYPED_TEST_SUITE_P
(
NumericTest
);
TYPED_TEST_P
(
NumericTest
,
DefaultIsZero
)
{
EXPECT_EQ
(
0
,
TypeParam
());
}
TYPED_TEST_P
(
NumericTest
,
DefaultIsZero
)
{
EXPECT_EQ
(
0
,
TypeParam
());
}
TYPED_TEST_P
(
NumericTest
,
ZeroIsLessThanOne
)
{
EXPECT_LT
(
TypeParam
(
0
),
TypeParam
(
1
));
}
REGISTER_TYPED_TEST_SUITE_P
(
NumericTest
,
DefaultIsZero
,
ZeroIsLessThanOne
);
REGISTER_TYPED_TEST_SUITE_P
(
NumericTest
,
DefaultIsZero
,
ZeroIsLessThanOne
);
typedef
Types
<
int
,
double
>
NumericTypes
;
INSTANTIATE_TYPED_TEST_SUITE_P
(
My
,
NumericTest
,
NumericTypes
);
...
...
@@ -418,20 +403,20 @@ static const char* GetTestName() {
return
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
name
();
}
// Test the stripping of space from test names
template
<
typename
T
>
class
TrimmedTest
:
public
Test
{
};
template
<
typename
T
>
class
TrimmedTest
:
public
Test
{};
TYPED_TEST_SUITE_P
(
TrimmedTest
);
TYPED_TEST_P
(
TrimmedTest
,
Test1
)
{
EXPECT_STREQ
(
"Test1"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test2
)
{
EXPECT_STREQ
(
"Test2"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test3
)
{
EXPECT_STREQ
(
"Test3"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test4
)
{
EXPECT_STREQ
(
"Test4"
,
GetTestName
());
}
TYPED_TEST_P
(
TrimmedTest
,
Test5
)
{
EXPECT_STREQ
(
"Test5"
,
GetTestName
());
}
REGISTER_TYPED_TEST_SUITE_P
(
TrimmedTest
,
Test1
,
Test2
,
Test3
,
Test4
,
Test5
);
// NOLINT
template
<
typename
T1
,
typename
T2
>
struct
MyPair
{};
REGISTER_TYPED_TEST_SUITE_P
(
TrimmedTest
,
Test1
,
Test2
,
Test3
,
Test4
,
Test5
);
// NOLINT
template
<
typename
T1
,
typename
T2
>
struct
MyPair
{};
// Be sure to try a type with a comma in its name just in case it matters.
typedef
Types
<
int
,
double
,
MyPair
<
int
,
int
>
>
TrimTypes
;
INSTANTIATE_TYPED_TEST_SUITE_P
(
My
,
TrimmedTest
,
TrimTypes
);
}
// namespace library2
googletest/test/gtest-typed-test_test.h
View file @
9e712372
...
...
@@ -40,21 +40,18 @@ using testing::Test;
// and gtest-typed-test2_test.cc.
template
<
typename
T
>
class
ContainerTest
:
public
Test
{
};
class
ContainerTest
:
public
Test
{};
TYPED_TEST_SUITE_P
(
ContainerTest
);
TYPED_TEST_P
(
ContainerTest
,
CanBeDefaultConstructed
)
{
TypeParam
container
;
}
TYPED_TEST_P
(
ContainerTest
,
CanBeDefaultConstructed
)
{
TypeParam
container
;
}
TYPED_TEST_P
(
ContainerTest
,
InitialSizeIsZero
)
{
TypeParam
container
;
EXPECT_EQ
(
0U
,
container
.
size
());
}
REGISTER_TYPED_TEST_SUITE_P
(
ContainerTest
,
CanBeDefaultConstructed
,
InitialSizeIsZero
);
REGISTER_TYPED_TEST_SUITE_P
(
ContainerTest
,
CanBeDefaultConstructed
,
InitialSizeIsZero
);
#endif // GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_
googletest/test/gtest-unittest-api_test.cc
View file @
9e712372
...
...
@@ -32,11 +32,12 @@
// This file contains tests verifying correctness of data provided via
// UnitTest's public methods.
#include "gtest/gtest.h"
#include <string.h> // For strcmp.
#include <algorithm>
#include "gtest/gtest.h"
using
::
testing
::
InitGoogleTest
;
namespace
testing
{
...
...
@@ -56,13 +57,12 @@ class UnitTestHelper {
static
TestSuite
const
**
GetSortedTestSuites
()
{
UnitTest
&
unit_test
=
*
UnitTest
::
GetInstance
();
auto
const
**
const
test_suites
=
new
const
TestSuite
*
[
static_cast
<
size_t
>
(
unit_test
.
total_test_suite_count
())];
unit_test
.
total_test_suite_count
())];
for
(
int
i
=
0
;
i
<
unit_test
.
total_test_suite_count
();
++
i
)
test_suites
[
i
]
=
unit_test
.
GetTestSuite
(
i
);
std
::
sort
(
test_suites
,
test_suites
+
unit_test
.
total_test_suite_count
(),
std
::
sort
(
test_suites
,
test_suites
+
unit_test
.
total_test_suite_count
(),
LessByName
<
TestSuite
>
());
return
test_suites
;
}
...
...
@@ -73,8 +73,7 @@ class UnitTestHelper {
UnitTest
&
unit_test
=
*
UnitTest
::
GetInstance
();
for
(
int
i
=
0
;
i
<
unit_test
.
total_test_suite_count
();
++
i
)
{
const
TestSuite
*
test_suite
=
unit_test
.
GetTestSuite
(
i
);
if
(
0
==
strcmp
(
test_suite
->
name
(),
name
))
return
test_suite
;
if
(
0
==
strcmp
(
test_suite
->
name
(),
name
))
return
test_suite
;
}
return
nullptr
;
}
...
...
@@ -84,7 +83,7 @@ class UnitTestHelper {
// array.
static
TestInfo
const
**
GetSortedTests
(
const
TestSuite
*
test_suite
)
{
TestInfo
const
**
const
tests
=
new
const
TestInfo
*
[
static_cast
<
size_t
>
(
test_suite
->
total_test_count
())];
test_suite
->
total_test_count
())];
for
(
int
i
=
0
;
i
<
test_suite
->
total_test_count
();
++
i
)
tests
[
i
]
=
test_suite
->
GetTestInfo
(
i
);
...
...
@@ -95,7 +94,8 @@ class UnitTestHelper {
}
};
template
<
typename
T
>
class
TestSuiteWithCommentTest
:
public
Test
{};
template
<
typename
T
>
class
TestSuiteWithCommentTest
:
public
Test
{};
TYPED_TEST_SUITE
(
TestSuiteWithCommentTest
,
Types
<
int
>
);
TYPED_TEST
(
TestSuiteWithCommentTest
,
Dummy
)
{}
...
...
@@ -319,7 +319,7 @@ class FinalSuccessChecker : public Environment {
}
// namespace internal
}
// namespace testing
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
InitGoogleTest
(
&
argc
,
argv
);
AddGlobalTestEnvironment
(
new
testing
::
internal
::
FinalSuccessChecker
());
...
...
googletest/test/gtest_assert_by_exception_test.cc
View file @
9e712372
...
...
@@ -27,16 +27,16 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Tests Google Test's assert-by-exception mode with exceptions enabled.
#include "gtest/gtest.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdexcept>
#include "gtest/gtest.h"
class
ThrowListener
:
public
testing
::
EmptyTestEventListener
{
void
OnTestPartResult
(
const
testing
::
TestPartResult
&
result
)
override
{
if
(
result
.
type
()
==
testing
::
TestPartResult
::
kFatalFailure
)
{
...
...
@@ -55,9 +55,7 @@ void Fail(const char* msg) {
exit
(
1
);
}
static
void
AssertFalse
()
{
ASSERT_EQ
(
2
,
3
)
<<
"Expected failure"
;
}
static
void
AssertFalse
()
{
ASSERT_EQ
(
2
,
3
)
<<
"Expected failure"
;
}
// Tests that an assertion failure throws a subclass of
// std::runtime_error.
...
...
@@ -65,21 +63,21 @@ TEST(Test, Test) {
// A successful assertion shouldn't throw.
try
{
EXPECT_EQ
(
3
,
3
);
}
catch
(...)
{
}
catch
(...)
{
Fail
(
"A successful assertion wrongfully threw."
);
}
// A successful assertion shouldn't throw.
try
{
EXPECT_EQ
(
3
,
4
);
}
catch
(...)
{
}
catch
(...)
{
Fail
(
"A failed non-fatal assertion wrongfully threw."
);
}
// A failed assertion should throw.
try
{
AssertFalse
();
}
catch
(
const
testing
::
AssertionException
&
e
)
{
}
catch
(
const
testing
::
AssertionException
&
e
)
{
if
(
strstr
(
e
.
what
(),
"Expected failure"
)
!=
nullptr
)
throw
;
printf
(
"%s"
,
...
...
@@ -87,7 +85,7 @@ TEST(Test, Test) {
"but the message is incorrect. Instead of containing
\"
Expected "
"failure
\"
, it is:
\n
"
);
Fail
(
e
.
what
());
}
catch
(...)
{
}
catch
(...)
{
Fail
(
"A failed assertion threw the wrong type of exception."
);
}
Fail
(
"A failed assertion should've thrown but didn't."
);
...
...
@@ -95,9 +93,7 @@ TEST(Test, Test) {
int
kTestForContinuingTest
=
0
;
TEST
(
Test
,
Test2
)
{
kTestForContinuingTest
=
1
;
}
TEST
(
Test
,
Test2
)
{
kTestForContinuingTest
=
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
googletest/test/gtest_environment_test.cc
View file @
9e712372
...
...
@@ -30,16 +30,15 @@
//
// Tests using global test environments.
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
namespace
{
enum
FailureType
{
NO_FAILURE
,
NON_FATAL_FAILURE
,
FATAL_FAILURE
};
enum
FailureType
{
NO_FAILURE
,
NON_FATAL_FAILURE
,
FATAL_FAILURE
};
// For testing using global test environments.
class
MyEnvironment
:
public
testing
::
Environment
{
...
...
@@ -79,9 +78,7 @@ class MyEnvironment : public testing::Environment {
// We call this function to set the type of failure SetUp() should
// generate.
void
set_failure_in_set_up
(
FailureType
type
)
{
failure_in_set_up_
=
type
;
}
void
set_failure_in_set_up
(
FailureType
type
)
{
failure_in_set_up_
=
type
;
}
// Was SetUp() run?
bool
set_up_was_run
()
const
{
return
set_up_was_run_
;
}
...
...
@@ -100,9 +97,7 @@ bool test_was_run;
// The sole purpose of this TEST is to enable us to check whether it
// was run.
TEST
(
FooTest
,
Bar
)
{
test_was_run
=
true
;
}
TEST
(
FooTest
,
Bar
)
{
test_was_run
=
true
;
}
// Prints the message and aborts the program if condition is false.
void
Check
(
bool
condition
,
const
char
*
msg
)
{
...
...
@@ -126,7 +121,7 @@ int RunAllTests(MyEnvironment* env, FailureType failure) {
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
// Registers a global test environment, and verifies that the
...
...
googletest/test/gtest_help_test_.cc
View file @
9e712372
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This program is meant to be run by gtest_help_test.py. Do not run
// it directly.
...
...
googletest/test/gtest_json_test_utils.py
View file @
9e712372
...
...
@@ -50,6 +50,8 @@ def normalize(obj):
elif
key
==
'failure'
:
value
=
re
.
sub
(
r
'^.*[/\\](.*:)\d+\n'
,
'
\\
1*
\n
'
,
value
)
return
re
.
sub
(
r
'Stack trace:\n(.|\n)*'
,
'Stack trace:
\n
*'
,
value
)
elif
key
==
'file'
:
return
re
.
sub
(
r
'^.*[/\\](.*)'
,
'
\\
1'
,
value
)
else
:
return
normalize
(
value
)
if
isinstance
(
obj
,
dict
):
...
...
googletest/test/gtest_main_unittest.cc
View file @
9e712372
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest.h"
// Tests that we don't have to define main() when we link to
...
...
@@ -35,8 +34,7 @@
namespace
{
TEST
(
GTestMainTest
,
ShouldSucceed
)
{
}
TEST
(
GTestMainTest
,
ShouldSucceed
)
{}
}
// namespace
...
...
googletest/test/gtest_pred_impl_unittest.cc
View file @
9e712372
...
...
@@ -46,8 +46,8 @@
#include <iostream>
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
// A user-defined data type.
struct
Bool
{
...
...
@@ -77,12 +77,8 @@ bool PredFunction1(T1 v1) {
// The following two functions are needed because a compiler doesn't have
// a context yet to know which template function must be instantiated.
bool
PredFunction1Int
(
int
v1
)
{
return
v1
>
0
;
}
bool
PredFunction1Bool
(
Bool
v1
)
{
return
v1
>
0
;
}
bool
PredFunction1Int
(
int
v1
)
{
return
v1
>
0
;
}
bool
PredFunction1Bool
(
Bool
v1
)
{
return
v1
>
0
;
}
// A unary predicate functor.
struct
PredFunctor1
{
...
...
@@ -94,22 +90,17 @@ struct PredFunctor1 {
// A unary predicate-formatter function.
template
<
typename
T1
>
testing
::
AssertionResult
PredFormatFunction1
(
const
char
*
e1
,
const
T1
&
v1
)
{
if
(
PredFunction1
(
v1
))
return
testing
::
AssertionSuccess
();
testing
::
AssertionResult
PredFormatFunction1
(
const
char
*
e1
,
const
T1
&
v1
)
{
if
(
PredFunction1
(
v1
))
return
testing
::
AssertionSuccess
();
return
testing
::
AssertionFailure
()
<<
e1
<<
" is expected to be positive, but evaluates to "
<<
v1
<<
"."
;
<<
e1
<<
" is expected to be positive, but evaluates to "
<<
v1
<<
"."
;
}
// A unary predicate-formatter functor.
struct
PredFormatFunctor1
{
template
<
typename
T1
>
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
T1
&
v1
)
const
{
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
T1
&
v1
)
const
{
return
PredFormatFunction1
(
e1
,
v1
);
}
};
...
...
@@ -127,9 +118,8 @@ class Predicate1Test : public testing::Test {
void
TearDown
()
override
{
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
// Verifies that the control flow in the test function is expected.
if
(
expected_to_finish_
&&
!
finished_
)
{
...
...
@@ -161,104 +151,100 @@ typedef Predicate1Test ASSERT_PRED1Test;
// Tests a successful EXPECT_PRED1 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED1Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED1
(
PredFunction1Int
,
++
n1_
);
EXPECT_PRED1
(
PredFunction1Int
,
++
n1_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED1Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED1
(
PredFunction1Bool
,
Bool
(
++
n1_
));
EXPECT_PRED1
(
PredFunction1Bool
,
Bool
(
++
n1_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED1Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED1
(
PredFunctor1
(),
++
n1_
);
EXPECT_PRED1
(
PredFunctor1
(),
++
n1_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED1Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED1
(
PredFunctor1
(),
Bool
(
++
n1_
));
EXPECT_PRED1
(
PredFunctor1
(),
Bool
(
++
n1_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED1 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED1Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED1
(
PredFunction1Int
,
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED1
(
PredFunction1Int
,
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED1Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED1
(
PredFunction1Bool
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED1
(
PredFunction1Bool
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED1Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED1
(
PredFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED1
(
PredFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED1Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED1
(
PredFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED1
(
PredFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED1 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED1Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED1
(
PredFunction1Int
,
++
n1_
);
ASSERT_PRED1
(
PredFunction1Int
,
++
n1_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED1Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED1
(
PredFunction1Bool
,
Bool
(
++
n1_
));
ASSERT_PRED1
(
PredFunction1Bool
,
Bool
(
++
n1_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED1Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED1
(
PredFunctor1
(),
++
n1_
);
ASSERT_PRED1
(
PredFunctor1
(),
++
n1_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED1Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED1
(
PredFunctor1
(),
Bool
(
++
n1_
));
ASSERT_PRED1
(
PredFunctor1
(),
Bool
(
++
n1_
));
finished_
=
true
;
}
...
...
@@ -266,147 +252,147 @@ TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED1Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED1
(
PredFunction1Int
,
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED1
(
PredFunction1Int
,
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED1Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED1
(
PredFunction1Bool
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED1
(
PredFunction1Bool
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED1Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED1
(
PredFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED1
(
PredFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED1Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED1
(
PredFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED1
(
PredFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
++
n1_
);
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
++
n1_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
++
n1_
));
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
++
n1_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
++
n1_
);
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
++
n1_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
++
n1_
));
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
++
n1_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT1Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
++
n1_
);
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
++
n1_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
++
n1_
));
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
++
n1_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
++
n1_
);
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
++
n1_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
++
n1_
));
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
++
n1_
));
finished_
=
true
;
}
...
...
@@ -414,44 +400,48 @@ TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunction1
,
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
n1_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT1 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT1Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT1
(
PredFormatFunctor1
(),
Bool
(
n1_
++
));
finished_
=
true
;
},
""
);
}
// Sample functions/functors for testing binary predicate assertions.
...
...
@@ -463,44 +453,33 @@ bool PredFunction2(T1 v1, T2 v2) {
// The following two functions are needed because a compiler doesn't have
// a context yet to know which template function must be instantiated.
bool
PredFunction2Int
(
int
v1
,
int
v2
)
{
return
v1
+
v2
>
0
;
}
bool
PredFunction2Bool
(
Bool
v1
,
Bool
v2
)
{
return
v1
+
v2
>
0
;
}
bool
PredFunction2Int
(
int
v1
,
int
v2
)
{
return
v1
+
v2
>
0
;
}
bool
PredFunction2Bool
(
Bool
v1
,
Bool
v2
)
{
return
v1
+
v2
>
0
;
}
// A binary predicate functor.
struct
PredFunctor2
{
template
<
typename
T1
,
typename
T2
>
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
)
{
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
)
{
return
v1
+
v2
>
0
;
}
};
// A binary predicate-formatter function.
template
<
typename
T1
,
typename
T2
>
testing
::
AssertionResult
PredFormatFunction2
(
const
char
*
e1
,
const
char
*
e2
,
const
T1
&
v1
,
const
T2
&
v2
)
{
if
(
PredFunction2
(
v1
,
v2
))
return
testing
::
AssertionSuccess
();
testing
::
AssertionResult
PredFormatFunction2
(
const
char
*
e1
,
const
char
*
e2
,
const
T1
&
v1
,
const
T2
&
v2
)
{
if
(
PredFunction2
(
v1
,
v2
))
return
testing
::
AssertionSuccess
();
return
testing
::
AssertionFailure
()
<<
e1
<<
" + "
<<
e2
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
<<
"."
;
<<
e1
<<
" + "
<<
e2
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
<<
"."
;
}
// A binary predicate-formatter functor.
struct
PredFormatFunctor2
{
template
<
typename
T1
,
typename
T2
>
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
T1
&
v1
,
const
T2
&
v2
)
const
{
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
T1
&
v1
,
const
T2
&
v2
)
const
{
return
PredFormatFunction2
(
e1
,
e2
,
v1
,
v2
);
}
};
...
...
@@ -518,12 +497,10 @@ class Predicate2Test : public testing::Test {
void
TearDown
()
override
{
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
// Verifies that the control flow in the test function is expected.
if
(
expected_to_finish_
&&
!
finished_
)
{
...
...
@@ -557,116 +534,100 @@ typedef Predicate2Test ASSERT_PRED2Test;
// Tests a successful EXPECT_PRED2 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED2Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED2
(
PredFunction2Int
,
++
n1_
,
++
n2_
);
EXPECT_PRED2
(
PredFunction2Int
,
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED2Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED2
(
PredFunction2Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
EXPECT_PRED2
(
PredFunction2Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED2Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED2
(
PredFunctor2
(),
++
n1_
,
++
n2_
);
EXPECT_PRED2
(
PredFunctor2
(),
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED2Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED2
(
PredFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
EXPECT_PRED2
(
PredFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED2 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED2Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunction2Int
,
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunction2Int
,
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED2Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunction2Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunction2Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED2Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunctor2
(),
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunctor2
(),
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED2Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED2
(
PredFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED2 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED2Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED2
(
PredFunction2Int
,
++
n1_
,
++
n2_
);
ASSERT_PRED2
(
PredFunction2Int
,
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED2Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED2
(
PredFunction2Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
ASSERT_PRED2
(
PredFunction2Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED2Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED2
(
PredFunctor2
(),
++
n1_
,
++
n2_
);
ASSERT_PRED2
(
PredFunctor2
(),
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED2Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED2
(
PredFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
ASSERT_PRED2
(
PredFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
...
...
@@ -674,163 +635,147 @@ TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED2Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunction2Int
,
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunction2Int
,
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED2Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunction2Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunction2Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED2Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunctor2
(),
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunctor2
(),
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED2Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED2
(
PredFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
++
n1_
,
++
n2_
);
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
++
n1_
,
++
n2_
);
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT2Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
++
n1_
,
++
n2_
);
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
++
n1_
,
++
n2_
);
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
++
n1_
,
++
n2_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
));
finished_
=
true
;
}
...
...
@@ -838,48 +783,48 @@ TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunction2
,
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
n1_
++
,
n2_
++
)
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
n1_
++
,
n2_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT2 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT2Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT2
(
PredFormatFunctor2
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
));
finished_
=
true
;
},
""
);
}
// Sample functions/functors for testing ternary predicate assertions.
...
...
@@ -891,49 +836,36 @@ bool PredFunction3(T1 v1, T2 v2, T3 v3) {
// The following two functions are needed because a compiler doesn't have
// a context yet to know which template function must be instantiated.
bool
PredFunction3Int
(
int
v1
,
int
v2
,
int
v3
)
{
return
v1
+
v2
+
v3
>
0
;
}
bool
PredFunction3Bool
(
Bool
v1
,
Bool
v2
,
Bool
v3
)
{
return
v1
+
v2
+
v3
>
0
;
}
bool
PredFunction3Int
(
int
v1
,
int
v2
,
int
v3
)
{
return
v1
+
v2
+
v3
>
0
;
}
bool
PredFunction3Bool
(
Bool
v1
,
Bool
v2
,
Bool
v3
)
{
return
v1
+
v2
+
v3
>
0
;
}
// A ternary predicate functor.
struct
PredFunctor3
{
template
<
typename
T1
,
typename
T2
,
typename
T3
>
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
)
{
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
)
{
return
v1
+
v2
+
v3
>
0
;
}
};
// A ternary predicate-formatter function.
template
<
typename
T1
,
typename
T2
,
typename
T3
>
testing
::
AssertionResult
PredFormatFunction3
(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
)
{
if
(
PredFunction3
(
v1
,
v2
,
v3
))
return
testing
::
AssertionSuccess
();
testing
::
AssertionResult
PredFormatFunction3
(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
)
{
if
(
PredFunction3
(
v1
,
v2
,
v3
))
return
testing
::
AssertionSuccess
();
return
testing
::
AssertionFailure
()
<<
e1
<<
" + "
<<
e2
<<
" + "
<<
e3
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
+
v3
<<
"."
;
<<
e1
<<
" + "
<<
e2
<<
" + "
<<
e3
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
+
v3
<<
"."
;
}
// A ternary predicate-formatter functor.
struct
PredFormatFunctor3
{
template
<
typename
T1
,
typename
T2
,
typename
T3
>
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
)
const
{
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
)
const
{
return
PredFormatFunction3
(
e1
,
e2
,
e3
,
v1
,
v2
,
v3
);
}
};
...
...
@@ -951,15 +883,12 @@ class Predicate3Test : public testing::Test {
void
TearDown
()
override
{
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n3_
)
<<
"The predicate assertion didn't evaluate argument 4 "
"exactly once."
;
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n3_
)
<<
"The predicate assertion didn't evaluate argument 4 "
"exactly once."
;
// Verifies that the control flow in the test function is expected.
if
(
expected_to_finish_
&&
!
finished_
)
{
...
...
@@ -995,128 +924,100 @@ typedef Predicate3Test ASSERT_PRED3Test;
// Tests a successful EXPECT_PRED3 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED3Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED3
(
PredFunction3Int
,
++
n1_
,
++
n2_
,
++
n3_
);
EXPECT_PRED3
(
PredFunction3Int
,
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED3Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED3
(
PredFunction3Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
EXPECT_PRED3
(
PredFunction3Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED3Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED3
(
PredFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
EXPECT_PRED3
(
PredFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED3Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED3
(
PredFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
EXPECT_PRED3
(
PredFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED3 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED3Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED3
(
PredFunction3Int
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED3
(
PredFunction3Int
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED3Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED3
(
PredFunction3Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED3
(
PredFunction3Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED3Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED3
(
PredFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED3
(
PredFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED3Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED3
(
PredFunctor3
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED3
(
PredFunctor3
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED3 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED3Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED3
(
PredFunction3Int
,
++
n1_
,
++
n2_
,
++
n3_
);
ASSERT_PRED3
(
PredFunction3Int
,
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED3Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED3
(
PredFunction3Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
ASSERT_PRED3
(
PredFunction3Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED3Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED3
(
PredFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
ASSERT_PRED3
(
PredFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED3Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED3
(
PredFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
ASSERT_PRED3
(
PredFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
...
...
@@ -1124,70 +1025,61 @@ TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED3Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED3
(
PredFunction3Int
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED3
(
PredFunction3Int
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED3Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED3
(
PredFunction3Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED3
(
PredFunction3Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED3Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED3
(
PredFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED3
(
PredFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED3Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED3
(
PredFunctor3
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED3
(
PredFunctor3
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
++
n1_
,
++
n2_
,
++
n3_
);
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
...
...
@@ -1195,19 +1087,14 @@ TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
// Tests a successful EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
...
...
@@ -1215,67 +1102,60 @@ TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
// Tests a failed EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
n1
_
++
),
Bool
(
n
2
_
++
)
,
Bool
(
n3_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
n1_
++
),
Bool
(
n2
_
++
),
Bool
(
n
3
_
++
)
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT3Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
n1
_
++
),
Bool
(
n
2
_
++
)
,
Bool
(
n3_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
n1_
++
),
Bool
(
n2
_
++
),
Bool
(
n
3
_
++
)
);
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
++
n1_
,
++
n2_
,
++
n3_
);
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
...
...
@@ -1283,19 +1163,14 @@ TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
// Tests a successful ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
++
n1_
,
++
n2_
,
++
n3_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
));
finished_
=
true
;
}
...
...
@@ -1304,52 +1179,50 @@ TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
n1
_
++
),
Bool
(
n
2
_
++
)
,
Bool
(
n3_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunction3
,
Bool
(
n1_
++
),
Bool
(
n2
_
++
),
Bool
(
n
3
_
++
)
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
n1_
++
,
n2_
++
,
n3_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT3 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT3Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
n1
_
++
),
Bool
(
n
2
_
++
)
,
Bool
(
n3_
++
))
;
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT3
(
PredFormatFunctor3
(),
Bool
(
n1_
++
),
Bool
(
n2
_
++
),
Bool
(
n
3
_
++
)
);
finished_
=
true
;
},
""
);
}
// Sample functions/functors for testing 4-ary predicate assertions.
...
...
@@ -1371,43 +1244,31 @@ bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
// A 4-ary predicate functor.
struct
PredFunctor4
{
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
>
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
)
{
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
)
{
return
v1
+
v2
+
v3
+
v4
>
0
;
}
};
// A 4-ary predicate-formatter function.
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
>
testing
::
AssertionResult
PredFormatFunction4
(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
)
{
if
(
PredFunction4
(
v1
,
v2
,
v3
,
v4
))
return
testing
::
AssertionSuccess
();
testing
::
AssertionResult
PredFormatFunction4
(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
)
{
if
(
PredFunction4
(
v1
,
v2
,
v3
,
v4
))
return
testing
::
AssertionSuccess
();
return
testing
::
AssertionFailure
()
<<
e1
<<
" + "
<<
e2
<<
" + "
<<
e3
<<
" + "
<<
e4
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
+
v3
+
v4
<<
"."
;
<<
e1
<<
" + "
<<
e2
<<
" + "
<<
e3
<<
" + "
<<
e4
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
+
v3
+
v4
<<
"."
;
}
// A 4-ary predicate-formatter functor.
struct
PredFormatFunctor4
{
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
>
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
)
const
{
return
PredFormatFunction4
(
e1
,
e2
,
e3
,
e4
,
v1
,
v2
,
v3
,
v4
);
}
...
...
@@ -1426,18 +1287,14 @@ class Predicate4Test : public testing::Test {
void
TearDown
()
override
{
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n3_
)
<<
"The predicate assertion didn't evaluate argument 4 "
"exactly once."
;
EXPECT_EQ
(
1
,
n4_
)
<<
"The predicate assertion didn't evaluate argument 5 "
"exactly once."
;
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n3_
)
<<
"The predicate assertion didn't evaluate argument 4 "
"exactly once."
;
EXPECT_EQ
(
1
,
n4_
)
<<
"The predicate assertion didn't evaluate argument 5 "
"exactly once."
;
// Verifies that the control flow in the test function is expected.
if
(
expected_to_finish_
&&
!
finished_
)
{
...
...
@@ -1475,21 +1332,14 @@ typedef Predicate4Test ASSERT_PRED4Test;
// Tests a successful EXPECT_PRED4 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED4Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED4
(
PredFunction4Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
EXPECT_PRED4
(
PredFunction4Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED4Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED4
(
PredFunction4Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
EXPECT_PRED4
(
PredFunction4Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
...
...
@@ -1497,21 +1347,14 @@ TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
// Tests a successful EXPECT_PRED4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED4Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED4
(
PredFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
EXPECT_PRED4
(
PredFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED4Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED4
(
PredFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
EXPECT_PRED4
(
PredFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
...
...
@@ -1519,73 +1362,60 @@ TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
// Tests a failed EXPECT_PRED4 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED4Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED4
(
PredFunction4Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED4
(
PredFunction4Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED4Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED4
(
PredFunction4Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED4
(
PredFunction4Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED4Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED4
(
PredFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED4
(
PredFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED4Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED4
(
PredFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED4
(
PredFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED4 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED4Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED4
(
PredFunction4Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
ASSERT_PRED4
(
PredFunction4Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED4Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED4
(
PredFunction4Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
ASSERT_PRED4
(
PredFunction4Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
...
...
@@ -1593,21 +1423,14 @@ TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
// Tests a successful ASSERT_PRED4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED4Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED4
(
PredFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
ASSERT_PRED4
(
PredFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED4Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED4
(
PredFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
ASSERT_PRED4
(
PredFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
...
...
@@ -1616,195 +1439,155 @@ TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED4Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED4
(
PredFunction4Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED4
(
PredFunction4Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED4Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED4
(
PredFunction4Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED4
(
PredFunction4Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED4Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED4
(
PredFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED4
(
PredFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED4Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED4
(
PredFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED4
(
PredFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT4Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
));
finished_
=
true
;
}
...
...
@@ -1812,56 +1595,50 @@ TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunction4
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT4 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT4Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT4
(
PredFormatFunctor4
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
));
finished_
=
true
;
},
""
);
}
// Sample functions/functors for testing 5-ary predicate assertions.
...
...
@@ -1883,10 +1660,7 @@ bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
// A 5-ary predicate functor.
struct
PredFunctor5
{
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
>
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
,
bool
operator
()(
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
,
const
T5
&
v5
)
{
return
v1
+
v2
+
v3
+
v4
+
v5
>
0
;
}
...
...
@@ -1894,37 +1668,26 @@ struct PredFunctor5 {
// A 5-ary predicate-formatter function.
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
>
testing
::
AssertionResult
PredFormatFunction5
(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
char
*
e5
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
,
const
T5
&
v5
)
{
if
(
PredFunction5
(
v1
,
v2
,
v3
,
v4
,
v5
))
return
testing
::
AssertionSuccess
();
testing
::
AssertionResult
PredFormatFunction5
(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
char
*
e5
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
,
const
T5
&
v5
)
{
if
(
PredFunction5
(
v1
,
v2
,
v3
,
v4
,
v5
))
return
testing
::
AssertionSuccess
();
return
testing
::
AssertionFailure
()
<<
e1
<<
" + "
<<
e2
<<
" + "
<<
e3
<<
" + "
<<
e4
<<
" + "
<<
e5
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
+
v3
+
v4
+
v5
<<
"."
;
<<
e1
<<
" + "
<<
e2
<<
" + "
<<
e3
<<
" + "
<<
e4
<<
" + "
<<
e5
<<
" is expected to be positive, but evaluates to "
<<
v1
+
v2
+
v3
+
v4
+
v5
<<
"."
;
}
// A 5-ary predicate-formatter functor.
struct
PredFormatFunctor5
{
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
>
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
char
*
e5
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
,
testing
::
AssertionResult
operator
()(
const
char
*
e1
,
const
char
*
e2
,
const
char
*
e3
,
const
char
*
e4
,
const
char
*
e5
,
const
T1
&
v1
,
const
T2
&
v2
,
const
T3
&
v3
,
const
T4
&
v4
,
const
T5
&
v5
)
const
{
return
PredFormatFunction5
(
e1
,
e2
,
e3
,
e4
,
e5
,
v1
,
v2
,
v3
,
v4
,
v5
);
}
...
...
@@ -1943,21 +1706,16 @@ class Predicate5Test : public testing::Test {
void
TearDown
()
override
{
// Verifies that each of the predicate's arguments was evaluated
// exactly once.
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n3_
)
<<
"The predicate assertion didn't evaluate argument 4 "
"exactly once."
;
EXPECT_EQ
(
1
,
n4_
)
<<
"The predicate assertion didn't evaluate argument 5 "
"exactly once."
;
EXPECT_EQ
(
1
,
n5_
)
<<
"The predicate assertion didn't evaluate argument 6 "
"exactly once."
;
EXPECT_EQ
(
1
,
n1_
)
<<
"The predicate assertion didn't evaluate argument 2 "
"exactly once."
;
EXPECT_EQ
(
1
,
n2_
)
<<
"The predicate assertion didn't evaluate argument 3 "
"exactly once."
;
EXPECT_EQ
(
1
,
n3_
)
<<
"The predicate assertion didn't evaluate argument 4 "
"exactly once."
;
EXPECT_EQ
(
1
,
n4_
)
<<
"The predicate assertion didn't evaluate argument 5 "
"exactly once."
;
EXPECT_EQ
(
1
,
n5_
)
<<
"The predicate assertion didn't evaluate argument 6 "
"exactly once."
;
// Verifies that the control flow in the test function is expected.
if
(
expected_to_finish_
&&
!
finished_
)
{
...
...
@@ -1997,152 +1755,106 @@ typedef Predicate5Test ASSERT_PRED5Test;
// Tests a successful EXPECT_PRED5 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED5Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED5
(
PredFunction5Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
EXPECT_PRED5
(
PredFunction5Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED5Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED5
(
PredFunction5Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
EXPECT_PRED5
(
PredFunction5Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED5Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED5
(
PredFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
EXPECT_PRED5
(
PredFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED5Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED5
(
PredFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
EXPECT_PRED5
(
PredFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED5 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED5Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED5
(
PredFunction5Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED5
(
PredFunction5Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED5Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED5
(
PredFunction5Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED5
(
PredFunction5Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED5Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED5
(
PredFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED5
(
PredFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED5Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED5
(
PredFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED5
(
PredFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED5 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED5Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED5
(
PredFunction5Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
ASSERT_PRED5
(
PredFunction5Int
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED5Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED5
(
PredFunction5Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
ASSERT_PRED5
(
PredFunction5Bool
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED5Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED5
(
PredFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
ASSERT_PRED5
(
PredFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED5Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED5
(
PredFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
ASSERT_PRED5
(
PredFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
...
...
@@ -2150,211 +1862,157 @@ TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED5Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED5
(
PredFunction5Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED5
(
PredFunction5Int
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED5Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED5
(
PredFunction5Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED5
(
PredFunction5Bool
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED5Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED5
(
PredFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED5
(
PredFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED5Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED5
(
PredFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED5
(
PredFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctionOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctionOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctorOnBuiltInTypeSuccess
)
{
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctorOnUserTypeSuccess
)
{
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
// Tests a failed EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctionOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctionOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctorOnBuiltInTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed EXPECT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
EXPECT_PRED_FORMAT5Test
,
FunctorOnUserTypeFailure
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_NONFATAL_FAILURE
(
{
// NOLINT
EXPECT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a successful ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctionOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctionOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctorOnBuiltInTypeSuccess
)
{
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
++
n1_
,
++
n2_
,
++
n3_
,
++
n4_
,
++
n5_
);
finished_
=
true
;
}
// Tests a successful ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctorOnUserTypeSuccess
)
{
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
++
n1_
),
Bool
(
++
n2_
),
Bool
(
++
n3_
),
Bool
(
++
n4_
),
Bool
(
++
n5_
));
finished_
=
true
;
}
...
...
@@ -2362,58 +2020,50 @@ TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
// predicate-formatter is a function on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctionOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a function on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctionOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunction5
,
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a built-in type (int).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctorOnBuiltInTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
n1_
++
,
n2_
++
,
n3_
++
,
n4_
++
,
n5_
++
);
finished_
=
true
;
},
""
);
}
// Tests a failed ASSERT_PRED_FORMAT5 where the
// predicate-formatter is a functor on a user-defined type (Bool).
TEST_F
(
ASSERT_PRED_FORMAT5Test
,
FunctorOnUserTypeFailure
)
{
expected_to_finish_
=
false
;
EXPECT_FATAL_FAILURE
({
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
EXPECT_FATAL_FAILURE
(
{
// NOLINT
ASSERT_PRED_FORMAT5
(
PredFormatFunctor5
(),
Bool
(
n1_
++
),
Bool
(
n2_
++
),
Bool
(
n3_
++
),
Bool
(
n4_
++
),
Bool
(
n5_
++
));
finished_
=
true
;
},
""
);
}
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment