aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-08 19:59:08 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-04-08 19:59:08 -0400
commit00314ad424035c5ed1ebdaf62cf387b8eeadeb55 (patch)
treec1a8beda8ef38bddaf8bb027d2bfeeaf2d74dd37
parent38010fc9eea2d914de8f3058979baace3f1d1e80 (diff)
downloadstasis-00314ad424035c5ed1ebdaf62cf387b8eeadeb55.tar.gz
Add test_tests.c
-rw-r--r--tests/test_tests.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_tests.c b/tests/test_tests.c
new file mode 100644
index 0000000..0f6d7ca
--- /dev/null
+++ b/tests/test_tests.c
@@ -0,0 +1,52 @@
+#include "delivery.h"
+#include "testing.h"
+
+static struct Test *mock_test(const int ident) {
+ struct Test *test = test_init();
+ if (asprintf(&test->name, "test_%d", ident) < 0) {
+ return NULL;
+ }
+ return test;
+}
+
+void test_tests() {
+ const int initial = TEST_NUM_ALLOC_INITIAL;
+ const int balloon = initial * 10;
+ struct Tests *tests = tests_init(initial);
+ STASIS_ASSERT_FATAL(tests != NULL, "tests structure allocation failed");
+ STASIS_ASSERT(tests->num_alloc == (size_t) initial, "incorrect number of records initialized");
+ STASIS_ASSERT(tests->num_used == 0, "incorrect number of records used");
+
+ for (int i = 0; i < balloon; i++) {
+ struct Test *test = mock_test(i);
+ if (!test) {
+ SYSERROR("unable to allocate memory for test %d", i);
+ return;
+ }
+ tests_add(tests, test);
+ }
+
+ size_t errors = 0;
+ for (int i = 0; i < initial * 10; i++) {
+ struct Test *test = tests->test[i];
+ if (!test) {
+ errors++;
+ continue;
+ }
+ if (!test->name) {
+ errors++;
+ }
+ }
+ STASIS_ASSERT(errors == 0, "no errors should be detected in test->name member");
+
+ tests_free(&tests);
+}
+
+int main(int argc, char *argv[]) {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
+ test_tests,
+ };
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
+} \ No newline at end of file