Test IsConvertibleToInt with a C++11 enum

This commit is contained in:
vitaut 2015-03-18 11:02:37 -07:00
parent 23b60f5735
commit 2adbfa4af7
2 changed files with 16 additions and 0 deletions

View File

@ -14,6 +14,14 @@ function(add_fmt_test name)
add_test(NAME ${name} COMMAND ${name}) add_test(NAME ${name} COMMAND ${name})
endfunction() endfunction()
check_cxx_source_compiles("
enum C : char {A};
int main() {}"
HAVE_ENUM_BASE)
if (HAVE_ENUM_BASE)
add_definitions(-DFMT_USE_ENUM_BASE=1)
endif ()
add_fmt_test(gtest-extra-test) add_fmt_test(gtest-extra-test)
add_fmt_test(format-test) add_fmt_test(format-test)
add_fmt_test(format-impl-test CUSTOM_LINK) add_fmt_test(format-impl-test CUSTOM_LINK)

View File

@ -837,3 +837,11 @@ TEST(UtilTest, IsConvertibleToInt) {
EXPECT_TRUE(fmt::internal::IsConvertibleToInt<char>::value); EXPECT_TRUE(fmt::internal::IsConvertibleToInt<char>::value);
EXPECT_FALSE(fmt::internal::IsConvertibleToInt<const char *>::value); EXPECT_FALSE(fmt::internal::IsConvertibleToInt<const char *>::value);
} }
#if FMT_USE_ENUM_BASE
enum TestEnum : char {TestValue};
TEST(UtilTest, IsEnumConvertibleToInt) {
EXPECT_TRUE(fmt::internal::IsConvertibleToInt<TestEnum>::value);
}
#endif