summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--tests/get_domainpart.c23
-rw-r--r--xmpp.h1
3 files changed, 32 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 18bde1e..f692264 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,16 @@
.PHONY: all clean
-all: build
+all: build/limox build/tests/get_domainpart
+ ./build/tests/get_domainpart
+
+build/limox: build
gcc main.c gui.c xmpp.c -o build/limox -lSDL2
+build/tests/get_domainpart: build
+ gcc tests/get_domainpart.c xmpp.c -o build/tests/get_domainpart -I.
+
build:
- mkdir -p build
+ mkdir -p build/tests
clean:
rm -rf build
diff --git a/tests/get_domainpart.c b/tests/get_domainpart.c
new file mode 100644
index 0000000..e05aee1
--- /dev/null
+++ b/tests/get_domainpart.c
@@ -0,0 +1,23 @@
+
+
+#include <string.h>
+#include <stdio.h>
+
+#include "xmpp.h"
+
+
+int main(void)
+{
+ char *input = "test@example.org/3f";
+ const char *expected = "example.org";
+
+ char *result = get_domainpart(input);
+
+ if (strcmp(result, expected) == 0) {
+ printf("Unit test passed - ok\n");
+ return 0;
+ } else {
+ printf("'%s' != '%s'!\n", result, expected);
+ return 1;
+ }
+}
diff --git a/xmpp.h b/xmpp.h
index b07e3b9..03b3dbd 100644
--- a/xmpp.h
+++ b/xmpp.h
@@ -1 +1,2 @@
void xmpp_connect(void);
+char *get_domainpart(char *jid);