mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-25 03:39:56 +01:00
Add FMT_STATIC_FORMAT
This commit is contained in:
@@ -236,6 +236,12 @@ TEST(compile_test, constexpr_formatted_size) {
|
||||
fmt::formatted_size(FMT_COMPILE("{:s}"), "abc");
|
||||
EXPECT_EQ(str_size, 3);
|
||||
}
|
||||
|
||||
TEST(compile_test, static_format) {
|
||||
constexpr auto result = FMT_STATIC_FORMAT("{}", 42);
|
||||
EXPECT_STREQ(result.c_str(), "42");
|
||||
EXPECT_EQ(result.str(), "42");
|
||||
}
|
||||
# endif
|
||||
|
||||
TEST(compile_test, text_and_arg) {
|
||||
@@ -423,22 +429,16 @@ TEST(compile_time_formatting_test, multibyte_fill) {
|
||||
#endif
|
||||
|
||||
#if FMT_USE_CONSTEXPR_STRING
|
||||
TEST(compile_test, constexpr_string_format) {
|
||||
constexpr auto result = []() {
|
||||
return fmt::format(FMT_COMPILE("{}"), 42) == "42";
|
||||
}();
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
TEST(compile_test, constexpr_format) {
|
||||
{
|
||||
constexpr auto result = []() {
|
||||
return fmt::format(FMT_COMPILE("{}"), 42) == "42";
|
||||
}();
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
{
|
||||
// Test with a larger string to avoid small string optimization.
|
||||
constexpr auto result = []() {
|
||||
return fmt::format(FMT_COMPILE("{:100}"), ' ') == std::string(100, ' ');
|
||||
}();
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
// Test with a larger string to avoid small string optimization.
|
||||
constexpr auto big = []() {
|
||||
return fmt::format(FMT_COMPILE("{:100}"), ' ') == std::string(100, ' ');
|
||||
}();
|
||||
EXPECT_TRUE(big);
|
||||
}
|
||||
|
||||
#endif // FMT_USE_CONSTEXPR_STRING
|
||||
|
||||
Reference in New Issue
Block a user