Implement the white space unit tests.
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
--- /dev/null
+32
+49824
+14785152
+14844032
+14844033
+14844034
+14844035
+14844036
+14844037
+14844038
+14844039
+14844040
+14844041
+14844042
+14844079
+14844319
+14909568
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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");
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");
}
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:
*
* @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.
*
* @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.
*
* @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.
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)) {
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)) {
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)) {
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);
}
--- /dev/null
+#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
--- /dev/null
+/**
+ * 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
--- /dev/null
+#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
--- /dev/null
+/**
+ * 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
--- /dev/null
+#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
--- /dev/null
+/**
+ * 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
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);
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);
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);
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) {
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) {
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) {
}
}
- 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);
}
--- /dev/null
+#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
--- /dev/null
+/**
+ * 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
--- /dev/null
+#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
--- /dev/null
+/**
+ * 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
--- /dev/null
+#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
--- /dev/null
+/**
+ * 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
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);
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);
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);
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),
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),
#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"
#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"