Mostly empty unit tests -- added mgos_mock to be able to run unit tests on x86_64

This commit is contained in:
Pim van Pelt
2017-11-26 10:43:44 +01:00
parent efa9b1bf68
commit 705c65c6c9
13 changed files with 1854 additions and 0 deletions

28
unittest/test_widget.c Normal file
View 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;
}