summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-07-26 21:59:50 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-07-26 21:59:50 +0000
commitd5ad2ca82051c34b19af628a3c81131ca65010c2 (patch)
treea393db9c0cebf32d9a62a2a95e8ade4f5750c62c /test
parent87b89d907bc1b5032581439d7de5028c824fa05b (diff)
downloadgoogletest-d5ad2ca82051c34b19af628a3c81131ca65010c2.tar.gz
Adds ADD_FAILURE_AT (by Zhanyong Wan); disables -Wswitch-default (by Vlad Losev).
git-svn-id: http://googletest.googlecode.com/svn/trunk@451 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'test')
-rw-r--r--test/gtest_output_test_.cc4
-rw-r--r--test/gtest_output_test_golden_lin.txt15
-rw-r--r--test/gtest_output_test_golden_win.txt14
-rw-r--r--test/gtest_unittest.cc15
4 files changed, 40 insertions, 8 deletions
diff --git a/test/gtest_output_test_.cc b/test/gtest_output_test_.cc
index 1ac439c..454e1ba 100644
--- a/test/gtest_output_test_.cc
+++ b/test/gtest_output_test_.cc
@@ -441,6 +441,10 @@ TEST_F(FatalFailureInSetUpTest, FailureInSetUp) {
<< "We should never get here, as SetUp() failed.";
}
+TEST(AddFailureAtTest, MessageContainsSpecifiedFileAndLineNumber) {
+ ADD_FAILURE_AT("foo.cc", 42) << "Expected failure in foo.cc";
+}
+
#if GTEST_OS_WINDOWS
// This group of tests verifies that Google Test handles SEH and C++
diff --git a/test/gtest_output_test_golden_lin.txt b/test/gtest_output_test_golden_lin.txt
index 9b30445..0ba9968 100644
--- a/test/gtest_output_test_golden_lin.txt
+++ b/test/gtest_output_test_golden_lin.txt
@@ -7,7 +7,7 @@ Expected: true
gtest_output_test_.cc:#: Failure
Value of: 3
Expected: 2
-[==========] Running 61 tests from 26 test cases.
+[==========] Running 62 tests from 27 test cases.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -235,6 +235,12 @@ gtest_output_test_.cc:#: Failure
Failed
Expected failure #3, in the test fixture d'tor.
[ FAILED ] FatalFailureInSetUpTest.FailureInSetUp
+[----------] 1 test from AddFailureAtTest
+[ RUN ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
+foo.cc:42: Failure
+Failed
+Expected failure in foo.cc
+[ FAILED ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[----------] 4 tests from MixedUpTestCaseTest
[ RUN ] MixedUpTestCaseTest.FirstTestFromNamespaceFoo
[ OK ] MixedUpTestCaseTest.FirstTestFromNamespaceFoo
@@ -580,9 +586,9 @@ FooEnvironment::TearDown() called.
gtest_output_test_.cc:#: Failure
Failed
Expected fatal failure.
-[==========] 61 tests from 26 test cases ran.
+[==========] 62 tests from 27 test cases ran.
[ PASSED ] 21 tests.
-[ FAILED ] 40 tests, listed below:
+[ FAILED ] 41 tests, listed below:
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine
[ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine
@@ -597,6 +603,7 @@ Expected fatal failure.
[ FAILED ] FatalFailureInFixtureConstructorTest.FailureInConstructor
[ FAILED ] NonFatalFailureInSetUpTest.FailureInSetUp
[ FAILED ] FatalFailureInSetUpTest.FailureInSetUp
+[ FAILED ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[ FAILED ] MixedUpTestCaseTest.ThisShouldFail
[ FAILED ] MixedUpTestCaseTest.ThisShouldFailToo
[ FAILED ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
@@ -624,7 +631,7 @@ Expected fatal failure.
[ FAILED ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
-40 FAILED TESTS
+41 FAILED TESTS
 YOU HAVE 1 DISABLED TEST
Note: Google Test filter = FatalFailureTest.*:LoggingTest.*
diff --git a/test/gtest_output_test_golden_win.txt b/test/gtest_output_test_golden_win.txt
index bf76b8c..135f39e 100644
--- a/test/gtest_output_test_golden_win.txt
+++ b/test/gtest_output_test_golden_win.txt
@@ -5,7 +5,7 @@ gtest_output_test_.cc:#: error: Value of: false
Expected: true
gtest_output_test_.cc:#: error: Value of: 3
Expected: 2
-[==========] Running 62 tests from 28 test cases.
+[==========] Running 63 tests from 29 test cases.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -173,6 +173,11 @@ Expected failure #2, in TearDown().
gtest_output_test_.cc:#: error: Failed
Expected failure #3, in the test fixture d'tor.
[ FAILED ] FatalFailureInSetUpTest.FailureInSetUp
+[----------] 1 test from AddFailureAtTest
+[ RUN ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
+foo.cc(42): error: Failed
+Expected failure in foo.cc
+[ FAILED ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[----------] 1 test from ExceptionInFixtureCtorTest
[ RUN ] ExceptionInFixtureCtorTest.ExceptionInFixtureCtor
(expecting a failure on thrown exception in the test fixture's constructor)
@@ -492,9 +497,9 @@ Expected non-fatal failure.
FooEnvironment::TearDown() called.
gtest_output_test_.cc:#: error: Failed
Expected fatal failure.
-[==========] 62 tests from 28 test cases ran.
+[==========] 63 tests from 29 test cases ran.
[ PASSED ] 21 tests.
-[ FAILED ] 41 tests, listed below:
+[ FAILED ] 42 tests, listed below:
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine
[ FAILED ] FatalFailureTest.NonfatalFailureInSubroutine
@@ -508,6 +513,7 @@ Expected fatal failure.
[ FAILED ] FatalFailureInFixtureConstructorTest.FailureInConstructor
[ FAILED ] NonFatalFailureInSetUpTest.FailureInSetUp
[ FAILED ] FatalFailureInSetUpTest.FailureInSetUp
+[ FAILED ] AddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber
[ FAILED ] ExceptionInFixtureCtorTest.ExceptionInFixtureCtor
[ FAILED ] ExceptionInSetUpTest.ExceptionInSetUp
[ FAILED ] ExceptionInTestFunctionTest.SEH
@@ -537,7 +543,7 @@ Expected fatal failure.
[ FAILED ] ExpectFailureTest.ExpectNonFatalFailureOnAllThreads
[ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
-41 FAILED TESTS
+42 FAILED TESTS
YOU HAVE 1 DISABLED TEST
Note: Google Test filter = FatalFailureTest.*:LoggingTest.*
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index e11b6a6..910d4e2 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -4393,6 +4393,21 @@ TEST(MacroTest, ADD_FAILURE) {
EXPECT_FALSE(aborted);
}
+// Tests ADD_FAILURE_AT.
+TEST(MacroTest, ADD_FAILURE_AT) {
+ // Verifies that ADD_FAILURE_AT does generate a nonfatal failure and
+ // the failure message contains the user-streamed part.
+ EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT("foo.cc", 42) << "Wrong!", "Wrong!");
+
+ // Verifies that the user-streamed part is optional.
+ EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT("foo.cc", 42), "Failed");
+
+ // Unfortunately, we cannot verify that the failure message contains
+ // the right file path and line number the same way, as
+ // EXPECT_NONFATAL_FAILURE() doesn't get to see the file path and
+ // line number. Instead, we do that in gtest_output_test_.cc.
+}
+
// Tests FAIL.
TEST(MacroTest, FAIL) {
EXPECT_FATAL_FAILURE(FAIL(),