add compile-time formatting switch and empty test
This commit is contained in:
parent
8a2de0f85d
commit
071142033c
@ -252,6 +252,17 @@
|
||||
# pragma execution_character_set("utf-8")
|
||||
#endif
|
||||
|
||||
#if defined(FMT_ENABLE_COMPILE_TIME_FORMATTING)
|
||||
# if !defined(FMT_HEADER_ONLY) || __cplusplus < 202002L
|
||||
# error "compile time formatting could not be enabled"
|
||||
# endif
|
||||
# define FMT_CTF_CONSTEXPR constexpr
|
||||
# define FMT_USE_CUSTOM_BACK_INSERT_ITERATOR 1
|
||||
#else
|
||||
# define FMT_CTF_CONSTEXPR
|
||||
# define FMT_USE_CUSTOM_BACK_INSERT_ITERATOR 0
|
||||
#endif
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
// Implementations of enable_if_t and other metafunctions for older systems.
|
||||
|
||||
@ -146,6 +146,12 @@ else ()
|
||||
target_compile_definitions(header-only-test PRIVATE FMT_HEADER_ONLY=1)
|
||||
endif ()
|
||||
|
||||
add_fmt_executable(compile-time-formatting-test
|
||||
compile-time-formatting-test.cc test-main.cc)
|
||||
target_link_libraries(compile-time-formatting-test gmock)
|
||||
target_include_directories(compile-time-formatting-test SYSTEM PUBLIC gtest gmock)
|
||||
target_link_libraries(compile-time-formatting-test fmt::fmt-header-only)
|
||||
|
||||
message(STATUS "FMT_PEDANTIC: ${FMT_PEDANTIC}")
|
||||
|
||||
if (FMT_PEDANTIC)
|
||||
|
||||
21
test/compile-time-formatting-test.cc
Normal file
21
test/compile-time-formatting-test.cc
Normal file
@ -0,0 +1,21 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
#define FMT_ENABLE_COMPILE_TIME_FORMATTING 1
|
||||
#include "fmt/format.h"
|
||||
#include "gmock.h"
|
||||
#include "gtest-extra.h"
|
||||
|
||||
template <size_t max_string_length> struct constexpr_buffer_helper {
|
||||
template <typename Func>
|
||||
constexpr constexpr_buffer_helper& modify(Func func) {
|
||||
func(buffer);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T> constexpr bool operator==(const T& rhs) const noexcept {
|
||||
return (std::string_view(rhs).compare(buffer.data()) == 0);
|
||||
}
|
||||
|
||||
std::array<char, max_string_length> buffer{};
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user