-b c d
-b c d
-b c d
-a b c
-b c
-d
-b c d
-b c d
-" b c d
-d
-d
-c d
-b c d
+b c d 1
+b c d 2
+b c d 3
+a b c 4
+b c 5
+d 6
+b c d 7
+b c d 8
+" b c d 9
+d 10
+d 11
+c d 12
+b c d 13
-c d
+c d 14
{
-c d
+c d 15
-b c d
-Ȁ b c d
-"Ȁ" b c d
-" Ȁ " b c d
-" Ȁ " b `c d`
-b c d
-b c d
-b c d
-c d' e
-c d" e
-c d` e
-c d' e
-c d" e
-c d` e
-b c d e
-b c d e '
-b c d
-b c
-c d
-b c d
-b c d
+b c d 16
+Ȁ b c d 17
+"Ȁ" b c d 18
+" Ȁ " b c d 19
+" Ȁ " b `c d` 20
+b c d 21
+b c d 22
+b c d 23
+c d' e 24
+c d" e 25
+c d` e 26
+c d' e 27
+c d" e 28
+c d` e 29
+b c d e 30
+b c d e 31 '
+b c d 32
+b c 33
+c d 34
+b c d 35
+b c d 36
+d zerowidth 37
+мир 38
+e␠
+space! <-- should have the word 'space!' 39
+a comment...should have no slashes. 40
+a comment either...should have one slash. 41
+a comment either...should have two slashes. 42
+"b c d" "e f g"
+"b c' d" "e' f g"
+"b c` d" "e` f g"
+'b c d' 'e f g'
+'b c" d' 'e" f g'
+`b c" d` `e" f g`
+\'b c' d
--- /dev/null
+ Has UTF-8 characters.
+
--- /dev/null
+ Has UTF-8: привет мир
--- /dev/null
+ content as well.
+ With multiple lines.
--- /dev/null
+Not tabbed over.
+
+
+Has empty lines before and after.
+
+
--- /dev/null
+This: is not a list.
+
--- /dev/null
+
+ just:
+ Add a slash.
+
--- /dev/null
+ slashes.
+Has Slashes but is not a list\:
+ This is part of the previous one.
+
--- /dev/null
+ The object name is an empty string.
+
--- /dev/null
+ Quotes aren't supported here, so this is not an empty object.
+:
+
--- /dev/null
+b
+b
+b
+a
+b
+d
+b
+b
+"
+d
+d
+c
+b
+
+c
+{
+c
+
+b
+Ȁ
+Ȁ
+ Ȁ
+ Ȁ
+b
+b
+b
+c
+c
+c
+c
+c
+c
+b
+b
+b
+b
+c
+b
+b
+d
+мир
+e␠
+space!
+a
+a
+a
+b c d
+b c' d
+b c` d
+b c d
+b c" d
+b c" d
+'b
--- /dev/null
+c
+c
+c
+b
+c
+6
+c
+c
+b
+10
+11
+d
+c
+
+d
+
+d
+
+c
+b
+b
+b
+b
+c
+c
+c
+d'
+d"
+d`
+d'
+d"
+d`
+c
+c
+c
+c
+d
+c
+c
+zerowidth
+38
+
+<--
+comment...should
+comment
+comment
+e f g
+e' f g
+e` f g
+e f g
+e" f g
+e" f g
+c'
--- /dev/null
+d
+d
+d
+c
+5
+
+d
+d
+c
+
+
+12
+d
+
+14
+
+15
+
+d
+c
+c
+c
+c d
+d
+d
+d
+e
+e
+e
+e
+e
+e
+d
+d
+d
+33
+34
+d
+d
+37
+
+
+should
+have
+either...should
+either...should
+
+
+
+
+
+
+d
--- /dev/null
+1
+2
+3
+4
+
+
+7
+8
+
+
+
+
+13
+
+
+
+
+
+16
+d
+d
+d
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+e
+e
+32
+
+
+35
+36
+
+
+
+have
+no
+have
+have
+
+
+
+
+
+
+
--- /dev/null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+17
+18
+19
+
+
+
+
+
+
+
+
+
+
+30
+31
+
+
+
+
+
+
+
+
+the
+slashes.
+one
+two
+
+
+
+
+
+
+
--- /dev/null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+'
+
+
+
+
+
+
+
+
+word
+40
+slash.
+slashes.
+
+
+
+
+
+
+
a
a
a
+c
+привет
+мир
+UTF
+#not
+\#not
+\\#not
+a
+a
+a
+a
+a
+a
+a
--- /dev/null
+first
+empty
+third
+fourth
+spaces around
+To "disable"
+Has\
+Also Has\\
+
+""
+привет
+Content also'
+Comments
--- /dev/null
+a
+a
+a
+.
+.a
+a b c
+"a
+a"
+a
+a b" c
+a b` c
+a b
+a:
+a:
+b
+a
+b
+}
+Ȁ
+Ȃ
+Ȃ
+Ȃ
+Ȃ
+Ȁ Ƞ
+Ȁ Ƞ
+Ȁ Ƞ
+'A b
+"A b
+`A b
+A b'
+A b"
+A b`
+a
+a
+a
+a
+a
+a
+a
+c
+привет
+мир
+UTF
+#not
+\#not
+\\#not
+a
+a
+a
+a
+a
+a
+a
-a b c d
- a b c d
- a b c d
-. a b c
-.a b c
-"a b c" d
-\"a b c d
-a" b c d
-a " b c d
-'a b" c' d
-'a b` c' d
-`a b` c d
-a: b c d
+a b c d 1
+ a b c d 2
+ a b c d 3
+. a b c 4
+.a b c 5
+"a b c" d 6
+\"a b c d 7
+a" b c d 8
+a " b c d 9
+'a b" c' d 10
+'a b` c' d 11
+`a b` c d 12
+a: b c d 13
a:
- b c d
+ b c d 14
a {
- b c d
+ b c d 15
}
-Ȁ b c d
-Ȃ Ȁ b c d
-Ȃ "Ȁ" b c d
-Ȃ " Ȁ " b c d
-Ȃ " Ȁ " b `c d`
-`Ȁ Ƞ` b c d
-"Ȁ Ƞ" b c d
-'Ȁ Ƞ' b c d
-''A b' c d' e
-""A b" c d" e
-``A b` c d` e
-'A b'' c d' e
-"A b"" c d" e
-`A b`` c d` e
-a b c d e
-a b c d e '
- a b c d
-a b c
- a c d
-a b c d
-a b c d
+Ȁ b c d 16
+Ȃ Ȁ b c d 17
+Ȃ "Ȁ" b c d 18
+Ȃ " Ȁ " b c d 19
+Ȃ " Ȁ " b `c d` 20
+`Ȁ Ƞ` b c d 21
+"Ȁ Ƞ" b c d 22
+'Ȁ Ƞ' b c d 23
+''A b' c d' e 24
+""A b" c d" e 25
+``A b` c d` e 26
+'A b'' c d' e 27
+"A b"" c d" e 28
+`A b`` c d` e 29
+a b c d e 30
+a b c d e 31 '
+ a b c d 32
+a b c 33
+ a c d 34
+a b c d 35
+a b c d 36
+c d zerowidth 37
+привет мир 38
+мир e␠
+ UTF space! <-- should have the word 'space!' 39
+\#not a comment...should have no slashes. 40
+\\#not a comment either...should have one slash. 41
+\\\#not a comment either...should have two slashes. 42
+a "b c d" "e f g"
+a "b c' d" "e' f g"
+a "b c` d" "e` f g"
+a 'b c d' 'e f g'
+a 'b c" d' 'e" f g'
+a `b c" d` `e" f g`
+a \'b c' d
--- /dev/null
+first:
+ content.
+empty:
+third:
+ content as well.
+ With multiple lines.
+fourth:
+Not tabbed over.
+
+
+Has empty lines before and after.
+
+
+ spaces around :
+This: is not a list.
+
+To "disable":
+
+ just\:
+ Add a slash.
+
+Has\\:
+ a slash.
+Also Has\\\\:
+ slashes.
+Has Slashes but is not a list\\\:
+ This is part of the previous one.
+
+:
+ The object name is an empty string.
+
+"":
+ Quotes aren't supported here, so this is not an empty object.
+\:
+
+привет:
+ Has UTF-8 characters.
+
+Content also':
+ Has UTF-8: привет мир
+Comments:
+# Are
+ #### ignored.
--- /dev/null
+a b c d 1
+ a b c d 2
+ a b c d 3
+. a b c 4
+.a b c 5
+"a b c" d 6
+\"a b c d 7
+a" b c d 8
+a " b c d 9
+'a b" c' d 10
+'a b` c' d 11
+`a b` c d 12
+a: b c d 13
+a:
+ b c d 14
+a {
+ b c d 15
+}
+Ȁ b c d 16
+Ȃ Ȁ b c d 17
+Ȃ "Ȁ" b c d 18
+Ȃ " Ȁ " b c d 19
+Ȃ " Ȁ " b `c d` 20
+`Ȁ Ƞ` b c d 21
+"Ȁ Ƞ" b c d 22
+'Ȁ Ƞ' b c d 23
+''A b' c d' e 24
+""A b" c d" e 25
+``A b` c d` e 26
+'A b'' c d' e 27
+"A b"" c d" e 28
+`A b`` c d` e 29
+a b c d e 30
+a b c d e 31 '
+ a b c d 32
+a b c 33
+ a c d 34
+a b c d 35
+a b c d 36
+c d zerowidth 37
+привет мир 38
+мир e␠
+ UTF space! <-- should have the word 'space!' 39
+\#not a comment...should have no slashes. 40
+\\#not a comment either...should have one slash. 41
+\\\#not a comment either...should have two slashes. 42
+a "b c d" "e f g"
+a "b c' d" "e' f g"
+a "b c` d" "e` f g"
+a 'b c d' 'e f g'
+a 'b c" d' 'e" f g'
+a `b c" d` `e" f g`
+a \'b c' d
extern "C" {
#endif
-FILE *data__contents_file_open__basic_all_read(void) {
- return fopen("./data/tests/contents/basic-all_read.txt", "r");
-}
+FILE *data__file_open__named__all_read(const f_string_t set, const f_string_t name) {
+ char path[255];
+
+ memset(path, 0, 255);
+
+ snprintf(path, 254, "./data/tests/%s/%s-all_read.txt", set, name);
-FILE *data__objects_file_open__basic_all_read(void) {
- return fopen("./data/tests/objects/basic-all_read.txt", "r");
+ return fopen(path, "r");
}
-FILE *data__strings_file_open__basic_all_read(void) {
- return fopen("./data/tests/strings/basic-all_read.txt", "r");
+FILE *data__file_open__named_at__all_read(const f_string_t set, const f_string_t name, const uint8_t at) {
+ char path[255];
+
+ memset(path, 0, 255);
+
+ snprintf(path, 254, "./data/tests/%s/%s-all_read-%d.txt", set, name, at);
+
+ return fopen(path, "r");
}
#ifdef __cplusplus
#endif
/**
- * Open the "FSS basic" contents file.
+ * Open the test data file for the given set with the given name.
*
- * 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/contents/basic-all_read.txt".
+ * This requires the following:
+ * - The file path is relative to the current working directory (tests are run from project root).
+ * - The file path is "data/tests/${set}/${name}-all_read.txt".
+ * - Where "${set}" represents the directory set, like "contents", "objects", or "strings".
+ * - Where "${name}" represents the standard name, such as "basic" or "extended".
*
- * @return
- * Non-zero on success.
- * 0 on failure.
- *
- * @see fopen()
- */
-extern FILE *data__contents_file_open__basic_all_read(void);
-
-/**
- * Open the "FSS basic" objects file.
- *
- * 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/objects/basic-all_read.txt".
+ * @param at
+ * A number representing the specific content index position.
*
* @return
* Non-zero on success.
*
* @see fopen()
*/
-extern FILE *data__objects_file_open__basic_all_read(void);
+extern FILE *data__file_open__named__all_read(const f_string_t set, const f_string_t name);
/**
- * Open the "fss basic" strings file.
+ * Open the test data file for the given set with the given name and the given at index.
+ *
+ * This requires the following:
+ * - The file path is relative to the current working directory (tests are run from project root).
+ * - The file path is "data/tests/${set}/${name}-all_read-${at}.txt".
+ * - Where "${at}" represents the index.
+ * - Where "${set}" represents the directory set, like "contents", "objects", or "strings".
+ * - Where "${name}" represents the standard name, such as "basic" or "extended".
*
- * 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/strings/basic-all_read.txt".
+ * @param at
+ * A number representing the specific content index position.
*
* @return
* Non-zero on success.
*
* @see fopen()
*/
-extern FILE *data__strings_file_open__basic_all_read(void);
+extern FILE *data__file_open__named_at__all_read(const f_string_t set, const f_string_t name, const uint8_t at);
#ifdef __cplusplus
} // extern "C"
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__strings_file_open__basic_all_read();
- FILE *file_contents = data__contents_file_open__basic_all_read();
+ FILE *file_strings = data__file_open__named__all_read("strings", "basic");
+ FILE *file_contents = data__file_open__named__all_read("contents", "basic");
assert_non_null(file_strings);
assert_non_null(file_contents);
ssize_t result = 0;
f_string_static_t buffer_string = f_string_static_t_initialize;
- f_string_static_t buffer_content = f_string_static_t_initialize;
f_state_t state = f_state_t_initialize;
f_range_t range = f_range_t_initialize;
result = getline(&line_content, &max, file_contents);
assert_return_code(result, 0);
- buffer_content.string = line_content;
- buffer_content.used = (f_number_unsigned_t) result;
- buffer_content.size = buffer_content.used;
-
// The newline is copied by getline(), and so remove that newline before comparing.
- buffer_content.string[--buffer_content.used] = 0;
+ line_content[result - 1] = 0;
state.status = F_none;
range.start = 0;
*/
extern void test__fl_fss_basic_content_read__returns_data_not(void **state);
-
/**
* Test that the function works.
*
}
}
+void test__fl_fss_basic_list_object_read__works(void **void_state) {
+
+ {
+ FILE *file_strings = data__file_open__named__all_read("strings", "basic_list");
+ FILE *file_objects = data__file_open__named__all_read("objects", "basic_list");
+
+ assert_non_null(file_strings);
+ assert_non_null(file_objects);
+
+ size_t max = 0;
+ char *line_string = 0;
+ char *line_object = 0;
+ ssize_t result = 0;
+
+ f_string_static_t buffer_string = f_string_static_t_initialize;
+
+ f_state_t state = f_state_t_initialize;
+ f_range_t range = f_range_t_initialize;
+ f_range_t found = f_range_t_initialize;
+ f_number_unsigneds_t delimits = f_number_unsigneds_t_initialize;
+ f_string_dynamic_t result_string = f_string_dynamic_t_initialize;
+ f_string_dynamic_t delimit_string = f_string_dynamic_t_initialize;
+
+ for (int line = 1;; ++line) {
+
+ max = 255;
+
+ result = getline(&line_string, &max, file_strings);
+ if (result == -1) break;
+
+ buffer_string.string = line_string;
+ buffer_string.used = (f_number_unsigned_t) result;
+ buffer_string.size = buffer_string.used;
+
+ state.status = F_none;
+ range.start = 0;
+ range.stop = buffer_string.used - 1;
+ found.start = 1;
+ found.stop = 0;
+
+ fl_fss_basic_list_object_read(buffer_string, &range, &found, &delimits, &state);
+
+ assert_true(state.status == F_fss_found_object || state.status == F_fss_found_object_not);
+
+ if (state.status == F_fss_found_object) {
+ max = 255;
+
+ result = getline(&line_object, &max, file_objects);
+ assert_return_code(result, 0);
+
+ // The newline is copied by getline(), and so remove that newline before comparing.
+ line_object[result - 1] = 0;
+
+ if (found.start <= found.stop) {
+ {
+ const f_status_t status = f_string_dynamic_append(buffer_string, &delimit_string);
+ assert_int_equal(status, F_okay);
+ }
+
+ state.status = F_none;
+
+ f_fss_apply_delimit(delimits, &delimit_string, &state);
+ assert_int_equal(state.status, F_okay);
+
+ {
+ const f_status_t status = f_string_dynamic_partial_append_nulless(delimit_string, found, &result_string);
+ assert_true(status == F_okay || status == F_data_not_eos);
+ }
+
+ {
+ const f_status_t status = f_string_dynamic_terminate_after(&result_string);
+ assert_int_equal(status, F_okay);
+ }
+
+ assert_string_equal(result_string.string, line_object);
+ }
+ else {
+ assert_int_equal(line_object[0], 0);
+ }
+ }
+
+ if (line_string) free(line_string);
+ if (line_object) free(line_object);
+ if (result_string.string) free(result_string.string);
+ if (delimit_string.string) free(delimit_string.string);
+ if (delimits.array) free(delimits.array);
+
+ line_string = 0;
+ line_object = 0;
+ result_string.string = 0;
+ result_string.used = 0;
+ result_string.size = 0;
+ delimit_string.string = 0;
+ delimit_string.used = 0;
+ delimit_string.size = 0;
+ delimits.array = 0;
+ delimits.used = 0;
+ delimits.size = 0;
+ } // for
+
+ if (file_strings) fclose(file_strings);
+ if (file_objects) fclose(file_objects);
+
+ if (delimits.array) free(delimits.array);
+ if (line_string) free(line_string);
+ if (line_object) free(line_object);
+ if (result_string.string) free(result_string.string);
+ if (delimit_string.string) free(delimit_string.string);
+ }
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
*/
extern void test__fl_fss_basic_list_object_read__returns_data_not(void **state);
+/**
+ * Test that the function works.
+ *
+ * @see fl_fss_basic_list_object_read()
+ */
+extern void test__fl_fss_basic_list_object_read__works(void **state);
+
#endif // _TEST__FL_fss_basic_list_object_read_list_h
{
// Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
- FILE *file_strings = data__strings_file_open__basic_all_read();
- FILE *file_objects = data__objects_file_open__basic_all_read();
+ FILE *file_strings = data__file_open__named__all_read("strings", "basic");
+ FILE *file_objects = data__file_open__named__all_read("objects", "basic");
assert_non_null(file_strings);
assert_non_null(file_objects);
ssize_t result = 0;
f_string_static_t buffer_string = f_string_static_t_initialize;
- f_string_static_t buffer_object = f_string_static_t_initialize;
f_state_t state = f_state_t_initialize;
f_range_t range = f_range_t_initialize;
result = getline(&line_object, &max, file_objects);
assert_return_code(result, 0);
- buffer_object.string = line_object;
- buffer_object.used = (f_number_unsigned_t) result;
- buffer_object.size = buffer_object.used;
-
// The newline is copied by getline(), and so remove that newline before comparing.
- buffer_object.string[--buffer_object.used] = 0;
+ line_object[result - 1] = 0;
state.status = F_none;
range.start = 0;
*/
extern void test__fl_fss_basic_object_read__returns_data_not(void **state);
-
/**
* Test that the function works.
*
}
}
+void test__fl_fss_extended_content_read__works(void **void_state) {
+
+ {
+ // Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
+ FILE *file_strings = data__file_open__named__all_read("strings", "extended");
+
+ FILE *file_contents[] = {
+ data__file_open__named_at__all_read("contents", "extended", 0),
+ data__file_open__named_at__all_read("contents", "extended", 1),
+ data__file_open__named_at__all_read("contents", "extended", 2),
+ data__file_open__named_at__all_read("contents", "extended", 3),
+ data__file_open__named_at__all_read("contents", "extended", 4),
+ data__file_open__named_at__all_read("contents", "extended", 5),
+ };
+
+ assert_non_null(file_strings);
+ assert_non_null(file_contents[0]);
+ assert_non_null(file_contents[1]);
+ assert_non_null(file_contents[2]);
+ assert_non_null(file_contents[3]);
+ assert_non_null(file_contents[4]);
+ assert_non_null(file_contents[5]);
+
+ size_t max = 0;
+ char *line_string = 0;
+ char *line_content[] = {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ };
+ ssize_t result = 0;
+ const uint8_t total_content = 6;
+
+ f_string_static_t buffer_string = f_string_static_t_initialize;
+
+ f_state_t state = f_state_t_initialize;
+ f_range_t range = f_range_t_initialize;
+ f_range_t found_object = f_range_t_initialize;
+ f_ranges_t found = f_ranges_t_initialize;
+ uint8_t quote = 0;
+ f_uint8s_t quotes = f_uint8s_t_initialize;
+ f_number_unsigneds_t delimits = f_number_unsigneds_t_initialize;
+ f_string_dynamic_t result_string = f_string_dynamic_t_initialize;
+ f_string_dynamic_t delimit_string = f_string_dynamic_t_initialize;
+ f_status_t status_object = F_okay;
+
+ for (;;) {
+
+ max = 255;
+
+ result = getline(&line_string, &max, file_strings);
+ if (result == -1) break;
+
+ buffer_string.string = line_string;
+ buffer_string.used = (f_number_unsigned_t) result;
+ buffer_string.size = buffer_string.used;
+
+ max = 255;
+
+ for (uint8_t i = 0; i < total_content; ++i) {
+
+ result = getline(&line_content[i], &max, file_contents[i]);
+ assert_return_code(result, 0);
+
+ // The newline is copied by getline(), and so remove that newline before comparing.
+ line_content[i][result - 1] = 0;
+ } // or
+
+ state.status = F_none;
+ range.start = 0;
+ range.stop = buffer_string.used - 1;
+ found_object.start = 1;
+ found_object.stop = 0;
+
+ fl_fss_extended_object_read(buffer_string, &range, &found_object, "e, &delimits, &state);
+
+ assert_true(state.status == F_fss_found_object || state.status == F_fss_found_object_content_not);
+
+ status_object = state.status;
+ state.status = F_none;
+
+ fl_fss_extended_content_read(buffer_string, &range, &found, "es, &delimits, &state);
+
+ if (status_object == F_fss_found_object) {
+ assert_int_equal(state.status, F_fss_found_content);
+ }
+ else {
+ assert_int_equal(state.status, F_data_not);
+ }
+
+ if (state.status == F_fss_found_content) {
+ assert_true(found.used);
+ assert_true(found.used < total_content);
+
+ {
+ const f_status_t status = f_string_dynamic_append(buffer_string, &delimit_string);
+ assert_int_equal(status, F_okay);
+ }
+
+ state.status = F_none;
+
+ f_fss_apply_delimit(delimits, &delimit_string, &state);
+ assert_int_equal(state.status, F_okay);
+
+ {
+ uint8_t i = 0;
+
+ for (; i < found.used; ++i) {
+
+ result_string.used = 0;
+
+ {
+ const f_status_t status = f_string_dynamic_partial_append_nulless(delimit_string, found.array[i], &result_string);
+ assert_true(status == F_okay || status == F_data_not_eos);
+ }
+
+ {
+ const f_status_t status = f_string_dynamic_terminate_after(&result_string);
+ assert_int_equal(status, F_okay);
+ }
+
+ assert_string_equal(result_string.string, line_content[i]);
+ } // for
+
+ // All remaining positions in the file need to be a zero length string.
+ for (; i < total_content; ++i) {
+ assert_int_equal(line_content[i][0], 0);
+ }
+ }
+ }
+ else {
+ assert_true(!found.used);
+ }
+
+ if (line_string) free(line_string);
+ if (line_content[0]) free(line_content[0]);
+ if (line_content[1]) free(line_content[1]);
+ if (line_content[2]) free(line_content[2]);
+ if (line_content[3]) free(line_content[3]);
+ if (line_content[4]) free(line_content[4]);
+ if (line_content[5]) free(line_content[5]);
+ if (result_string.string) free(result_string.string);
+ if (delimit_string.string) free(delimit_string.string);
+ if (delimits.array) free(delimits.array);
+ if (found.array) free(found.array);
+ if (quotes.array) free(quotes.array);
+
+ line_string = 0;
+ line_content[0] = 0;
+ line_content[1] = 0;
+ line_content[2] = 0;
+ line_content[3] = 0;
+ line_content[4] = 0;
+ line_content[5] = 0;
+ result_string.string = 0;
+ result_string.used = 0;
+ result_string.size = 0;
+ delimit_string.string = 0;
+ delimit_string.used = 0;
+ delimit_string.size = 0;
+ delimits.array = 0;
+ delimits.used = 0;
+ delimits.size = 0;
+ found.array = 0;
+ found.used = 0;
+ found.size = 0;
+ quotes.array = 0;
+ quotes.used = 0;
+ quotes.size = 0;
+ } // for
+
+ if (file_strings) fclose(file_strings);
+ if (file_contents[0]) fclose(file_contents[0]);
+ if (file_contents[1]) fclose(file_contents[1]);
+ if (file_contents[2]) fclose(file_contents[2]);
+ if (file_contents[3]) fclose(file_contents[3]);
+ if (file_contents[4]) fclose(file_contents[4]);
+ if (file_contents[5]) fclose(file_contents[5]);
+
+ if (delimits.array) free(delimits.array);
+ if (found.array) free(found.array);
+ if (quotes.array) free(quotes.array);
+ if (line_string) free(line_string);
+ if (line_content[0]) free(line_content[0]);
+ if (line_content[1]) free(line_content[1]);
+ if (line_content[2]) free(line_content[2]);
+ if (line_content[3]) free(line_content[3]);
+ if (line_content[4]) free(line_content[4]);
+ if (line_content[5]) free(line_content[5]);
+ if (result_string.string) free(result_string.string);
+ if (delimit_string.string) free(delimit_string.string);
+ }
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
*/
extern void test__fl_fss_extended_content_read__returns_data_not(void **state);
+/**
+ * Test that the function works.
+ *
+ * @see fl_fss_extended_content_read()
+ */
+extern void test__fl_fss_extended_content_read__works(void **state);
+
#endif // _TEST__FL_fss_extended_content_read_h
}
}
+void test__fl_fss_extended_object_read__works(void **void_state) {
+
+ {
+ // Note: These files are required to have the same number of lines and each line should probably be at max 255 characters.
+ FILE *file_strings = data__file_open__named__all_read("strings", "extended");
+ FILE *file_objects = data__file_open__named__all_read("objects", "extended");
+
+ assert_non_null(file_strings);
+ assert_non_null(file_objects);
+
+ size_t max = 0;
+ char *line_string = 0;
+ char *line_object = 0;
+ ssize_t result = 0;
+
+ f_string_static_t buffer_string = f_string_static_t_initialize;
+
+ f_state_t state = f_state_t_initialize;
+ f_range_t range = f_range_t_initialize;
+ f_range_t found = f_range_t_initialize;
+ uint8_t quote = 0;
+ f_number_unsigneds_t delimits = f_number_unsigneds_t_initialize;
+ f_string_dynamic_t result_string = f_string_dynamic_t_initialize;
+ f_string_dynamic_t delimit_string = f_string_dynamic_t_initialize;
+
+ for (int line = 0; ; ++line) {
+
+ max = 255;
+
+ result = getline(&line_string, &max, file_strings);
+ if (result == -1) break;
+
+ buffer_string.string = line_string;
+ buffer_string.used = (f_number_unsigned_t) result;
+ buffer_string.size = buffer_string.used;
+
+ max = 255;
+
+ result = getline(&line_object, &max, file_objects);
+ assert_return_code(result, 0);
+
+ // The newline is copied by getline(), and so remove that newline before comparing.
+ line_object[result - 1] = 0;
+
+ state.status = F_none;
+ range.start = 0;
+ range.stop = buffer_string.used - 1;
+ found.start = 1;
+ found.stop = 0;
+
+ fl_fss_extended_object_read(buffer_string, &range, &found, "e, &delimits, &state);
+
+ assert_true(state.status == F_fss_found_object || state.status == F_fss_found_object_content_not);
+ assert_true(found.start <= found.stop);
+
+ {
+ const f_status_t status = f_string_dynamic_append(buffer_string, &delimit_string);
+ assert_int_equal(status, F_okay);
+ }
+
+ state.status = F_none;
+
+ f_fss_apply_delimit(delimits, &delimit_string, &state);
+ assert_int_equal(state.status, F_okay);
+
+ {
+ const f_status_t status = f_string_dynamic_partial_append_nulless(delimit_string, found, &result_string);
+ assert_true(status == F_okay || status == F_data_not_eos);
+ }
+
+ {
+ const f_status_t status = f_string_dynamic_terminate_after(&result_string);
+ assert_int_equal(status, F_okay);
+ }
+
+ assert_string_equal(result_string.string, line_object);
+
+ if (line_string) free(line_string);
+ if (line_object) free(line_object);
+ if (result_string.string) free(result_string.string);
+ if (delimit_string.string) free(delimit_string.string);
+ if (delimits.array) free(delimits.array);
+
+ line_string = 0;
+ line_object = 0;
+ result_string.string = 0;
+ result_string.used = 0;
+ result_string.size = 0;
+ delimit_string.string = 0;
+ delimit_string.used = 0;
+ delimit_string.size = 0;
+ delimits.array = 0;
+ delimits.used = 0;
+ delimits.size = 0;
+ } // for
+
+ if (file_strings) fclose(file_strings);
+ if (file_objects) fclose(file_objects);
+
+ if (delimits.array) free(delimits.array);
+ if (line_string) free(line_string);
+ if (line_object) free(line_object);
+ if (result_string.string) free(result_string.string);
+ if (delimit_string.string) free(delimit_string.string);
+ }
+}
+
#ifdef __cplusplus
} // extern "C"
#endif
*/
extern void test__fl_fss_extended_object_read__returns_data_not(void **state);
+/**
+ * Test that the function works.
+ *
+ * @see fl_fss_extended_object_read()
+ */
+extern void test__fl_fss_extended_object_read__works(void **state);
+
#endif // _TEST__FL_fss_extended_object_read_h
cmocka_unit_test(test__fl_fss_basic_list_object_read__returns_data_not),
cmocka_unit_test(test__fl_fss_basic_list_object_write__returns_data_not),
+ //cmocka_unit_test(test__fl_fss_basic_list_content_read__works),
+ cmocka_unit_test(test__fl_fss_basic_list_object_read__works),
+
cmocka_unit_test(test__fl_fss_embedded_list_content_read__returns_data_not),
cmocka_unit_test(test__fl_fss_embedded_list_content_write__returns_data_not),
cmocka_unit_test(test__fl_fss_embedded_list_object_read__returns_data_not),
cmocka_unit_test(test__fl_fss_extended_object_read__returns_data_not),
cmocka_unit_test(test__fl_fss_extended_object_write__returns_data_not),
+ cmocka_unit_test(test__fl_fss_extended_content_read__works),
+ cmocka_unit_test(test__fl_fss_extended_object_read__works),
+
cmocka_unit_test(test__fl_fss_extended_list_content_read__returns_data_not),
cmocka_unit_test(test__fl_fss_extended_list_content_write__returns_data_not),
cmocka_unit_test(test__fl_fss_extended_list_object_read__returns_data_not),