-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.test.c
More file actions
62 lines (50 loc) · 1.3 KB
/
Copy pathjson.test.c
File metadata and controls
62 lines (50 loc) · 1.3 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
51
52
53
54
55
56
57
58
59
60
61
62
#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 (WIP)
// test_string = "10";
// test_json = NULL;
// test_json = StringToJSON(test_string);
// assert(test_json != NULL);
// assert(test_json->root->value_type == JSONNUMBER_INT_t);
// FreeJSON(test_json);
// test 4
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);
}
static void testJSONFromFile() {}
extern void TestJSON()
{
testJSONInit();
testStringToJSON();
testJSONFromFile();
}