// host_runner.c — dynamic registration runner for Unity on host.
// Tests self-register via constructor attributes defined in unity_test_case.h.
#include "unity.h"
#include "unity_test_case.h"
#include <stdio.h>
#include <stdlib.h>

#define HOST_TEST_TABLE_CAPACITY 64

static host_test_fn_t s_fns[HOST_TEST_TABLE_CAPACITY];
static const char    *s_names[HOST_TEST_TABLE_CAPACITY];
static int            s_count = 0;

void host_register_test(host_test_fn_t fn, const char *name)
{
    if (s_count >= HOST_TEST_TABLE_CAPACITY) {
        fprintf(stderr, "host_runner: test table full (capacity %d) — cannot register \"%s\"\n",
                HOST_TEST_TABLE_CAPACITY, name);
        exit(1);
    }
    s_fns[s_count]   = fn;
    s_names[s_count] = name;
    s_count++;
}

void setUp(void)    {}
void tearDown(void) {}

int main(void)
{
    UNITY_BEGIN();
    for (int i = 0; i < s_count; i++) {
        UnityDefaultTestRun(s_fns[i], s_names[i], 0);
    }
    return UNITY_END();
}
