aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMosder <xmosder12@gmail.com>2026-07-30 19:19:54 +0200
committerMosder <xmosder12@gmail.com>2026-07-30 19:19:54 +0200
commit850e7df12a7e7a3b7bda841837e4eb6d450f58f4 (patch)
tree15774e28efdc46a69ec5b869ef39cf4e03343e93 /include
parent1ea30ddbfa1d16651c8bd65282f4093dcbe6d0bb (diff)
feat: added quick usage guide for tester
Diffstat (limited to 'include')
-rw-r--r--include/moslib.h2
-rw-r--r--include/moslib/tester.h64
2 files changed, 57 insertions, 9 deletions
diff --git a/include/moslib.h b/include/moslib.h
index a781a34..341db7e 100644
--- a/include/moslib.h
+++ b/include/moslib.h
@@ -4,4 +4,4 @@
#include "moslib/ds/array.h"
#include "moslib/mem/alloc.h"
-#include "moslib/tests.h"
+#include "moslib/tester.h"
diff --git a/include/moslib/tester.h b/include/moslib/tester.h
index 1a548bc..0165257 100644
--- a/include/moslib/tester.h
+++ b/include/moslib/tester.h
@@ -1,19 +1,67 @@
// moslib/tester.h
// Helper functions for writing and running tests
+// ======================================== QUICK USAGE GUIDE =========================================
+// ----------------------------------------------------------------------------------------------------
+//
+// Define the tester:
+//
+// Tester *tester = NULL;
+//
+// It will initialize on first operation.
+//
+// You can also initialize a tester from the get go:
+//
+// Tester *tester = new_tester();
+//
+// ----------------------------------------------------------------------------------------------------
+//
+// Add test groups:
+//
+// TestGroup *test_group = add_test_group(tester, group_name);
+//
+// ----------------------------------------------------------------------------------------------------
+//
+// Create tests.
+// Tests are of type TestFn (Test (*)()).
+// They should use test_assert functions to check correctness.
+//
+// Example:
+// Test test_fn() {
+// int result1 = 1 + 2;
+// int result2 = 3 + 5;
+//
+// test_assert(result1 == 3, "1 + 2 should equal 3");
+// test_assert(result2 == 8, "3 + 5 should equal 8");
+// }
+//
+// ----------------------------------------------------------------------------------------------------
+//
+// Add tests to test group:
+//
+// add_test(test_group, test_fn);
+//
+// ----------------------------------------------------------------------------------------------------
+//
+// Run tests:
+//
+// run_tests(tester);
+//
+// ----------------------------------------------------------------------------------------------------
+//
+// Free tester:
+//
+// free_tester(tester);
+//
+// ----------------------------------------------------------------------------------------------------
+// ===================================== END OF QUICK USAGE GUIDE =====================================
+
#ifndef MOSLIB_TESTER_H
#define MOSLIB_TESTER_H
typedef void Test; // this is just for nice indication that a function is a test
typedef struct Tester Tester;
typedef struct TestGroup TestGroup;
-typedef Test (*TestFn)(TestGroup *);
-
-// Tester *tester = NULL; (new_tester())
-// TestGroup *test_group = add_test_group(Tester *tester, const char *group_name);
-// add_test(TestGroup *test_group, TestFn test);
-// test_assert(int expression, const char *error_message);
-// run_tests(Tester *tester);
-// free_tester(Tester *tester);
+typedef Test (*TestFn)();
#endif // MOSLIB_TESTER_H