From: Kevin Day Date: Sat, 25 Jun 2022 15:51:37 +0000 (-0500) Subject: Update: Add the last of the planned f_utf unit tests. X-Git-Tag: 0.5.10~16 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=7f62b8f57316962249dd4c8f86ff336b56a0fa98;p=fll Update: Add the last of the planned f_utf unit tests. Implement the white space unit tests. --- diff --git a/level_0/f_utf/data/build/settings-tests b/level_0/f_utf/data/build/settings-tests index 62e6dca..05f218b 100644 --- a/level_0/f_utf/data/build/settings-tests +++ b/level_0/f_utf/data/build/settings-tests @@ -42,6 +42,9 @@ build_sources_program test-utf-character_is_superscript.c test-utf-is_superscrip build_sources_program test-utf-character_is_symbol.c test-utf-is_symbol.c build_sources_program test-utf-character_is_valid.c test-utf-is_valid.c build_sources_program test-utf-character_is_whitespace.c test-utf-is_whitespace.c +build_sources_program test-utf-character_is_whitespace_modifier.c test-utf-is_whitespace_modifier.c +build_sources_program test-utf-character_is_whitespace_other.c test-utf-is_whitespace_other.c +build_sources_program test-utf-character_is_whitespace_zero_width.c test-utf-is_whitespace_zero_width.c build_sources_program test-utf-character_is_wide.c test-utf-is_wide.c build_sources_program test-utf-character_is_word.c test-utf-is_word.c build_sources_program test-utf-character_is_word_dash.c test-utf-is_word_dash.c diff --git a/level_0/f_utf/data/tests/bytesequences/whitespace-all.txt b/level_0/f_utf/data/tests/bytesequences/whitespace-all.txt new file mode 100644 index 0000000..6ed2817 --- /dev/null +++ b/level_0/f_utf/data/tests/bytesequences/whitespace-all.txt @@ -0,0 +1,17 @@ +32 +49824 +14785152 +14844032 +14844033 +14844034 +14844035 +14844036 +14844037 +14844038 +14844039 +14844040 +14844041 +14844042 +14844079 +14844319 +14909568 diff --git a/level_0/f_utf/data/tests/bytesequences/whitespace-modifier.txt b/level_0/f_utf/data/tests/bytesequences/whitespace-modifier.txt new file mode 100644 index 0000000..296f48f --- /dev/null +++ b/level_0/f_utf/data/tests/bytesequences/whitespace-modifier.txt @@ -0,0 +1,80 @@ +51888 +51889 +51890 +51891 +51892 +51893 +51894 +51895 +51896 +51897 +51898 +51899 +51900 +51901 +51902 +51903 +52096 +52097 +52098 +52099 +52100 +52101 +52102 +52103 +52104 +52105 +52106 +52107 +52108 +52109 +52110 +52111 +52112 +52113 +52114 +52115 +52116 +52117 +52118 +52119 +52120 +52121 +52122 +52123 +52124 +52125 +52126 +52127 +52128 +52129 +52130 +52131 +52132 +52133 +52134 +52135 +52136 +52137 +52138 +52139 +52140 +52141 +52142 +52143 +52144 +52145 +52146 +52147 +52148 +52149 +52150 +52151 +52152 +52153 +52154 +52155 +52156 +52157 +52158 +52159 diff --git a/level_0/f_utf/data/tests/bytesequences/whitespace-other.txt b/level_0/f_utf/data/tests/bytesequences/whitespace-other.txt new file mode 100644 index 0000000..c581199 --- /dev/null +++ b/level_0/f_utf/data/tests/bytesequences/whitespace-other.txt @@ -0,0 +1 @@ +14785152 diff --git a/level_0/f_utf/data/tests/bytesequences/whitespace-zero_width.txt b/level_0/f_utf/data/tests/bytesequences/whitespace-zero_width.txt new file mode 100644 index 0000000..f846e4f --- /dev/null +++ b/level_0/f_utf/data/tests/bytesequences/whitespace-zero_width.txt @@ -0,0 +1 @@ +14844043 diff --git a/level_0/f_utf/data/tests/codepoints/whitespace-all.txt b/level_0/f_utf/data/tests/codepoints/whitespace-all.txt new file mode 100644 index 0000000..433ee9f --- /dev/null +++ b/level_0/f_utf/data/tests/codepoints/whitespace-all.txt @@ -0,0 +1,14 @@ +U+00A0 +U+2000 +U+2001 +U+2002 +U+2003 +U+2004 +U+2005 +U+2006 +U+2007 +U+2008 +U+2009 +U+200A +U+200B +U+3000 diff --git a/level_0/f_utf/data/tests/codepoints/whitespace-modifier.txt b/level_0/f_utf/data/tests/codepoints/whitespace-modifier.txt new file mode 100644 index 0000000..be9c212 --- /dev/null +++ b/level_0/f_utf/data/tests/codepoints/whitespace-modifier.txt @@ -0,0 +1,80 @@ +U+02B0 +U+02B1 +U+02B2 +U+02B3 +U+02B4 +U+02B5 +U+02B6 +U+02B7 +U+02B8 +U+02B9 +U+02BA +U+02BB +U+02BC +U+02BD +U+02BE +U+02BF +U+02C0 +U+02C1 +U+02C2 +U+02C3 +U+02C4 +U+02C5 +U+02C6 +U+02C7 +U+02C8 +U+02C9 +U+02CA +U+02CB +U+02CC +U+02CD +U+02CE +U+02CF +U+02D0 +U+02D1 +U+02D2 +U+02D3 +U+02D4 +U+02D5 +U+02D6 +U+02D7 +U+02D8 +U+02D9 +U+02DA +U+02DB +U+02DC +U+02DD +U+02DE +U+02DF +U+02E0 +U+02E1 +U+02E2 +U+02E3 +U+02E4 +U+02E5 +U+02E6 +U+02E7 +U+02E8 +U+02E9 +U+02EA +U+02EB +U+02EC +U+02ED +U+02EE +U+02EF +U+02F0 +U+02F1 +U+02F2 +U+02F3 +U+02F4 +U+02F5 +U+02F6 +U+02F7 +U+02F8 +U+02F9 +U+02FA +U+02FB +U+02FC +U+02FD +U+02FE +U+02FF diff --git a/level_0/f_utf/data/tests/codepoints/whitespace-other.txt b/level_0/f_utf/data/tests/codepoints/whitespace-other.txt new file mode 100644 index 0000000..e313bd2 --- /dev/null +++ b/level_0/f_utf/data/tests/codepoints/whitespace-other.txt @@ -0,0 +1 @@ +U+1680 diff --git a/level_0/f_utf/data/tests/codepoints/whitespace-zero_width.txt b/level_0/f_utf/data/tests/codepoints/whitespace-zero_width.txt new file mode 100644 index 0000000..ef54693 --- /dev/null +++ b/level_0/f_utf/data/tests/codepoints/whitespace-zero_width.txt @@ -0,0 +1 @@ +U+200B diff --git a/level_0/f_utf/tests/unit/c/data-utf.c b/level_0/f_utf/tests/unit/c/data-utf.c index ed036b0..b66bfc5 100644 --- a/level_0/f_utf/tests/unit/c/data-utf.c +++ b/level_0/f_utf/tests/unit/c/data-utf.c @@ -74,6 +74,21 @@ FILE *data__bytesequence_file_open__whitespace(void) { return fopen("./data/tests/bytesequences/whitespace-all.txt", "r"); } +FILE *data__bytesequence_file_open__whitespace__modifier(void) { + + return fopen("./data/tests/bytesequences/whitespace-modifier.txt", "r"); +} + +FILE *data__bytesequence_file_open__whitespace__other(void) { + + return fopen("./data/tests/bytesequences/whitespace-other.txt", "r"); +} + +FILE *data__bytesequence_file_open__whitespace__zero_width(void) { + + return fopen("./data/tests/bytesequences/whitespace-zero_width.txt", "r"); +} + FILE *data__bytesequence_file_open__wide(void) { return fopen("./data/tests/bytesequences/wide-all.txt", "r"); @@ -94,17 +109,17 @@ FILE *data__bytesequence_file_open__word_dash_plus(void) { return fopen("./data/tests/bytesequences/word_dash_plus-all.txt", "r"); } -FILE *data__bytesequence_file_open_lax__word(void) { +FILE *data__bytesequence_file_open__word__lax(void) { return fopen("./data/tests/bytesequences/word-lax.txt", "r"); } -FILE *data__bytesequence_file_open_lax__word_dash(void) { +FILE *data__bytesequence_file_open__word_dash__lax(void) { return fopen("./data/tests/bytesequences/word_dash-lax.txt", "r"); } -FILE *data__bytesequence_file_open_lax__word_dash_plus(void) { +FILE *data__bytesequence_file_open__word_dash_plus__lax(void) { return fopen("./data/tests/bytesequences/word_dash_plus-lax.txt", "r"); } diff --git a/level_0/f_utf/tests/unit/c/data-utf.h b/level_0/f_utf/tests/unit/c/data-utf.h index 6126e34..a12bcdc 100644 --- a/level_0/f_utf/tests/unit/c/data-utf.h +++ b/level_0/f_utf/tests/unit/c/data-utf.h @@ -233,6 +233,51 @@ extern FILE *data__bytesequence_file_open__valid(void); extern FILE *data__bytesequence_file_open__whitespace(void); /** + * Open the "whitespace_modifier" bytesequence file, the "modifier" variation. + * + * This assumes the following: + * - The file path is relative to the current working directory (tests are run from project root). + * - The file path is "data/tests/bytesequences/whitespace-modifier.txt". + * + * @return + * Non-zero on success. + * 0 on failure. + * + * @see fopen() + */ +extern FILE *data__bytesequence_file_open__whitespace__modifier(void); + +/** + * Open the "whitespace_other" bytesequence file, the "other" variation. + * + * This assumes the following: + * - The file path is relative to the current working directory (tests are run from project root). + * - The file path is "data/tests/bytesequences/whitespace-other.txt". + * + * @return + * Non-zero on success. + * 0 on failure. + * + * @see fopen() + */ +extern FILE *data__bytesequence_file_open__whitespace__other(void); + +/** + * Open the "whitespace_zero_width" bytesequence file, the "zero_width" variation. + * + * This assumes the following: + * - The file path is relative to the current working directory (tests are run from project root). + * - The file path is "data/tests/bytesequences/whitespace-zero_width.txt". + * + * @return + * Non-zero on success. + * 0 on failure. + * + * @see fopen() + */ +extern FILE *data__bytesequence_file_open__whitespace__zero_width(void); + +/** * Open the "wide" bytesequence file. * * This assumes the following: @@ -305,7 +350,7 @@ extern FILE *data__bytesequence_file_open__word_dash_plus(void); * * @see fopen() */ -extern FILE *data__bytesequence_file_open_lax__word(void); +extern FILE *data__bytesequence_file_open__word__lax(void); /** * Open the "word_dash" bytesequence file, the "lax" variation. @@ -320,7 +365,7 @@ extern FILE *data__bytesequence_file_open_lax__word(void); * * @see fopen() */ -extern FILE *data__bytesequence_file_open_lax__word_dash(void); +extern FILE *data__bytesequence_file_open__word_dash__lax(void); /** * Open the "word_dash_plus" bytesequence file, the "lax" variation. @@ -335,7 +380,7 @@ extern FILE *data__bytesequence_file_open_lax__word_dash(void); * * @see fopen() */ -extern FILE *data__bytesequence_file_open_lax__word_dash_plus(void); +extern FILE *data__bytesequence_file_open__word_dash_plus__lax(void); /** * Open the "zero_width" bytesequence file. diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic.c index 9194cbe..99ae58d 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic.c @@ -27,7 +27,7 @@ static inline void private__test__f_utf_character_is_alphabetic__works(const f_s else if (f_utf_character_is_combining(sequence)) { assert_int_equal(status, F_false); } - else if (f_utf_character_is_whitespace(sequence)) { + else if (f_utf_character_is_whitespace(sequence, F_true)) { assert_int_equal(status, F_false); } else if (f_utf_character_is_whitespace_modifier(sequence)) { diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_digit.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_digit.c index f58a6de..ec3722c 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_digit.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_digit.c @@ -30,7 +30,7 @@ static inline void private__test__f_utf_character_is_alphabetic_digit__works(con else if (f_utf_character_is_combining(sequence)) { assert_int_equal(status, F_false); } - else if (f_utf_character_is_whitespace(sequence)) { + else if (f_utf_character_is_whitespace(sequence, F_true)) { assert_int_equal(status, F_false); } else if (f_utf_character_is_whitespace_modifier(sequence)) { diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_numeric.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_numeric.c index e13cb3a..8bb24c7 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_numeric.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_alphabetic_numeric.c @@ -30,7 +30,7 @@ static inline void private__test__f_utf_character_is_alphabetic_numeric__works(c else if (f_utf_character_is_combining(sequence)) { assert_int_equal(status, F_false); } - else if (f_utf_character_is_whitespace(sequence)) { + else if (f_utf_character_is_whitespace(sequence, F_true)) { assert_int_equal(status, F_false); } else if (f_utf_character_is_whitespace_modifier(sequence)) { diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace.c index bc8e964..801d43d 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace.c @@ -21,7 +21,7 @@ void test__f_utf_character_is_whitespace__works(void **state) { bytes = data__bytesequence_get_line(file, &sequence); if (bytes > 0) { - const f_status_t status = f_utf_character_is_whitespace(sequence); + const f_status_t status = f_utf_character_is_whitespace(sequence, F_true); assert_int_equal(status, F_true); } diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_modifier.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_modifier.c new file mode 100644 index 0000000..47c6308 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_modifier.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-character_is_whitespace_modifier.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_character_is_whitespace_modifier__works(void **state) { + + { + FILE *file = data__bytesequence_file_open__whitespace__modifier(); + + assert_non_null(file); + + f_utf_char_t sequence = 0; + ssize_t bytes = 0; + + f_array_length_t line = 0; + + do { + bytes = data__bytesequence_get_line(file, &sequence); + + if (bytes > 0) { + const f_status_t status = f_utf_character_is_whitespace_modifier(sequence); + + assert_int_equal(status, F_true); + } + + ++line; + + } while (bytes > 0); + + fclose(file); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_modifier.h b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_modifier.h new file mode 100644 index 0000000..0e913cf --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_modifier.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the function in the utf project. + */ +#ifndef _TEST__F_utf_character_is_whitespace_modifier_h +#define _TEST__F_utf_character_is_whitespace_modifier_h + +/** + * Test that the function works. + * + * @see f_utf_character_is_whitespace_modifier() + */ +extern void test__f_utf_character_is_whitespace_modifier__works(void **state); + +#endif // _TEST__F_utf_character_is_whitespace_modifier_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_other.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_other.c new file mode 100644 index 0000000..de038a1 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_other.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-character_is_whitespace_other.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_character_is_whitespace_other__works(void **state) { + + { + FILE *file = data__bytesequence_file_open__whitespace__other(); + + assert_non_null(file); + + f_utf_char_t sequence = 0; + ssize_t bytes = 0; + + f_array_length_t line = 0; + + do { + bytes = data__bytesequence_get_line(file, &sequence); + + if (bytes > 0) { + const f_status_t status = f_utf_character_is_whitespace_other(sequence); + + assert_int_equal(status, F_true); + } + + ++line; + + } while (bytes > 0); + + fclose(file); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_other.h b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_other.h new file mode 100644 index 0000000..73a2b8e --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_other.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the function in the utf project. + */ +#ifndef _TEST__F_utf_character_is_whitespace_other_h +#define _TEST__F_utf_character_is_whitespace_other_h + +/** + * Test that the function works. + * + * @see f_utf_character_is_whitespace_other() + */ +extern void test__f_utf_character_is_whitespace_other__works(void **state); + +#endif // _TEST__F_utf_character_is_whitespace_other_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_zero_width.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_zero_width.c new file mode 100644 index 0000000..dca1919 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_zero_width.c @@ -0,0 +1,39 @@ +#include "test-utf.h" +#include "test-utf-character_is_whitespace_zero_width.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_character_is_whitespace_zero_width__works(void **state) { + + { + FILE *file = data__bytesequence_file_open__whitespace__zero_width(); + + assert_non_null(file); + + f_utf_char_t sequence = 0; + ssize_t bytes = 0; + + f_array_length_t line = 0; + + do { + bytes = data__bytesequence_get_line(file, &sequence); + + if (bytes > 0) { + const f_status_t status = f_utf_character_is_whitespace_zero_width(sequence); + + assert_int_equal(status, F_true); + } + + ++line; + + } while (bytes > 0); + + fclose(file); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_zero_width.h b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_zero_width.h new file mode 100644 index 0000000..108ff94 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_whitespace_zero_width.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the function in the utf project. + */ +#ifndef _TEST__F_utf_character_is_whitespace_zero_width_h +#define _TEST__F_utf_character_is_whitespace_zero_width_h + +/** + * Test that the function works. + * + * @see f_utf_character_is_whitespace_zero_width() + */ +extern void test__f_utf_character_is_whitespace_zero_width__works(void **state); + +#endif // _TEST__F_utf_character_is_whitespace_zero_width_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_word.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_word.c index f622f8f..c433a15 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_word.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_word.c @@ -8,7 +8,7 @@ extern "C" { void test__f_utf_character_is_word__strict_is_false(void **state) { { - FILE *file = data__bytesequence_file_open_lax__word(); + FILE *file = data__bytesequence_file_open__word__lax(); assert_non_null(file); diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash.c index f2c2411..580cf92 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash.c @@ -8,7 +8,7 @@ extern "C" { void test__f_utf_character_is_word_dash__strict_is_false(void **state) { { - FILE *file = data__bytesequence_file_open_lax__word_dash(); + FILE *file = data__bytesequence_file_open__word_dash__lax(); assert_non_null(file); diff --git a/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash_plus.c b/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash_plus.c index 70f0832..6d2a76f 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash_plus.c +++ b/level_0/f_utf/tests/unit/c/test-utf-character_is_word_dash_plus.c @@ -8,7 +8,7 @@ extern "C" { void test__f_utf_character_is_word_dash_plus__strict_is_false(void **state) { { - FILE *file = data__bytesequence_file_open_lax__word_dash_plus(); + FILE *file = data__bytesequence_file_open__word_dash_plus__lax(); assert_non_null(file); diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic.c b/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic.c index 8ec43cb..a0eca42 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic.c @@ -27,7 +27,7 @@ static inline void private__test__f_utf_is_alphabetic__works(const f_status_t st else if (f_utf_character_is_combining(sequence) == F_true) { assert_int_equal(status, F_false); } - else if (f_utf_character_is_whitespace(sequence) == F_true) { + else if (f_utf_character_is_whitespace(sequence, F_true) == F_true) { assert_int_equal(status, F_false); } else if (f_utf_character_is_whitespace_modifier(sequence) == F_true) { diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_digit.c b/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_digit.c index 586a254..74bbad6 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_digit.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_digit.c @@ -30,7 +30,7 @@ static inline void private__test__f_utf_is_alphabetic_digit__works(const f_statu else if (f_utf_character_is_combining(sequence) == F_true) { assert_int_equal(status, F_false); } - else if (f_utf_character_is_whitespace(sequence) == F_true) { + else if (f_utf_character_is_whitespace(sequence, F_true) == F_true) { assert_int_equal(status, F_false); } else if (f_utf_character_is_whitespace_modifier(sequence) == F_true) { diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_numeric.c b/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_numeric.c index 700070c..665a3ea 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_numeric.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_alphabetic_numeric.c @@ -30,7 +30,7 @@ static inline void private__test__f_utf_is_alphabetic_numeric__works(const f_sta else if (f_utf_character_is_combining(sequence) == F_true) { assert_int_equal(status, F_false); } - else if (f_utf_character_is_whitespace(sequence) == F_true) { + else if (f_utf_character_is_whitespace(sequence, F_true) == F_true) { assert_int_equal(status, F_false); } else if (f_utf_character_is_whitespace_modifier(sequence) == F_true) { diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace.c b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace.c index eede603..ba78894 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace.c @@ -38,7 +38,7 @@ void test__f_utf_is_whitespace__works(void **state) { } } - const f_status_t status = f_utf_is_whitespace(buffer, 5); + const f_status_t status = f_utf_is_whitespace(buffer, 5, F_true); assert_int_equal(status, F_true); } diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_modifier.c b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_modifier.c new file mode 100644 index 0000000..57c5771 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_modifier.c @@ -0,0 +1,56 @@ +#include "test-utf.h" +#include "test-utf-is_whitespace_modifier.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_is_whitespace_modifier__works(void **state) { + + { + FILE *file = data__bytesequence_file_open__whitespace__modifier(); + + assert_non_null(file); + + f_utf_char_t sequence = 0; + ssize_t bytes = 0; + + f_array_length_t line = 0; + + do { + bytes = data__bytesequence_get_line(file, &sequence); + + if (bytes > 0) { + const uint8_t width = macro_f_utf_char_t_width(sequence); + char buffer[5] = { 0, 0, 0, 0, 0 }; + + buffer[0] = macro_f_utf_char_t_to_char_1(sequence); + + if (width > 1) { + buffer[1] = macro_f_utf_char_t_to_char_2(sequence); + + if (width > 2) { + buffer[2] = macro_f_utf_char_t_to_char_3(sequence); + + if (width > 3) { + buffer[3] = macro_f_utf_char_t_to_char_4(sequence); + } + } + } + + const f_status_t status = f_utf_is_whitespace_modifier(buffer, 5); + + assert_int_equal(status, F_true); + } + + ++line; + + } while (bytes > 0); + + fclose(file); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_modifier.h b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_modifier.h new file mode 100644 index 0000000..d9637d7 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_modifier.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the function in the utf project. + */ +#ifndef _TEST__F_utf_is_whitespace_modifier_h +#define _TEST__F_utf_is_whitespace_modifier_h + +/** + * Test that the function works. + * + * @see f_utf_is_whitespace_modifier() + */ +extern void test__f_utf_is_whitespace_modifier__works(void **state); + +#endif // _TEST__F_utf_is_whitespace_modifier_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_other.c b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_other.c new file mode 100644 index 0000000..5690110 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_other.c @@ -0,0 +1,56 @@ +#include "test-utf.h" +#include "test-utf-is_whitespace_other.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_is_whitespace_other__works(void **state) { + + { + FILE *file = data__bytesequence_file_open__whitespace__other(); + + assert_non_null(file); + + f_utf_char_t sequence = 0; + ssize_t bytes = 0; + + f_array_length_t line = 0; + + do { + bytes = data__bytesequence_get_line(file, &sequence); + + if (bytes > 0) { + const uint8_t width = macro_f_utf_char_t_width(sequence); + char buffer[5] = { 0, 0, 0, 0, 0 }; + + buffer[0] = macro_f_utf_char_t_to_char_1(sequence); + + if (width > 1) { + buffer[1] = macro_f_utf_char_t_to_char_2(sequence); + + if (width > 2) { + buffer[2] = macro_f_utf_char_t_to_char_3(sequence); + + if (width > 3) { + buffer[3] = macro_f_utf_char_t_to_char_4(sequence); + } + } + } + + const f_status_t status = f_utf_is_whitespace_other(buffer, 5); + + assert_int_equal(status, F_true); + } + + ++line; + + } while (bytes > 0); + + fclose(file); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_other.h b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_other.h new file mode 100644 index 0000000..d7787a3 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_other.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the function in the utf project. + */ +#ifndef _TEST__F_utf_is_whitespace_other_h +#define _TEST__F_utf_is_whitespace_other_h + +/** + * Test that the function works. + * + * @see f_utf_is_whitespace_other() + */ +extern void test__f_utf_is_whitespace_other__works(void **state); + +#endif // _TEST__F_utf_is_whitespace_other_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_zero_width.c b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_zero_width.c new file mode 100644 index 0000000..bc5dbe9 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_zero_width.c @@ -0,0 +1,56 @@ +#include "test-utf.h" +#include "test-utf-is_whitespace_zero_width.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_utf_is_whitespace_zero_width__works(void **state) { + + { + FILE *file = data__bytesequence_file_open__whitespace__zero_width(); + + assert_non_null(file); + + f_utf_char_t sequence = 0; + ssize_t bytes = 0; + + f_array_length_t line = 0; + + do { + bytes = data__bytesequence_get_line(file, &sequence); + + if (bytes > 0) { + const uint8_t width = macro_f_utf_char_t_width(sequence); + char buffer[5] = { 0, 0, 0, 0, 0 }; + + buffer[0] = macro_f_utf_char_t_to_char_1(sequence); + + if (width > 1) { + buffer[1] = macro_f_utf_char_t_to_char_2(sequence); + + if (width > 2) { + buffer[2] = macro_f_utf_char_t_to_char_3(sequence); + + if (width > 3) { + buffer[3] = macro_f_utf_char_t_to_char_4(sequence); + } + } + } + + const f_status_t status = f_utf_is_whitespace_zero_width(buffer, 5); + + assert_int_equal(status, F_true); + } + + ++line; + + } while (bytes > 0); + + fclose(file); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_zero_width.h b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_zero_width.h new file mode 100644 index 0000000..6be4ae0 --- /dev/null +++ b/level_0/f_utf/tests/unit/c/test-utf-is_whitespace_zero_width.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the function in the utf project. + */ +#ifndef _TEST__F_utf_is_whitespace_zero_width_h +#define _TEST__F_utf_is_whitespace_zero_width_h + +/** + * Test that the function works. + * + * @see f_utf_is_whitespace_zero_width() + */ +extern void test__f_utf_is_whitespace_zero_width__works(void **state); + +#endif // _TEST__F_utf_is_whitespace_zero_width_h diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_word.c b/level_0/f_utf/tests/unit/c/test-utf-is_word.c index 9c75ec7..3d35ba4 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_word.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_word.c @@ -8,7 +8,7 @@ extern "C" { void test__f_utf_is_word__strict_is_false(void **state) { { - FILE *file = data__bytesequence_file_open_lax__word(); + FILE *file = data__bytesequence_file_open__word__lax(); assert_non_null(file); diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_word_dash.c b/level_0/f_utf/tests/unit/c/test-utf-is_word_dash.c index 4b8bb45..d65d1ae 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_word_dash.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_word_dash.c @@ -8,7 +8,7 @@ extern "C" { void test__f_utf_is_word_dash__strict_is_false(void **state) { { - FILE *file = data__bytesequence_file_open_lax__word_dash(); + FILE *file = data__bytesequence_file_open__word_dash__lax(); assert_non_null(file); diff --git a/level_0/f_utf/tests/unit/c/test-utf-is_word_dash_plus.c b/level_0/f_utf/tests/unit/c/test-utf-is_word_dash_plus.c index 0f0ed19..50da276 100644 --- a/level_0/f_utf/tests/unit/c/test-utf-is_word_dash_plus.c +++ b/level_0/f_utf/tests/unit/c/test-utf-is_word_dash_plus.c @@ -8,7 +8,7 @@ extern "C" { void test__f_utf_is_word_dash_plus__strict_is_false(void **state) { { - FILE *file = data__bytesequence_file_open_lax__word_dash_plus(); + FILE *file = data__bytesequence_file_open__word_dash_plus__lax(); assert_non_null(file); diff --git a/level_0/f_utf/tests/unit/c/test-utf.c b/level_0/f_utf/tests/unit/c/test-utf.c index 81dbe34..0401e56 100644 --- a/level_0/f_utf/tests/unit/c/test-utf.c +++ b/level_0/f_utf/tests/unit/c/test-utf.c @@ -39,7 +39,10 @@ int main(void) { cmocka_unit_test(test__f_utf_character_is_superscript__works), cmocka_unit_test(test__f_utf_character_is_symbol__works), cmocka_unit_test(test__f_utf_character_is_valid__works), - //cmocka_unit_test(test__f_utf_character_is_whitespace__works), + cmocka_unit_test(test__f_utf_character_is_whitespace__works), + cmocka_unit_test(test__f_utf_character_is_whitespace_modifier__works), + cmocka_unit_test(test__f_utf_character_is_whitespace_other__works), + cmocka_unit_test(test__f_utf_character_is_whitespace_zero_width__works), cmocka_unit_test(test__f_utf_character_is_wide__works), cmocka_unit_test(test__f_utf_character_is_zero_width__works), @@ -155,7 +158,10 @@ int main(void) { cmocka_unit_test(test__f_utf_is_superscript__works), cmocka_unit_test(test__f_utf_is_symbol__works), cmocka_unit_test(test__f_utf_is_valid__works), - //cmocka_unit_test(test__f_utf_is_whitespace__works), + cmocka_unit_test(test__f_utf_is_whitespace__works), + cmocka_unit_test(test__f_utf_is_whitespace_modifier__works), + cmocka_unit_test(test__f_utf_is_whitespace_other__works), + cmocka_unit_test(test__f_utf_is_whitespace_zero_width__works), cmocka_unit_test(test__f_utf_is_wide__works), cmocka_unit_test(test__f_utf_is_zero_width__works), diff --git a/level_0/f_utf/tests/unit/c/test-utf.h b/level_0/f_utf/tests/unit/c/test-utf.h index b96c4a8..00d8969 100644 --- a/level_0/f_utf/tests/unit/c/test-utf.h +++ b/level_0/f_utf/tests/unit/c/test-utf.h @@ -50,6 +50,9 @@ #include "test-utf-character_is_symbol.h" #include "test-utf-character_is_valid.h" #include "test-utf-character_is_whitespace.h" +#include "test-utf-character_is_whitespace_modifier.h" +#include "test-utf-character_is_whitespace_other.h" +#include "test-utf-character_is_whitespace_zero_width.h" #include "test-utf-character_is_wide.h" #include "test-utf-character_is_word.h" #include "test-utf-character_is_word_dash.h" @@ -123,6 +126,9 @@ #include "test-utf-is_symbol.h" #include "test-utf-is_valid.h" #include "test-utf-is_whitespace.h" +#include "test-utf-is_whitespace_modifier.h" +#include "test-utf-is_whitespace_other.h" +#include "test-utf-is_whitespace_zero_width.h" #include "test-utf-is_wide.h" #include "test-utf-is_word.h" #include "test-utf-is_word_dash.h"