diff --git a/lib/common/tests/strings/crm_str_to_boolean_test.c b/lib/common/tests/strings/crm_str_to_boolean_test.c index 0c30d8ac11..1b0ba45972 100644 --- a/lib/common/tests/strings/crm_str_to_boolean_test.c +++ b/lib/common/tests/strings/crm_str_to_boolean_test.c @@ -1,106 +1,106 @@ /* - * Copyright 2024 the Pacemaker project contributors + * Copyright 2021-2024 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU General Public License version 2 * or later (GPLv2+) WITHOUT ANY WARRANTY. */ #include #include static void bad_input(void **state) { assert_int_equal(crm_str_to_boolean(NULL, NULL), -1); assert_int_equal(crm_str_to_boolean("", NULL), -1); assert_int_equal(crm_str_to_boolean("blahblah", NULL), -1); } static void is_true(void **state) { int ret; assert_int_equal(crm_str_to_boolean("true", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("TrUe", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("on", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("ON", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("yes", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("yES", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("y", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("Y", &ret), 1); assert_true(ret); assert_int_equal(crm_str_to_boolean("1", &ret), 1); assert_true(ret); // Ensure it still validates the string with a NULL result argument assert_int_equal(crm_str_to_boolean("true", NULL), 1); assert_int_equal(crm_str_to_boolean("on", NULL), 1); assert_int_equal(crm_str_to_boolean("yes", NULL), 1); assert_int_equal(crm_str_to_boolean("y", NULL), 1); assert_int_equal(crm_str_to_boolean("1", NULL), 1); } static void is_not_true(void **state) { assert_int_equal(crm_str_to_boolean("truedat", NULL), -1); assert_int_equal(crm_str_to_boolean("onnn", NULL), -1); assert_int_equal(crm_str_to_boolean("yep", NULL), -1); assert_int_equal(crm_str_to_boolean("Y!", NULL), -1); assert_int_equal(crm_str_to_boolean("100", NULL), -1); } static void is_false(void **state) { int ret; assert_int_equal(crm_str_to_boolean("false", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("fAlSe", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("off", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("OFF", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("no", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("No", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("n", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("N", &ret), 1); assert_false(ret); assert_int_equal(crm_str_to_boolean("0", &ret), 1); assert_false(ret); // Ensure it still validates the string with a NULL result argument assert_int_equal(crm_str_to_boolean("false", NULL), 1); assert_int_equal(crm_str_to_boolean("off", NULL), 1); assert_int_equal(crm_str_to_boolean("no", NULL), 1); assert_int_equal(crm_str_to_boolean("n", NULL), 1); assert_int_equal(crm_str_to_boolean("0", NULL), 1); } static void is_not_false(void **state) { assert_int_equal(crm_str_to_boolean("falseee", NULL), -1); assert_int_equal(crm_str_to_boolean("of", NULL), -1); assert_int_equal(crm_str_to_boolean("nope", NULL), -1); assert_int_equal(crm_str_to_boolean("N!", NULL), -1); assert_int_equal(crm_str_to_boolean("000", NULL), -1); } PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(is_true), cmocka_unit_test(is_not_true), cmocka_unit_test(is_false), cmocka_unit_test(is_not_false)) diff --git a/lib/common/tests/strings/pcmk__btoa_test.c b/lib/common/tests/strings/pcmk__btoa_test.c index 870b31823e..f7dee9ee78 100644 --- a/lib/common/tests/strings/pcmk__btoa_test.c +++ b/lib/common/tests/strings/pcmk__btoa_test.c @@ -1,22 +1,22 @@ /* - * Copyright 2020-2024 the Pacemaker project contributors + * Copyright 2020-2021 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU General Public License version 2 * or later (GPLv2+) WITHOUT ANY WARRANTY. */ #include #include static void btoa(void **state) { assert_string_equal(pcmk__btoa(false), "false"); assert_string_equal(pcmk__btoa(true), "true"); assert_string_equal(pcmk__btoa(1 == 0), "false"); } PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(btoa))