From 4efd8084ecf47132ba51577ee3f79d2ed2637b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 5 Oct 2016 16:34:19 +0200 Subject: test/core: tweak tests to work with tis-interpreter $ tis-inertpreter.sh --cc "-I. -I../.." text.c ../../text.c or more conveniently $ make tis --- core/buffer.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'core/buffer.c') diff --git a/core/buffer.c b/core/buffer.c index 14ad667..ab8488a 100644 --- a/core/buffer.c +++ b/core/buffer.c @@ -1,8 +1,8 @@ -#include #include #include #include #include +#include "tap.h" #include "buffer.h" static bool compare(Buffer *buf, const char *data, size_t len) { @@ -58,24 +58,27 @@ int main(int argc, char *argv[]) { buffer_clear(&buf); ok(buf.data && buffer_length(&buf) == 0 && buffer_capacity(&buf) == cap, "Clear"); - ok(buffer_printf(&buf, "Test: %d\n", 42) && compare0(&buf, "Test: 42\n"), "Set formatted"); - ok(buffer_printf(&buf, "%d\n", 42) && compare0(&buf, "42\n"), "Set formatted overwrite"); - buffer_clear(&buf); + skip_if(TIS_INTERPRETER, 1, "vsnprintf not supported") { - ok(buffer_printf(&buf, "") && compare0(&buf, ""), "Set formatted empty string"); - buffer_clear(&buf); + ok(buffer_printf(&buf, "Test: %d\n", 42) && compare0(&buf, "Test: 42\n"), "Set formatted"); + ok(buffer_printf(&buf, "%d\n", 42) && compare0(&buf, "42\n"), "Set formatted overwrite"); + buffer_clear(&buf); - bool append = true; - for (int i = 1; i <= 10; i++) - append &= buffer_appendf(&buf, "%d", i); - ok(append && compare0(&buf, "12345678910"), "Append formatted"); - buffer_clear(&buf); + ok(buffer_printf(&buf, "") && compare0(&buf, ""), "Set formatted empty string"); + buffer_clear(&buf); - append = true; - for (int i = 1; i <= 10; i++) - append &= buffer_appendf(&buf, ""); - ok(append && compare0(&buf, ""), "Append formatted empty string"); - buffer_clear(&buf); + bool append = true; + for (int i = 1; i <= 10; i++) + append &= buffer_appendf(&buf, "%d", i); + ok(append && compare0(&buf, "12345678910"), "Append formatted"); + buffer_clear(&buf); + + append = true; + for (int i = 1; i <= 10; i++) + append &= buffer_appendf(&buf, ""); + ok(append && compare0(&buf, ""), "Append formatted empty string"); + buffer_clear(&buf); + } buffer_release(&buf); -- cgit v1.2.3