mirror of
https://github.com/json-c/json-c.git
synced 2026-04-02 03:49:06 +08:00
Extend test1 and test2 to run using json_object_to_json_string_ext() based on an additional command line parameter.
Extend the run_output_test() function so we actually can pass command line parameters and so we can support different output files for the same test executable. Also provide some hints about what to do if a test fails (i.e. set VERBOSE=1).
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "json.h"
|
||||
#include "parse_flags.h"
|
||||
|
||||
static int sort_fn (const void *j1, const void *j2)
|
||||
{
|
||||
@@ -29,13 +30,26 @@ static int sort_fn (const void *j1, const void *j2)
|
||||
return i1 - i2;
|
||||
}
|
||||
|
||||
#ifdef TEST_FORMATTED
|
||||
#define json_object_to_json_string(obj) json_object_to_json_string_ext(obj,sflags)
|
||||
#else
|
||||
/* no special define */
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
json_object *my_string, *my_int, *my_object, *my_array;
|
||||
int i;
|
||||
#ifdef TEST_FORMATTED
|
||||
int sflags = 0;
|
||||
#endif
|
||||
|
||||
MC_SET_DEBUG(1);
|
||||
|
||||
#ifdef TEST_FORMATTED
|
||||
sflags = parse_flags(argc, argv);
|
||||
#endif
|
||||
|
||||
my_string = json_object_new_string("\t");
|
||||
printf("my_string=%s\n", json_object_get_string(my_string));
|
||||
printf("my_string.to_string()=%s\n", json_object_to_json_string(my_string));
|
||||
|
||||
Reference in New Issue
Block a user