Move implementation tests to format-impl-test.

This commit is contained in:
Victor Zverovich 2014-09-05 07:12:20 -07:00
parent 93bcad6d8e
commit fe9888a1e2
2 changed files with 9 additions and 21 deletions

View File

@ -3,20 +3,21 @@ add_library(test-main ${TEST_MAIN_SRC})
target_link_libraries(test-main gtest)
# Adds a test.
# Usage: add_fmt_test(name libs srcs...)
function(add_fmt_test name libs)
# Usage: add_fmt_test(name [CUSTOM_LINK] srcs...)
function(add_fmt_test name)
cmake_parse_arguments(add_fmt_test CUSTOM_LINK "" "" ${ARGN})
add_executable(${name} ${name}.cc ${add_fmt_test_UNPARSED_ARGUMENTS})
target_link_libraries(${name} ${libs})
target_link_libraries(${name} test-main)
if (NOT add_fmt_test_CUSTOM_LINK)
target_link_libraries(${name} format)
endif ()
add_test(${name} ${name})
endfunction()
add_fmt_test(gtest-extra-test test-main)
add_fmt_test(format-test test-main CUSTOM_LINK ../posix.cc ../posix.h)
add_fmt_test(printf-test test-main)
add_fmt_test(gtest-extra-test)
add_fmt_test(format-test)
add_fmt_test(format-impl-test CUSTOM_LINK)
add_fmt_test(printf-test)
foreach (target format-test printf-test)
if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${target} PROPERTIES COMPILE_FLAGS
@ -26,7 +27,7 @@ foreach (target format-test printf-test)
set_target_properties(${target} PROPERTIES COMPILE_FLAGS ${CPP11_FLAG})
endif ()
endforeach ()
add_fmt_test(util-test test-main)
add_fmt_test(util-test)
foreach (src ${FMT_SOURCES})
set(FMT_TEST_SOURCES ${FMT_TEST_SOURCES} ../${src})

View File

@ -36,7 +36,7 @@
#include <sstream>
// Include format.cc instead of format.h to test implementation-specific stuff.
#include "format.cc"
#include "format.h"
#include "util.h"
#include "gtest-extra.h"
@ -1226,10 +1226,6 @@ TEST(FormatterTest, FormatNaN) {
double nan = std::numeric_limits<double>::quiet_NaN();
EXPECT_EQ("nan", format("{}", nan));
EXPECT_EQ("+nan", format("{:+}", nan));
if (getsign(-nan))
EXPECT_EQ("-nan", format("{}", -nan));
else
fmt::print("Warning: compiler doesn't handle negative NaN correctly");
EXPECT_EQ(" nan", format("{: }", nan));
EXPECT_EQ("NAN", format("{:F}", nan));
EXPECT_EQ("nan ", format("{:<7}", nan));
@ -1532,15 +1528,6 @@ TEST(FormatTest, FormatMessageExample) {
format_message(42, "{} happened", "something"));
}
TEST(FormatTest, ArgConverter) {
using fmt::internal::Arg;
Arg arg = Arg();
arg.type = Arg::LONG_LONG;
arg.long_long_value = std::numeric_limits<fmt::LongLong>::max();
ArgConverter<fmt::LongLong>(arg, 'd').visit(arg);
EXPECT_EQ(Arg::LONG_LONG, arg.type);
}
#if FMT_USE_VARIADIC_TEMPLATES
template<typename... Args>
void print_error(const char *file, int line, const char *format,