2024-10-04 12:57:57 -07:00
|
|
|
// Formatting library for C++ - formatting library tests
|
|
|
|
|
//
|
2026-05-31 08:54:06 -07:00
|
|
|
// Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors
|
2024-10-04 12:57:57 -07:00
|
|
|
// All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// For the license information refer to format.h.
|
|
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
2025-12-07 07:23:19 -08:00
|
|
|
#if !defined(__GNUC__) || (__GNUC__ >= 5 || defined(__clang__))
|
|
|
|
|
|
2025-05-03 07:29:09 -07:00
|
|
|
# define FMT_BUILTIN_TYPES 0
|
2025-12-07 07:23:19 -08:00
|
|
|
# include "fmt/compile.h"
|
2024-10-04 12:57:57 -07:00
|
|
|
|
|
|
|
|
TEST(no_builtin_types_test, format) {
|
|
|
|
|
EXPECT_EQ(fmt::format("{}", 42), "42");
|
2025-03-22 07:33:28 -07:00
|
|
|
EXPECT_EQ(fmt::format("{}", 42L), "42");
|
2024-10-04 12:57:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(no_builtin_types_test, double_is_custom_type) {
|
|
|
|
|
double d = 42;
|
|
|
|
|
auto args = fmt::make_format_args(d);
|
|
|
|
|
EXPECT_EQ(fmt::format_args(args).get(0).type(),
|
|
|
|
|
fmt::detail::type::custom_type);
|
|
|
|
|
}
|
2025-12-07 07:23:19 -08:00
|
|
|
|
|
|
|
|
TEST(no_builtin_types_test, format_pointer_compiled) {
|
|
|
|
|
const void* p = nullptr;
|
|
|
|
|
fmt::format(FMT_COMPILE("{:} {}"), 42, p);
|
|
|
|
|
}
|
2024-10-04 12:57:57 -07:00
|
|
|
#endif
|