mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-11-30 16:48:21 +01:00
Introduce ctest_suite_t, ctest_parse_args, ctest_run_suites and CTEST_MAIN macro to standardize test binary entry points. Support --grep / --grep= / --list / --interactive / --help. Add lib/ctest/tests/ for self-tests covering str converters and grep filter logic.
58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
#include <assert.h>
|
|
#include <string.h>
|
|
#include <ctest.h>
|
|
|
|
static void test_should_run_no_pattern(void)
|
|
{
|
|
ctest_set_grep(NULL);
|
|
assert(ctest_should_run("anything") == true);
|
|
assert(ctest_should_run("") == true);
|
|
}
|
|
|
|
static void test_should_run_with_pattern(void)
|
|
{
|
|
ctest_set_grep("widget");
|
|
assert(ctest_should_run("widget event") == true);
|
|
assert(ctest_should_run("widget opacity") == true);
|
|
assert(ctest_should_run("settings") == false);
|
|
assert(ctest_should_run("thread") == false);
|
|
}
|
|
|
|
static void test_should_run_exact_match(void)
|
|
{
|
|
ctest_set_grep("steptimer");
|
|
assert(ctest_should_run("steptimer") == true);
|
|
assert(ctest_should_run("ptk/steptimer") == true);
|
|
assert(ctest_should_run("widget event") == false);
|
|
}
|
|
|
|
static void test_should_run_empty_pattern(void)
|
|
{
|
|
ctest_set_grep("");
|
|
assert(ctest_should_run("anything") == true);
|
|
}
|
|
|
|
static void test_is_interactive_default(void)
|
|
{
|
|
ctest_set_interactive(false);
|
|
assert(ctest_is_interactive() == false);
|
|
}
|
|
|
|
static void test_is_interactive_set(void)
|
|
{
|
|
ctest_set_interactive(true);
|
|
assert(ctest_is_interactive() == true);
|
|
ctest_set_interactive(false);
|
|
assert(ctest_is_interactive() == false);
|
|
}
|
|
|
|
void test_grep_funcs(void)
|
|
{
|
|
test_should_run_no_pattern();
|
|
test_should_run_with_pattern();
|
|
test_should_run_exact_match();
|
|
test_should_run_empty_pattern();
|
|
test_is_interactive_default();
|
|
test_is_interactive_set();
|
|
}
|