Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac2ebe8d76 | ||
|
|
b64a0a6b49 |
No files matched your search
@@ -622,7 +622,7 @@ TEST_CASE("BON8")
|
|||||||
// with a terminated string, strict = false leaves the next value in the stream
|
// with a terminated string, strict = false leaves the next value in the stream
|
||||||
std::istringstream terminated(std::string("\x61\xFF\x90", 3));
|
std::istringstream terminated(std::string("\x61\xFF\x90", 3));
|
||||||
CHECK(json::from_bon8(terminated, false) == "a");
|
CHECK(json::from_bon8(terminated, false) == "a");
|
||||||
CHECK((terminated.tellg() == 2));
|
CHECK(static_cast<std::streamoff>(terminated.tellg()) == 2);
|
||||||
CHECK(json::from_bon8(terminated, false) == 0);
|
CHECK(json::from_bon8(terminated, false) == 0);
|
||||||
|
|
||||||
// without the terminator, the next value would be lost
|
// without the terminator, the next value would be lost
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ using nlohmann::json;
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <random>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -2875,13 +2876,16 @@ TEST_CASE("diagnostic positions: value lifetime, input adapters, and SAX")
|
|||||||
SECTION("std::ifstream: positions are consistent, not npos")
|
SECTION("std::ifstream: positions are consistent, not npos")
|
||||||
{
|
{
|
||||||
const std::string s = R"({"a":1,"b":2})";
|
const std::string s = R"({"a":1,"b":2})";
|
||||||
|
// the C++11 and C++20 builds of this test run in parallel in the same directory
|
||||||
|
std::random_device rd;
|
||||||
|
const std::string temp_name = "unit-class_parser_diagnostic_positions-" + std::to_string(rd()) + ".tmp";
|
||||||
{
|
{
|
||||||
std::ofstream file("unit-class_parser_diagnostic_positions.tmp");
|
std::ofstream file(temp_name);
|
||||||
file << s;
|
file << s;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ifstream f("unit-class_parser_diagnostic_positions.tmp");
|
std::ifstream f(temp_name);
|
||||||
const json j = json::parse(f);
|
const json j = json::parse(f);
|
||||||
|
|
||||||
CHECK(j.start_pos() == 0);
|
CHECK(j.start_pos() == 0);
|
||||||
@@ -2889,7 +2893,7 @@ TEST_CASE("diagnostic positions: value lifetime, input adapters, and SAX")
|
|||||||
CHECK(j["a"].start_pos() == 5);
|
CHECK(j["a"].start_pos() == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<void>(std::remove("unit-class_parser_diagnostic_positions.tmp"));
|
static_cast<void>(std::remove(temp_name.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("iterator-pair input: positions are consistent, not npos")
|
SECTION("iterator-pair input: positions are consistent, not npos")
|
||||||
|
|||||||
@@ -238,8 +238,8 @@ TEST_CASE("UBJSON the valueless elements of a whole input are bounded")
|
|||||||
std::vector<std::uint8_t> input = {'['};
|
std::vector<std::uint8_t> input = {'['};
|
||||||
utils::append_valueless_array(input, 'Z', first_count);
|
utils::append_valueless_array(input, 'Z', first_count);
|
||||||
input.insert(input.end(), {'[', '$', 'U', '#', 'l',
|
input.insert(input.end(), {'[', '$', 'U', '#', 'l',
|
||||||
static_cast<std::uint8_t>(payload >> 24), static_cast<std::uint8_t>(payload >> 16),
|
static_cast<std::uint8_t>((payload >> 24) & 0xFFu), static_cast<std::uint8_t>((payload >> 16) & 0xFFu),
|
||||||
static_cast<std::uint8_t>(payload >> 8), static_cast<std::uint8_t>(payload)
|
static_cast<std::uint8_t>((payload >> 8) & 0xFFu), static_cast<std::uint8_t>(payload & 0xFFu)
|
||||||
});
|
});
|
||||||
input.insert(input.end(), payload, 0x01);
|
input.insert(input.end(), payload, 0x01);
|
||||||
utils::append_valueless_array(input, 'Z', count);
|
utils::append_valueless_array(input, 'Z', count);
|
||||||
|
|||||||
Reference in new issue
Block a user