aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-02-02 10:07:04 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-02-02 10:07:04 +0000
commit9d7455f9844e293dff8b7902f0c2553094f2f976 (patch)
treedfb2f65d0932332b217c19dd22ed62d18e70e2c9 /test
parent40d0ba7a62a8bc749fbaf0747621b0aa10ddf1b9 (diff)
downloadgoogletest-9d7455f9844e293dff8b7902f0c2553094f2f976.tar.gz
googletest-9d7455f9844e293dff8b7902f0c2553094f2f976.tar.bz2
googletest-9d7455f9844e293dff8b7902f0c2553094f2f976.zip
Adds null check for file locations in XML output printer.
Diffstat (limited to 'test')
-rw-r--r--test/gtest-port_test.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/gtest-port_test.cc b/test/gtest-port_test.cc
index 5afba2d8..be0f8b0a 100644
--- a/test/gtest-port_test.cc
+++ b/test/gtest-port_test.cc
@@ -209,6 +209,44 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
GTEST_CHECK_(true) << "Check failed in switch case";
}
+// Verifies behavior of FormatFileLocation.
+TEST(FormatFileLocationTest, FormatsFileLocation) {
+ EXPECT_PRED_FORMAT2(IsSubstring, "foo.cc", FormatFileLocation("foo.cc", 42));
+ EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation("foo.cc", 42));
+}
+
+TEST(FormatFileLocationTest, FormatsUnknownFile) {
+ EXPECT_PRED_FORMAT2(
+ IsSubstring, "unknown file", FormatFileLocation(NULL, 42));
+ EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(NULL, 42));
+}
+
+TEST(FormatFileLocationTest, FormatsUknownLine) {
+ EXPECT_EQ("foo.cc:", FormatFileLocation("foo.cc", -1));
+}
+
+TEST(FormatFileLocationTest, FormatsUknownFileAndLine) {
+ EXPECT_EQ("unknown file:", FormatFileLocation(NULL, -1));
+}
+
+// Verifies behavior of FormatCompilerIndependentFileLocation.
+TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {
+ EXPECT_EQ("foo.cc:42", FormatCompilerIndependentFileLocation("foo.cc", 42));
+}
+
+TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) {
+ EXPECT_EQ("unknown file:42",
+ FormatCompilerIndependentFileLocation(NULL, 42));
+}
+
+TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
+ EXPECT_EQ("foo.cc", FormatCompilerIndependentFileLocation("foo.cc", -1));
+}
+
+TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
+ EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(NULL, -1));
+}
+
#if GTEST_OS_MAC
void* ThreadFunc(void* data) {
pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data);