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
f3a9fa6a
Unverified
Commit
f3a9fa6a
authored
Aug 16, 2018
by
Gennadiy Civil
Committed by
GitHub
Aug 16, 2018
Browse files
Merge branch 'master' into master
parents
6c093a23
490554aa
Changes
245
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
278 additions
and
65 deletions
+278
-65
googletest/test/googletest-test-part-test.cc
googletest/test/googletest-test-part-test.cc
+1
-4
googletest/test/googletest-test2_test.cc
googletest/test/googletest-test2_test.cc
+61
-0
googletest/test/googletest-throw-on-failure-test.py
googletest/test/googletest-throw-on-failure-test.py
+7
-9
googletest/test/googletest-throw-on-failure-test_.cc
googletest/test/googletest-throw-on-failure-test_.cc
+2
-3
googletest/test/googletest-tuple-test.cc
googletest/test/googletest-tuple-test.cc
+1
-2
googletest/test/googletest-uninitialized-test.py
googletest/test/googletest-uninitialized-test.py
+5
-8
googletest/test/googletest-uninitialized-test_.cc
googletest/test/googletest-uninitialized-test_.cc
+3
-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
+1
-2
googletest/test/gtest-typed-test_test.h
googletest/test/gtest-typed-test_test.h
+1
-2
googletest/test/gtest-unittest-api_test.cc
googletest/test/gtest-unittest-api_test.cc
+2
-3
googletest/test/gtest_all_test.cc
googletest/test/gtest_all_test.cc
+8
-9
googletest/test/gtest_assert_by_exception_test.cc
googletest/test/gtest_assert_by_exception_test.cc
+118
-0
googletest/test/gtest_environment_test.cc
googletest/test/gtest_environment_test.cc
+1
-5
googletest/test/gtest_help_test.py
googletest/test/gtest_help_test.py
+1
-3
googletest/test/gtest_help_test_.cc
googletest/test/gtest_help_test_.cc
+1
-2
googletest/test/gtest_json_test_utils.py
googletest/test/gtest_json_test_utils.py
+60
-0
googletest/test/gtest_main_unittest.cc
googletest/test/gtest_main_unittest.cc
+3
-4
googletest/test/gtest_no_test_unittest.cc
googletest/test/gtest_no_test_unittest.cc
+0
-2
googletest/test/gtest_pred_impl_unittest.cc
googletest/test/gtest_pred_impl_unittest.cc
+1
-1
No files found.
googletest/test/gtest-test-part
_
test.cc
→
googletest/test/g
oogle
test-test-part
-
test.cc
View file @
f3a9fa6a
...
...
@@ -26,9 +26,6 @@
// 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: mheule@google.com (Markus Heule)
//
#include "gtest/gtest-test-part.h"
...
...
@@ -203,6 +200,6 @@ TEST_F(TestPartResultArrayDeathTest, DiesWhenIndexIsOutOfBound) {
EXPECT_DEATH_IF_SUPPORTED
(
results
.
GetTestPartResult
(
1
),
""
);
}
//
TODO(mheule@google.com)
: Add a test for the class HasNewFatalFailureHelper.
//
FIXME
: Add a test for the class HasNewFatalFailureHelper.
}
// namespace
googletest/test/googletest-test2_test.cc
0 → 100644
View file @
f3a9fa6a
// Copyright 2008, 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.
//
// Tests for Google Test itself. This verifies that the basic constructs of
// Google Test work.
#include "gtest/gtest.h"
#include "googletest-param-test-test.h"
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
// Tests that generators defined in a different translation unit
// are functional. The test using extern_gen_2 is defined
// in googletest-param-test-test.cc.
ParamGenerator
<
int
>
extern_gen_2
=
Values
(
33
);
// Tests that a parameterized test case can be defined in one translation unit
// and instantiated in another. The test is defined in
// googletest-param-test-test.cc and ExternalInstantiationTest fixture class is
// defined in gtest-param-test_test.h.
INSTANTIATE_TEST_CASE_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
// in googletest-param-test-test.cc and
// InstantiationInMultipleTranslaionUnitsTest fixture is defined in
// gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P
(
Sequence2
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
googletest/test/gtest
_
throw
_
on
_
failure
_
test.py
→
googletest/test/g
oogle
test
-
throw
-
on
-
failure
-
test.py
View file @
f3a9fa6a
...
...
@@ -31,12 +31,10 @@
"""Tests Google Test's throw-on-failure mode with exceptions disabled.
This script invokes gtest
_
throw
_
on
_
failure
_
test_ (a program written with
This script invokes g
oogle
test
-
throw
-
on
-
failure
-
test_ (a program written with
Google Test) with different environments and command line flags.
"""
__author__
=
'wan@google.com (Zhanyong Wan)'
import
os
import
gtest_test_utils
...
...
@@ -46,10 +44,10 @@ import gtest_test_utils
# The command line flag for enabling/disabling the throw-on-failure mode.
THROW_ON_FAILURE
=
'gtest_throw_on_failure'
# Path to the gtest
_
throw
_
on
_
failure
_
test_ program, compiled with
# Path to the g
oogle
test
-
throw
-
on
-
failure
-
test_ program, compiled with
# exceptions disabled.
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
throw
_
on
_
failure
_
test_'
)
'g
oogle
test
-
throw
-
on
-
failure
-
test_'
)
# Utilities.
...
...
@@ -70,18 +68,18 @@ def SetEnvVar(env_var, value):
def
Run
(
command
):
"""Runs a command; returns True/False if its exit code is/isn't 0."""
print
(
'Running "%s". . .'
%
' '
.
join
(
command
)
)
print
'Running "%s". . .'
%
' '
.
join
(
command
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
return
p
.
exited
and
p
.
exit_code
==
0
# The tests.
TODO(wan@google.com)
: refactor the class to share common
# logic with code in gtest
_
break
_
on
_
failure
_
unittest.py.
# The tests.
FIXME
: refactor the class to share common
# logic with code in g
oogle
test
-
break
-
on
-
failure
-
unittest.py.
class
ThrowOnFailureTest
(
gtest_test_utils
.
TestCase
):
"""Tests the throw-on-failure mode."""
def
RunAndVerify
(
self
,
env_var_value
,
flag_value
,
should_fail
):
"""Runs gtest
_
throw
_
on
_
failure
_
test_ and verifies that it does
"""Runs g
oogle
test
-
throw
-
on
-
failure
-
test_ and verifies that it does
(or does not) exit with a non-zero code.
Args:
...
...
googletest/test/gtest
_
throw
_
on
_
failure
_
test_.cc
→
googletest/test/g
oogle
test
-
throw
-
on
-
failure
-
test_.cc
View file @
f3a9fa6a
...
...
@@ -26,13 +26,12 @@
// 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 throw-on-failure mode with exceptions disabled.
//
// This program must be compiled with exceptions disabled. It will be
// invoked by gtest
_
throw
_
on
_
failure
_
test.py, and is expected to exit
// invoked by g
oogle
test
-
throw
-
on
-
failure
-
test.py, and is expected to exit
// with non-zero in the throw-on-failure mode or 0 otherwise.
#include "gtest/gtest.h"
...
...
googletest/test/gtest-tuple
_
test.cc
→
googletest/test/g
oogle
test-tuple
-
test.cc
View file @
f3a9fa6a
...
...
@@ -26,8 +26,7 @@
// 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)
#include "gtest/internal/gtest-tuple.h"
#include <utility>
...
...
googletest/test/gtest
_
uninitialized
_
test.py
→
googletest/test/g
oogle
test
-
uninitialized
-
test.py
View file @
f3a9fa6a
...
...
@@ -31,12 +31,9 @@
"""Verifies that Google Test warns the user when not initialized properly."""
__author__
=
'wan@google.com (Zhanyong Wan)'
import
gtest_test_utils
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest_uninitialized_test_'
)
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'googletest-uninitialized-test_'
)
def
Assert
(
condition
):
...
...
@@ -46,8 +43,8 @@ def Assert(condition):
def
AssertEq
(
expected
,
actual
):
if
expected
!=
actual
:
print
(
'Expected: %s'
%
(
expected
,)
)
print
(
' Actual: %s'
%
(
actual
,)
)
print
'Expected: %s'
%
(
expected
,)
print
' Actual: %s'
%
(
actual
,)
raise
AssertionError
...
...
@@ -56,8 +53,8 @@ def TestExitCodeAndOutput(command):
# Verifies that 'command' exits with code 1.
p
=
gtest_test_utils
.
Subprocess
(
command
)
Assert
(
p
.
exited
)
Assert
Eq
(
1
,
p
.
exit_code
)
if
p
.
exited
and
p
.
exit_code
==
0
:
Assert
(
'IMPORTANT NOTICE'
in
p
.
output
);
Assert
(
'InitGoogleTest'
in
p
.
output
)
...
...
googletest/test/gtest
_
uninitialized
_
test_.cc
→
googletest/test/g
oogle
test
-
uninitialized
-
test_.cc
View file @
f3a9fa6a
...
...
@@ -26,16 +26,15 @@
// 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)
#include "gtest/gtest.h"
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
testing::InitGoogleTest() being
// called first.
// RUN_ALL_TESTS() is called without
//
testing::InitGoogleTest() being
called first.
}
int
main
()
{
...
...
googletest/test/gtest-typed-test2_test.cc
View file @
f3a9fa6a
...
...
@@ -26,8 +26,7 @@
// 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)
#include <vector>
...
...
googletest/test/gtest-typed-test_test.cc
View file @
f3a9fa6a
...
...
@@ -26,8 +26,7 @@
// 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)
#include "test/gtest-typed-test_test.h"
...
...
googletest/test/gtest-typed-test_test.h
View file @
f3a9fa6a
...
...
@@ -26,8 +26,7 @@
// 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)
#ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
#define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_
...
...
googletest/test/gtest-unittest-api_test.cc
View file @
f3a9fa6a
...
...
@@ -25,10 +25,9 @@
// 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: vladl@google.com (Vlad Losev)
//
// The Google C++ Testing Framework (Google Test)
// The Google C++ Testing and Mocking Framework (Google Test)
//
// This file contains tests verifying correctness of data provided via
// UnitTest's public methods.
...
...
googletest/test/gtest_all_test.cc
View file @
f3a9fa6a
...
...
@@ -26,21 +26,20 @@
// 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 for Google C++ Testing Framework (Google Test)
// Tests for Google C++ Testing and Mocking Framework (Google Test)
//
// 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/g
oogle
test-filepath
-
test.cc"
#include "test/g
oogle
test-linked
-
ptr
-
test.cc"
#include "test/g
oogle
test-message
-
test.cc"
#include "test/g
oogle
test-options
-
test.cc"
#include "test/g
oogle
test-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/g
oogle
test-test-part
-
test.cc"
#include "test/gtest-typed-test_test.cc"
#include "test/gtest-typed-test2_test.cc"
#include "test/gtest_unittest.cc"
...
...
googletest/test/gtest_assert_by_exception_test.cc
0 → 100644
View file @
f3a9fa6a
// 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.
// 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: 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_environment_test.cc
View file @
f3a9fa6a
...
...
@@ -26,18 +26,14 @@
// 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 using global test environments.
#include <stdlib.h>
#include <stdio.h>
#include "gtest/gtest.h"
#define GTEST_IMPLEMENTATION_ 1 // Required for the next #include.
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
GTEST_DECLARE_string_
(
filter
);
...
...
googletest/test/gtest_help_test.py
View file @
f3a9fa6a
...
...
@@ -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.
"""Tests the --help flag of Google C++ Testing Framework.
"""Tests the --help flag of Google C++ Testing
and Mocking
Framework.
SYNOPSIS
gtest_help_test.py --build_dir=BUILD/DIR
...
...
@@ -37,8 +37,6 @@ SYNOPSIS
gtest_help_test.py
"""
__author__
=
'wan@google.com (Zhanyong Wan)'
import
os
import
re
import
gtest_test_utils
...
...
googletest/test/gtest_help_test_.cc
View file @
f3a9fa6a
...
...
@@ -26,8 +26,7 @@
// 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)
// This program is meant to be run by gtest_help_test.py. Do not run
// it directly.
...
...
googletest/test/gtest_json_test_utils.py
0 → 100644
View file @
f3a9fa6a
# Copyright 2018, 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.
"""Unit test utilities for gtest_json_output."""
import
re
def
normalize
(
obj
):
"""Normalize output object.
Args:
obj: Google Test's JSON output object to normalize.
Returns:
Normalized output without any references to transient information that may
change from run to run.
"""
def
_normalize
(
key
,
value
):
if
key
==
'time'
:
return
re
.
sub
(
r
'^\d+(\.\d+)?s$'
,
'*'
,
value
)
elif
key
==
'timestamp'
:
return
re
.
sub
(
r
'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$'
,
'*'
,
value
)
elif
key
==
'failure'
:
value
=
re
.
sub
(
r
'^.*[/\\](.*:)\d+\n'
,
'
\\
1*
\n
'
,
value
)
return
re
.
sub
(
r
'Stack trace:\n(.|\n)*'
,
'Stack trace:
\n
*'
,
value
)
else
:
return
normalize
(
value
)
if
isinstance
(
obj
,
dict
):
return
{
k
:
_normalize
(
k
,
v
)
for
k
,
v
in
obj
.
items
()}
if
isinstance
(
obj
,
list
):
return
[
normalize
(
x
)
for
x
in
obj
]
else
:
return
obj
googletest/test/gtest_main_unittest.cc
View file @
f3a9fa6a
...
...
@@ -26,8 +26,7 @@
// 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)
#include "gtest/gtest.h"
...
...
@@ -41,5 +40,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_no_test_unittest.cc
View file @
f3a9fa6a
...
...
@@ -29,8 +29,6 @@
// Tests that a Google Test program that has no test defined can run
// successfully.
//
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest.h"
...
...
googletest/test/gtest_pred_impl_unittest.cc
View file @
f3a9fa6a
...
...
@@ -27,7 +27,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.
// This file is AUTOMATICALLY GENERATED on
10/31
/201
1
by command
// This file is AUTOMATICALLY GENERATED on
01/02
/201
8
by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// Regression test for gtest_pred_impl.h
...
...
Prev
1
…
7
8
9
10
11
12
13
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