mirror of
https://github.com/google/googletest.git
synced 2026-07-30 16:26:24 +08:00
Merge 653aec68afdcadaae9913d7baf79f738fac538d2 into a0f06a70e3da7afa88da9527c43951bca1f7cef2
This commit is contained in:
commit
4f2473cbe0
@ -227,12 +227,12 @@ FilePath FilePath::RemoveFileName() const {
|
||||
FilePath FilePath::MakeFileName(const FilePath& directory,
|
||||
const FilePath& base_name, int number,
|
||||
const char* extension) {
|
||||
std::string base = base_name.IsEmpty() ? "file" : base_name.string();
|
||||
std::string file;
|
||||
if (number == 0) {
|
||||
file = base_name.string() + "." + extension;
|
||||
file = base + "." + extension;
|
||||
} else {
|
||||
file =
|
||||
base_name.string() + "_" + StreamableToString(number) + "." + extension;
|
||||
file = base + "_" + StreamableToString(number) + "." + extension;
|
||||
}
|
||||
return ConcatPaths(directory, FilePath(file));
|
||||
}
|
||||
|
||||
@ -274,6 +274,18 @@ TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {
|
||||
EXPECT_EQ("bar_14.xml", actual.string());
|
||||
}
|
||||
|
||||
TEST(MakeFileNameTest, GenerateWhenBaseNameEmpty) {
|
||||
FilePath actual =
|
||||
FilePath::MakeFileName(FilePath("foo"), FilePath(""), 0, "xml");
|
||||
EXPECT_EQ("foo" GTEST_PATH_SEP_ "file.xml", actual.string());
|
||||
}
|
||||
|
||||
TEST(MakeFileNameTest, GenerateWhenBaseNameEmptyNumberNonZero) {
|
||||
FilePath actual =
|
||||
FilePath::MakeFileName(FilePath("foo"), FilePath(""), 42, "xml");
|
||||
EXPECT_EQ("foo" GTEST_PATH_SEP_ "file_42.xml", actual.string());
|
||||
}
|
||||
|
||||
TEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) {
|
||||
FilePath actual = FilePath::ConcatPaths(FilePath("foo"), FilePath("bar.xml"));
|
||||
EXPECT_EQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.string());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user