This commit is contained in:
Victor Zverovich
2024-09-06 12:27:48 -07:00
parent cad876be4c
commit f5a16a484b
8 changed files with 24 additions and 60 deletions

View File

@@ -115,8 +115,7 @@ function (run_tests)
endif ()
endfunction ()
# check if the source file skeleton compiles
# Check if the source file skeleton compiles.
expect_compile(check "")
expect_compile(check-error "compilation_error" ERROR)
@@ -166,31 +165,6 @@ expect_compile(format-lots-of-arguments-with-function "
fmt::format(\"\", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, f);
" ERROR)
# Check if user-defined literals are available
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS ${CXX_STANDARD_FLAG})
check_cxx_source_compiles("
void operator\"\" _udl(long double);
int main() {}"
SUPPORTS_USER_DEFINED_LITERALS)
set(CMAKE_REQUIRED_FLAGS )
if (NOT SUPPORTS_USER_DEFINED_LITERALS)
set (SUPPORTS_USER_DEFINED_LITERALS OFF)
endif ()
# Make sure that compiler features detected in the header
# match the features detected in CMake.
if (SUPPORTS_USER_DEFINED_LITERALS)
set(supports_udl 1)
else ()
set(supports_udl 0)
endif ()
expect_compile(udl-check "
#if FMT_USE_USER_DEFINED_LITERALS != ${supports_udl}
# error
#endif
")
if (CMAKE_CXX_STANDARD GREATER_EQUAL 20)
# Compile-time argument type check
expect_compile(format-string-number-spec "

View File

@@ -2005,7 +2005,7 @@ TEST(format_test, custom_format_compile_time_string) {
EXPECT_EQ(fmt::format(FMT_STRING("{}"), const_answer), "42");
}
#if FMT_USE_USER_DEFINED_LITERALS
#if FMT_USE_USER_LITERALS
TEST(format_test, named_arg_udl) {
using namespace fmt::literals;
auto udl_a = fmt::format("{first}{second}{first}{third}", "first"_a = "abra",
@@ -2017,7 +2017,7 @@ TEST(format_test, named_arg_udl) {
EXPECT_EQ(fmt::format("{answer}", "answer"_a = Answer()), "42");
}
#endif // FMT_USE_USER_DEFINED_LITERALS
#endif // FMT_USE_USER_LITERALS
TEST(format_test, enum) { EXPECT_EQ(fmt::format("{}", foo), "0"); }

View File

@@ -231,7 +231,7 @@ TEST(format_test, wide_format_to_n) {
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
}
#if FMT_USE_USER_DEFINED_LITERALS
#if FMT_USE_USER_LITERALS
TEST(xchar_test, named_arg_udl) {
using namespace fmt::literals;
auto udl_a =
@@ -242,7 +242,7 @@ TEST(xchar_test, named_arg_udl) {
fmt::arg(L"second", L"cad"), fmt::arg(L"third", 99)),
udl_a);
}
#endif // FMT_USE_USER_DEFINED_LITERALS
#endif // FMT_USE_USER_LITERALS
TEST(xchar_test, print) {
// Check that the wide print overload compiles.