From 313b259891d9f784c817db397de462bccb397bc6 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 30 Sep 2014 07:30:05 -0700 Subject: [PATCH] Use type_traits to test if copyable/assignable Replace compile tests that check if types are copy constructible and copy assignable with normal tests that use type_traits (if available). --- test/compile-test/CMakeLists.txt | 8 -------- test/format-test.cc | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/test/compile-test/CMakeLists.txt b/test/compile-test/CMakeLists.txt index f8f9e04a..5fcbb1f1 100644 --- a/test/compile-test/CMakeLists.txt +++ b/test/compile-test/CMakeLists.txt @@ -22,14 +22,6 @@ function (expect_compile_error code) endif () endfunction () -# Array is noncopyable. -expect_compile_error("fmt::internal::Array a, b(a);") -expect_compile_error("fmt::internal::Array a, b; b = a;") - -# Writer is noncopyable. -expect_compile_error("const fmt::Writer a, b(a);") -expect_compile_error("fmt::Writer a, b; b = a;") - # MakeArg doesn't accept [const] volatile char *. expect_compile_error("volatile char s[] = \"test\"; (fmt::internal::MakeArg)(s);") expect_compile_error("const volatile char s[] = \"test\"; (fmt::internal::MakeArg)(s);") diff --git a/test/format-test.cc b/test/format-test.cc index a2ce47c6..5d146524 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -36,6 +36,10 @@ #include #include +#if FMT_USE_TYPE_TRAITS +# include +#endif + #include "gmock/gmock.h" #include "format.h" @@ -124,6 +128,16 @@ class TestString { } }; +#if FMT_USE_TYPE_TRAITS +TEST(WriterTest, NotCopyConstructible) { + EXPECT_FALSE(std::is_copy_constructible >::value); +} + +TEST(WriterTest, NotCopyAssignable) { + EXPECT_FALSE(std::is_copy_assignable >::value); +} +#endif + TEST(WriterTest, Ctor) { MemoryWriter w; EXPECT_EQ(0u, w.size());