summaryrefslogtreecommitdiff
path: root/src/target/test.c
blob: 60439a53d6fb99acdced69c628f846f1c0739492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "munit.h"

#include "unicode.h"

struct u_pair {
    char    *utf8;
    wchar_t *utf32;
};

struct u_pair *text_fixture;

static void *test_text_setup(const MunitParameter params[], void *user_data) {
    (void) params;
    (void) user_data;

    return text_fixture;
}

static MunitResult test_text(const MunitParameter params[], void *fixture) {
    (void) params;
    struct u_pair *f = fixture;

    munit_assert_ulong(utf8_strlen(f[0].utf8), ==, strlen(f[0].utf8));

    return MUNIT_OK;
}

static MunitTest test_suite_tests[] = {
    {
        "/example/parameters",
        test_text,
        test_text_setup,
        NULL,
        MUNIT_TEST_OPTION_NONE,
        NULL
    },
    {NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL}
};

static const MunitSuite test_suite = {
    "unit",
    test_suite_tests,
    NULL,
    1,
    MUNIT_SUITE_OPTION_NONE
};

int main(int argc, char **argv) {
    text_fixture = (struct u_pair []){
        {
            .utf8 = "Single byte ascii symbols string",
            .utf32 = L"Single byte ascii symbols string"
        }
    };

    return munit_suite_main(&test_suite, NULL, argc, argv);
}