From: Kevin Day Date: Fri, 28 Aug 2026 01:12:34 +0000 (-0500) Subject: Progress: Beginning basic list read and do some other tweaks. X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=39541fa3a3170b4052a1d87454a8c6fec6783568;p=fll Progress: Beginning basic list read and do some other tweaks. Make some consistency tweaks and clean ups in basic read as well. This has only been tested to confirm/deny that existing tests work. There still needs to be additional tests added for the combining and joiner characters. --- diff --git a/level_1/fl_fss/c/fss/extended.h b/level_1/fl_fss/c/fss/extended.h index c57f5e168..c71483254 100644 --- a/level_1/fl_fss/c/fss/extended.h +++ b/level_1/fl_fss/c/fss/extended.h @@ -102,7 +102,6 @@ extern "C" { * @see f_utf_buffer_increment() * @see fl_fss_basic_object_read() * @see fl_fss_extended_object_read() - * @see fl_fss_extended_content_read() */ #ifndef _di_fl_fss_extended_content_read_ extern void fl_fss_extended_content_read(const f_string_static_t buffer, f_range_t * const range, f_ranges_t * const found, f_uint8s_t * const quotes, f_number_unsigneds_t * const delimits, f_state_t * const state); @@ -176,7 +175,6 @@ extern "C" { * @see f_utf_buffer_increment() * @see fl_fss_basic_object_write() * @see fl_fss_extended_object_write() - * @see fl_fss_extended_content_write() */ #ifndef _di_fl_fss_extended_content_write_ extern void fl_fss_extended_content_write(const f_string_static_t content, const uint8_t quote, const uint8_t complete, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state); @@ -253,7 +251,6 @@ extern "C" { * @see f_memory_array_increase() * @see f_utf_buffer_increment() * @see fl_fss_basic_object_read() - * @see fl_fss_extended_object_read() * @see fl_fss_extended_content_read() */ #ifndef _di_fl_fss_extended_object_read_ diff --git a/level_1/fl_fss/c/private-fss-list.c b/level_1/fl_fss/c/private-fss-list.c index a7e62792d..522fad358 100644 --- a/level_1/fl_fss/c/private-fss-list.c +++ b/level_1/fl_fss/c/private-fss-list.c @@ -36,66 +36,122 @@ extern "C" { return; } + const f_number_unsigned_t begin = range->start; + // Ignore all comment lines. - if (buffer.string[range->start] == f_fss_comment_s.string[0]) { - f_fss_seek_to_eol(buffer, range, state); + if (buffer.string[begin] == f_fss_comment_s.string[0]) { + state->status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(state->status)) return; + + f_fss_skip_past_delimit(buffer, range, state); if (F_status_is_error(state->status)) return; - if (state->status == F_okay_eos || state->status == F_okay_stop) { - state->status = state->status == F_okay_eos ? F_data_not_eos : F_data_not_stop; + if (range->start >= buffer.used || range->start > range->stop) { + state->status = range->start >= buffer.used ? F_data_not_eos : F_data_not_stop; return; } - // Move the start position to after the EOL. - ++range->start; - state->status = F_fss_found_object_not; + if (f_fss_is_combining_joiner(buffer, *range, state) == F_false) { + if (F_status_is_error_not(state->status)) { + f_fss_seek_to_eol(buffer, range, state); + } - return; + if (F_status_is_error(state->status)) return; + + if (range->start >= buffer.used || range->start > range->stop) { + state->status = range->start >= buffer.used ? F_data_not_eos : F_data_not_stop; + + return; + } + + // Move the start position to after the EOL. + ++range->start; + state->status = F_fss_found_object_not; + + return; + } + + range->start = begin; } + #define ___fl_flag_do_escape___ 0x1 + #define ___fl_flag_has_graph_first___ 0x2 + const f_number_unsigned_t delimits_used = delimits->used; + f_number_unsigned_t location = 0; f_number_unsigned_t slash_first = 0; f_number_unsigned_t slash_count = 0; f_number_unsigned_t start = 1; f_number_unsigned_t stop = 0; - uint8_t graph_first = F_true; + uint8_t flag_fl = ___fl_flag_has_graph_first___; found->start = range->start; // Identify where the object ends. - while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { + while (F_status_is_error_not(state->status) && range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { if (state->interrupt) { state->interrupt((void *) state, 0); - - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; - - return; - } + if (F_status_is_error(state->status)) break; } if (buffer.string[range->start] == f_fss_slash_s.string[0]) { slash_first = range->start++; slash_count = 1; + flag_fl |= ___fl_flag_do_escape___; - for (; range->start <= range->stop && range->start < buffer.used && (buffer.string[range->start] == f_fss_placeholder_s.string[0] || buffer.string[range->start] == f_fss_slash_s.string[0]); ++range->start) { + f_fss_skip_past_delimit(buffer, range, state); - if (state->interrupt) { - state->interrupt((void *) state, 0); + // If first slash has a combining/joiner following it, then there is no escaping at all but this is not a valid escaping slash. + if (F_status_is_error_not(state->status)) { + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + flag_fl &= ~___fl_flag_do_escape___; - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; + f_fss_skip_past_combining_joiner(buffer, range, state); + } + } - return; + if (flag_fl & ___fl_flag_do_escape___) { + while (F_status_is_error_not(state->status) && range->start <= range->stop && range->start < buffer.used) { + + if (state->interrupt) { + state->interrupt((void *) state, 0); + if (F_status_is_error(state->status)) break; } - } - if (buffer.string[range->start] == f_fss_slash_s.string[0]) ++slash_count; - } // for + if (buffer.string[range->start] == f_fss_placeholder_s.string[0]) { + // Do nothing. + } + else if (buffer.string[range->start] == f_fss_slash_s.string[0]) { + ++slash_count; + } + else if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + flag_fl &= ~___fl_flag_do_escape___; + + f_fss_skip_past_combining_joiner(buffer, range, state); + + break; + } + else { + break; + } + + if (F_status_is_error_not(state->status)) { + state->status = f_utf_buffer_increment(buffer, range, 1); + } + } // while + } + + if (F_status_is_error(state->status)) break; + + if (!(flag_fl & ___fl_flag_do_escape___)) { + slash_count = 0; + + continue; + } if (range->start >= buffer.used || range->start > range->stop) { delimits->used = delimits_used; @@ -113,31 +169,26 @@ extern "C" { } if (buffer.string[range->start] == list_open.string[0]) { - graph_first = F_false; + flag_fl &= ~___fl_flag_has_graph_first___; stop = range->start++; - while (range->start <= range->stop && range->start < buffer.used) { + f_fss_skip_past_delimit(buffer, range, state); - if (state->interrupt) { - state->interrupt((void *) state, 0); + if (F_status_is_error_not(state->status)) { + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + slash_count = 0; - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; + f_fss_skip_past_combining_joiner(buffer, range, state); - return; - } + continue; } + } - if (buffer.string[range->start] == f_fss_eol_s.string[0] || f_fss_is_space(buffer, *range, state) == F_false) break; - - state->status = f_utf_buffer_increment(buffer, range, 1); - - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; + if (F_status_is_error_not(state->status)) { + f_fss_skip_past_space(buffer, range, state); + } - return; - } - } // while + if (F_status_is_error(state->status)) break; if (range->start >= buffer.used || range->start > range->stop) { delimits->used = delimits_used; @@ -215,9 +266,26 @@ extern "C" { return; } } - else if (graph_first && buffer.string[range->start] == f_fss_comment_s.string[0]) { - graph_first = F_false; + else if ((flag_fl & ___fl_flag_has_graph_first___) && buffer.string[range->start] == f_fss_comment_s.string[0]) { + flag_fl &= ~___fl_flag_has_graph_first___; start = slash_first; + location = range->start++; + + f_fss_skip_past_delimit(buffer, range, state); + + if (F_status_is_error_not(state->status)) { + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + slash_count = 0; + + f_fss_skip_past_combining_joiner(buffer, range, state); + + continue; + } + } + + if (F_status_is_error(state->status)) break; + + range->start = location; // Comments may only have white space before the '#', therefore only the first slash needs to be delimited. state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size); @@ -233,7 +301,7 @@ extern "C" { stop = range->start++; } else { - graph_first = F_false; + flag_fl &= ~___fl_flag_has_graph_first___; stop = range->start; } @@ -243,28 +311,25 @@ extern "C" { if (buffer.string[range->start] == list_open.string[0]) { ++range->start; - while (range->start <= range->stop && range->start < buffer.used) { + f_fss_skip_past_delimit(buffer, range, state); - if (state->interrupt) { - state->interrupt((void *) state, 0); + if (F_status_is_error_not(state->status)) { + location = range->start; - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + f_fss_skip_past_combining_joiner(buffer, range, state); - return; - } + continue; } + } - if (buffer.string[range->start] == f_fss_eol_s.string[0] || f_fss_is_space(buffer, *range, state) == F_false) break; - - state->status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error_not(state->status)) { + range->start = location; - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; + f_fss_skip_past_space(buffer, range, state); + } - return; - } - } // while + if (F_status_is_error(state->status)) break; if (range->start >= buffer.used) { found->stop = buffer.used - 1; @@ -289,8 +354,8 @@ extern "C" { return; } - if (graph_first) { - graph_first = F_false; + if (flag_fl & ___fl_flag_has_graph_first___) { + flag_fl &= ~___fl_flag_has_graph_first___; start = 1; stop = 0; } @@ -302,28 +367,34 @@ extern "C" { } if (f_fss_is_space(buffer, *range, state) == F_false) { - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; - - return; + if (F_status_is_error_not(state->status)) { + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + f_fss_skip_past_combining_joiner(buffer, range, state); + } } - if (graph_first) { - graph_first = F_false; - start = range->start; + if (F_status_is_error_not(state->status)) { + if (flag_fl & ___fl_flag_has_graph_first___) { + flag_fl &= ~___fl_flag_has_graph_first___; + start = range->start; + } + + stop = range->start; } + } - stop = range->start; + if (F_status_is_error_not(state->status)) { + state->status = f_utf_buffer_increment(buffer, range, 1); } - state->status = f_utf_buffer_increment(buffer, range, 1); + if (F_status_is_error(state->status)) break; + } // while - if (F_status_is_error(state->status)) { - delimits->used = delimits_used; + if (F_status_is_error(state->status)) { + delimits->used = delimits_used; - return; - } - } // while + return; + } if (range->start >= buffer.used) { found->stop = buffer.used - 1; @@ -351,6 +422,9 @@ extern "C" { // Move the start position to after the EOL. ++range->start; } + + #undef ___fl_flag_do_escape___ + #undef ___fl_flag_has_graph_first___ } #endif // !defined(_di_fl_fss_basic_list_object_read_) || !defined(_di_fl_fss_embedded_list_object_read_) || !defined(_di_fl_fss_extended_list_object_read_) diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 9bbb12052..1017af231 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -70,15 +70,14 @@ extern "C" { } #define ___fl_flag_do_escape___ 0x1 - #define ___fl_flag_has_graph___ 0x2 - #define ___fl_flag_has_joiner_combining___ 0x4 + #define ___fl_flag_has_joiner_combining___ 0x2 const f_number_unsigned_t delimits_used = delimits->used; - f_number_unsigned_t first_slash = 0; f_number_unsigned_t location = 0; f_number_unsigned_t previous = 0; f_number_unsigned_t slash_count = 0; + f_number_unsigned_t slash_first = 0; uint8_t flag_fl = 0x0; f_char_t quote_found = 0; @@ -87,19 +86,18 @@ extern "C" { // Identify where the object begins. if (buffer.string[range->start] == f_fss_slash_s.string[0]) { - first_slash = found->start = range->start; + slash_first = found->start = range->start; flag_fl |= ___fl_flag_do_escape___; state->status = f_utf_buffer_increment(buffer, range, 1); - if (state->status == F_okay) { + if (F_status_is_error_not(state->status)) { f_fss_skip_past_delimit(buffer, range, state); } - // If first slash has a combining/joiner following it, then there is no escaping at all so first_slash is the start of an object and is not considered an escaping character. + // If first slash has a combining/joiner following it, then there is no escaping at all so slash_first is the start of an object and is not considered an escaping character. if (F_status_is_error_not(state->status)) { if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { - range->start = first_slash; flag_fl &= ~___fl_flag_do_escape___; f_fss_skip_past_combining_joiner(buffer, range, state); @@ -189,7 +187,7 @@ extern "C" { state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size); if (F_status_is_error(state->status)) return; - delimits->array[delimits->used++] = first_slash; + delimits->array[delimits->used++] = slash_first; ++range->start; } } @@ -216,7 +214,7 @@ extern "C" { // Identify where the object ends. if (quote_found) { - first_slash = 0; + slash_first = 0; slash_count = 0; location = 0; @@ -228,12 +226,15 @@ extern "C" { } if (buffer.string[range->start] == f_fss_slash_s.string[0]) { - first_slash = range->start; + slash_first = range->start; slash_count = 1; state->status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(state->status)) return; + f_fss_skip_past_delimit(buffer, range, state); + if (F_status_is_error(state->status)) return; + if (range->start <= range->stop && range->start < buffer.used) { if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { f_fss_skip_past_combining_joiner(buffer, range, state); @@ -241,8 +242,6 @@ extern "C" { continue; } - - if (F_status_is_error(state->status)) return; } flag_fl &= ~___fl_flag_has_joiner_combining___; @@ -267,13 +266,11 @@ extern "C" { else { if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { f_fss_skip_past_combining_joiner(buffer, range, state); - if (F_status_is_error(state->status)) return; flag_fl |= ___fl_flag_has_joiner_combining___; } - else { - if (F_status_is_error(state->status)) return; - } + + if (F_status_is_error(state->status)) return; break; } @@ -391,7 +388,7 @@ extern "C" { } } - range->start = first_slash; + range->start = slash_first; if (slash_count % 2 == 0) { state->status = f_memory_array_increase_by(slash_count / 2, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size); @@ -699,13 +696,10 @@ extern "C" { else { if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { f_fss_skip_past_combining_joiner(buffer, range, state); - if (F_status_is_error(state->status)) return; - - continue; - } - else { - if (F_status_is_error(state->status)) return; + if (F_status_is_error_not(state->status)) continue; } + + if (F_status_is_error(state->status)) return; } state->status = f_utf_buffer_increment(buffer, range, 1); @@ -737,17 +731,15 @@ extern "C" { } f_fss_skip_past_delimit(buffer, range, state); - if (F_status_is_error(state->status)) break; - if (range->start > range->stop || range->start >= buffer.used) break; + if (F_status_is_error(state->status)) return; if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { f_fss_skip_past_combining_joiner(buffer, range, state); - if (F_status_is_error(state->status)) return; - - continue; + if (F_status_is_error_not(state->status)) continue; } if (F_status_is_error(state->status)) return; + if (range->start > range->stop || range->start >= buffer.used) break; // Break if a space that is not part of a joiner is found (as in if the space is not followed by a combining or joiner). if (f_fss_is_space(buffer, *range, state) == F_true) { @@ -764,25 +756,24 @@ extern "C" { } f_fss_skip_past_delimit(buffer, range, state); - if (F_status_is_error(state->status)) break; + if (F_status_is_error(state->status)) return; if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { f_fss_skip_past_combining_joiner(buffer, range, state); - if (F_status_is_error(state->status)) return; - - continue; + if (F_status_is_error_not(state->status)) continue; } - if (F_status_is_error(state->status)) break; + if (F_status_is_error(state->status)) return; range->start = previous; break; } - if (F_status_is_error(state->status)) return; + if (F_status_is_error_not(state->status)) { + state->status = f_utf_buffer_increment(buffer, range, 1); + } - state->status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(state->status)) return; } // while @@ -822,7 +813,6 @@ extern "C" { state->status = F_fss_found_object_not; #undef ___fl_flag_do_escape___ - #undef ___fl_flag_has_graph___ #undef ___fl_flag_has_joiner_combining___ } #endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) @@ -830,6 +820,8 @@ extern "C" { #if !defined(_di_fl_fss_basic_content_read_) || !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_read_) || !defined(_di_fl_fss_extended_content_write_) || !defined(_di_fl_fss_payload_header_map_) void private_fl_fss_basic_write(const uint8_t flag, const f_string_static_t object, const uint8_t quote, f_range_t * const range, f_string_dynamic_t * const destination, f_state_t * const state, void * const internal) { + // TODO: update this (and all FSS write functions) to handle combining and joiners. + f_fss_skip_past_space(object, range, state); if (F_status_is_error(state->status) || state->status == F_data_not) return; diff --git a/level_1/fl_fss/tests/unit/c/test-fss-basic_list_object_read.c b/level_1/fl_fss/tests/unit/c/test-fss-basic_list_object_read.c index fb7b4443a..683057135 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-basic_list_object_read.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-basic_list_object_read.c @@ -126,12 +126,21 @@ void test__fl_fss_basic_list_object_read__works(void **void_state) { fl_fss_basic_list_object_read(buffer_string, &range, &found, &delimits, &state); + if (!(state.status == F_fss_found_object || state.status == F_fss_found_object_not)) { + printf("[ -------> ] --- [00] Failure with line (%u) '%s', status=%u, expected %u or %u.\n", line, line_string, state.status, F_fss_found_object, F_fss_found_object_not); + } + 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); + + if (!result) { + printf("[ -------> ] --- [01] Failure with line (%u) '%s', line_object = '%s', result=%zu.\n", line, line_string, line_object, result); + } + assert_return_code(result, 0); // The newline is copied by getline(), and so remove that newline before comparing. @@ -140,27 +149,55 @@ void test__fl_fss_basic_list_object_read__works(void **void_state) { if (found.start <= found.stop) { { const f_status_t status = f_string_dynamic_append(buffer_string, &delimit_string); + + if (status != F_okay) { + printf("[ -------> ] --- [02] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, status, F_okay); + } + assert_int_equal(status, F_okay); } state.status = F_none; f_fss_apply_delimit(delimits, &delimit_string, &state); + + if (state.status != F_okay) { + printf("[ -------> ] --- [03] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, state.status, F_okay); + } + assert_int_equal(state.status, F_okay); { const f_status_t status = f_string_dynamic_partial_append_nulless(delimit_string, found, &result_string); + + if (!(status == F_okay || status == F_data_not_eos)) { + printf("[ -------> ] --- [04] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u or %u.\n", line, line_string, line_object, status, F_okay, F_data_not_eos); + } + assert_true(status == F_okay || status == F_data_not_eos); } { const f_status_t status = f_string_dynamic_terminate_after(&result_string); + + if (status != F_okay) { + printf("[ -------> ] --- [05] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, status, F_okay); + } + assert_int_equal(status, F_okay); } + if (strncmp(result_string.string, line_object, result_string.used)) { + printf("[ -------> ] --- [06] Failure with line (%u) '%s', line_object = '%s', result '%s'.\n", line, line_string, line_object, result_string.string); + } + assert_string_equal(result_string.string, line_object); } else { + if (line_object[0]) { + printf("[ -------> ] --- [07] Failure with line (%u) '%s', line_object[0]=%c.\n", line, line_string, line_object[0]); + } + assert_int_equal(line_object[0], 0); } } diff --git a/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_object_read.c b/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_object_read.c index c7a791de1..a253df8b5 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_object_read.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_object_read.c @@ -126,12 +126,21 @@ void test__fl_fss_embedded_list_object_read__works(void **void_state) { fl_fss_embedded_list_object_read(buffer_string, &range, &found, &delimits, &state); + if (!(state.status == F_fss_found_object || state.status == F_fss_found_object_not)) { + printf("[ -------> ] --- [00] Failure with line (%u) '%s', status=%u, expected %u or %u.\n", line, line_string, state.status, F_fss_found_object, F_fss_found_object_not); + } + 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); + + if (!result) { + printf("[ -------> ] --- [01] Failure with line (%u) '%s', line_object = '%s', result=%zu.\n", line, line_string, line_object, result); + } + assert_return_code(result, 0); // The newline is copied by getline(), and so remove that newline before comparing. @@ -140,27 +149,55 @@ void test__fl_fss_embedded_list_object_read__works(void **void_state) { if (found.start <= found.stop) { { const f_status_t status = f_string_dynamic_append(buffer_string, &delimit_string); + + if (status != F_okay) { + printf("[ -------> ] --- [02] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, status, F_okay); + } + assert_int_equal(status, F_okay); } state.status = F_none; f_fss_apply_delimit(delimits, &delimit_string, &state); + + if (state.status != F_okay) { + printf("[ -------> ] --- [03] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, state.status, F_okay); + } + assert_int_equal(state.status, F_okay); { const f_status_t status = f_string_dynamic_partial_append_nulless(delimit_string, found, &result_string); + + if (!(status == F_okay || status == F_data_not_eos)) { + printf("[ -------> ] --- [04] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u or %u.\n", line, line_string, line_object, status, F_okay, F_data_not_eos); + } + assert_true(status == F_okay || status == F_data_not_eos); } { const f_status_t status = f_string_dynamic_terminate_after(&result_string); + + if (status != F_okay) { + printf("[ -------> ] --- [05] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, status, F_okay); + } + assert_int_equal(status, F_okay); } + if (strncmp(result_string.string, line_object, result_string.used)) { + printf("[ -------> ] --- [06] Failure with line (%u) '%s', line_object = '%s', result '%s'.\n", line, line_string, line_object, result_string.string); + } + assert_string_equal(result_string.string, line_object); } else { + if (line_object[0]) { + printf("[ -------> ] --- [07] Failure with line (%u) '%s', line_object[0]=%c.\n", line, line_string, line_object[0]); + } + assert_int_equal(line_object[0], 0); } } diff --git a/level_1/fl_fss/tests/unit/c/test-fss-extended_list_object_read.c b/level_1/fl_fss/tests/unit/c/test-fss-extended_list_object_read.c index 941479c00..6c94852b6 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-extended_list_object_read.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-extended_list_object_read.c @@ -126,12 +126,21 @@ void test__fl_fss_extended_list_object_read__works(void **void_state) { fl_fss_extended_list_object_read(buffer_string, &range, &found, &delimits, &state); + if (!(state.status == F_fss_found_object || state.status == F_fss_found_object_not)) { + printf("[ -------> ] --- [00] Failure with line (%u) '%s', status=%u, expected %u or %u.\n", line, line_string, state.status, F_fss_found_object, F_fss_found_object_not); + } + 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); + + if (!result) { + printf("[ -------> ] --- [01] Failure with line (%u) '%s', line_object = '%s', result=%zu.\n", line, line_string, line_object, result); + } + assert_return_code(result, 0); // The newline is copied by getline(), and so remove that newline before comparing. @@ -140,27 +149,55 @@ void test__fl_fss_extended_list_object_read__works(void **void_state) { if (found.start <= found.stop) { { const f_status_t status = f_string_dynamic_append(buffer_string, &delimit_string); + + if (status != F_okay) { + printf("[ -------> ] --- [02] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, status, F_okay); + } + assert_int_equal(status, F_okay); } state.status = F_none; f_fss_apply_delimit(delimits, &delimit_string, &state); + + if (state.status != F_okay) { + printf("[ -------> ] --- [03] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, state.status, F_okay); + } + assert_int_equal(state.status, F_okay); { const f_status_t status = f_string_dynamic_partial_append_nulless(delimit_string, found, &result_string); + + if (!(status == F_okay || status == F_data_not_eos)) { + printf("[ -------> ] --- [04] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u or %u.\n", line, line_string, line_object, status, F_okay, F_data_not_eos); + } + assert_true(status == F_okay || status == F_data_not_eos); } { const f_status_t status = f_string_dynamic_terminate_after(&result_string); + + if (status != F_okay) { + printf("[ -------> ] --- [05] Failure with line (%u) '%s', line_object = '%s', status=%u, expected %u.\n", line, line_string, line_object, status, F_okay); + } + assert_int_equal(status, F_okay); } + if (strncmp(result_string.string, line_object, result_string.used)) { + printf("[ -------> ] --- [06] Failure with line (%u) '%s', line_object = '%s', result '%s'.\n", line, line_string, line_object, result_string.string); + } + assert_string_equal(result_string.string, line_object); } else { + if (line_object[0]) { + printf("[ -------> ] --- [07] Failure with line (%u) '%s', line_object[0]=%c.\n", line, line_string, line_object[0]); + } + assert_int_equal(line_object[0], 0); } }