commit 7cd7db5b0b05fc4ca3ec2fc1a93830e92fc14f4d
parent 4e882ad6e1d33574f987d7cf7d4317acee904c5c
Author: lash <dev@holbrook.no>
Date: Sat, 1 Mar 2025 18:10:15 +0000
Add libcheck stub
Diffstat:
3 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1 +1,2 @@
*.o
+*_bin
diff --git a/src/test/Makefile b/src/test/Makefile
@@ -0,0 +1,9 @@
+OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
+INCLUDES := -I..
+CFLAGS += $(INCLUDES) -Wall -g3
+
+%.o: %.c
+ $(CC) $(CFLAGS) $< -o $*_bin $(LDFLAGS) ../crypto/dummy.o ../mem/std.o -lcheck
+ ./$*_bin
+
+all: $(OBJS)
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
@@ -0,0 +1,46 @@
+#include <check.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "lq/crypto.h"
+
+
+
+START_TEST(check_digest) {
+ int r;
+ const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
+ char out[32];
+
+ r = lq_digest(data, strlen(data), (char*)out);
+ ck_assert(r == 0);
+
+}
+END_TEST
+
+Suite * common_suite(void) {
+ Suite *s;
+ TCase *tc;
+
+ s = suite_create("crypto");
+ tc = tcase_create("dummy");
+ tcase_add_test(tc, check_digest);
+ suite_add_tcase(s, tc);
+
+ return s;
+}
+
+int main(void) {
+ int n_fail;
+
+ Suite *s;
+ SRunner *sr;
+
+ s = common_suite();
+ sr = srunner_create(s);
+
+ srunner_run_all(sr, CK_VERBOSE);
+ n_fail = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (n_fail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}