kwil-header-tool/test_files/implementation.c

36 lines
706 B
C
Raw Normal View History

2023-09-11 16:44:37 +00:00
#include "header.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
KWIL_GEN_IMPL()
int main(int argc, char* argv[]) {
printf("running kwil test\n");
struct struct_A b = {
.b = -10,
.u = 13,
.a = 1.0,
.dyn_str = "WHOOAAAAA"
};
char* json = NULL;
int json_len = struct_A_to_json(&b, &json);
printf("allocated %d bytes for json of struct_A\n", json_len);
printf("struct_A as json:\n%s\n", json);
int real_len = strlen(json);
free(json);
if(real_len != json_len) {
printf("Json Length (%d) does not match allocated space %d\n", real_len, json_len);
return 1;
}
return 0;
}