-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.test.c
More file actions
50 lines (41 loc) · 1.01 KB
/
Copy pathjson.test.c
File metadata and controls
50 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./json.h"
static void testJSONInit()
{
JSON *test = JSONInit();
assert(test != NULL);
assert(test->root == NULL);
FreeJSON(test);
}
static void testStringToJSON()
{
// test 1
char *test_string = "[]";
JSON *test_json = NULL;
test_json = StringToJSON("[]");
assert(test_json != NULL);
assert(test_json->root->value_type == JSONLIST_t);
FreeJSON(test_json);
// test 2
test_string = "{}";
test_json = NULL;
test_json = StringToJSON(test_string);
assert(test_json != NULL);
assert(test_json->root->value_type == JSONOBJ_t);
FreeJSON(test_json);
// test 3
test_string = "{\"foo\": \"bar\", \"bar\": \"foo\"}";
test_json = NULL;
test_json = StringToJSON(test_string);
assert(test_json != NULL);
assert(test_json->root->value_type == JSONOBJ_t);
FreeJSON(test_json);
}
extern void TestJSON()
{
testJSONInit();
testStringToJSON();
}