Add a grisu test stub

This commit is contained in:
Victor Zverovich 2019-01-27 06:47:27 -08:00
parent 9f70b034e1
commit 4f6fda558c
3 changed files with 34 additions and 0 deletions

View File

@ -10,6 +10,10 @@
FMT_BEGIN_NAMESPACE
template struct internal::basic_data<void>;
// Workaround a bug in MSVC2013 that prevents instantiation of grisu2_format.
bool (*instantiate_grisu2_format)(double, internal::buffer&,
core_format_specs) = internal::grisu2_format;
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
template FMT_API internal::locale_ref::locale_ref(const std::locale& loc);
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;

View File

@ -87,6 +87,7 @@ endfunction()
add_fmt_test(assert-test)
add_fmt_test(chrono-test)
add_fmt_test(core-test)
add_fmt_test(grisu-test)
add_fmt_test(gtest-extra-test)
add_fmt_test(format-test mock-allocator.h)
if (NOT (MSVC AND BUILD_SHARED_LIBS))

29
test/grisu-test.cc Normal file
View File

@ -0,0 +1,29 @@
// Formatting library for C++ - Grisu tests
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#define FMT_USE_GRISU std::numeric_limits<double>::is_iec559
#include "fmt/format.h"
#include "gtest.h"
bool reported_skipped;
#undef TEST
#define TEST(test_fixture, test_name) \
void test_fixture##test_name(); \
GTEST_TEST(test_fixture, test_name) { \
if (FMT_USE_GRISU) { \
test_fixture##test_name(); \
} else if (!reported_skipped) { \
reported_skipped = true; \
fmt::print("Skipping Grisu tests.\n"); \
} \
} \
void test_fixture##test_name()
TEST(GrisuTest, NaN) {
EXPECT_EQ("nan", fmt::format("{}", std::numeric_limits<double>::quiet_NaN()));
}