This commit is contained in:
2023-09-04 22:12:47 +02:00
parent 00b5cb548a
commit c31faa5c9b
11 changed files with 310 additions and 67 deletions

View File

@@ -12,25 +12,54 @@
void test01(void) {
jblock_t jb;
jblock_t* jb = new_jblock();
jblock_init(&jb);
jblock_addint(&jb, "id1", 12345);
jblock_addstr(&jb, "id2", "qwerty");
jblock_addbool(&jb, "b1", true);
jblock_addbool(&jb, "b2", false);
jblock_addfloat(&jb, "f1", (double)123e1);
jblock_init(jb);
jblock_addint(jb, "id1", 12345);
jblock_addstr(jb, "id2", "qwerty");
jblock_addbool(jb, "b1", true);
jblock_addbool(jb, "b2", false);
jblock_addfloat(jb, "f1", (double)123e1);
char* jsonstr = NULL;
jblock_outjson(&jb, &jsonstr);
jblock_destroy(&jb);
jblock_outjson(jb, &jsonstr);
jblock_free(jb);
printf("%s\n", jsonstr);
free(jsonstr);
}
void test02(void) {
jintarr_t* arr = new_jintarr();
jintarr_init(arr);
for (int64_t i = 0; i < 1024 + 1; i++) {
jintarr_append(arr, i);
}
printf("size: %d capa: %d\n", arr->size, arr->capa);
printf("last: %ld\n", arr->data[arr->size - 1]);
jintarr_free(arr);
}
void test03(void) {
jfltarr_t arr;
jfltarr_init(&arr);
for (int64_t i = 0; i < 1024 + 1; i++) {
jfltarr_append(&arr, i);
}
printf("size: %d capa: %d\n", arr.size, arr.capa);
printf("last: %f\n", arr.data[arr.size - 1]);
jfltarr_destroy(&arr);
}
int main(void) {
test01();
//test01();
test02();
test03();
return 0;
}