summaryrefslogtreecommitdiff
path: root/examples/unit
diff options
context:
space:
mode:
authorTom Harley2023-02-01 20:48:40 +0000
committerTom Harley2023-02-01 20:56:29 +0000
commite600b4729cee5f624b6f1f457c07aa75aa0ed278 (patch)
treeb011e0a6aa88eb2a5eab614c7b8e2b6ee55bb057 /examples/unit
parentAdjust int type in run_func.c (diff)
downloadsinter-e600b4729cee5f624b6f1f457c07aa75aa0ed278.tar.gz
sinter-e600b4729cee5f624b6f1f457c07aa75aa0ed278.zip

Fix unit tests

Now the unit tests will run again! :)

Diffstat (limited to 'examples/unit')
-rw-r--r--examples/unit/Makefile7
-rw-r--r--examples/unit/test_framework.c20
2 files changed, 21 insertions, 6 deletions
diff --git a/examples/unit/Makefile b/examples/unit/Makefile
index aadf541..a663eb3 100644
--- a/examples/unit/Makefile
+++ b/examples/unit/Makefile
@@ -1,9 +1,8 @@
CC = clang
-SINC = ../../sinter
+SINC = ../../sinc -w 32
TRGT = $(patsubst %.sin,%,$(wildcard test*.sin))
-LDFLAGS = -L$(HOME)/usr/lib
-LDLIBS = -lgc
+LDLIBS += -lgc
include ../../common.mak
@@ -13,7 +12,7 @@ default: all
all: $(TRGT)
-$(TRGT): test_framework.o ../../common.o
+$(TRGT): test_framework.o
clean:
$(RM) *.o *.ll $(TRGT)
diff --git a/examples/unit/test_framework.c b/examples/unit/test_framework.c
index 22ededd..0a86efc 100644
--- a/examples/unit/test_framework.c
+++ b/examples/unit/test_framework.c
@@ -1,9 +1,19 @@
#include <assert.h>
+#include <string.h>
+
+#include <gc.h>
void *test(void);
-void *inter_main(void) {
- return test();
+int main(void) {
+ test();
+ return 0;
+}
+
+void *gc_alloc(size_t size) {
+ void *p = GC_MALLOC(size);
+ assert(p);
+ return p;
}
void *assert_equals(void *a, void *b, void *c) {
@@ -11,3 +21,9 @@ void *assert_equals(void *a, void *b, void *c) {
assert(ia == ib);
return c;
}
+
+void *assert_string_equals(void *a, void *b, void *c) {
+ char *sa = (char *) a, *sb = (char *) b;
+ assert(!strcmp(sa, sb));
+ return c;
+}