From f93ad9312e2ce09baf669de88e22acf7025c24d2 Mon Sep 17 00:00:00 2001 From: Isidro Date: Sun, 27 Oct 2024 09:52:11 +0100 Subject: [PATCH] Test that long sections are truncated (#180) * test that long sections are truncated at MAX_SECTION=50 * generated .txt executing unittest.sh * expected result * Sections will be ignores when len(section) > len(INI_MAX_LINE) --------- Co-authored-by: Ben Hoyt --- tests/baseline_allow_no_value.txt | 3 +++ tests/baseline_call_handler_on_new_section.txt | 3 +++ tests/baseline_disallow_inline_comments.txt | 3 +++ tests/baseline_handler_lineno.txt | 3 +++ tests/baseline_heap.txt | 3 +++ tests/baseline_heap_max_line.txt | 2 ++ tests/baseline_heap_realloc.txt | 3 +++ tests/baseline_heap_realloc_max_line.txt | 2 ++ tests/baseline_multi.txt | 3 +++ tests/baseline_multi_max_line.txt | 2 ++ tests/baseline_single.txt | 3 +++ tests/baseline_stop_on_first_error.txt | 3 +++ tests/long_section.ini | 3 +++ tests/unittest.c | 1 + 14 files changed, 37 insertions(+) create mode 100644 tests/long_section.ini diff --git a/tests/baseline_allow_no_value.txt b/tests/baseline_allow_no_value.txt index c26aa93..f84771d 100644 --- a/tests/baseline_allow_no_value.txt +++ b/tests/baseline_allow_no_value.txt @@ -69,3 +69,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=0 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_call_handler_on_new_section.txt b/tests/baseline_call_handler_on_new_section.txt index d8c639b..133737b 100644 --- a/tests/baseline_call_handler_on_new_section.txt +++ b/tests/baseline_call_handler_on_new_section.txt @@ -67,3 +67,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_disallow_inline_comments.txt b/tests/baseline_disallow_inline_comments.txt index bb63721..df1dc3f 100644 --- a/tests/baseline_disallow_inline_comments.txt +++ b/tests/baseline_disallow_inline_comments.txt @@ -65,3 +65,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_handler_lineno.txt b/tests/baseline_handler_lineno.txt index 40a3934..5903d79 100644 --- a/tests/baseline_handler_lineno.txt +++ b/tests/baseline_handler_lineno.txt @@ -64,3 +64,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; line 9 no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; line 3 +long_section.ini: e=0 user=110 diff --git a/tests/baseline_heap.txt b/tests/baseline_heap.txt index 04ec0ae..76f205a 100644 --- a/tests/baseline_heap.txt +++ b/tests/baseline_heap.txt @@ -64,3 +64,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_heap_max_line.txt b/tests/baseline_heap_max_line.txt index 24ee5af..265c8a6 100644 --- a/tests/baseline_heap_max_line.txt +++ b/tests/baseline_heap_max_line.txt @@ -68,3 +68,5 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... name=value; +long_section.ini: e=2 user=110 diff --git a/tests/baseline_heap_realloc.txt b/tests/baseline_heap_realloc.txt index 04ec0ae..76f205a 100644 --- a/tests/baseline_heap_realloc.txt +++ b/tests/baseline_heap_realloc.txt @@ -64,3 +64,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_heap_realloc_max_line.txt b/tests/baseline_heap_realloc_max_line.txt index 24ee5af..265c8a6 100644 --- a/tests/baseline_heap_realloc_max_line.txt +++ b/tests/baseline_heap_realloc_max_line.txt @@ -68,3 +68,5 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... name=value; +long_section.ini: e=2 user=110 diff --git a/tests/baseline_multi.txt b/tests/baseline_multi.txt index 04ec0ae..76f205a 100644 --- a/tests/baseline_multi.txt +++ b/tests/baseline_multi.txt @@ -64,3 +64,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_multi_max_line.txt b/tests/baseline_multi_max_line.txt index 24ee5af..265c8a6 100644 --- a/tests/baseline_multi_max_line.txt +++ b/tests/baseline_multi_max_line.txt @@ -68,3 +68,5 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... name=value; +long_section.ini: e=2 user=110 diff --git a/tests/baseline_single.txt b/tests/baseline_single.txt index 8123f95..d8e3e37 100644 --- a/tests/baseline_single.txt +++ b/tests/baseline_single.txt @@ -59,3 +59,6 @@ duplicate_sections.ini: e=0 user=108 ... [section1] ... key1=val1; no_value.ini: e=2 user=109 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/baseline_stop_on_first_error.txt b/tests/baseline_stop_on_first_error.txt index aa91014..ecefd2b 100644 --- a/tests/baseline_stop_on_first_error.txt +++ b/tests/baseline_stop_on_first_error.txt @@ -58,3 +58,6 @@ bom.ini: e=0 user=107 ... single2=qrs; duplicate_sections.ini: e=0 user=108 no_value.ini: e=2 user=108 +... [_123456789_123456789_123456789_123456789_12345678] +... name=value; +long_section.ini: e=0 user=110 diff --git a/tests/long_section.ini b/tests/long_section.ini new file mode 100644 index 0000000..ca6d63e --- /dev/null +++ b/tests/long_section.ini @@ -0,0 +1,3 @@ +# check that section is truncated +[_123456789_123456789_123456789_123456789_123456789_123456789] +name = value diff --git a/tests/unittest.c b/tests/unittest.c index fde8e61..8ac6e27 100644 --- a/tests/unittest.c +++ b/tests/unittest.c @@ -72,5 +72,6 @@ int main(void) parse("bom.ini"); parse("duplicate_sections.ini"); parse("no_value.ini"); + parse("long_section.ini"); return 0; }