diff --git a/meson.build b/meson.build index 0d0f588..7e794be 100644 --- a/meson.build +++ b/meson.build @@ -9,3 +9,8 @@ executable('ex03', ['ex03/main.c', 'utils.c'], dependencies: m_dep) executable('ex04', ['ex04/main.c', 'utils.c'], dependencies: m_dep) executable('ex05', ['ex05/main.c', 'utils.c'], dependencies: m_dep) executable('ex06', ['ex06/main.c', 'utils.c'], dependencies: m_dep) + +munit_dep = dependency('munit', fallback: ['munit', 'munit_dep']) + +tests = executable('tests', ['tests/main.c', 'utils.c'], dependencies: [m_dep, munit_dep]) +test('tests', tests) diff --git a/subprojects/munit b/subprojects/munit new file mode 160000 index 0000000..fbbdf14 --- /dev/null +++ b/subprojects/munit @@ -0,0 +1 @@ +Subproject commit fbbdf1467eb0d04a6ee465def2e529e4c87f2118 diff --git a/subprojects/munit.wrap b/subprojects/munit.wrap new file mode 100644 index 0000000..c53b275 --- /dev/null +++ b/subprojects/munit.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory=munit +url=https://github.com/nemequ/munit/ +revision=head diff --git a/tests/main.c b/tests/main.c new file mode 100644 index 0000000..ed09292 --- /dev/null +++ b/tests/main.c @@ -0,0 +1,31 @@ +#define MUNIT_ENABLE_ASSERT_ALIASES +#include "munit.h" +#include +#include "utils.h" + +static MunitResult test_hex_to_byte(const MunitParameter params[], void *data) { + (void)params; + (void)data; + + assert_uchar(hex_to_byte('0'), ==, 0); + assert_uchar(hex_to_byte('a'), ==, 10); + assert_uchar(hex_to_byte('f'), ==, 15); + + return MUNIT_OK; +} + +static MunitTest test_suite_tests[] = { + {"/hex_to_byte", test_hex_to_byte, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL}, + {NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL}}; + +static const MunitSuite test_suite = { + (char*) "", + test_suite_tests, + NULL, + 1, + MUNIT_SUITE_OPTION_NONE +}; + +int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) { + return munit_suite_main(&test_suite, NULL, argc, argv); +}