Mostly empty unit tests -- added mgos_mock to be able to run unit tests on x86_64
This commit is contained in:
28
unittest/test_widget.c
Normal file
28
unittest/test_widget.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include "test.h"
|
||||
|
||||
int test_widget() {
|
||||
char *json;
|
||||
void *h = NULL;
|
||||
struct json_token key, val;
|
||||
int idx;
|
||||
|
||||
json = json_fread("data/TestWidget.json");
|
||||
if (!json) {
|
||||
printf("Could not read json\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Traverse Object
|
||||
while ((h = json_next_key(json, strlen(json), h, ".", &key, &val)) != NULL) {
|
||||
printf("[%.*s] -> [%.*s]\n", key.len, key.ptr, val.len, val.ptr);
|
||||
}
|
||||
|
||||
// Traverse Array
|
||||
while ((h = json_next_elem(json, strlen(json), h, ".widgets", &idx, &val)) != NULL) {
|
||||
printf("[%d]: [%.*s]\n", idx, val.len, val.ptr);
|
||||
}
|
||||
|
||||
exit:
|
||||
free(json);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user