2021-10-28 09:01:14 +02:00
|
|
|
/*
|
|
|
|
* boxes - Command line filter to draw/remove ASCII boxes around text
|
|
|
|
* Copyright (c) 1999-2021 Thomas Jensen and the boxes contributors
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License, version 2, as published
|
|
|
|
* by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main module for running the unit tests.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
|
|
|
|
|
|
|
#include "global_mock.h"
|
2021-11-04 14:12:40 +01:00
|
|
|
#include "cmdline_test.h"
|
2021-10-28 09:01:14 +02:00
|
|
|
#include "tools_test.h"
|
|
|
|
#include "regulex_test.h"
|
|
|
|
|
|
|
|
|
2021-11-01 21:20:37 +01:00
|
|
|
static int beforeTest(void** state) {
|
|
|
|
(void) state; /* unused */
|
|
|
|
|
|
|
|
collect_reset();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
setup_mocks();
|
|
|
|
|
2021-11-04 14:12:40 +01:00
|
|
|
const struct CMUnitTest cmdline_tests[] = {
|
|
|
|
cmocka_unit_test_setup(test_indentmode_none, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_indentmode_invalid_long, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_indentmode_invalid_short, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_indentmode_box, beforeTest),
|
2021-11-04 21:53:35 +01:00
|
|
|
cmocka_unit_test_setup(test_indentmode_text, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_killblank_true, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_killblank_false, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_killblank_invalid, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_killblank_multiple, beforeTest)
|
2021-10-28 09:01:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct CMUnitTest regulex_tests[] = {
|
2021-11-01 21:20:37 +01:00
|
|
|
cmocka_unit_test_setup(test_compile_pattern_error, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_compile_pattern_empty, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_regex_replace_invalid_utf, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_regex_replace_buffer_resize, beforeTest),
|
|
|
|
cmocka_unit_test_setup(test_regex_replace_error, beforeTest)
|
2021-10-28 09:01:14 +02:00
|
|
|
};
|
|
|
|
|
2021-11-04 14:12:40 +01:00
|
|
|
const struct CMUnitTest tools_tests[] = {
|
|
|
|
cmocka_unit_test(test_strisyes_true),
|
|
|
|
cmocka_unit_test(test_strisyes_false),
|
|
|
|
cmocka_unit_test(test_strisno_true),
|
|
|
|
cmocka_unit_test(test_strisno_false)
|
|
|
|
};
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
int num_failed = 0;
|
2021-11-04 14:12:40 +01:00
|
|
|
num_failed += cmocka_run_group_tests(cmdline_tests, NULL, NULL);
|
2021-10-28 09:01:14 +02:00
|
|
|
num_failed += cmocka_run_group_tests(regulex_tests, NULL, NULL);
|
2021-11-04 14:12:40 +01:00
|
|
|
num_failed += cmocka_run_group_tests(tools_tests, NULL, NULL);
|
2021-10-28 09:01:14 +02:00
|
|
|
|
|
|
|
teardown();
|
|
|
|
return num_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*EOF*/ /* vim: set cindent sw=4: */
|