From cc7b64fe5e94f817d2523645ed50801662104251 Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Sat, 29 May 2021 20:00:41 +0200 Subject: [PATCH] Re-enable module testing Prepare for compilation with gcc (modules branch). --- src/fmt.cc | 8 ++++++++ test/CMakeLists.txt | 4 ++-- test/module-test.cc | 10 ++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/fmt.cc b/src/fmt.cc index 728436ffca1d6..b4910336e7c64 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -75,6 +75,11 @@ export module fmt; #define FMT_END_DETAIL_NAMESPACE \ } \ export { + +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER > 192930036 +#define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0 +#endif + // all library-provided declarations and definitions // must be in the module purview to be exported #include "fmt/args.h" @@ -86,7 +91,10 @@ export module fmt; #include "fmt/printf.h" #include "fmt/xchar.h" +// gcc doesn't yet implement private module fragments +#if !FMT_GCC_VERSION module : private; +#endif #include "format.cc" #include "os.cc" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bd94b95ec23fc..abaef78a8e31d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -94,10 +94,10 @@ if (FMT_CAN_MODULE) $) enable_module(test-module) - #add_fmt_test(module-test MODULE) + add_fmt_test(module-test MODULE) if (MSVC) target_compile_options(test-module PRIVATE /utf-8) - #target_compile_options(module-test PRIVATE /utf-8) + target_compile_options(module-test PRIVATE /utf-8) endif () endif () diff --git a/test/module-test.cc b/test/module-test.cc index fe38a79a344bf..58d440a0009fe 100644 --- a/test/module-test.cc +++ b/test/module-test.cc @@ -9,6 +9,12 @@ // All Rights Reserved // {fmt} module. +#ifdef _MSC_FULL_VER +// hide some implementation bugs in msvc +// that are not essential to users of the module. +# define FMT_HIDE_MODULE_BUGS +#endif + #include #include #include @@ -405,9 +411,9 @@ TEST(module_test, color) { TEST(module_test, cstring_view) { fmt::cstring_view nsv("fmt"); - EXPECT_EQ("fmt", nsv.c_str()); + EXPECT_EQ(std::string("fmt"), nsv.c_str()); fmt::wcstring_view wsv(L"fmt"); - EXPECT_EQ(L"fmt", wsv.c_str()); + EXPECT_EQ(std::wstring(L"fmt"), wsv.c_str()); } TEST(module_test, buffered_file) {