From 2adbfa4af7b9bcb437b4341bae06d9d8a766d6b2 Mon Sep 17 00:00:00 2001 From: vitaut Date: Wed, 18 Mar 2015 11:02:37 -0700 Subject: [PATCH] Test IsConvertibleToInt with a C++11 enum --- test/CMakeLists.txt | 8 ++++++++ test/util-test.cc | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6ddd5871a6cc..210f3abd6d76 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,6 +14,14 @@ function(add_fmt_test name) add_test(NAME ${name} COMMAND ${name}) 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(format-test) add_fmt_test(format-impl-test CUSTOM_LINK) diff --git a/test/util-test.cc b/test/util-test.cc index 92d22d35cc19..6392528799a5 100644 --- a/test/util-test.cc +++ b/test/util-test.cc @@ -837,3 +837,11 @@ TEST(UtilTest, IsConvertibleToInt) { EXPECT_TRUE(fmt::internal::IsConvertibleToInt::value); EXPECT_FALSE(fmt::internal::IsConvertibleToInt::value); } + +#if FMT_USE_ENUM_BASE +enum TestEnum : char {TestValue}; +TEST(UtilTest, IsEnumConvertibleToInt) { + EXPECT_TRUE(fmt::internal::IsConvertibleToInt::value); +} +#endif +