Skip to content

Commit

Permalink
Split test/std-test.cc.
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <[email protected]>
  • Loading branch information
phprus committed Jun 4, 2022
1 parent 8644654 commit 21456dd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions test/std-filesystem-test.cc
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 0 additions & 8 deletions test/std-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit 21456dd

Please sign in to comment.