mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-22 02:20:06 +00:00
add tests for format string compile-time checks
This commit is contained in:
parent
8a2c3fb88f
commit
c7f88180f6
@ -167,5 +167,37 @@ expect_compile(udl-check "
|
||||
#endif
|
||||
")
|
||||
|
||||
if (CMAKE_CXX_STANDARD GREATER_EQUAL 20)
|
||||
# Compile-time argument type check
|
||||
expect_compile(format-string-number-spec "
|
||||
#ifdef FMT_HAS_CONSTEVAL
|
||||
fmt::format(\"{:d}\", 42);
|
||||
#endif
|
||||
")
|
||||
expect_compile(format-string-number-spec-error "
|
||||
#ifdef FMT_HAS_CONSTEVAL
|
||||
fmt::format(\"{:d}\", \"I am not a number\");
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
" ERROR)
|
||||
|
||||
# Compile-time argument name check
|
||||
expect_compile(format-string-name "
|
||||
#if defined(FMT_HAS_CONSTEVAL) && FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
|
||||
using namespace fmt::literals;
|
||||
fmt::print(\"{foo}\", \"foo\"_a=42);
|
||||
#endif
|
||||
")
|
||||
expect_compile(format-string-name-error "
|
||||
#if defined(FMT_HAS_CONSTEVAL) && FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
|
||||
using namespace fmt::literals;
|
||||
fmt::print(\"{foo}\", \"bar\"_a=42);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
" ERROR)
|
||||
endif ()
|
||||
|
||||
# Run all tests
|
||||
run_tests()
|
||||
|
Loading…
Reference in New Issue
Block a user