chromium/base/files/safe_base_name_unittest.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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  // FILE_PATH_USES_WIN_SEPARATORS

TEST(SafeBaseNameTest, Separators) {}

}  // namespace base