🚧 fixed more warnings

This commit is contained in:
Niels Lohmann 2017-02-22 18:14:29 +01:00
parent 345a106d73
commit 8cec55a271
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
10 changed files with 82 additions and 30 deletions

View file

@ -63,9 +63,9 @@ TEST_CASE("bad_alloc")
}
}
bool next_construct_fails = false;
bool next_destroy_fails = false;
bool next_deallocate_fails = false;
static bool next_construct_fails = false;
static bool next_destroy_fails = false;
static bool next_deallocate_fails = false;
template<class T>
struct my_allocator : std::allocator<T>

View file

@ -237,7 +237,7 @@ TEST_CASE("CBOR")
const auto result = json::to_cbor(j);
CHECK(result == expected);
int16_t restored = -1 - ((result[1] << 8) + result[2]);
int16_t restored = static_cast<int16_t>(-1 - ((result[1] << 8) + result[2]));
CHECK(restored == -9263);
// roundtrip

View file

@ -725,7 +725,7 @@ TEST_CASE("constructors")
SECTION("long double")
{
long double n = 42.23;
long double n = 42.23l;
json j(n);
CHECK(j.type() == json::value_t::number_float);
CHECK(j.m_value.number_float == Approx(j_reference.m_value.number_float));

View file

@ -342,7 +342,7 @@ TEST_CASE("MessagePack")
const auto result = json::to_msgpack(j);
CHECK(result == expected);
int16_t restored = (result[1] << 8) + result[2];
int16_t restored = static_cast<int16_t>((result[1] << 8) + result[2]);
CHECK(restored == -9263);
// roundtrip
@ -374,7 +374,7 @@ TEST_CASE("MessagePack")
// check individual bytes
CHECK(result[0] == 0xd1);
int16_t restored = (result[1] << 8) + result[2];
int16_t restored = static_cast<int16_t>((result[1] << 8) + result[2]);
CHECK(restored == i);
// roundtrip

View file

@ -163,7 +163,7 @@ TEST_CASE("README", "[hide]")
j.clear(); // the array is empty again
// comparison
j == "[\"foo\", 1, true]"_json; // true
bool x = (j == "[\"foo\", 1, true]"_json); // true
// create an object
json o;

View file

@ -350,8 +350,8 @@ TEST_CASE("regression tests")
// double
nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double> j_double =
1.23e35f;
CHECK(j_double.get<double>() == 1.23e35f);
1.23e35;
CHECK(j_double.get<double>() == 1.23e35);
// long double
nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, long double>
@ -641,7 +641,7 @@ TEST_CASE("regression tests")
CHECK_THROWS_AS(json::from_msgpack(vec1), std::out_of_range);
// more test cases for MessagePack
for (uint8_t b :
for (auto b :
{
0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, // fixmap
0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, // fixarray
@ -649,12 +649,12 @@ TEST_CASE("regression tests")
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf
})
{
std::vector<uint8_t> vec(1, b);
std::vector<uint8_t> vec(1, static_cast<uint8_t>(b));
CHECK_THROWS_AS(json::from_msgpack(vec), std::out_of_range);
}
// more test cases for CBOR
for (uint8_t b :
for (auto b :
{
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, // UTF-8 string
@ -664,7 +664,7 @@ TEST_CASE("regression tests")
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7 // map
})
{
std::vector<uint8_t> vec(1, b);
std::vector<uint8_t> vec(1, static_cast<uint8_t>(b));
CHECK_THROWS_AS(json::from_cbor(vec), std::out_of_range);
}

View file

@ -816,6 +816,8 @@ TEST_CASE("nst's JSONTestSuite")
}
}
std::string trim(const std::string& str);
// from http://stackoverflow.com/a/25829178/266378
std::string trim(const std::string& str)
{