summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2010-02-03 02:27:02 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2010-02-03 02:27:02 +0000
commit673a0cb9079f8f37bd61588a3160e12daf70ec44 (patch)
treeaf456a0d47524f6bb5cbb49d160e0aaf60110daf /test
parent8236131e25705a809d496672a3819e1741166c4b (diff)
downloadgoogletest-673a0cb9079f8f37bd61588a3160e12daf70ec44.tar.gz
Adds Solaris support (by Hady Zalek)
git-svn-id: http://googletest.googlecode.com/svn/trunk@371 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'test')
-rw-r--r--test/gtest-filepath_test.cc51
-rw-r--r--test/gtest_unittest.cc39
2 files changed, 55 insertions, 35 deletions
diff --git a/test/gtest-filepath_test.cc b/test/gtest-filepath_test.cc
index 5706c8e..c5f58f4 100644
--- a/test/gtest-filepath_test.cc
+++ b/test/gtest-filepath_test.cc
@@ -153,31 +153,31 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
#if GTEST_HAS_ALT_PATH_SEP_
-// Test RemoveDirectory* functions with "/".
+// Tests that RemoveDirectoryName() works with the alternate separator
+// on Windows.
-// RemoveDirectoryName "/afile" -> "afile"
+// RemoveDirectoryName("/afile") -> "afile"
TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileNameForAlternateSeparator) {
EXPECT_STREQ("afile",
- FilePath("/afile").RemoveDirectoryName().c_str());
+ FilePath("/afile").RemoveDirectoryName().c_str());
}
-// RemoveDirectoryName "adir/" -> ""
+// RemoveDirectoryName("adir/") -> ""
TEST(RemoveDirectoryNameTest, WhereThereIsNoFileNameForAlternateSeparator) {
EXPECT_STREQ("",
- FilePath("adir/").RemoveDirectoryName().c_str());
+ FilePath("adir/").RemoveDirectoryName().c_str());
}
-// RemoveDirectoryName "adir/afile" -> "afile"
+// RemoveDirectoryName("adir/afile") -> "afile"
TEST(RemoveDirectoryNameTest, ShouldGiveFileNameForAlternateSeparator) {
EXPECT_STREQ("afile",
- FilePath("adir/afile").RemoveDirectoryName().c_str());
+ FilePath("adir/afile").RemoveDirectoryName().c_str());
}
-// RemoveDirectoryName "adir/subdir/afile" -> "afile"
+// RemoveDirectoryName("adir/subdir/afile") -> "afile"
TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {
EXPECT_STREQ("afile",
- FilePath("adir/subdir/afile")
- .RemoveDirectoryName().c_str());
+ FilePath("adir/subdir/afile").RemoveDirectoryName().c_str());
}
#endif
@@ -222,32 +222,31 @@ TEST(RemoveFileNameTest, GivesRootDir) {
#if GTEST_HAS_ALT_PATH_SEP_
-// Test RemoveFile* functions with "/".
+// Tests that RemoveFileName() works with the alternate separator on
+// Windows.
-// RemoveFileName "adir/" -> "adir/"
+// RemoveFileName("adir/") -> "adir/"
TEST(RemoveFileNameTest, ButNoFileForAlternateSeparator) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_,
- FilePath("adir/").RemoveFileName().c_str());
+ FilePath("adir/").RemoveFileName().c_str());
}
-// RemoveFileName "adir/afile" -> "adir/"
+// RemoveFileName("adir/afile") -> "adir/"
TEST(RemoveFileNameTest, GivesDirNameForAlternateSeparator) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_,
- FilePath("adir/afile")
- .RemoveFileName().c_str());
+ FilePath("adir/afile").RemoveFileName().c_str());
}
-// RemoveFileName "adir/subdir/afile" -> "adir/subdir/"
+// RemoveFileName("adir/subdir/afile") -> "adir/subdir/"
TEST(RemoveFileNameTest, GivesDirAndSubDirNameForAlternateSeparator) {
EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
- FilePath("adir/subdir/afile")
- .RemoveFileName().c_str());
+ FilePath("adir/subdir/afile").RemoveFileName().c_str());
}
-// RemoveFileName "/afile" -> "\"
+// RemoveFileName("/afile") -> "\"
TEST(RemoveFileNameTest, GivesRootDirForAlternateSeparator) {
EXPECT_STREQ(GTEST_PATH_SEP_,
- FilePath("/afile").RemoveFileName().c_str());
+ FilePath("/afile").RemoveFileName().c_str());
}
#endif
@@ -357,9 +356,8 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {
"foo",
FilePath("foo" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().c_str());
#if GTEST_HAS_ALT_PATH_SEP_
- EXPECT_STREQ(
- "foo",
- FilePath("foo/").RemoveTrailingPathSeparator().c_str());
+ EXPECT_STREQ("foo",
+ FilePath("foo/").RemoveTrailingPathSeparator().c_str());
#endif
}
@@ -465,7 +463,9 @@ TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {
#if GTEST_HAS_ALT_PATH_SEP_
-// "foo\" =="foo/\" == "foo\\/"
+// Tests that separators at the end of the string are normalized
+// regardless of their combination (e.g. "foo\" =="foo/\" ==
+// "foo\\/").
TEST(NormalizeTest, MixAlternateSeparatorAtStringEnd) {
EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo/").c_str());
@@ -678,6 +678,7 @@ TEST(FilePathTest, IsRootDirectory) {
EXPECT_FALSE(FilePath("c|/").IsRootDirectory());
#else
EXPECT_TRUE(FilePath("/").IsRootDirectory());
+ EXPECT_TRUE(FilePath("//").IsRootDirectory());
EXPECT_FALSE(FilePath("").IsRootDirectory());
EXPECT_FALSE(FilePath("\\").IsRootDirectory());
EXPECT_FALSE(FilePath("/x").IsRootDirectory());
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index a593494..55313e3 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -74,9 +74,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <pthread.h>
#endif // GTEST_HAS_PTHREAD
-#ifdef __BORLANDC__
#include <map>
-#endif
namespace testing {
namespace internal {
@@ -1388,12 +1386,16 @@ TEST(StringTest, CanBeAssignedSelf) {
EXPECT_STREQ("hello", dest.c_str());
}
+// Sun Studio < 12 incorrectly rejects this code due to an overloading
+// ambiguity.
+#if !(defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
// Tests streaming a String.
TEST(StringTest, Streams) {
EXPECT_EQ(StreamableToString(String()), "(null)");
EXPECT_EQ(StreamableToString(String("")), "");
EXPECT_EQ(StreamableToString(String("a\0b", 3)), "a\\0b");
}
+#endif
// Tests that String::Format() works.
TEST(StringTest, FormatWorks) {
@@ -2050,7 +2052,7 @@ static void SetEnv(const char* name, const char* value) {
#if GTEST_OS_WINDOWS_MOBILE
// Environment variables are not supported on Windows CE.
return;
-#elif defined(__BORLANDC__)
+#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
// C++Builder's putenv only stores a pointer to its parameter; we have to
// ensure that the string remains valid as long as it might be needed.
// We use an std::map to do so.
@@ -2063,7 +2065,11 @@ static void SetEnv(const char* name, const char* value) {
prev_env = added_env[name];
}
added_env[name] = new String((Message() << name << "=" << value).GetString());
- putenv(added_env[name]->c_str());
+
+ // The standard signature of putenv accepts a 'char*' argument. Other
+ // implementations, like C++Builder's, accept a 'const char*'.
+ // We cast away the 'const' since that would work for both variants.
+ putenv(const_cast<char*>(added_env[name]->c_str()));
delete prev_env;
#elif GTEST_OS_WINDOWS // If we are on Windows proper.
_putenv((Message() << name << "=" << value).GetString().c_str());
@@ -3013,7 +3019,10 @@ TEST_F(FloatTest, AlmostZeros) {
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
- static const FloatTest::TestValues& v(this->values_);
+ // We use the assignment syntax since some compilers, like Sun Studio,
+ // don't allow initializing references using construction syntax
+ // (parentheses).
+ static const FloatTest::TestValues& v = this->values_;
EXPECT_FLOAT_EQ(0.0, v.close_to_positive_zero);
EXPECT_FLOAT_EQ(-0.0, v.close_to_negative_zero);
@@ -3065,7 +3074,10 @@ TEST_F(FloatTest, NaN) {
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
- static const FloatTest::TestValues& v(this->values_);
+ // We use the assignment syntax since some compilers, like Sun Studio,
+ // don't allow initializing references using construction syntax
+ // (parentheses).
+ static const FloatTest::TestValues& v = this->values_;
EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan1),
"v.nan1");
@@ -3180,7 +3192,10 @@ TEST_F(DoubleTest, AlmostZeros) {
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
- static const DoubleTest::TestValues& v(this->values_);
+ // We use the assignment syntax since some compilers, like Sun Studio,
+ // don't allow initializing references using construction syntax
+ // (parentheses).
+ static const DoubleTest::TestValues& v = this->values_;
EXPECT_DOUBLE_EQ(0.0, v.close_to_positive_zero);
EXPECT_DOUBLE_EQ(-0.0, v.close_to_negative_zero);
@@ -3230,7 +3245,10 @@ TEST_F(DoubleTest, NaN) {
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
- static const DoubleTest::TestValues& v(this->values_);
+ // We use the assignment syntax since some compilers, like Sun Studio,
+ // don't allow initializing references using construction syntax
+ // (parentheses).
+ static const DoubleTest::TestValues& v = this->values_;
// Nokia's STLport crashes if we try to output infinity or NaN.
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan1),
@@ -4015,7 +4033,8 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) {
// The version of gcc used in XCode 2.2 has a bug and doesn't allow
// anonymous enums in assertions. Therefore the following test is not
// done on Mac.
-#if !GTEST_OS_MAC
+// Sun Studio also rejects this code.
+#if !GTEST_OS_MAC && !defined(__SUNPRO_CC)
// Tests using assertions with anonymous enums.
enum {
@@ -4060,7 +4079,7 @@ TEST(AssertionTest, AnonymousEnum) {
"Value of: CASE_B");
}
-#endif // !GTEST_OS_MAC
+#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
#if GTEST_OS_WINDOWS