1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-15 21:24:48 +00:00
janet/unittests/buffer_test.c
Calvin Rose d84cc5342e Fix write after free bug.
Remove caching from strings, tuples, and structs.
Keyword style strings removed, now are just symbols. The
compiler can decide to treat symbols with a leading ':'
differently for mostly the same effect. This was done because
as strings are no longer interned, symbols are cheaper to look
up and check for equality.
2017-11-27 14:03:34 -05:00

21 lines
578 B
C

#include "unit.h"
#include <dst/dst.h>
int main() {
dst_init();
DstBuffer *buffer = dst_buffer(100);
assert(buffer->count == 0);
assert(buffer->capacity == 100);
dst_buffer_push_u8(buffer, 'h');
dst_buffer_push_u8(buffer, 'e');
dst_buffer_push_u8(buffer, 'l');
dst_buffer_push_u8(buffer, 'l');
dst_buffer_push_u8(buffer, 'o');
dst_buffer_push_cstring(buffer, " world!");
assert(dst_equals(
dst_wrap_string(dst_cstring("hello world!")),
dst_wrap_string(dst_string(buffer->data, buffer->count))
));
return 0;
}