From: Kevin Day Date: Fri, 25 Nov 2022 01:11:29 +0000 (-0600) Subject: Update: Fix and improve FSS unit test regarding zero-width. X-Git-Tag: 0.6.2~64 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=c9f4919e2755f4d4a6f0a6431fb310c977adaa7a;p=fll Update: Fix and improve FSS unit test regarding zero-width. Recent changes to the Unicode functions regarding zero-width improved or changed how what is designated as a zero-width character. The test is failing due to this change. Update the test to treat the tested character as zero-width. Add an additional test condition to test the stop range. --- diff --git a/level_0/f_fss/tests/unit/c/test-fss-is_zero_width.c b/level_0/f_fss/tests/unit/c/test-fss-is_zero_width.c index b7a9adc..75664ae 100644 --- a/level_0/f_fss/tests/unit/c/test-fss-is_zero_width.c +++ b/level_0/f_fss/tests/unit/c/test-fss-is_zero_width.c @@ -21,7 +21,9 @@ void test__f_fss_is_zero_width__works(void **state) { macro_f_string_static_t_initialize("$", 0, 1), macro_f_string_static_t_initialize(".", 0, 1), macro_f_string_static_t_initialize(" ́", 0, 3), // Space followed by a combining character (U+0020 U+0301). + macro_f_string_static_t_initialize(" ॐ", 0, 5), // Space followed by a printing character (U+0020 U+0061). macro_f_string_static_t_initialize("​", 0, 3), // Zero-width space (U+200B). + macro_f_string_static_t_initialize("a b", 0, 3), }; f_status_t expects[] = { @@ -35,31 +37,33 @@ void test__f_fss_is_zero_width__works(void **state) { F_false, F_false, F_false, + F_true, F_false, F_true, + F_false, }; - // Apply an offset so that the combining character is combining into something inside the quotes rather than the quotes for convenience and code safety. - f_array_length_t offset[] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, + // Use range to designate which part of a string is to be tested. + f_string_range_t ranges[] = { + { .start = 0, .stop = tests[0].used }, + { .start = 0, .stop = tests[1].used }, + { .start = 0, .stop = tests[2].used }, + { .start = 0, .stop = tests[3].used }, + { .start = 0, .stop = tests[4].used }, + { .start = 0, .stop = tests[5].used }, + { .start = 0, .stop = tests[6].used }, + { .start = 0, .stop = tests[7].used }, + { .start = 0, .stop = tests[8].used }, + { .start = 0, .stop = tests[9].used }, + { .start = 1, .stop = tests[10].used }, + { .start = 1, .stop = tests[11].used }, + { .start = 0, .stop = tests[12].used }, + { .start = 1, .stop = 1 }, }; - for (f_array_length_t i = 0; i < 12; ++i) { - - const f_string_range_t range = macro_f_string_range_t_initialize(offset[i], tests[i].used - 1); + for (f_array_length_t i = 0; i < 14; ++i) { - const f_status_t status = f_fss_is_zero_width(state_data, tests[i], range); + const f_status_t status = f_fss_is_zero_width(state_data, tests[i], ranges[i]); assert_int_equal(status, expects[i]); } // for