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