fixed tests for copy assignment
This commit is contained in:
parent
d760ff5142
commit
29a8d43d5a
3 changed files with 14 additions and 9 deletions
|
@ -445,7 +445,6 @@ class basic_json
|
||||||
/// copy assignment
|
/// copy assignment
|
||||||
inline reference& operator=(basic_json other) noexcept
|
inline reference& operator=(basic_json other) noexcept
|
||||||
{
|
{
|
||||||
assert(false); // not sure if function will ever be called
|
|
||||||
std::swap(m_type, other.m_type);
|
std::swap(m_type, other.m_type);
|
||||||
std::swap(m_value, other.m_value);
|
std::swap(m_value, other.m_value);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -445,7 +445,6 @@ class basic_json
|
||||||
/// copy assignment
|
/// copy assignment
|
||||||
inline reference& operator=(basic_json other) noexcept
|
inline reference& operator=(basic_json other) noexcept
|
||||||
{
|
{
|
||||||
assert(false); // not sure if function will ever be called
|
|
||||||
std::swap(m_type, other.m_type);
|
std::swap(m_type, other.m_type);
|
||||||
std::swap(m_value, other.m_value);
|
std::swap(m_value, other.m_value);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -963,49 +963,56 @@ TEST_CASE("other constructors and destructor")
|
||||||
SECTION("object")
|
SECTION("object")
|
||||||
{
|
{
|
||||||
json j {{"foo", 1}, {"bar", false}};
|
json j {{"foo", 1}, {"bar", false}};
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("array")
|
SECTION("array")
|
||||||
{
|
{
|
||||||
json j {"foo", 1, 42.23, false};
|
json j {"foo", 1, 42.23, false};
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("null")
|
SECTION("null")
|
||||||
{
|
{
|
||||||
json j(nullptr);
|
json j(nullptr);
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("boolean")
|
SECTION("boolean")
|
||||||
{
|
{
|
||||||
json j(true);
|
json j(true);
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("string")
|
SECTION("string")
|
||||||
{
|
{
|
||||||
json j("Hello world");
|
json j("Hello world");
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("number (integer)")
|
SECTION("number (integer)")
|
||||||
{
|
{
|
||||||
json j(42);
|
json j(42);
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("number (floating-point)")
|
SECTION("number (floating-point)")
|
||||||
{
|
{
|
||||||
json j(42.23);
|
json j(42.23);
|
||||||
json k = j;
|
json k;
|
||||||
|
k = j;
|
||||||
CHECK(j == k);
|
CHECK(j == k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue