Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a SplitPath unit test exercising Windows paths with drive letters #13246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion Source/UnitTests/Common/StringUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,37 @@ TEST(StringUtil, SplitPathBackslashesNotRecognizedAsSeparators)
EXPECT_EQ(extension, ".txt");
}

// TODO: add `SplitPath` test coverage for paths containing Windows drives, e.g., "C:".
#ifdef _WIN32
TEST(StringUtil, SplitPathWindowsPathWithDriveLetter)
{
// Verify that on Windows, valid paths that include a drive letter and volume separator (e.g.,
// "C:") parse correctly.
std::string path;
std::string filename;
std::string extension;

// Absolute path with drive letter
EXPECT_TRUE(SplitPath("C:/dir/some_file.txt", &path, &filename, &extension));
EXPECT_EQ(path, "C:/dir/");
EXPECT_EQ(filename, "some_file");
EXPECT_EQ(extension, ".txt");

// Relative path with drive letter
EXPECT_TRUE(SplitPath("C:dir/some_file.txt", &path, &filename, &extension));
EXPECT_EQ(path, "C:dir/");
EXPECT_EQ(filename, "some_file");
EXPECT_EQ(extension, ".txt");

// Relative path with drive letter and no directory
EXPECT_TRUE(SplitPath("C:some_file.txt", &path, &filename, &extension));
EXPECT_EQ(path, "C:");
EXPECT_EQ(filename, "some_file");
EXPECT_EQ(extension, ".txt");

// Path that is just the drive letter
EXPECT_TRUE(SplitPath("C:", &path, &filename, &extension));
EXPECT_EQ(path, "C:");
EXPECT_EQ(filename, "");
EXPECT_EQ(extension, "");
}
#endif