2021-10-20 22:28:34 +02:00
|
|
|
/*
|
|
|
|
* boxes - Command line filter to draw/remove ASCII boxes around text
|
2023-03-26 21:32:08 +02:00
|
|
|
* Copyright (c) 1999-2023 Thomas Jensen and the boxes contributors
|
2021-10-20 22:28:34 +02:00
|
|
|
*
|
2022-09-18 14:56:30 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License, version 3, 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, see <https://www.gnu.org/licenses/>.
|
2021-10-20 22:28:34 +02:00
|
|
|
*
|
2022-09-18 14:56:30 +02:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2021-10-20 22:28:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unit tests of the 'tools' module
|
|
|
|
*/
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
#include "config.h"
|
2021-10-20 22:28:34 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
|
|
|
#include "tools.h"
|
2021-10-28 09:01:14 +02:00
|
|
|
#include "tools_test.h"
|
2021-10-20 22:28:34 +02:00
|
|
|
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
void test_strisyes_true(void **state)
|
2021-10-20 22:28:34 +02:00
|
|
|
{
|
2021-10-28 09:01:14 +02:00
|
|
|
(void) state; /* unused */
|
|
|
|
|
2021-10-20 22:28:34 +02:00
|
|
|
assert_int_equal(1, strisyes("On"));
|
|
|
|
assert_int_equal(1, strisyes("on"));
|
|
|
|
assert_int_equal(1, strisyes("yes"));
|
|
|
|
assert_int_equal(1, strisyes("YEs"));
|
|
|
|
assert_int_equal(1, strisyes("true"));
|
|
|
|
assert_int_equal(1, strisyes("True"));
|
|
|
|
assert_int_equal(1, strisyes("1"));
|
|
|
|
assert_int_equal(1, strisyes("t"));
|
|
|
|
assert_int_equal(1, strisyes("T"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
void test_strisyes_false(void **state)
|
2021-10-20 22:28:34 +02:00
|
|
|
{
|
2021-10-28 09:01:14 +02:00
|
|
|
(void) state; /* unused */
|
|
|
|
|
2021-10-20 22:28:34 +02:00
|
|
|
assert_int_equal(0, strisyes(NULL));
|
|
|
|
assert_int_equal(0, strisyes(""));
|
|
|
|
assert_int_equal(0, strisyes(" "));
|
|
|
|
assert_int_equal(0, strisyes("off"));
|
|
|
|
assert_int_equal(0, strisyes("false"));
|
|
|
|
assert_int_equal(0, strisyes("no"));
|
|
|
|
assert_int_equal(0, strisyes("0"));
|
|
|
|
assert_int_equal(0, strisyes("f"));
|
|
|
|
assert_int_equal(0, strisyes("F"));
|
|
|
|
assert_int_equal(0, strisyes("tru"));
|
|
|
|
assert_int_equal(0, strisyes("yes sir"));
|
|
|
|
assert_int_equal(0, strisyes("100"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
void test_strisno_true(void **state)
|
2021-10-21 20:49:49 +02:00
|
|
|
{
|
2021-10-28 09:01:14 +02:00
|
|
|
(void) state; /* unused */
|
|
|
|
|
2021-10-21 20:49:49 +02:00
|
|
|
assert_int_equal(1, strisno("off"));
|
|
|
|
assert_int_equal(1, strisno("Off"));
|
|
|
|
assert_int_equal(1, strisno("no"));
|
|
|
|
assert_int_equal(1, strisno("NO"));
|
|
|
|
assert_int_equal(1, strisno("false"));
|
|
|
|
assert_int_equal(1, strisno("False"));
|
|
|
|
assert_int_equal(1, strisno("0"));
|
|
|
|
assert_int_equal(1, strisno("f"));
|
|
|
|
assert_int_equal(1, strisno("F"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
void test_strisno_false(void **state)
|
2021-10-21 20:49:49 +02:00
|
|
|
{
|
2021-10-28 09:01:14 +02:00
|
|
|
(void) state; /* unused */
|
|
|
|
|
2021-10-21 20:49:49 +02:00
|
|
|
assert_int_equal(0, strisno(NULL));
|
|
|
|
assert_int_equal(0, strisno(""));
|
|
|
|
assert_int_equal(0, strisno(" "));
|
|
|
|
assert_int_equal(0, strisno("on"));
|
|
|
|
assert_int_equal(0, strisno("true"));
|
|
|
|
assert_int_equal(0, strisno("yes"));
|
|
|
|
assert_int_equal(0, strisno("1"));
|
|
|
|
assert_int_equal(0, strisno("t"));
|
|
|
|
assert_int_equal(0, strisno("T"));
|
|
|
|
assert_int_equal(0, strisno("fal"));
|
|
|
|
assert_int_equal(0, strisno("no sir"));
|
|
|
|
assert_int_equal(0, strisno("00"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-28 09:01:14 +02:00
|
|
|
/*EOF*/ /* vim: set cindent sw=4: */
|