#include #include #include #include #include "nbt.h" void debug_list(nbt_tag_t *tag) { if (!tag) { printf("list: (null)\n"); return; } printf("list %p (%zu len, %zu cap)\n", tag, nbt_list_length(tag), nbt_list_capacity(tag)); for (size_t n = 0; n < nbt_list_length(tag); ++n) { nbt_tag_t *t = nbt_list_get(tag, n); printf("%zu %p: tag %p(%s)\n", n, tag, t, nbt_typestr(nbt_tag_type(tag))); } } void test__is_true(int i, const char *test, const char *ex, const char *file, int line, const char *func) { if (!i) { fprintf(stderr, "Test \"%s\" failed: %s == %d (%s:%d @ %s)\n", test, ex, i, file, line, func); abort(); } } void nbt_compound_clear(nbt_tag_t *a) { } #define TEST_TRUE(_e) test__is_true(_e, "is true", #_e, __FILE__, __LINE__, __func__) #define TEST_NONNULL(_e) test__is_true(!!(_e), "is nonnull", #_e, __FILE__, __LINE__, __func__) int main(int argc, char **argv) { nbt_tag_t *list = nbt_list(); debug_list(list); printf("%s\n", nbt_typestr(nbt_list_type(list))); TEST_TRUE(nbt_list_append_move(list, nbt_byte(5)) >= 0); printf("%s\n", nbt_typestr(nbt_list_type(list))); TEST_TRUE(nbt_list_append_move(list, nbt_string("somestr")) < 0); printf("%s\n", nbt_typestr(nbt_list_type(list))); nbt_list_clear(list); TEST_TRUE(nbt_list_append_move(list, nbt_string("somestr2")) >= 0); printf("%s\n", nbt_typestr(nbt_list_type(list))); debug_list(list); nbt_decref(list); printf("%s\n", "test complete"); return 0; }