From 471eb472dbd3462b6a5ab21f85621e16c411709b Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 1 Mar 2015 13:20:08 -0500 Subject: add vec --- test/test-vec.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/test-vec.cpp (limited to 'test') diff --git a/test/test-vec.cpp b/test/test-vec.cpp new file mode 100644 index 0000000..f587c1b --- /dev/null +++ b/test/test-vec.cpp @@ -0,0 +1,23 @@ +#include "cbit/vec.h" +#include +DECL_VEC(const char *, ccp); + +int main() { + VEC_STORAGE(ccp) stor; + VEC_STORAGE_INIT(&stor, ccp); + struct vec_ccp *vec = &stor.v; + for (int i = 0; i < 20; i++) { + char *x; + asprintf(&x, "el%d", i); + vec_append_ccp(vec, x); + } + vec_remove_ccp(vec, 5, 4); + vec_add_space_ccp(vec, 9, 2); + for (int i = 9; i <= 10; i++) + vec->els[i] = "TILT"; + vec_concat_ccp(vec, vec); + VEC_FOREACH(vec, i, const char **c, ccp) { + printf("%zd->%s\n", i, *c); + } + +} -- cgit v1.2.3