8#include <univalue/test/fail1.json.h>
9#include <univalue/test/fail10.json.h>
10#include <univalue/test/fail11.json.h>
11#include <univalue/test/fail12.json.h>
12#include <univalue/test/fail13.json.h>
13#include <univalue/test/fail14.json.h>
14#include <univalue/test/fail15.json.h>
15#include <univalue/test/fail16.json.h>
16#include <univalue/test/fail17.json.h>
17#include <univalue/test/fail18.json.h>
18#include <univalue/test/fail19.json.h>
19#include <univalue/test/fail2.json.h>
20#include <univalue/test/fail20.json.h>
21#include <univalue/test/fail21.json.h>
22#include <univalue/test/fail22.json.h>
23#include <univalue/test/fail23.json.h>
24#include <univalue/test/fail24.json.h>
25#include <univalue/test/fail25.json.h>
26#include <univalue/test/fail26.json.h>
27#include <univalue/test/fail27.json.h>
28#include <univalue/test/fail28.json.h>
29#include <univalue/test/fail29.json.h>
30#include <univalue/test/fail3.json.h>
31#include <univalue/test/fail30.json.h>
32#include <univalue/test/fail31.json.h>
33#include <univalue/test/fail32.json.h>
34#include <univalue/test/fail33.json.h>
35#include <univalue/test/fail34.json.h>
36#include <univalue/test/fail35.json.h>
37#include <univalue/test/fail36.json.h>
38#include <univalue/test/fail37.json.h>
39#include <univalue/test/fail38.json.h>
40#include <univalue/test/fail39.json.h>
41#include <univalue/test/fail4.json.h>
42#include <univalue/test/fail40.json.h>
43#include <univalue/test/fail41.json.h>
44#include <univalue/test/fail42.json.h>
45#include <univalue/test/fail44.json.h>
46#include <univalue/test/fail45.json.h>
47#include <univalue/test/fail5.json.h>
48#include <univalue/test/fail6.json.h>
49#include <univalue/test/fail7.json.h>
50#include <univalue/test/fail8.json.h>
51#include <univalue/test/fail9.json.h>
52#include <univalue/test/pass1.json.h>
53#include <univalue/test/pass2.json.h>
54#include <univalue/test/pass3.json.h>
55#include <univalue/test/pass4.json.h>
56#include <univalue/test/round1.json.h>
57#include <univalue/test/round2.json.h>
58#include <univalue/test/round3.json.h>
59#include <univalue/test/round4.json.h>
60#include <univalue/test/round5.json.h>
61#include <univalue/test/round6.json.h>
62#include <univalue/test/round7.json.h>
69static std::string
rtrim(std::string
s)
71 s.erase(
s.find_last_not_of(
" \n\r\t") + 1);
75static void runtest(std::string filename,
const std::string& jdata)
77 std::string
prefix = filename.substr(0, 4);
79 bool wantPass = (
prefix ==
"pass") || (
prefix ==
"roun");
80 bool wantFail = (
prefix ==
"fail");
81 bool wantRoundTrip = (
prefix ==
"roun");
82 assert(wantPass || wantFail);
85 bool testResult = val.
read(jdata);
88 assert(testResult ==
true);
90 assert(testResult ==
false);
94 std::string odata = val.
write(0, 0);
99#define TEST_FILE(name) {#name, json_tests::name}
100inline constexpr std::array
tests{std::to_array<std::tuple<std::string_view, std::string_view>>({
164 testResult = val.
read(
"[\"\\u0022\"]");
166 assert(val[0].get_str() ==
"\"");
168 testResult = val.
read(
"[\"\\u0191\"]");
170 assert(val[0].get_str() ==
"\xc6\x91");
172 testResult = val.
read(
"[\"\\u2191\"]");
174 assert(val[0].get_str() ==
"\xe2\x86\x91");
176 testResult = val.
read(
"[\"\\ud834\\udd61\"]");
178 assert(val[0].get_str() ==
"\xf0\x9d\x85\xa1");
183 char buf[] =
"___[1,2,3]___";
188int main(
int argc,
char* argv[])
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
bool read(std::string_view raw)
char const * json() noexcept
Template to generate JSON data.
int main(int argc, char *argv[])
static std::string rtrim(std::string s)
void unescape_unicode_test()
static void runtest(std::string filename, const std::string &jdata)
constexpr std::array tests