rizin/test/unit/test_pj.c
Riccardo Schirone a7fd3fa3c6 Use mu_main to reduce boilerplate in unit tests
* Disable colors on Windows because terminal looks bad otherwise
* Use environment on Windows to set PATH and make sure unit tests use
  the compiled libraries and not the installed ones
* Define ssize_t on Windows as well by using SSIZE_T

Update test_analysis_block.c

Update test_intervaltree.c

Update test_unum.c
2021-01-03 11:42:38 +01:00

27 lines
No EOL
587 B
C

#include <rz_types.h>
#include <rz_util/pj.h>
#include "minunit.h"
bool test_pj_reset() {
PJ *j = pj_new ();
pj_o (j);
pj_ks (j, "test", "object");
pj_end (j);
mu_assert_streq (pj_string (j), "{\"test\":\"object\"}", "before reset");
pj_reset (j);
mu_assert_streq (pj_string (j), "", "empty after reset");
pj_a (j);
pj_s (j, "test");
pj_s (j, "array");
pj_end (j);
mu_assert_streq (pj_string (j), "[\"test\",\"array\"]", "reuse after reset");
pj_free (j);
mu_end;
}
int all_tests() {
mu_run_test (test_pj_reset);
return tests_passed != tests_run;
}
mu_main (all_tests)