mirror of
https://github.com/vale981/libblobpack
synced 2025-03-05 09:51:42 -05:00
29 lines
630 B
C
29 lines
630 B
C
#include "test-funcs.h"
|
|
#include <blobpack.h>
|
|
#include <stdbool.h>
|
|
#include <math.h>
|
|
#include <memory.h>
|
|
|
|
int main(void){
|
|
struct blob blob;
|
|
blob_init(&blob, 0, 0);
|
|
|
|
blob_put_bool(&blob, true);
|
|
blob_put_string(&blob, "foo");
|
|
blob_put_int(&blob, -13);
|
|
blob_put_real(&blob, M_PI);
|
|
|
|
const struct blob_field *out[4];
|
|
|
|
blob_dump_json(&blob);
|
|
|
|
TEST(blob_field_parse(blob_head(&blob), "isif", out, 4));
|
|
|
|
TEST(blob_field_get_bool(out[0]) == true);
|
|
TEST(strcmp(blob_field_get_string(out[1]), "foo") == 0);
|
|
TEST(blob_field_get_int(out[2]) == -13);
|
|
TEST(is_equal(blob_field_get_real(out[3]), M_PI));
|
|
|
|
return 0;
|
|
}
|
|
|