# else
- EXPECT_STREQ(GTEST_PATH_SEP_, cwd.c_str());
+ EXPECT_EQ(GTEST_PATH_SEP_, cwd.string());
# endif
}
TEST(IsEmptyTest, ReturnsTrueForEmptyPath) {
EXPECT_TRUE(FilePath("").IsEmpty());
- EXPECT_TRUE(FilePath(NULL).IsEmpty());
}
TEST(IsEmptyTest, ReturnsFalseForNonEmptyPath) {
// RemoveDirectoryName "" -> ""
TEST(RemoveDirectoryNameTest, WhenEmptyName) {
- EXPECT_STREQ("", FilePath("").RemoveDirectoryName().c_str());
+ EXPECT_EQ("", FilePath("").RemoveDirectoryName().string());
}
// RemoveDirectoryName "afile" -> "afile"
TEST(RemoveDirectoryNameTest, ButNoDirectory) {
- EXPECT_STREQ("afile",
- FilePath("afile").RemoveDirectoryName().c_str());
+ EXPECT_EQ("afile",
+ FilePath("afile").RemoveDirectoryName().string());
}
// RemoveDirectoryName "/afile" -> "afile"
TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) {
- EXPECT_STREQ("afile",
- FilePath(GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str());
+ EXPECT_EQ("afile",
+ FilePath(GTEST_PATH_SEP_ "afile").RemoveDirectoryName().string());
}
// RemoveDirectoryName "adir/" -> ""
TEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) {
- EXPECT_STREQ("",
- FilePath("adir" GTEST_PATH_SEP_).RemoveDirectoryName().c_str());
+ EXPECT_EQ("",
+ FilePath("adir" GTEST_PATH_SEP_).RemoveDirectoryName().string());
}
// RemoveDirectoryName "adir/afile" -> "afile"
TEST(RemoveDirectoryNameTest, ShouldGiveFileName) {
- EXPECT_STREQ("afile",
- FilePath("adir" GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str());
+ EXPECT_EQ("afile",
+ FilePath("adir" GTEST_PATH_SEP_ "afile").RemoveDirectoryName().string());
}
// RemoveDirectoryName "adir/subdir/afile" -> "afile"
TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
- EXPECT_STREQ("afile",
+ EXPECT_EQ("afile",
FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile")
- .RemoveDirectoryName().c_str());
+ .RemoveDirectoryName().string());
}
#if GTEST_HAS_ALT_PATH_SEP_
// RemoveDirectoryName("/afile") -> "afile"
TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileNameForAlternateSeparator) {
- EXPECT_STREQ("afile",
- FilePath("/afile").RemoveDirectoryName().c_str());
+ EXPECT_EQ("afile", FilePath("/afile").RemoveDirectoryName().string());
}
// RemoveDirectoryName("adir/") -> ""
TEST(RemoveDirectoryNameTest, WhereThereIsNoFileNameForAlternateSeparator) {
- EXPECT_STREQ("",
- FilePath("adir/").RemoveDirectoryName().c_str());
+ EXPECT_EQ("", FilePath("adir/").RemoveDirectoryName().string());
}
// RemoveDirectoryName("adir/afile") -> "afile"
TEST(RemoveDirectoryNameTest, ShouldGiveFileNameForAlternateSeparator) {
- EXPECT_STREQ("afile",
- FilePath("adir/afile").RemoveDirectoryName().c_str());
+ EXPECT_EQ("afile", FilePath("adir/afile").RemoveDirectoryName().string());
}
// RemoveDirectoryName("adir/subdir/afile") -> "afile"
TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {
- EXPECT_STREQ("afile",
- FilePath("adir/subdir/afile").RemoveDirectoryName().c_str());
+ EXPECT_EQ("afile",
+ FilePath("adir/subdir/afile").RemoveDirectoryName().string());
}
#endif
TEST(RemoveFileNameTest, EmptyName) {
#if GTEST_OS_WINDOWS_MOBILE
// On Windows CE, we use the root as the current directory.
- EXPECT_STREQ(GTEST_PATH_SEP_,
- FilePath("").RemoveFileName().c_str());
+ EXPECT_EQ(GTEST_PATH_SEP_, FilePath("").RemoveFileName().string());
#else
- EXPECT_STREQ("." GTEST_PATH_SEP_,
- FilePath("").RemoveFileName().c_str());
+ EXPECT_EQ("." GTEST_PATH_SEP_, FilePath("").RemoveFileName().string());
#endif
}
// RemoveFileName "adir/" -> "adir/"
TEST(RemoveFileNameTest, ButNoFile) {
- EXPECT_STREQ("adir" GTEST_PATH_SEP_,
- FilePath("adir" GTEST_PATH_SEP_).RemoveFileName().c_str());
+ EXPECT_EQ("adir" GTEST_PATH_SEP_,
+ FilePath("adir" GTEST_PATH_SEP_).RemoveFileName().string());
}
// RemoveFileName "adir/afile" -> "adir/"
TEST(RemoveFileNameTest, GivesDirName) {
- EXPECT_STREQ("adir" GTEST_PATH_SEP_,
- FilePath("adir" GTEST_PATH_SEP_ "afile")
- .RemoveFileName().c_str());
+ EXPECT_EQ("adir" GTEST_PATH_SEP_,
+ FilePath("adir" GTEST_PATH_SEP_ "afile").RemoveFileName().string());
}
// RemoveFileName "adir/subdir/afile" -> "adir/subdir/"
TEST(RemoveFileNameTest, GivesDirAndSubDirName) {
- EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
+ EXPECT_EQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile")
- .RemoveFileName().c_str());
+ .RemoveFileName().string());
}
// RemoveFileName "/afile" -> "/"
TEST(RemoveFileNameTest, GivesRootDir) {
- EXPECT_STREQ(GTEST_PATH_SEP_,
- FilePath(GTEST_PATH_SEP_ "afile").RemoveFileName().c_str());
+ EXPECT_EQ(GTEST_PATH_SEP_,
+ FilePath(GTEST_PATH_SEP_ "afile").RemoveFileName().string());
}
#if GTEST_HAS_ALT_PATH_SEP_
// RemoveFileName("adir/") -> "adir/"
TEST(RemoveFileNameTest, ButNoFileForAlternateSeparator) {
- EXPECT_STREQ("adir" GTEST_PATH_SEP_,
- FilePath("adir/").RemoveFileName().c_str());
+ EXPECT_EQ("adir" GTEST_PATH_SEP_,
+ FilePath("adir/").RemoveFileName().string());
}
// RemoveFileName("adir/afile") -> "adir/"
TEST(RemoveFileNameTest, GivesDirNameForAlternateSeparator) {
- EXPECT_STREQ("adir" GTEST_PATH_SEP_,
- FilePath("adir/afile").RemoveFileName().c_str());
+ EXPECT_EQ("adir" GTEST_PATH_SEP_,
+ FilePath("adir/afile").RemoveFileName().string());
}
// 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());
+ EXPECT_EQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
+ FilePath("adir/subdir/afile").RemoveFileName().string());
}
// RemoveFileName("/afile") -> "\"
TEST(RemoveFileNameTest, GivesRootDirForAlternateSeparator) {
- EXPECT_STREQ(GTEST_PATH_SEP_,
- FilePath("/afile").RemoveFileName().c_str());
+ EXPECT_EQ(GTEST_PATH_SEP_, FilePath("/afile").RemoveFileName().string());
}
#endif
TEST(MakeFileNameTest, GenerateWhenNumberIsZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"),
0, "xml");
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.string());
}
TEST(MakeFileNameTest, GenerateFileNameNumberGtZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"),
12, "xml");
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.string());
}
TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar"), 0, "xml");
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.string());
}
TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar"), 12, "xml");
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.string());
}
TEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) {
FilePath actual = FilePath::MakeFileName(FilePath(""), FilePath("bar"),
0, "xml");
- EXPECT_STREQ("bar.xml", actual.c_str());
+ EXPECT_EQ("bar.xml", actual.string());
}
TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {
FilePath actual = FilePath::MakeFileName(FilePath(""), FilePath("bar"),
14, "xml");
- EXPECT_STREQ("bar_14.xml", actual.c_str());
+ EXPECT_EQ("bar_14.xml", actual.string());
}
TEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("bar.xml"));
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.string());
}
TEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar.xml"));
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.string());
}
TEST(ConcatPathsTest, Path1BeingEmpty) {
FilePath actual = FilePath::ConcatPaths(FilePath(""),
FilePath("bar.xml"));
- EXPECT_STREQ("bar.xml", actual.c_str());
+ EXPECT_EQ("bar.xml", actual.string());
}
TEST(ConcatPathsTest, Path2BeingEmpty) {
- FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
- FilePath(""));
- EXPECT_STREQ("foo" GTEST_PATH_SEP_, actual.c_str());
+ FilePath actual = FilePath::ConcatPaths(FilePath("foo"), FilePath(""));
+ EXPECT_EQ("foo" GTEST_PATH_SEP_, actual.string());
}
TEST(ConcatPathsTest, BothPathBeingEmpty) {
FilePath actual = FilePath::ConcatPaths(FilePath(""),
FilePath(""));
- EXPECT_STREQ("", actual.c_str());
+ EXPECT_EQ("", actual.string());
}
TEST(ConcatPathsTest, Path1ContainsPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_ "bar"),
FilePath("foobar.xml"));
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "foobar.xml",
- actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "foobar.xml",
+ actual.string());
}
TEST(ConcatPathsTest, Path2ContainsPathSep) {
FilePath actual = FilePath::ConcatPaths(
FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar" GTEST_PATH_SEP_ "bar.xml"));
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "bar.xml",
- actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "bar.xml",
+ actual.string());
}
TEST(ConcatPathsTest, Path2EndsWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("bar" GTEST_PATH_SEP_));
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_, actual.c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_, actual.string());
}
// RemoveTrailingPathSeparator "" -> ""
TEST(RemoveTrailingPathSeparatorTest, EmptyString) {
- EXPECT_STREQ("",
- FilePath("").RemoveTrailingPathSeparator().c_str());
+ EXPECT_EQ("", FilePath("").RemoveTrailingPathSeparator().string());
}
// RemoveTrailingPathSeparator "foo" -> "foo"
TEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) {
- EXPECT_STREQ("foo",
- FilePath("foo").RemoveTrailingPathSeparator().c_str());
+ EXPECT_EQ("foo", FilePath("foo").RemoveTrailingPathSeparator().string());
}
// RemoveTrailingPathSeparator "foo/" -> "foo"
TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {
- EXPECT_STREQ(
- "foo",
- FilePath("foo" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().c_str());
+ EXPECT_EQ("foo",
+ FilePath("foo" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().string());
#if GTEST_HAS_ALT_PATH_SEP_
- EXPECT_STREQ("foo",
- FilePath("foo/").RemoveTrailingPathSeparator().c_str());
+ EXPECT_EQ("foo", FilePath("foo/").RemoveTrailingPathSeparator().string());
#endif
}
// RemoveTrailingPathSeparator "foo/bar/" -> "foo/bar/"
TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) {
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
- FilePath("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_)
- .RemoveTrailingPathSeparator().c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar",
+ FilePath("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_)
+ .RemoveTrailingPathSeparator().string());
}
// RemoveTrailingPathSeparator "foo/bar" -> "foo/bar"
TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
- FilePath("foo" GTEST_PATH_SEP_ "bar")
- .RemoveTrailingPathSeparator().c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar",
+ FilePath("foo" GTEST_PATH_SEP_ "bar")
+ .RemoveTrailingPathSeparator().string());
}
TEST(DirectoryTest, RootDirectoryExists) {
#endif // GTEST_OS_WINDOWS
}
-TEST(NormalizeTest, NullStringsEqualEmptyDirectory) {
- EXPECT_STREQ("", FilePath(NULL).c_str());
- EXPECT_STREQ("", FilePath(String(NULL)).c_str());
-}
-
// "foo/bar" == foo//bar" == "foo///bar"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) {
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
- FilePath("foo" GTEST_PATH_SEP_ "bar").c_str());
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
- FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
- EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
- FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_
- GTEST_PATH_SEP_ "bar").c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar",
+ FilePath("foo" GTEST_PATH_SEP_ "bar").string());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar",
+ FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar",
+ FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_
+ GTEST_PATH_SEP_ "bar").string());
}
// "/bar" == //bar" == "///bar"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) {
- EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
- FilePath(GTEST_PATH_SEP_ "bar").c_str());
- EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
- FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
- EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
- FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
+ EXPECT_EQ(GTEST_PATH_SEP_ "bar",
+ FilePath(GTEST_PATH_SEP_ "bar").string());
+ EXPECT_EQ(GTEST_PATH_SEP_ "bar",
+ FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string());
+ EXPECT_EQ(GTEST_PATH_SEP_ "bar",
+ FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string());
}
// "foo/" == foo//" == "foo///"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {
- EXPECT_STREQ("foo" GTEST_PATH_SEP_,
- FilePath("foo" GTEST_PATH_SEP_).c_str());
- EXPECT_STREQ("foo" GTEST_PATH_SEP_,
- FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str());
- EXPECT_STREQ("foo" GTEST_PATH_SEP_,
- FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_,
+ FilePath("foo" GTEST_PATH_SEP_).string());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_,
+ FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_).string());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_,
+ FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).string());
}
#if GTEST_HAS_ALT_PATH_SEP_
// regardless of their combination (e.g. "foo\" =="foo/\" ==
// "foo\\/").
TEST(NormalizeTest, MixAlternateSeparatorAtStringEnd) {
- EXPECT_STREQ("foo" GTEST_PATH_SEP_,
- FilePath("foo/").c_str());
- EXPECT_STREQ("foo" GTEST_PATH_SEP_,
- FilePath("foo" GTEST_PATH_SEP_ "/").c_str());
- EXPECT_STREQ("foo" GTEST_PATH_SEP_,
- FilePath("foo//" GTEST_PATH_SEP_).c_str());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_,
+ FilePath("foo/").string());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_,
+ FilePath("foo" GTEST_PATH_SEP_ "/").string());
+ EXPECT_EQ("foo" GTEST_PATH_SEP_,
+ FilePath("foo//" GTEST_PATH_SEP_).string());
}
#endif
FilePath default_path;
FilePath non_default_path("path");
non_default_path = default_path;
- EXPECT_STREQ("", non_default_path.c_str());
- EXPECT_STREQ("", default_path.c_str()); // RHS var is unchanged.
+ EXPECT_EQ("", non_default_path.string());
+ EXPECT_EQ("", default_path.string()); // RHS var is unchanged.
}
TEST(AssignmentOperatorTest, NonDefaultAssignedToDefault) {
FilePath non_default_path("path");
FilePath default_path;
default_path = non_default_path;
- EXPECT_STREQ("path", default_path.c_str());
- EXPECT_STREQ("path", non_default_path.c_str()); // RHS var is unchanged.
+ EXPECT_EQ("path", default_path.string());
+ EXPECT_EQ("path", non_default_path.string()); // RHS var is unchanged.
}
TEST(AssignmentOperatorTest, ConstAssignedToNonConst) {
const FilePath const_default_path("const_path");
FilePath non_default_path("path");
non_default_path = const_default_path;
- EXPECT_STREQ("const_path", non_default_path.c_str());
+ EXPECT_EQ("const_path", non_default_path.string());
}
class DirectoryCreationTest : public Test {
protected:
virtual void SetUp() {
- testdata_path_.Set(FilePath(String::Format("%s%s%s",
- TempDir().c_str(), GetCurrentExecutableName().c_str(),
- "_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_)));
+ testdata_path_.Set(FilePath(
+ TempDir() + GetCurrentExecutableName().string() +
+ "_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_));
testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator());
unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"),
posix::RmDir(testdata_path_.c_str());
}
- String TempDir() const {
-#if GTEST_OS_WINDOWS_MOBILE
- return String("\\temp\\");
-#elif GTEST_OS_WINDOWS
- const char* temp_dir = posix::GetEnv("TEMP");
- if (temp_dir == NULL || temp_dir[0] == '\0')
- return String("\\temp\\");
- else if (String(temp_dir).EndsWith("\\"))
- return String(temp_dir);
- else
- return String::Format("%s\\", temp_dir);
-#else
- return String("/tmp/");
-#endif // GTEST_OS_WINDOWS_MOBILE
- }
-
void CreateTextFile(const char* filename) {
FILE* f = posix::FOpen(filename, "w");
fprintf(f, "text\n");
};
TEST_F(DirectoryCreationTest, CreateDirectoriesRecursively) {
- EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.c_str();
+ EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.string();
EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());
EXPECT_TRUE(testdata_path_.DirectoryExists());
}
TEST_F(DirectoryCreationTest, CreateDirectoriesForAlreadyExistingPath) {
- EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.c_str();
+ EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.string();
EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());
// Call 'create' again... should still succeed.
EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());
TEST_F(DirectoryCreationTest, CreateDirectoriesAndUniqueFilename) {
FilePath file_path(FilePath::GenerateUniqueFileName(testdata_path_,
FilePath("unique"), "txt"));
- EXPECT_STREQ(unique_file0_.c_str(), file_path.c_str());
+ EXPECT_EQ(unique_file0_.string(), file_path.string());
EXPECT_FALSE(file_path.FileOrDirectoryExists()); // file not there
testdata_path_.CreateDirectoriesRecursively();
FilePath file_path2(FilePath::GenerateUniqueFileName(testdata_path_,
FilePath("unique"), "txt"));
- EXPECT_STREQ(unique_file1_.c_str(), file_path2.c_str());
+ EXPECT_EQ(unique_file1_.string(), file_path2.string());
EXPECT_FALSE(file_path2.FileOrDirectoryExists()); // file not there
CreateTextFile(file_path2.c_str());
EXPECT_TRUE(file_path2.FileOrDirectoryExists());
TEST(FilePathTest, DefaultConstructor) {
FilePath fp;
- EXPECT_STREQ("", fp.c_str());
+ EXPECT_EQ("", fp.string());
}
TEST(FilePathTest, CharAndCopyConstructors) {
const FilePath fp("spicy");
- EXPECT_STREQ("spicy", fp.c_str());
+ EXPECT_EQ("spicy", fp.string());
const FilePath fp_copy(fp);
- EXPECT_STREQ("spicy", fp_copy.c_str());
+ EXPECT_EQ("spicy", fp_copy.string());
}
TEST(FilePathTest, StringConstructor) {
- const FilePath fp(String("cider"));
- EXPECT_STREQ("cider", fp.c_str());
+ const FilePath fp(std::string("cider"));
+ EXPECT_EQ("cider", fp.string());
}
TEST(FilePathTest, Set) {
const FilePath apple("apple");
FilePath mac("mac");
mac.Set(apple); // Implement Set() since overloading operator= is forbidden.
- EXPECT_STREQ("apple", mac.c_str());
- EXPECT_STREQ("apple", apple.c_str());
+ EXPECT_EQ("apple", mac.string());
+ EXPECT_EQ("apple", apple.string());
}
TEST(FilePathTest, ToString) {
const FilePath file("drink");
- String str(file.ToString());
- EXPECT_STREQ("drink", str.c_str());
+ EXPECT_EQ("drink", file.string());
}
TEST(FilePathTest, RemoveExtension) {
- EXPECT_STREQ("app", FilePath("app.exe").RemoveExtension("exe").c_str());
- EXPECT_STREQ("APP", FilePath("APP.EXE").RemoveExtension("exe").c_str());
+ EXPECT_EQ("app", FilePath("app.cc").RemoveExtension("cc").string());
+ EXPECT_EQ("app", FilePath("app.exe").RemoveExtension("exe").string());
+ EXPECT_EQ("APP", FilePath("APP.EXE").RemoveExtension("exe").string());
}
TEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) {
- EXPECT_STREQ("app", FilePath("app").RemoveExtension("exe").c_str());
+ EXPECT_EQ("app", FilePath("app").RemoveExtension("exe").string());
}
TEST(FilePathTest, IsDirectory) {