mirror of
https://github.com/nlohmann/json.git
synced 2026-10-11 08:57:15 +00:00
Fix MSVC C4244 and C2017 in the image test
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 file changed
+5
-2
@@ -301,7 +301,8 @@ TEST_CASE("json_view images: round trips")
|
|||||||
for (std::uint64_t counter = 0; colliding.size() < colliding_count || spread.size() < spread_count; ++counter)
|
for (std::uint64_t counter = 0; colliding.size() < colliding_count || spread.size() < spread_count; ++counter)
|
||||||
{
|
{
|
||||||
std::string key(8, 'a');
|
std::string key(8, 'a');
|
||||||
for (std::uint64_t x = counter, i = 0; i < 8; ++i, x /= 26)
|
std::uint64_t x = counter;
|
||||||
|
for (std::size_t i = 0; i < 8; ++i, x /= 26)
|
||||||
{
|
{
|
||||||
key[i] = static_cast<char>('a' + (x % 26));
|
key[i] = static_cast<char>('a' + (x % 26));
|
||||||
}
|
}
|
||||||
@@ -1062,7 +1063,9 @@ TEST_CASE("json_view images: check")
|
|||||||
set_node(same, 2, node_at(img2, 1));
|
set_node(same, 2, node_at(img2, 1));
|
||||||
set_node(same, 4, node_at(img2, 3));
|
set_node(same, 4, node_at(img2, 3));
|
||||||
CHECK(load_result(same, image_check::full).empty());
|
CHECK(load_result(same, image_check::full).empty());
|
||||||
CHECK(loaded_dump(same) == R"(["a\"b","a\"b",1.25,1.25,1250.0])");
|
// (a raw string with a backslash must not be a macro argument: MSVC C2017)
|
||||||
|
const std::string expected_same = R"(["a\"b","a\"b",1.25,1.25,1250.0])";
|
||||||
|
CHECK(loaded_dump(same) == expected_same);
|
||||||
std::vector<std::uint8_t> layout = same;
|
std::vector<std::uint8_t> layout = same;
|
||||||
node f4 = node_at(layout, 4);
|
node f4 = node_at(layout, 4);
|
||||||
f4.extra = 0x0100u; // the layout of "1.", and not that of "1.25"
|
f4.extra = 0x0100u; // the layout of "1.", and not that of "1.25"
|
||||||
|
|||||||
Reference in new issue
Block a user