aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorshiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2008-07-31 18:34:08 +0000
committershiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2008-07-31 18:34:08 +0000
commitbf9b4b48dc65adc2edd44175f77b4a7363c59234 (patch)
tree4da8e8084682bbd9121ed76e450ee2074620b59f /test
parentdc6ee0e36df772499e5a86ee638f5aae160c1023 (diff)
downloadgoogletest-bf9b4b48dc65adc2edd44175f77b4a7363c59234.tar.gz
googletest-bf9b4b48dc65adc2edd44175f77b4a7363c59234.tar.bz2
googletest-bf9b4b48dc65adc2edd44175f77b4a7363c59234.zip
Makes gtest work on Windows Mobile and Symbian. By Mika Raento.
Diffstat (limited to 'test')
-rw-r--r--test/gtest-filepath_test.cc36
-rw-r--r--test/gtest_unittest.cc30
2 files changed, 64 insertions, 2 deletions
diff --git a/test/gtest-filepath_test.cc b/test/gtest-filepath_test.cc
index 559b599b..f4b70c36 100644
--- a/test/gtest-filepath_test.cc
+++ b/test/gtest-filepath_test.cc
@@ -51,7 +51,11 @@
#undef GTEST_IMPLEMENTATION
#ifdef GTEST_OS_WINDOWS
+#ifdef _WIN32_WCE
+#include <windows.h>
+#else
#include <direct.h>
+#endif // _WIN32_WCE
#define PATH_SEP "\\"
#else
#define PATH_SEP "/"
@@ -61,6 +65,32 @@ namespace testing {
namespace internal {
namespace {
+#ifdef _WIN32_WCE
+// Windows CE doesn't have the remove C function.
+int remove(const char* path) {
+ LPCWSTR wpath = String::AnsiToUtf16(path);
+ int ret = DeleteFile(wpath) ? 0 : -1;
+ delete [] wpath;
+ return ret;
+}
+// Windows CE doesn't have the _rmdir C function.
+int _rmdir(const char* path) {
+ FilePath filepath(path);
+ LPCWSTR wpath = String::AnsiToUtf16(
+ filepath.RemoveTrailingPathSeparator().c_str());
+ int ret = RemoveDirectory(wpath) ? 0 : -1;
+ delete [] wpath;
+ return ret;
+}
+
+#elif defined(GTEST_LINUX_GOOGLE3_MODE)
+// Creates a temporary directory and returns its path.
+const char* MakeTempDir() {
+ static char dir_name[] = "gtest-filepath_test_tmpXXXXXX";
+ return mkdtemp(dir_name);
+}
+#endif // _WIN32_WCE
+
// FilePath's functions used by UnitTestOptions::GetOutputFile.
// RemoveDirectoryName "" -> ""
@@ -102,8 +132,14 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
// RemoveFileName "" -> "./"
TEST(RemoveFileNameTest, EmptyName) {
+#ifdef _WIN32_WCE
+ // On Windows CE, we use the root as the current directory.
+ EXPECT_STREQ(PATH_SEP,
+ FilePath("").RemoveFileName().c_str());
+#else
EXPECT_STREQ("." PATH_SEP,
FilePath("").RemoveFileName().c_str());
+#endif
}
// RemoveFileName "adir/" -> "adir/"
diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc
index e88a8d02..374f7c14 100644
--- a/test/gtest_unittest.cc
+++ b/test/gtest_unittest.cc
@@ -295,7 +295,9 @@ TEST(ListTest, InsertAfterNotAtBeginning) {
TEST(StringTest, Constructors) {
// Default ctor.
String s1;
- EXPECT_EQ(NULL, s1.c_str());
+ // We aren't using EXPECT_EQ(NULL, s1.c_str()) because comparing
+ // pointers with NULL isn't supported on all platforms.
+ EXPECT_TRUE(NULL == s1.c_str());
// Implicitly constructs from a C-string.
String s2 = "Hi";
@@ -442,6 +444,31 @@ TEST(StringTest, ShowWideCStringQuoted) {
String::ShowWideCStringQuoted(L"foo").c_str());
}
+#ifdef _WIN32_WCE
+TEST(StringTest, AnsiAndUtf16Null) {
+ EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));
+ EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));
+}
+
+TEST(StringTest, AnsiAndUtf16ConvertBasic) {
+ const char* ansi = String::Utf16ToAnsi(L"str");
+ EXPECT_STREQ("str", ansi);
+ delete [] ansi;
+ const WCHAR* utf16 = String::AnsiToUtf16("str");
+ EXPECT_TRUE(wcsncmp(L"str", utf16, 3) == 0);
+ delete [] utf16;
+}
+
+TEST(StringTest, AnsiAndUtf16ConvertPathChars) {
+ const char* ansi = String::Utf16ToAnsi(L".:\\ \"*?");
+ EXPECT_STREQ(".:\\ \"*?", ansi);
+ delete [] ansi;
+ const WCHAR* utf16 = String::AnsiToUtf16(".:\\ \"*?");
+ EXPECT_TRUE(wcsncmp(L".:\\ \"*?", utf16, 3) == 0);
+ delete [] utf16;
+}
+#endif // _WIN32_WCE
+
#endif // GTEST_OS_WINDOWS
// Tests TestProperty construction.
@@ -2865,7 +2892,6 @@ TEST(StreamableTest, BasicIoManip) {
}, "Line 1.\nA NUL char \\0 in line 2.");
}
-
// Tests the macros that haven't been covered so far.
void AddFailureHelper(bool* aborted) {