1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-14 20:54:48 +00:00
janet/unittests/table_test.c

20 lines
575 B
C

#include "unit.h"
#include <dst/dst.h>
int main() {
dst_init();
DstTable *table = dst_table(10);
assert(table->count == 0);
dst_table_put(table, dst_cstringv("a"), dst_cstringv("b"));
dst_table_put(table, dst_cstringv("b"), dst_cstringv("a"));
dst_table_put(table, dst_cstringv("a"), dst_cstringv("c"));
assert(table->count == 2);
dst_table_remove(table, dst_cstringv("a"));
assert(table->count == 1);
assert(dst_equals(
dst_table_get(table, dst_cstringv("b")),
dst_cstringv("a")
));
return 0;
}