#include "base/files/safe_base_name.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
TEST(SafeBaseNameTest, Basic) { … }
#if defined(FILE_PATH_USES_WIN_SEPARATORS)
TEST(SafeBaseNameTest, WinRoot) {
std::optional<SafeBaseName> basename(
SafeBaseName::Create(FILE_PATH_LITERAL("C:\\foo\\bar")));
EXPECT_TRUE(basename.has_value());
EXPECT_EQ(basename->path(), FilePath(FILE_PATH_LITERAL("bar")));
basename = SafeBaseName::Create(FILE_PATH_LITERAL("C:\\"));
EXPECT_FALSE(basename.has_value());
}
#else
TEST(SafeBaseNameTest, Root) { … }
#endif
TEST(SafeBaseNameTest, Separators) { … }
}