Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
8965a6a0
Commit
8965a6a0
authored
Nov 04, 2011
by
vladlosev
Browse files
Improves conformance to the Google C++ Style Guide (by Greg Miller).
parent
829402ed
Changes
35
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
33 additions
and
30 deletions
+33
-30
src/gtest.cc
src/gtest.cc
+0
-2
src/gtest_main.cc
src/gtest_main.cc
+2
-3
test/gtest-death-test_test.cc
test/gtest-death-test_test.cc
+1
-0
test/gtest-linked_ptr_test.cc
test/gtest-linked_ptr_test.cc
+1
-2
test/gtest-listener_test.cc
test/gtest-listener_test.cc
+1
-1
test/gtest-param-test_test.cc
test/gtest-param-test_test.cc
+2
-0
test/gtest-param-test_test.h
test/gtest-param-test_test.h
+4
-2
test/gtest-port_test.cc
test/gtest-port_test.cc
+4
-4
test/gtest-printers_test.cc
test/gtest-printers_test.cc
+1
-1
test/gtest_environment_test.cc
test/gtest_environment_test.cc
+1
-0
test/gtest_no_test_unittest.cc
test/gtest_no_test_unittest.cc
+0
-1
test/gtest_output_test_.cc
test/gtest_output_test_.cc
+1
-0
test/gtest_pred_impl_unittest.cc
test/gtest_pred_impl_unittest.cc
+1
-1
test/gtest_repeat_test.cc
test/gtest_repeat_test.cc
+1
-1
test/gtest_unittest.cc
test/gtest_unittest.cc
+13
-12
No files found.
src/gtest.cc
View file @
8965a6a0
...
@@ -3864,7 +3864,6 @@ int UnitTest::Run() {
...
@@ -3864,7 +3864,6 @@ int UnitTest::Run() {
// process. In either case the user does not want to see pop-up dialogs
// process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected.
// about crashes - they are expected.
if
(
impl
()
->
catch_exceptions
()
||
in_death_test_child_process
)
{
if
(
impl
()
->
catch_exceptions
()
||
in_death_test_child_process
)
{
# if !GTEST_OS_WINDOWS_MOBILE
# if !GTEST_OS_WINDOWS_MOBILE
// SetErrorMode doesn't exist on CE.
// SetErrorMode doesn't exist on CE.
SetErrorMode
(
SEM_FAILCRITICALERRORS
|
SEM_NOALIGNMENTFAULTEXCEPT
|
SetErrorMode
(
SEM_FAILCRITICALERRORS
|
SEM_NOALIGNMENTFAULTEXCEPT
|
...
@@ -3895,7 +3894,6 @@ int UnitTest::Run() {
...
@@ -3895,7 +3894,6 @@ int UnitTest::Run() {
0x0
,
// Clear the following flags:
0x0
,
// Clear the following flags:
_WRITE_ABORT_MSG
|
_CALL_REPORTFAULT
);
// pop-up window, core dump.
_WRITE_ABORT_MSG
|
_CALL_REPORTFAULT
);
// pop-up window, core dump.
# endif
# endif
}
}
#endif // GTEST_HAS_SEH
#endif // GTEST_HAS_SEH
...
...
src/gtest_main.cc
View file @
8965a6a0
...
@@ -27,13 +27,12 @@
...
@@ -27,13 +27,12 @@
// (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 <
iostream
>
#include <
stdio.h
>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
GTEST_API_
int
main
(
int
argc
,
char
**
argv
)
{
GTEST_API_
int
main
(
int
argc
,
char
**
argv
)
{
std
::
cout
<<
"Running main() from gtest_main.cc
\n
"
;
printf
(
"Running main() from gtest_main.cc
\n
"
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
}
}
test/gtest-death-test_test.cc
View file @
8965a6a0
...
@@ -896,6 +896,7 @@ class MockDeathTest : public DeathTest {
...
@@ -896,6 +896,7 @@ class MockDeathTest : public DeathTest {
virtual
void
Abort
(
AbortReason
reason
)
{
virtual
void
Abort
(
AbortReason
reason
)
{
parent_
->
abort_args_
.
push_back
(
reason
);
parent_
->
abort_args_
.
push_back
(
reason
);
}
}
private:
private:
MockDeathTestFactory
*
const
parent_
;
MockDeathTestFactory
*
const
parent_
;
const
TestRole
role_
;
const
TestRole
role_
;
...
...
test/gtest-linked_ptr_test.cc
View file @
8965a6a0
...
@@ -148,8 +148,7 @@ TEST_F(LinkedPtrTest, GeneralTest) {
...
@@ -148,8 +148,7 @@ TEST_F(LinkedPtrTest, GeneralTest) {
"A0 dtor
\n
"
"A0 dtor
\n
"
"A3 dtor
\n
"
"A3 dtor
\n
"
"A1 dtor
\n
"
,
"A1 dtor
\n
"
,
history
->
GetString
().
c_str
()
history
->
GetString
().
c_str
());
);
}
}
}
// Unnamed namespace
}
// Unnamed namespace
test/gtest-listener_test.cc
View file @
8965a6a0
...
@@ -55,7 +55,7 @@ namespace internal {
...
@@ -55,7 +55,7 @@ namespace internal {
class
EventRecordingListener
:
public
TestEventListener
{
class
EventRecordingListener
:
public
TestEventListener
{
public:
public:
EventRecordingListener
(
const
char
*
name
)
:
name_
(
name
)
{}
explicit
EventRecordingListener
(
const
char
*
name
)
:
name_
(
name
)
{}
protected:
protected:
virtual
void
OnTestProgramStart
(
const
UnitTest
&
/*unit_test*/
)
{
virtual
void
OnTestProgramStart
(
const
UnitTest
&
/*unit_test*/
)
{
...
...
test/gtest-param-test_test.cc
View file @
8965a6a0
...
@@ -606,6 +606,7 @@ class TestGenerationEnvironment : public ::testing::Environment {
...
@@ -606,6 +606,7 @@ class TestGenerationEnvironment : public ::testing::Environment {
<<
"has not been run as expected."
;
<<
"has not been run as expected."
;
}
}
}
}
private:
private:
TestGenerationEnvironment
()
:
fixture_constructor_count_
(
0
),
set_up_count_
(
0
),
TestGenerationEnvironment
()
:
fixture_constructor_count_
(
0
),
set_up_count_
(
0
),
tear_down_count_
(
0
),
test_body_count_
(
0
)
{}
tear_down_count_
(
0
),
test_body_count_
(
0
)
{}
...
@@ -674,6 +675,7 @@ class TestGenerationTest : public TestWithParam<int> {
...
@@ -674,6 +675,7 @@ class TestGenerationTest : public TestWithParam<int> {
EXPECT_TRUE
(
collected_parameters_
==
expected_values
);
EXPECT_TRUE
(
collected_parameters_
==
expected_values
);
}
}
protected:
protected:
int
current_parameter_
;
int
current_parameter_
;
static
vector
<
int
>
collected_parameters_
;
static
vector
<
int
>
collected_parameters_
;
...
...
test/gtest-param-test_test.h
View file @
8965a6a0
...
@@ -43,12 +43,14 @@
...
@@ -43,12 +43,14 @@
// 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
InstantiationInMultipleTranslaionUnitsTest
class
InstantiationInMultipleTranslaionUnitsTest
:
public
::
testing
::
TestWithParam
<
int
>
{};
:
public
::
testing
::
TestWithParam
<
int
>
{
};
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_HAS_PARAM_TEST
...
...
test/gtest-port_test.cc
View file @
8965a6a0
...
@@ -92,7 +92,7 @@ TEST(ImplicitCastTest, CanUseInheritance) {
...
@@ -92,7 +92,7 @@ TEST(ImplicitCastTest, CanUseInheritance) {
class
Castable
{
class
Castable
{
public:
public:
Castable
(
bool
*
converted
)
:
converted_
(
converted
)
{}
explicit
Castable
(
bool
*
converted
)
:
converted_
(
converted
)
{}
operator
Base
()
{
operator
Base
()
{
*
converted_
=
true
;
*
converted_
=
true
;
return
Base
();
return
Base
();
...
@@ -111,7 +111,7 @@ TEST(ImplicitCastTest, CanUseNonConstCastOperator) {
...
@@ -111,7 +111,7 @@ TEST(ImplicitCastTest, CanUseNonConstCastOperator) {
class
ConstCastable
{
class
ConstCastable
{
public:
public:
ConstCastable
(
bool
*
converted
)
:
converted_
(
converted
)
{}
explicit
ConstCastable
(
bool
*
converted
)
:
converted_
(
converted
)
{}
operator
Base
()
const
{
operator
Base
()
const
{
*
converted_
=
true
;
*
converted_
=
true
;
return
Base
();
return
Base
();
...
@@ -224,7 +224,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
...
@@ -224,7 +224,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
GTEST_CHECK_
(
true
);
GTEST_CHECK_
(
true
);
}
}
switch
(
0
)
switch
(
0
)
case
0
:
case
0
:
GTEST_CHECK_
(
true
)
<<
"Check failed in switch case"
;
GTEST_CHECK_
(
true
)
<<
"Check failed in switch case"
;
}
}
...
@@ -929,7 +929,7 @@ TEST(CaptureTest, CapturesStdoutAndStderr) {
...
@@ -929,7 +929,7 @@ TEST(CaptureTest, CapturesStdoutAndStderr) {
TEST
(
CaptureDeathTest
,
CannotReenterStdoutCapture
)
{
TEST
(
CaptureDeathTest
,
CannotReenterStdoutCapture
)
{
CaptureStdout
();
CaptureStdout
();
EXPECT_DEATH_IF_SUPPORTED
(
CaptureStdout
()
;
,
EXPECT_DEATH_IF_SUPPORTED
(
CaptureStdout
(),
"Only one stdout capturer can exist at a time"
);
"Only one stdout capturer can exist at a time"
);
GetCapturedStdout
();
GetCapturedStdout
();
...
...
test/gtest-printers_test.cc
View file @
8965a6a0
...
@@ -841,7 +841,7 @@ TEST(PrintStlContainerTest, HashMultiSet) {
...
@@ -841,7 +841,7 @@ TEST(PrintStlContainerTest, HashMultiSet) {
std
::
vector
<
int
>
numbers
;
std
::
vector
<
int
>
numbers
;
for
(
size_t
i
=
0
;
i
!=
result
.
length
();
i
++
)
{
for
(
size_t
i
=
0
;
i
!=
result
.
length
();
i
++
)
{
if
(
expected_pattern
[
i
]
==
'd'
)
{
if
(
expected_pattern
[
i
]
==
'd'
)
{
ASSERT_
TRU
E
(
isdigit
(
static_cast
<
unsigned
char
>
(
result
[
i
]))
!=
0
);
ASSERT_
N
E
(
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
])
<<
" where result is "
...
...
test/gtest_environment_test.cc
View file @
8965a6a0
...
@@ -96,6 +96,7 @@ class MyEnvironment : public testing::Environment {
...
@@ -96,6 +96,7 @@ class MyEnvironment : public testing::Environment {
// Was TearDown() run?
// Was TearDown() run?
bool
tear_down_was_run
()
const
{
return
tear_down_was_run_
;
}
bool
tear_down_was_run
()
const
{
return
tear_down_was_run_
;
}
private:
private:
FailureType
failure_in_set_up_
;
FailureType
failure_in_set_up_
;
bool
set_up_was_run_
;
bool
set_up_was_run_
;
...
...
test/gtest_no_test_unittest.cc
View file @
8965a6a0
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
test/gtest_output_test_.cc
View file @
8965a6a0
...
@@ -378,6 +378,7 @@ class FatalFailureInFixtureConstructorTest : public testing::Test {
...
@@ -378,6 +378,7 @@ class FatalFailureInFixtureConstructorTest : public testing::Test {
<<
"We should never get here, as the test fixture c'tor "
<<
"We should never get here, as the test fixture c'tor "
<<
"had a fatal failure."
;
<<
"had a fatal failure."
;
}
}
private:
private:
void
Init
()
{
void
Init
()
{
FAIL
()
<<
"Expected failure #1, in the test fixture c'tor."
;
FAIL
()
<<
"Expected failure #1, in the test fixture c'tor."
;
...
...
test/gtest_pred_impl_unittest.cc
View file @
8965a6a0
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
// (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 file is AUTOMATICALLY GENERATED on
09/24
/201
0
by command
// This file is AUTOMATICALLY GENERATED on
10/31
/201
1
by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// Regression test for gtest_pred_impl.h
// Regression test for gtest_pred_impl.h
...
...
test/gtest_repeat_test.cc
View file @
8965a6a0
...
@@ -71,7 +71,7 @@ namespace {
...
@@ -71,7 +71,7 @@ namespace {
<< "Which is: " << expected_val << "\n";\
<< "Which is: " << expected_val << "\n";\
::testing::internal::posix::Abort();\
::testing::internal::posix::Abort();\
}\
}\
} while(::testing::internal::AlwaysFalse())
} while
(::testing::internal::AlwaysFalse())
// Used for verifying that global environment set-up and tear-down are
// Used for verifying that global environment set-up and tear-down are
...
...
test/gtest_unittest.cc
View file @
8965a6a0
...
@@ -33,8 +33,6 @@
...
@@ -33,8 +33,6 @@
// Google Test work.
// Google Test work.
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include <vector>
#include <ostream>
// Verifies that the command line flag variables can be accessed
// Verifies that the command line flag variables can be accessed
// in code once <gtest/gtest.h> has been #included.
// in code once <gtest/gtest.h> has been #included.
...
@@ -58,6 +56,15 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
...
@@ -58,6 +56,15 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
EXPECT_TRUE
(
dummy
||
!
dummy
);
// Suppresses warning that dummy is unused.
EXPECT_TRUE
(
dummy
||
!
dummy
);
// Suppresses warning that dummy is unused.
}
}
#include <limits.h> // For INT_MAX.
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <map>
#include <vector>
#include <ostream>
#include "gtest/gtest-spi.h"
#include "gtest/gtest-spi.h"
// Indicates that this translation unit is part of Google Test's
// Indicates that this translation unit is part of Google Test's
...
@@ -69,13 +76,6 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
...
@@ -69,13 +76,6 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#undef GTEST_IMPLEMENTATION_
#include <limits.h> // For INT_MAX.
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <map>
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
...
@@ -1141,7 +1141,7 @@ TEST(StringTest, Equals) {
...
@@ -1141,7 +1141,7 @@ TEST(StringTest, Equals) {
EXPECT_TRUE
(
foo
==
"foo"
);
// NOLINT
EXPECT_TRUE
(
foo
==
"foo"
);
// NOLINT
const
String
bar
(
"x
\0
y"
,
3
);
const
String
bar
(
"x
\0
y"
,
3
);
EXPECT_
FALS
E
(
bar
==
"x"
);
EXPECT_
N
E
(
bar
,
"x"
);
}
}
// Tests String::operator!=().
// Tests String::operator!=().
...
@@ -1163,7 +1163,7 @@ TEST(StringTest, NotEquals) {
...
@@ -1163,7 +1163,7 @@ TEST(StringTest, NotEquals) {
EXPECT_FALSE
(
foo
!=
"foo"
);
// NOLINT
EXPECT_FALSE
(
foo
!=
"foo"
);
// NOLINT
const
String
bar
(
"x
\0
y"
,
3
);
const
String
bar
(
"x
\0
y"
,
3
);
EXPECT_
TRU
E
(
bar
!=
"x"
);
EXPECT_
N
E
(
bar
,
"x"
);
}
}
// Tests String::length().
// Tests String::length().
...
@@ -1902,6 +1902,7 @@ class GTestFlagSaverTest : public Test {
...
@@ -1902,6 +1902,7 @@ class GTestFlagSaverTest : public Test {
GTEST_FLAG
(
stream_result_to
)
=
"localhost:1234"
;
GTEST_FLAG
(
stream_result_to
)
=
"localhost:1234"
;
GTEST_FLAG
(
throw_on_failure
)
=
true
;
GTEST_FLAG
(
throw_on_failure
)
=
true
;
}
}
private:
private:
// For saving Google Test flags during this test case.
// For saving Google Test flags during this test case.
static
GTestFlagSaver
*
saver_
;
static
GTestFlagSaver
*
saver_
;
...
@@ -2797,7 +2798,6 @@ TEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) {
...
@@ -2797,7 +2798,6 @@ TEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) {
template
<
typename
RawType
>
template
<
typename
RawType
>
class
FloatingPointTest
:
public
Test
{
class
FloatingPointTest
:
public
Test
{
protected:
protected:
// Pre-calculated numbers to be used by the tests.
// Pre-calculated numbers to be used by the tests.
struct
TestValues
{
struct
TestValues
{
RawType
close_to_positive_zero
;
RawType
close_to_positive_zero
;
...
@@ -7278,6 +7278,7 @@ TEST(ArrayEqTest, WorksForDegeneratedArrays) {
...
@@ -7278,6 +7278,7 @@ TEST(ArrayEqTest, WorksForDegeneratedArrays) {
}
}
TEST
(
ArrayEqTest
,
WorksForOneDimensionalArrays
)
{
TEST
(
ArrayEqTest
,
WorksForOneDimensionalArrays
)
{
// Note that a and b are distinct but compatible types.
const
int
a
[]
=
{
0
,
1
};
const
int
a
[]
=
{
0
,
1
};
long
b
[]
=
{
0
,
1
};
long
b
[]
=
{
0
,
1
};
EXPECT_TRUE
(
ArrayEq
(
a
,
b
));
EXPECT_TRUE
(
ArrayEq
(
a
,
b
));
...
...
Prev
1
2
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