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).
This commit is contained in:
Victor Zverovich 2014-09-30 07:30:05 -07:00
parent d00f689c40
commit 313b259891
2 changed files with 14 additions and 8 deletions

View File

@ -22,14 +22,6 @@ function (expect_compile_error code)
endif ()
endfunction ()
# Array is noncopyable.
expect_compile_error("fmt::internal::Array<char, 5> a, b(a);")
expect_compile_error("fmt::internal::Array<char, 5> 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<char>)(s);")
expect_compile_error("const volatile char s[] = \"test\"; (fmt::internal::MakeArg<char>)(s);")

View File

@ -36,6 +36,10 @@
#include <sstream>
#include <stdint.h>
#if FMT_USE_TYPE_TRAITS
# include <type_traits>
#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<BasicWriter<char> >::value);
}
TEST(WriterTest, NotCopyAssignable) {
EXPECT_FALSE(std::is_copy_assignable<BasicWriter<char> >::value);
}
#endif
TEST(WriterTest, Ctor) {
MemoryWriter w;
EXPECT_EQ(0u, w.size());