aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile18
-rw-r--r--hyde.dSYM/Contents/Info.plist20
-rw-r--r--tests/test.h24
-rw-r--r--tests/test_hashmap.c14
5 files changed, 55 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index d15a9d2..4157400 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
hyde
-*.dSYM \ No newline at end of file
+*.dSYM
+bin/ \ No newline at end of file
diff --git a/Makefile b/Makefile
index c04520b..0551369 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,17 @@
-CFLAGS= -g -Wall -std=c11 -Ivendor/
+CFLAGS= -g -Wall -std=c11 -Ivendor/ -I.
LIBS=
-hyde: hyde.c hashmap.c vendor/mpc.c
- $(CC) $(CFLAGS) $^ -o $@ \ No newline at end of file
+all: bin/hyde
+
+bin:
+ mkdir -p bin/
+
+bin/hyde: hyde.c hashmap.c vendor/mpc.c | bin
+ $(CC) $(CFLAGS) $^ -o $@
+
+bin/test_hashmap: hashmap.c tests/test_hashmap.c | bin
+ $(CC) $(CFLAGS) $^ -o $@
+
+.PHONY: check
+check: bin/test_hashmap
+ for test in $^; do $$test || exit 1; done \ No newline at end of file
diff --git a/hyde.dSYM/Contents/Info.plist b/hyde.dSYM/Contents/Info.plist
deleted file mode 100644
index f51e946..0000000
--- a/hyde.dSYM/Contents/Info.plist
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
- <dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleIdentifier</key>
- <string>com.apple.xcode.dsym.hyde</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundlePackageType</key>
- <string>dSYM</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleVersion</key>
- <string>1</string>
- </dict>
-</plist>
diff --git a/tests/test.h b/tests/test.h
new file mode 100644
index 0000000..19868f8
--- /dev/null
+++ b/tests/test.h
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+
+#define assert(assertion, format, ...) _assert(assertion, __FILE__, __LINE__, format, ##__VA_ARGS__)
+#define TESTNAME(v) strcpy(current_test, v);
+
+char current_test[256] = {'\0'};
+
+void _assert(int assertion, const char filename[64], const int line, char *format, ...)
+{
+ if (assertion)
+ {
+ return;
+ }
+
+ va_list args;
+ va_start(args, format);
+ printf("%s:%d:%s failed: ", filename, line, current_test);
+ vprintf(format, args);
+ va_end(args);
+ printf("\n");
+} \ No newline at end of file
diff --git a/tests/test_hashmap.c b/tests/test_hashmap.c
new file mode 100644
index 0000000..cf6f7a2
--- /dev/null
+++ b/tests/test_hashmap.c
@@ -0,0 +1,14 @@
+#include "test.h"
+#include "hashmap.h"
+
+int main() {
+ struct hashmap *hm = hashmap_new();
+ assert(hashmap_get(hm, "foo") == NULL, "expected NULL");
+
+ hashmap_insert(hm, "foo", "bar");
+ char *value = hashmap_get(hm, "foo");
+ assert(value != NULL, "expected value, got NULL");
+ assert(strcmp(value, "bar") == 0, "expected %s, got %s", "bar", value);
+
+ hashmap_free(hm);
+} \ No newline at end of file