aboutsummaryrefslogtreecommitdiff
path: root/core/buffer.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-10-05 16:34:19 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-12-22 11:56:35 +0100
commit4efd8084ecf47132ba51577ee3f79d2ed2637b44 (patch)
tree09f6c30c079be1de57af19c450dd6cb5fa4ff036 /core/buffer.c
parentcca3d303023d53b5d0af96751f379b2d0e28cd18 (diff)
downloadvis-4efd8084ecf47132ba51577ee3f79d2ed2637b44.tar.gz
vis-4efd8084ecf47132ba51577ee3f79d2ed2637b44.tar.xz
test/core: tweak tests to work with tis-interpreter
$ tis-inertpreter.sh --cc "-I. -I../.." text.c ../../text.c or more conveniently $ make tis
Diffstat (limited to 'core/buffer.c')
-rw-r--r--core/buffer.c35
1 files changed, 19 insertions, 16 deletions
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 <ccan/tap/tap.h>
#include <stddef.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
+#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);