Fix additional compilation errors in unit tests for VC
This commit is contained in:
parent
c8bed6b8cc
commit
26491cff1e
@ -25,48 +25,48 @@
|
|||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
||||||
TEST(StringBuffer, InitialSize) {
|
TEST(StringBuffer, InitialSize) {
|
||||||
StringBuffer buffer;
|
StringBuffer buffer;
|
||||||
EXPECT_EQ(0u, buffer.GetSize());
|
EXPECT_EQ(0u, buffer.GetSize());
|
||||||
EXPECT_STREQ("", buffer.GetString());
|
EXPECT_STREQ("", buffer.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringBuffer, Put) {
|
TEST(StringBuffer, Put) {
|
||||||
StringBuffer buffer;
|
StringBuffer buffer;
|
||||||
buffer.Put('A');
|
buffer.Put('A');
|
||||||
|
|
||||||
EXPECT_EQ(1u, buffer.GetSize());
|
EXPECT_EQ(1u, buffer.GetSize());
|
||||||
EXPECT_STREQ("A", buffer.GetString());
|
EXPECT_STREQ("A", buffer.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringBuffer, Clear) {
|
TEST(StringBuffer, Clear) {
|
||||||
StringBuffer buffer;
|
StringBuffer buffer;
|
||||||
buffer.Put('A');
|
buffer.Put('A');
|
||||||
buffer.Put('B');
|
buffer.Put('B');
|
||||||
buffer.Put('C');
|
buffer.Put('C');
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
|
|
||||||
EXPECT_EQ(0u, buffer.GetSize());
|
EXPECT_EQ(0u, buffer.GetSize());
|
||||||
EXPECT_STREQ("", buffer.GetString());
|
EXPECT_STREQ("", buffer.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringBuffer, Push) {
|
TEST(StringBuffer, Push) {
|
||||||
StringBuffer buffer;
|
StringBuffer buffer;
|
||||||
buffer.Push(5);
|
buffer.Push(5);
|
||||||
|
|
||||||
EXPECT_EQ(5u, buffer.GetSize());
|
EXPECT_EQ(5u, buffer.GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringBuffer, Pop) {
|
TEST(StringBuffer, Pop) {
|
||||||
StringBuffer buffer;
|
StringBuffer buffer;
|
||||||
buffer.Put('A');
|
buffer.Put('A');
|
||||||
buffer.Put('B');
|
buffer.Put('B');
|
||||||
buffer.Put('C');
|
buffer.Put('C');
|
||||||
buffer.Put('D');
|
buffer.Put('D');
|
||||||
buffer.Put('E');
|
buffer.Put('E');
|
||||||
buffer.Pop(3);
|
buffer.Pop(3);
|
||||||
|
|
||||||
EXPECT_EQ(2u, buffer.GetSize());
|
EXPECT_EQ(2u, buffer.GetSize());
|
||||||
EXPECT_STREQ("AB", buffer.GetString());
|
EXPECT_STREQ("AB", buffer.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||||
@ -74,67 +74,73 @@ TEST(StringBuffer, Pop) {
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
TEST(StringBuffer, Traits) {
|
TEST(StringBuffer, Traits) {
|
||||||
static_assert( std::is_constructible<StringBuffer>::value, "");
|
static_assert( std::is_constructible<StringBuffer>::value, "");
|
||||||
static_assert( std::is_default_constructible<StringBuffer>::value, "");
|
static_assert( std::is_default_constructible<StringBuffer>::value, "");
|
||||||
static_assert(!std::is_copy_constructible<StringBuffer>::value, "");
|
#ifndef _MSC_VER
|
||||||
static_assert( std::is_move_constructible<StringBuffer>::value, "");
|
static_assert(!std::is_copy_constructible<StringBuffer>::value, "");
|
||||||
|
#endif
|
||||||
|
static_assert( std::is_move_constructible<StringBuffer>::value, "");
|
||||||
|
|
||||||
static_assert(!std::is_nothrow_constructible<StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_constructible<StringBuffer>::value, "");
|
||||||
static_assert(!std::is_nothrow_default_constructible<StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_default_constructible<StringBuffer>::value, "");
|
||||||
static_assert(!std::is_nothrow_copy_constructible<StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_copy_constructible<StringBuffer>::value, "");
|
||||||
static_assert(!std::is_nothrow_move_constructible<StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_move_constructible<StringBuffer>::value, "");
|
||||||
|
|
||||||
static_assert( std::is_assignable<StringBuffer,StringBuffer>::value, "");
|
static_assert( std::is_assignable<StringBuffer,StringBuffer>::value, "");
|
||||||
static_assert(!std::is_copy_assignable<StringBuffer>::value, "");
|
#ifndef _MSC_VER
|
||||||
static_assert( std::is_move_assignable<StringBuffer>::value, "");
|
static_assert(!std::is_copy_assignable<StringBuffer>::value, "");
|
||||||
|
#endif
|
||||||
|
static_assert( std::is_move_assignable<StringBuffer>::value, "");
|
||||||
|
|
||||||
static_assert(!std::is_nothrow_assignable<StringBuffer,StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_assignable<StringBuffer,StringBuffer>::value, "");
|
||||||
static_assert(!std::is_nothrow_copy_assignable<StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_copy_assignable<StringBuffer>::value, "");
|
||||||
static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, "");
|
static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, "");
|
||||||
|
|
||||||
static_assert( std::is_destructible<StringBuffer>::value, "");
|
static_assert( std::is_destructible<StringBuffer>::value, "");
|
||||||
static_assert( std::is_nothrow_destructible<StringBuffer>::value, "");
|
#ifndef _MSC_VER
|
||||||
|
static_assert(std::is_nothrow_destructible<StringBuffer>::value, "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringBuffer, MoveConstructor) {
|
TEST(StringBuffer, MoveConstructor) {
|
||||||
StringBuffer x;
|
StringBuffer x;
|
||||||
x.Put('A');
|
x.Put('A');
|
||||||
x.Put('B');
|
x.Put('B');
|
||||||
x.Put('C');
|
x.Put('C');
|
||||||
x.Put('D');
|
x.Put('D');
|
||||||
|
|
||||||
EXPECT_EQ(4u, x.GetSize());
|
EXPECT_EQ(4u, x.GetSize());
|
||||||
EXPECT_STREQ("ABCD", x.GetString());
|
EXPECT_STREQ("ABCD", x.GetString());
|
||||||
|
|
||||||
// StringBuffer y(x); // does not compile (!is_copy_constructible)
|
// StringBuffer y(x); // does not compile (!is_copy_constructible)
|
||||||
StringBuffer y(std::move(x));
|
StringBuffer y(std::move(x));
|
||||||
EXPECT_EQ(0u, x.GetSize());
|
EXPECT_EQ(0u, x.GetSize());
|
||||||
EXPECT_EQ(4u, y.GetSize());
|
EXPECT_EQ(4u, y.GetSize());
|
||||||
EXPECT_STREQ("ABCD", y.GetString());
|
EXPECT_STREQ("ABCD", y.GetString());
|
||||||
|
|
||||||
// StringBuffer z = y; // does not compile (!is_copy_assignable)
|
// StringBuffer z = y; // does not compile (!is_copy_assignable)
|
||||||
StringBuffer z = std::move(y);
|
StringBuffer z = std::move(y);
|
||||||
EXPECT_EQ(0u, y.GetSize());
|
EXPECT_EQ(0u, y.GetSize());
|
||||||
EXPECT_EQ(4u, z.GetSize());
|
EXPECT_EQ(4u, z.GetSize());
|
||||||
EXPECT_STREQ("ABCD", z.GetString());
|
EXPECT_STREQ("ABCD", z.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringBuffer, MoveAssignment) {
|
TEST(StringBuffer, MoveAssignment) {
|
||||||
StringBuffer x;
|
StringBuffer x;
|
||||||
x.Put('A');
|
x.Put('A');
|
||||||
x.Put('B');
|
x.Put('B');
|
||||||
x.Put('C');
|
x.Put('C');
|
||||||
x.Put('D');
|
x.Put('D');
|
||||||
|
|
||||||
EXPECT_EQ(4u, x.GetSize());
|
EXPECT_EQ(4u, x.GetSize());
|
||||||
EXPECT_STREQ("ABCD", x.GetString());
|
EXPECT_STREQ("ABCD", x.GetString());
|
||||||
|
|
||||||
StringBuffer y;
|
StringBuffer y;
|
||||||
// y = x; // does not compile (!is_copy_assignable)
|
// y = x; // does not compile (!is_copy_assignable)
|
||||||
y = std::move(x);
|
y = std::move(x);
|
||||||
EXPECT_EQ(0u, x.GetSize());
|
EXPECT_EQ(0u, x.GetSize());
|
||||||
EXPECT_EQ(4u, y.GetSize());
|
EXPECT_EQ(4u, y.GetSize());
|
||||||
EXPECT_STREQ("ABCD", y.GetString());
|
EXPECT_STREQ("ABCD", y.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user