Add a simple unit test for widget_add_from_file()

This commit is contained in:
Pim van Pelt
2017-11-26 11:28:09 +01:00
parent b005dd8a26
commit 6985b30dc2
8 changed files with 854 additions and 8 deletions

View File

@ -1,6 +1,7 @@
#include "test.h"
#include "widget.h"
int test_widget() {
/*
char *json;
void *h = NULL;
struct json_token key, val;
@ -25,4 +26,26 @@ int test_widget() {
exit:
free(json);
return 0;
*/
static int test_widget_add_from_file(void) {
struct widget_t *w;
const char *fn = "data/TestWidget.json";
w = widget_add_from_file(fn, 0, NULL, NULL);
if (!w) {
LOG(LL_ERROR, ("Could not add %s", fn));
return -1;
}
if (16 != w->x || 48 != w->w || 16 != w->y || 48 != w->h) {
LOG(LL_ERROR, ("widget x, y, w, h incorrect"));
return -1;
}
return 0;
}
int test_widget() {
test_widget_add_from_file();
return 0;
}