From 01aa9dae10f34ac8a174239d8407455d2cebc10d Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Tue, 31 May 2022 19:58:49 +0500 Subject: [PATCH] Split test/std-test.cc. Signed-off-by: Vladislav Shchapov --- test/CMakeLists.txt | 4 ++++ test/std-filesystem-test.cc | 22 ++++++++++++++++++++++ test/std-test.cc | 8 -------- 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 test/std-filesystem-test.cc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6cdb7ac42fa04..18818b38cfd21 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -78,6 +78,10 @@ add_fmt_test(printf-test) add_fmt_test(ranges-test ranges-odr-test.cc) add_fmt_test(scan-test) add_fmt_test(std-test) +add_fmt_test(std-filesystem-test) +if (MSVC) + target_compile_options(std-filesystem-test PRIVATE /source-charset:utf-8) +endif () add_fmt_test(unicode-test HEADER_ONLY) if (MSVC) target_compile_options(unicode-test PRIVATE /utf-8) diff --git a/test/std-filesystem-test.cc b/test/std-filesystem-test.cc new file mode 100644 index 0000000000000..f769076ad3cf5 --- /dev/null +++ b/test/std-filesystem-test.cc @@ -0,0 +1,22 @@ +// Formatting library for C++ - tests of formatters for standard library types +// +// Copyright (c) 2012 - present, Victor Zverovich +// All rights reserved. +// +// For the license information refer to format.h. + +#include "fmt/std.h" +#include "gtest/gtest.h" + +TEST(std_filesystem_test, path) { +#ifdef __cpp_lib_filesystem + EXPECT_EQ(fmt::format("{:8}", std::filesystem::path("foo")), "\"foo\" "); + EXPECT_EQ(fmt::format("{}", std::filesystem::path("foo\"bar.txt")), + "\"foo\\\"bar.txt\""); + +# ifdef _WIN32 + EXPECT_EQ(fmt::format("{}", std::filesystem::path(L"Файл.txt")), + "\"\xd0\xa4\xd0\xb0\xd0\xb9\xd0\xbb.txt\""); +# endif +#endif +} diff --git a/test/std-test.cc b/test/std-test.cc index 069c83871955c..7d3e6484f36c5 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -9,14 +9,6 @@ #include "gtest/gtest.h" -TEST(std_test, path) { -#ifdef __cpp_lib_filesystem - EXPECT_EQ(fmt::format("{:8}", std::filesystem::path("foo")), "\"foo\" "); - EXPECT_EQ(fmt::format("{}", std::filesystem::path("foo\"bar.txt")), - "\"foo\\\"bar.txt\""); -#endif -} - TEST(std_test, thread_id) { EXPECT_FALSE(fmt::format("{}", std::this_thread::get_id()).empty()); }