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
d4f77c1e
Unverified
Commit
d4f77c1e
authored
Feb 27, 2018
by
Gennadiy Civil
Committed by
GitHub
Feb 27, 2018
Browse files
Merge branch 'master' into win-libcxx2
parents
3498a1ac
ac34e6c9
Changes
52
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
307 additions
and
135 deletions
+307
-135
googletest/test/gtest-death-test_test.cc
googletest/test/gtest-death-test_test.cc
+5
-1
googletest/test/gtest-param-test_test.cc
googletest/test/gtest-param-test_test.cc
+54
-9
googletest/test/gtest-printers_test.cc
googletest/test/gtest-printers_test.cc
+20
-8
googletest/test/gtest_all_test.cc
googletest/test/gtest_all_test.cc
+12
-12
googletest/test/gtest_assert_by_exception_test.cc
googletest/test/gtest_assert_by_exception_test.cc
+119
-0
googletest/test/gtest_env_var_test.py
googletest/test/gtest_env_var_test.py
+1
-1
googletest/test/gtest_env_var_test_.cc
googletest/test/gtest_env_var_test_.cc
+1
-0
googletest/test/gtest_main_unittest.cc
googletest/test/gtest_main_unittest.cc
+2
-2
googletest/test/gtest_test_utils.py
googletest/test/gtest_test_utils.py
+1
-1
googletest/test/gtest_uninitialized_test_.cc
googletest/test/gtest_uninitialized_test_.cc
+1
-1
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+90
-99
googletest/xcode/Scripts/versiongenerate.py
googletest/xcode/Scripts/versiongenerate.py
+1
-1
No files found.
googletest/test/gtest-death-test_test.cc
View file @
d4f77c1e
...
...
@@ -617,7 +617,11 @@ TEST_F(TestForDeathTest, ReturnIsFailure) {
TEST_F
(
TestForDeathTest
,
TestExpectDebugDeath
)
{
int
sideeffect
=
0
;
EXPECT_DEBUG_DEATH
(
DieInDebugElse12
(
&
sideeffect
),
"death.*DieInDebugElse12"
)
// Put the regex in a local variable to make sure we don't get an "unused"
// warning in opt mode.
const
char
*
regex
=
"death.*DieInDebugElse12"
;
EXPECT_DEBUG_DEATH
(
DieInDebugElse12
(
&
sideeffect
),
regex
)
<<
"Must accept a streamed message"
;
# ifdef NDEBUG
...
...
googletest/test/gtest-param-test_test.cc
View file @
d4f77c1e
...
...
@@ -41,8 +41,8 @@
# include <sstream>
# include <string>
# include <vector>
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# include "test/gtest-param-test_test.h"
using
::
std
::
vector
;
...
...
@@ -536,6 +536,51 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
VerifyGenerator
(
gen
,
expected_values
);
}
#if GTEST_LANG_CXX11
class
NonDefaultConstructAssignString
{
public:
NonDefaultConstructAssignString
(
const
std
::
string
&
s
)
:
str_
(
s
)
{}
const
std
::
string
&
str
()
const
{
return
str_
;
}
private:
std
::
string
str_
;
// Not default constructible
NonDefaultConstructAssignString
();
// Not assignable
void
operator
=
(
const
NonDefaultConstructAssignString
&
);
};
TEST
(
CombineTest
,
NonDefaultConstructAssign
)
{
const
ParamGenerator
<
tuple
<
int
,
NonDefaultConstructAssignString
>
>
gen
=
Combine
(
Values
(
0
,
1
),
Values
(
NonDefaultConstructAssignString
(
"A"
),
NonDefaultConstructAssignString
(
"B"
)));
ParamGenerator
<
tuple
<
int
,
NonDefaultConstructAssignString
>
>::
iterator
it
=
gen
.
begin
();
EXPECT_EQ
(
0
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"A"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_EQ
(
0
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"B"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_EQ
(
1
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"A"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_EQ
(
1
,
std
::
get
<
0
>
(
*
it
));
EXPECT_EQ
(
"B"
,
std
::
get
<
1
>
(
*
it
).
str
());
++
it
;
EXPECT_TRUE
(
it
==
gen
.
end
());
}
#endif // GTEST_LANG_CXX11
# endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being
...
...
@@ -811,8 +856,8 @@ class CustomFunctorNamingTest : public TestWithParam<std::string> {};
TEST_P
(
CustomFunctorNamingTest
,
CustomTestNames
)
{}
struct
CustomParamNameFunctor
{
std
::
string
operator
()(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
o
)
{
return
inf
o
.
param
;
std
::
string
operator
()(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
}
};
...
...
@@ -829,8 +874,8 @@ INSTANTIATE_TEST_CASE_P(AllAllowedCharacters,
CustomParamNameFunctor
());
inline
std
::
string
CustomParamNameFunction
(
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
o
)
{
return
inf
o
.
param
;
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
}
class
CustomFunctionNamingTest
:
public
TestWithParam
<
std
::
string
>
{};
...
...
@@ -848,11 +893,10 @@ INSTANTIATE_TEST_CASE_P(CustomParamNameFunction,
class
CustomLambdaNamingTest
:
public
TestWithParam
<
std
::
string
>
{};
TEST_P
(
CustomLambdaNamingTest
,
CustomTestNames
)
{}
INSTANTIATE_TEST_CASE_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
INSTANTIATE_TEST_CASE_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
Values
(
std
::
string
(
"LambdaName"
)),
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
tp
inf
o
)
{
return
tp
inf
o
.
param
;
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
inf
)
{
return
inf
.
param
;
});
#endif // GTEST_LANG_CXX11
...
...
@@ -1019,6 +1063,7 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
INSTANTIATE_TEST_CASE_P
(
RangeZeroToFive
,
ParameterizedDerivedTest
,
Range
(
0
,
5
));
int
main
(
int
argc
,
char
**
argv
)
{
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
...
...
googletest/test/gtest-printers_test.cc
View file @
d4f77c1e
...
...
@@ -837,22 +837,22 @@ TEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {
EXPECT_EQ
(
"AllowsGenericStreamingAndImplicitConversionTemplate"
,
Print
(
a
));
}
#if GTEST_HAS_
STRING_PIECE_
#if GTEST_HAS_
ABSL
// Tests printing
StringPiece
.
// Tests printing
::absl::string_view
.
TEST
(
PrintString
P
ie
ce
Test
,
SimpleString
P
ie
ce
)
{
const
StringPiece
sp
=
"Hello"
;
TEST
(
PrintString
V
ie
w
Test
,
SimpleString
V
ie
w
)
{
const
::
absl
::
string_view
sp
=
"Hello"
;
EXPECT_EQ
(
"
\"
Hello
\"
"
,
Print
(
sp
));
}
TEST
(
PrintString
P
ie
ce
Test
,
UnprintableCharacters
)
{
TEST
(
PrintString
V
ie
w
Test
,
UnprintableCharacters
)
{
const
char
str
[]
=
"NUL (
\0
) and
\r\t
"
;
const
StringPiece
sp
(
str
,
sizeof
(
str
)
-
1
);
const
::
absl
::
string_view
sp
(
str
,
sizeof
(
str
)
-
1
);
EXPECT_EQ
(
"
\"
NUL (
\\
0) and
\\
r
\\
t
\"
"
,
Print
(
sp
));
}
#endif // GTEST_HAS_
STRING_PIECE_
#endif // GTEST_HAS_
ABSL
// Tests printing STL containers.
...
...
@@ -1327,7 +1327,7 @@ TEST(FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer) {
}
// Tests formatting a char pointer when it's compared with another pointer.
// In this case we want to print it as a raw pointer, as the comparis
i
on is by
// In this case we want to print it as a raw pointer, as the comparison is by
// pointer.
// char pointer vs pointer
...
...
@@ -1765,5 +1765,17 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
#endif // GTEST_HAS_STD_TUPLE_
#if GTEST_HAS_ABSL
TEST
(
PrintOptionalTest
,
Basic
)
{
absl
::
optional
<
int
>
value
;
EXPECT_EQ
(
"(nullopt)"
,
PrintToString
(
value
));
value
=
{
7
};
EXPECT_EQ
(
"(7)"
,
PrintToString
(
value
));
EXPECT_EQ
(
"(1.1)"
,
PrintToString
(
absl
::
optional
<
double
>
{
1.1
}));
EXPECT_EQ
(
"(
\"
A
\"
)"
,
PrintToString
(
absl
::
optional
<
std
::
string
>
{
"A"
}));
}
#endif // GTEST_HAS_ABSL
}
// namespace gtest_printers_test
}
// namespace testing
googletest/test/gtest_all_test.cc
View file @
d4f77c1e
...
...
@@ -33,15 +33,15 @@
//
// Sometimes it's desirable to build most of Google Test's own tests
// by compiling a single file. This file serves this purpose.
#include "
test/
gtest-filepath_test.cc"
#include "
test/
gtest-linked_ptr_test.cc"
#include "
test/
gtest-message_test.cc"
#include "
test/
gtest-options_test.cc"
#include "
test/
gtest-port_test.cc"
#include "
test/
gtest_pred_impl_unittest.cc"
#include "
test/
gtest_prod_test.cc"
#include "
test/
gtest-test-part_test.cc"
#include "
test/
gtest-typed-test_test.cc"
#include "
test/
gtest-typed-test2_test.cc"
#include "
test/
gtest_unittest.cc"
#include "
test/
production.cc"
#include "gtest-filepath_test.cc"
#include "gtest-linked_ptr_test.cc"
#include "gtest-message_test.cc"
#include "gtest-options_test.cc"
#include "gtest-port_test.cc"
#include "gtest_pred_impl_unittest.cc"
#include "gtest_prod_test.cc"
#include "gtest-test-part_test.cc"
#include "gtest-typed-test_test.cc"
#include "gtest-typed-test2_test.cc"
#include "gtest_unittest.cc"
#include "production.cc"
googletest/test/gtest_assert_by_exception_test.cc
0 → 100644
View file @
d4f77c1e
// Copyright 2009, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Tests Google Test's assert-by-exception mode with exceptions enabled.
#include "gtest/gtest.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdexcept>
class
ThrowListener
:
public
testing
::
EmptyTestEventListener
{
void
OnTestPartResult
(
const
testing
::
TestPartResult
&
result
)
override
{
if
(
result
.
type
()
==
testing
::
TestPartResult
::
kFatalFailure
)
{
throw
testing
::
AssertionException
(
result
);
}
}
};
// Prints the given failure message and exits the program with
// non-zero. We use this instead of a Google Test assertion to
// indicate a failure, as the latter is been tested and cannot be
// relied on.
void
Fail
(
const
char
*
msg
)
{
printf
(
"FAILURE: %s
\n
"
,
msg
);
fflush
(
stdout
);
exit
(
1
);
}
static
void
AssertFalse
()
{
ASSERT_EQ
(
2
,
3
)
<<
"Expected failure"
;
}
// Tests that an assertion failure throws a subclass of
// std::runtime_error.
TEST
(
Test
,
Test
)
{
// A successful assertion shouldn't throw.
try
{
EXPECT_EQ
(
3
,
3
);
}
catch
(...)
{
Fail
(
"A successful assertion wrongfully threw."
);
}
// A successful assertion shouldn't throw.
try
{
EXPECT_EQ
(
3
,
4
);
}
catch
(...)
{
Fail
(
"A failed non-fatal assertion wrongfully threw."
);
}
// A failed assertion should throw.
try
{
AssertFalse
();
}
catch
(
const
testing
::
AssertionException
&
e
)
{
if
(
strstr
(
e
.
what
(),
"Expected failure"
)
!=
NULL
)
throw
;
printf
(
"%s"
,
"A failed assertion did throw an exception of the right type, "
"but the message is incorrect. Instead of containing
\"
Expected "
"failure
\"
, it is:
\n
"
);
Fail
(
e
.
what
());
}
catch
(...)
{
Fail
(
"A failed assertion threw the wrong type of exception."
);
}
Fail
(
"A failed assertion should've thrown but didn't."
);
}
int
kTestForContinuingTest
=
0
;
TEST
(
Test
,
Test2
)
{
// FIXME(sokolov): how to force Test2 to be after Test?
kTestForContinuingTest
=
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
UnitTest
::
GetInstance
()
->
listeners
().
Append
(
new
ThrowListener
);
int
result
=
RUN_ALL_TESTS
();
if
(
result
==
0
)
{
printf
(
"RUN_ALL_TESTS returned %d
\n
"
,
result
);
Fail
(
"Expected failure instead."
);
}
if
(
kTestForContinuingTest
==
0
)
{
Fail
(
"Should have continued with other tests, but did not."
);
}
return
0
;
}
googletest/test/gtest_env_var_test.py
View file @
d4f77c1e
...
...
@@ -92,7 +92,7 @@ class GTestEnvVarTest(gtest_test_utils.TestCase):
TestFlag
(
'print_time'
,
'0'
,
'1'
)
TestFlag
(
'repeat'
,
'999'
,
'1'
)
TestFlag
(
'throw_on_failure'
,
'1'
,
'0'
)
TestFlag
(
'death_test_style'
,
'threadsafe'
,
'fast'
)
TestFlag
(
'death_test_style'
,
'fast'
,
'threadsafe'
)
TestFlag
(
'catch_exceptions'
,
'0'
,
'1'
)
if
IS_LINUX
:
...
...
googletest/test/gtest_env_var_test_.cc
View file @
d4f77c1e
...
...
@@ -35,6 +35,7 @@
#include "gtest/gtest.h"
#include <iostream>
#include "src/gtest-internal-inl.h"
using
::
std
::
cout
;
...
...
googletest/test/gtest_main_unittest.cc
View file @
d4f77c1e
...
...
@@ -41,5 +41,5 @@ TEST(GTestMainTest, ShouldSucceed) {
}
// namespace
// We are using the main() function defined in
src/
gtest_main.cc, so
//
we
don't define it here.
// We are using the main() function defined in gtest_main.cc, so
we
// don't define it here.
googletest/test/gtest_test_utils.py
View file @
d4f77c1e
...
...
@@ -227,7 +227,7 @@ class Subprocess:
combined in a string.
"""
# The subprocess module is the prefer
r
able way of running programs
# The subprocess module is the preferable way of running programs
# since it is available and behaves consistently on all platforms,
# including Windows. But it is only available starting in python 2.4.
# In earlier python versions, we revert to the popen2 module, which is
...
...
googletest/test/gtest_uninitialized_test_.cc
View file @
d4f77c1e
...
...
@@ -34,7 +34,7 @@
TEST
(
DummyTest
,
Dummy
)
{
// This test doesn't verify anything. We just need it to create a
// realistic stage for testing the behavior of Google Test when
// RUN_ALL_TESTS() is called without
// RUN_ALL_TESTS() is called without
// testing::InitGoogleTest() being called first.
}
...
...
googletest/test/gtest_unittest.cc
View file @
d4f77c1e
This diff is collapsed.
Click to expand it.
googletest/xcode/Scripts/versiongenerate.py
View file @
d4f77c1e
...
...
@@ -29,7 +29,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""A script to prepare version informtion for use the gtest Info.plist file.
"""A script to prepare version inform
a
tion for use the gtest Info.plist file.
This script extracts the version information from the configure.ac file and
uses it to generate a header file containing the same information. The
...
...
Prev
1
2
3
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