Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
Go to the documentation of this file. 13 #error JSON_TEST_SRC must point to test source directory 17 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 21 string srcdir(JSON_TEST_SRC);
24 #define d_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", filename.c_str()); } } 25 #define f_assert(expr) { if (!(expr)) { test_failed = true; fprintf(stderr, "%s failed\n", __func__); } } 27 static std::string
rtrim(std::string s)
29 s.erase(s.find_last_not_of(
" \n\r\t")+1);
33 static void runtest(
string filename,
const string& jdata)
35 string prefix = filename.substr(0, 4);
37 bool wantPass = (
prefix ==
"pass") || (
prefix ==
"roun");
38 bool wantFail = (
prefix ==
"fail");
39 bool wantRoundTrip = (
prefix ==
"roun");
40 assert(wantPass || wantFail);
43 bool testResult = val.
read(jdata);
52 std::string odata = val.
write(0, 0);
53 assert(odata ==
rtrim(jdata));
59 string basename(filename_);
60 string filename =
srcdir +
"/" + basename;
61 FILE *f =
fopen(filename.c_str(),
"r");
68 int bread = fread(buf, 1,
sizeof(buf), f);
143 testResult = val.
read(
"[\"\\u0022\"]");
147 testResult = val.
read(
"[\"\\u0191\"]");
149 f_assert(val[0].get_str() ==
"\xc6\x91");
151 testResult = val.
read(
"[\"\\u2191\"]");
153 f_assert(val[0].get_str() ==
"\xe2\x86\x91");
155 testResult = val.
read(
"[\"\\ud834\\udd61\"]");
157 f_assert(val[0].get_str() ==
"\xf0\x9d\x85\xa1");
160 int main (
int argc,
char *argv[])
FILE * fopen(const fs::path &p, const char *mode)
int main(int argc, char *argv[])
static void runtest(string filename, const string &jdata)
bool read(const char *raw, size_t len)
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
static const char * filenames[]
static void runtest_file(const char *filename_)
void unescape_unicode_test()
string srcdir(JSON_TEST_SRC)
static std::string rtrim(std::string s)