Skip to content

Commit

Permalink
Test FMT_BUILTIN_TYPES
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Oct 4, 2024
1 parent 22701d5 commit c68c5fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ if (NOT (MSVC AND BUILD_SHARED_LIBS))
endif ()
add_fmt_test(ostream-test)
add_fmt_test(compile-test)
add_fmt_test(compile-fp-test HEADER_ONLY)
add_fmt_test(compile-fp-test)
if (MSVC)
# Without this option, MSVC returns 199711L for the __cplusplus macro.
target_compile_options(compile-fp-test PRIVATE /Zc:__cplusplus)
endif()
add_fmt_test(printf-test)
add_fmt_test(ranges-test ranges-odr-test.cc)
add_fmt_test(no-builtin-types-test HEADER_ONLY)

add_fmt_test(scan-test HEADER_ONLY)
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
Expand Down
24 changes: 24 additions & 0 deletions test/no-builtin-types-test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Formatting library for C++ - formatting library tests
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.

#include "gtest/gtest.h"

#if !defined(__GNUC__) || __GNUC__ >= 5
#define FMT_BUILTIN_TYPES 0
#include "fmt/format.h"

TEST(no_builtin_types_test, format) {
EXPECT_EQ(fmt::format("{}", 42), "42");
}

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);
}
#endif

0 comments on commit c68c5fa

Please sign in to comment.