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
44a041b7
Commit
44a041b7
authored
Mar 11, 2009
by
zhanyong.wan
Browse files
Fixes death-test-related tests on Windows, by Vlad Losev.
parent
40e72a8a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
11 deletions
+17
-11
include/gtest/internal/gtest-internal.h
include/gtest/internal/gtest-internal.h
+1
-0
include/gtest/internal/gtest-port.h
include/gtest/internal/gtest-port.h
+1
-1
src/gtest-internal-inl.h
src/gtest-internal-inl.h
+4
-3
src/gtest-typed-test.cc
src/gtest-typed-test.cc
+1
-0
test/gtest-death-test_test.cc
test/gtest-death-test_test.cc
+6
-3
test/gtest-typed-test_test.cc
test/gtest-typed-test_test.cc
+4
-4
No files found.
include/gtest/internal/gtest-internal.h
View file @
44a041b7
...
@@ -616,6 +616,7 @@ class TypedTestCasePState {
...
@@ -616,6 +616,7 @@ class TypedTestCasePState {
fprintf
(
stderr
,
"%s Test %s must be defined before "
fprintf
(
stderr
,
"%s Test %s must be defined before "
"REGISTER_TYPED_TEST_CASE_P(%s, ...).
\n
"
,
"REGISTER_TYPED_TEST_CASE_P(%s, ...).
\n
"
,
FormatFileLocation
(
file
,
line
).
c_str
(),
test_name
,
case_name
);
FormatFileLocation
(
file
,
line
).
c_str
(),
test_name
,
case_name
);
fflush
(
stderr
);
abort
();
abort
();
}
}
defined_test_names_
.
insert
(
test_name
);
defined_test_names_
.
insert
(
test_name
);
...
...
include/gtest/internal/gtest-port.h
View file @
44a041b7
...
@@ -198,7 +198,7 @@
...
@@ -198,7 +198,7 @@
// simple regex implementation instead.
// simple regex implementation instead.
#define GTEST_USES_SIMPLE_RE 1
#define GTEST_USES_SIMPLE_RE 1
#endif // GTEST_OS_
LINUX
#endif // GTEST_OS_
CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
// otherwise.
// otherwise.
...
...
src/gtest-internal-inl.h
View file @
44a041b7
...
@@ -49,16 +49,17 @@
...
@@ -49,16 +49,17 @@
#include <stddef.h>
#include <stddef.h>
#include <stdlib.h> // For strtoll/_strtoul64.
#include <stdlib.h> // For strtoll/_strtoul64.
#include <string>
#include <gtest/internal/gtest-port.h>
#if GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
#include <windows.h> // For DWORD.
#include <windows.h> // For DWORD.
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#include <gtest/internal/gtest-port.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <gtest/gtest-spi.h>
#include <gtest/gtest-spi.h>
#include <string>
namespace
testing
{
namespace
testing
{
// Declares the flags.
// Declares the flags.
...
...
src/gtest-typed-test.cc
View file @
44a041b7
...
@@ -85,6 +85,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
...
@@ -85,6 +85,7 @@ const char* TypedTestCasePState::VerifyRegisteredTestNames(
if
(
errors_str
!=
""
)
{
if
(
errors_str
!=
""
)
{
fprintf
(
stderr
,
"%s %s"
,
FormatFileLocation
(
file
,
line
).
c_str
(),
fprintf
(
stderr
,
"%s %s"
,
FormatFileLocation
(
file
,
line
).
c_str
(),
errors_str
.
c_str
());
errors_str
.
c_str
());
fflush
(
stderr
);
abort
();
abort
();
}
}
...
...
test/gtest-death-test_test.cc
View file @
44a041b7
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
#include <limits.h>
#include <limits.h>
#include <signal.h>
#include <signal.h>
#include <stdio.h>
#include <stdio.h>
#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
...
@@ -284,14 +285,16 @@ void DieWithEmbeddedNul() {
...
@@ -284,14 +285,16 @@ void DieWithEmbeddedNul() {
_exit
(
1
);
_exit
(
1
);
}
}
#if GTEST_USES_PCRE
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// message has a NUL character in it.
// message has a NUL character in it.
TEST_F
(
TestForDeathTest
,
DISABLED_
EmbeddedNulInMessage
)
{
TEST_F
(
TestForDeathTest
,
EmbeddedNulInMessage
)
{
// TODO(wan@google.com): <regex.h> doesn't support matching strings
// TODO(wan@google.com): <regex.h> doesn't support matching strings
// with embedded NUL characters - find a way to workaround it.
// with embedded NUL characters - find a way to workaround it.
EXPECT_DEATH
(
DieWithEmbeddedNul
(),
"w.*ld"
);
EXPECT_DEATH
(
DieWithEmbeddedNul
(),
"w.*ld"
);
ASSERT_DEATH
(
DieWithEmbeddedNul
(),
"w.*ld"
);
ASSERT_DEATH
(
DieWithEmbeddedNul
(),
"w.*ld"
);
}
}
#endif // GTEST_USES_PCRE
// Tests that death test macros expand to code which interacts well with switch
// Tests that death test macros expand to code which interacts well with switch
// statements.
// statements.
...
@@ -594,7 +597,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
...
@@ -594,7 +597,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
}
}
#if GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
TEST
(
TestForPopUps
,
DoesNotShowPopUpOnAbort
)
{
TEST
(
PopUpDeathTest
,
DoesNotShowPopUpOnAbort
)
{
printf
(
"This test should be considered failing if it shows "
printf
(
"This test should be considered failing if it shows "
"any pop-up dialogs.
\n
"
);
"any pop-up dialogs.
\n
"
);
fflush
(
stdout
);
fflush
(
stdout
);
...
@@ -605,7 +608,7 @@ TEST(TestForPopUps, DoesNotShowPopUpOnAbort) {
...
@@ -605,7 +608,7 @@ TEST(TestForPopUps, DoesNotShowPopUpOnAbort) {
},
""
);
},
""
);
}
}
TEST
(
TestForPopUps
,
DoesNotShowPopUpOnThrow
)
{
TEST
(
PopUpDeathTest
,
DoesNotShowPopUpOnThrow
)
{
printf
(
"This test should be considered failing if it shows "
printf
(
"This test should be considered failing if it shows "
"any pop-up dialogs.
\n
"
);
"any pop-up dialogs.
\n
"
);
fflush
(
stdout
);
fflush
(
stdout
);
...
...
test/gtest-typed-test_test.cc
View file @
44a041b7
...
@@ -205,19 +205,19 @@ typedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;
...
@@ -205,19 +205,19 @@ typedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;
TEST_F
(
TypedTestCasePStateDeathTest
,
DetectsDuplicates
)
{
TEST_F
(
TypedTestCasePStateDeathTest
,
DetectsDuplicates
)
{
EXPECT_DEATH
(
EXPECT_DEATH
(
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, A, C"
),
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, A, C"
),
"foo
\\
.cc
:1
: Test A is listed more than once
\\
."
);
"foo
\\
.cc
.1.?
: Test A is listed more than once
\\
."
);
}
}
TEST_F
(
TypedTestCasePStateDeathTest
,
DetectsExtraTest
)
{
TEST_F
(
TypedTestCasePStateDeathTest
,
DetectsExtraTest
)
{
EXPECT_DEATH
(
EXPECT_DEATH
(
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, C, D"
),
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, C, D"
),
"foo
\\
.cc
:1
: No test named D can be found in this test case
\\
."
);
"foo
\\
.cc
.1.?
: No test named D can be found in this test case
\\
."
);
}
}
TEST_F
(
TypedTestCasePStateDeathTest
,
DetectsMissedTest
)
{
TEST_F
(
TypedTestCasePStateDeathTest
,
DetectsMissedTest
)
{
EXPECT_DEATH
(
EXPECT_DEATH
(
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, C"
),
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, C"
),
"foo
\\
.cc
:1
: You forgot to list test B
\\
."
);
"foo
\\
.cc
.1.?
: You forgot to list test B
\\
."
);
}
}
// Tests that defining a test for a parameterized test case generates
// Tests that defining a test for a parameterized test case generates
...
@@ -226,7 +226,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
...
@@ -226,7 +226,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, C"
);
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
"A, B, C"
);
EXPECT_DEATH
(
EXPECT_DEATH
(
state_
.
AddTestName
(
"foo.cc"
,
2
,
"FooTest"
,
"D"
),
state_
.
AddTestName
(
"foo.cc"
,
2
,
"FooTest"
,
"D"
),
"foo
\\
.cc
:2
: Test D must be defined before REGISTER_TYPED_TEST_CASE_P"
"foo
\\
.cc
.2.?
: Test D must be defined before REGISTER_TYPED_TEST_CASE_P"
"
\\
(FooTest,
\\
.
\\
.
\\
.
\\
)
\\
."
);
"
\\
(FooTest,
\\
.
\\
.
\\
.
\\
)
\\
."
);
}
}
...
...
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