Skip to content

Commit

Permalink
Test IsConvertibleToInt with a C++11 enum
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Mar 18, 2015
1 parent 23b60f5 commit 2adbfa4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/util-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -837,3 +837,11 @@ TEST(UtilTest, IsConvertibleToInt) {
EXPECT_TRUE(fmt::internal::IsConvertibleToInt<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

0 comments on commit 2adbfa4

Please sign in to comment.