From d8349a72a270072ff04cf1ec9cde1adda810ab75 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 27 Feb 2024 21:46:41 -0600 Subject: [PATCH] Progress: Add some unit tests for fl_fss_payload_header_map(), focusing on number types. This does not add tests for the join digits flag. Such tests will be added at a later time. --- level_1/fl_fss/data/build/settings-tests | 5 + .../headers/payload-combined-abstruse_int16-2.txt | 2 +- .../headers/payload-combined-abstruse_int16s-0.txt | 6 + .../headers/payload-combined-abstruse_int16s-1.txt | 5 + .../headers/payload-combined-abstruse_int16s-2.txt | 5 + .../headers/payload-combined-abstruse_int32s-0.txt | 6 + .../headers/payload-combined-abstruse_int32s-1.txt | 5 + .../headers/payload-combined-abstruse_int32s-2.txt | 5 + .../headers/payload-combined-abstruse_int64s-0.txt | 6 + .../headers/payload-combined-abstruse_int64s-1.txt | 5 + .../headers/payload-combined-abstruse_int64s-2.txt | 6 + .../headers/payload-combined-abstruse_int8s-0.txt | 6 + .../headers/payload-combined-abstruse_int8s-1.txt | 5 + .../headers/payload-combined-abstruse_int8s-2.txt | 5 + .../payload-combined-abstruse_signeds-0.txt | 6 + .../payload-combined-abstruse_signeds-1.txt | 5 + .../payload-combined-abstruse_signeds-2.txt | 5 + .../payload-combined-abstruse_uint16s-0.txt | 6 + .../payload-combined-abstruse_uint16s-1.txt | 5 + .../payload-combined-abstruse_uint16s-2.txt | 4 + .../payload-combined-abstruse_uint32s-0.txt | 6 + .../payload-combined-abstruse_uint32s-1.txt | 5 + .../payload-combined-abstruse_uint32s-2.txt | 4 + .../payload-combined-abstruse_uint64s-0.txt | 6 + .../payload-combined-abstruse_uint64s-1.txt | 5 + .../payload-combined-abstruse_uint64s-2.txt | 5 + .../headers/payload-combined-abstruse_uint8s-0.txt | 6 + .../headers/payload-combined-abstruse_uint8s-1.txt | 5 + .../headers/payload-combined-abstruse_uint8s-2.txt | 4 + .../payload-combined-abstruse_unsigneds-0.txt | 6 + .../payload-combined-abstruse_unsigneds-1.txt | 5 + .../payload-combined-abstruse_unsigneds-2.txt | 4 + .../variables/payload-combined-abstruse_int16s.txt | 16 +++ .../variables/payload-combined-abstruse_int32s.txt | 16 +++ .../variables/payload-combined-abstruse_int64s.txt | 17 +++ .../variables/payload-combined-abstruse_int8s.txt | 16 +++ .../payload-combined-abstruse_signeds.txt | 16 +++ .../payload-combined-abstruse_uint16s.txt | 15 +++ .../payload-combined-abstruse_uint32s.txt | 15 +++ .../payload-combined-abstruse_uint64s.txt | 16 +++ .../variables/payload-combined-abstruse_uint8s.txt | 15 +++ .../payload-combined-abstruse_unsigneds.txt | 15 +++ level_1/fl_fss/tests/unit/c/help-fss.c | 6 +- .../test-fss-payload_header_map-abstruse_int16s.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_int16s.h | 20 +++ .../test-fss-payload_header_map-abstruse_int32s.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_int32s.h | 20 +++ .../test-fss-payload_header_map-abstruse_int64s.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_int64s.h | 20 +++ .../c/test-fss-payload_header_map-abstruse_int8s.c | 149 ++++++++++++++++++++ .../c/test-fss-payload_header_map-abstruse_int8s.h | 20 +++ .../test-fss-payload_header_map-abstruse_signed.c | 4 +- .../test-fss-payload_header_map-abstruse_signeds.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_signeds.h | 20 +++ .../test-fss-payload_header_map-abstruse_uint16s.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_uint16s.h | 20 +++ .../test-fss-payload_header_map-abstruse_uint32s.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_uint32s.h | 20 +++ .../test-fss-payload_header_map-abstruse_uint64s.c | 150 +++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_uint64s.h | 20 +++ .../test-fss-payload_header_map-abstruse_uint8s.c | 149 ++++++++++++++++++++ .../test-fss-payload_header_map-abstruse_uint8s.h | 20 +++ ...test-fss-payload_header_map-abstruse_unsigned.c | 4 +- ...est-fss-payload_header_map-abstruse_unsigneds.c | 149 ++++++++++++++++++++ ...est-fss-payload_header_map-abstruse_unsigneds.h | 20 +++ level_1/fl_fss/tests/unit/c/test-fss.c | 10 ++ level_1/fl_fss/tests/unit/c/test-fss.h | 10 ++ 67 files changed, 2038 insertions(+), 8 deletions(-) create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-2.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-0.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-1.txt create mode 100644 level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-2.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int16s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int32s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int64s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int8s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_signeds.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint16s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint32s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint64s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint8s.txt create mode 100644 level_1/fl_fss/data/tests/variables/payload-combined-abstruse_unsigneds.txt create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.h create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.c create mode 100644 level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.h diff --git a/level_1/fl_fss/data/build/settings-tests b/level_1/fl_fss/data/build/settings-tests index b8c101f..2979d95 100644 --- a/level_1/fl_fss/data/build/settings-tests +++ b/level_1/fl_fss/data/build/settings-tests @@ -31,7 +31,12 @@ build_sources_program test-fss-embedded_list_content_read.c test-fss-embedded_li build_sources_program test-fss-extended_content_read.c test-fss-extended_content_write.c test-fss-extended_object_read.c test-fss-extended_object_write.c build_sources_program test-fss-extended_list_content_read.c test-fss-extended_list_content_write.c test-fss-extended_list_object_read.c test-fss-extended_list_object_write.c build_sources_program test-fss-payload_header_map.c +build_sources_program test-fss-payload_header_map-abstruse_int8s.c test-fss-payload_header_map-abstruse_uint8s.c +build_sources_program test-fss-payload_header_map-abstruse_int16s.c test-fss-payload_header_map-abstruse_uint16s.c +build_sources_program test-fss-payload_header_map-abstruse_int32s.c test-fss-payload_header_map-abstruse_uint32s.c +build_sources_program test-fss-payload_header_map-abstruse_int64s.c test-fss-payload_header_map-abstruse_uint64s.c build_sources_program test-fss-payload_header_map-abstruse_signed.c test-fss-payload_header_map-abstruse_unsigned.c +build_sources_program test-fss-payload_header_map-abstruse_signeds.c test-fss-payload_header_map-abstruse_unsigneds.c build_sources_program test-fss.c data-fss.c help-fss.c diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16-2.txt index eebcb15..0f3cdb7 100644 --- a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16-2.txt +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16-2.txt @@ -1,6 +1,6 @@ c 1 -012345 +12345 1 -32700 1 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-1.txt new file mode 100644 index 0000000..bf5e577 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +555 +7777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-2.txt new file mode 100644 index 0000000..0abef78 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int16s-2.txt @@ -0,0 +1,5 @@ +c +3 +12345 +-32700 +-1 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-1.txt new file mode 100644 index 0000000..651898c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-2.txt new file mode 100644 index 0000000..8b53bbd --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int32s-2.txt @@ -0,0 +1,5 @@ +c +3 +123456789 +-2147483600 +-1 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-1.txt new file mode 100644 index 0000000..651898c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-2.txt new file mode 100644 index 0000000..f0b9a22 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int64s-2.txt @@ -0,0 +1,6 @@ +c +4 +123456789 +-9876543210 +-1 +-9223372036854775000 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-1.txt new file mode 100644 index 0000000..506392d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55 +77 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-2.txt new file mode 100644 index 0000000..207d6da --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_int8s-2.txt @@ -0,0 +1,5 @@ +c +3 +12 +-120 +-1 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-1.txt new file mode 100644 index 0000000..651898c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-2.txt new file mode 100644 index 0000000..157e821 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_signeds-2.txt @@ -0,0 +1,5 @@ +c +3 +123456789 +-9876543210 +-1 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-1.txt new file mode 100644 index 0000000..14c6dbc --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +7777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-2.txt new file mode 100644 index 0000000..395bf7d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint16s-2.txt @@ -0,0 +1,4 @@ +c +2 +1234 +65500 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-1.txt new file mode 100644 index 0000000..651898c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-2.txt new file mode 100644 index 0000000..261b457 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint32s-2.txt @@ -0,0 +1,4 @@ +c +2 +123456789 +4294967200 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-1.txt new file mode 100644 index 0000000..651898c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-2.txt new file mode 100644 index 0000000..5926486 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint64s-2.txt @@ -0,0 +1,5 @@ +c +3 +123456789 +9876543210 +18446744073709550000 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-1.txt new file mode 100644 index 0000000..506392d --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55 +77 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-2.txt new file mode 100644 index 0000000..6636c04 --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_uint8s-2.txt @@ -0,0 +1,4 @@ +c +2 +25 +250 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-0.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-0.txt new file mode 100644 index 0000000..67ba4ea --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-0.txt @@ -0,0 +1,6 @@ +a +4 +0 +1 +2 +3 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-1.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-1.txt new file mode 100644 index 0000000..651898c --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-1.txt @@ -0,0 +1,5 @@ +b +3 +44 +55555 +77777777 diff --git a/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-2.txt b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-2.txt new file mode 100644 index 0000000..df4092e --- /dev/null +++ b/level_1/fl_fss/data/tests/headers/payload-combined-abstruse_unsigneds-2.txt @@ -0,0 +1,4 @@ +c +2 +123456789 +9876543210 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int16s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int16s.txt new file mode 100644 index 0000000..7fedf92 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int16s.txt @@ -0,0 +1,16 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +555 +7777 +c +3 +012345 +-32700 +-1 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int32s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int32s.txt new file mode 100644 index 0000000..50445fa --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int32s.txt @@ -0,0 +1,16 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +77777777 +c +3 +0123456789 +-2147483600 +-1 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int64s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int64s.txt new file mode 100644 index 0000000..8081765 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int64s.txt @@ -0,0 +1,17 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +77777777 +c +4 +0123456789 +-9876543210 +-1 +-9223372036854775000 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int8s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int8s.txt new file mode 100644 index 0000000..cd76372 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_int8s.txt @@ -0,0 +1,16 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55 +77 +c +3 +012 +-120 +-1 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_signeds.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_signeds.txt new file mode 100644 index 0000000..485a2ee --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_signeds.txt @@ -0,0 +1,16 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +77777777 +c +3 +0123456789 +-9876543210 +-1 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint16s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint16s.txt new file mode 100644 index 0000000..34784a2 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint16s.txt @@ -0,0 +1,15 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +7777 +c +2 +01234 +65500 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint32s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint32s.txt new file mode 100644 index 0000000..312aafd --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint32s.txt @@ -0,0 +1,15 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +77777777 +c +2 +0123456789 +4294967200 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint64s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint64s.txt new file mode 100644 index 0000000..59ee745 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint64s.txt @@ -0,0 +1,16 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +77777777 +c +3 +0123456789 +9876543210 +18446744073709550000 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint8s.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint8s.txt new file mode 100644 index 0000000..2873e85 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_uint8s.txt @@ -0,0 +1,15 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55 +77 +c +2 +025 +250 diff --git a/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_unsigneds.txt b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_unsigneds.txt new file mode 100644 index 0000000..25a8316 --- /dev/null +++ b/level_1/fl_fss/data/tests/variables/payload-combined-abstruse_unsigneds.txt @@ -0,0 +1,15 @@ +a +4 +0 +1 +2 +3 +b +3 +44 +55555 +77777777 +c +2 +0123456789 +9876543210 diff --git a/level_1/fl_fss/tests/unit/c/help-fss.c b/level_1/fl_fss/tests/unit/c/help-fss.c index f1b6186..447e7eb 100644 --- a/level_1/fl_fss/tests/unit/c/help-fss.c +++ b/level_1/fl_fss/tests/unit/c/help-fss.c @@ -83,13 +83,13 @@ uint8_t help__read_line_expects__single(FILE *file, const f_string_static_t obje for (f_number_unsigned_t i = 0; i < count; ++i, ++expects->used) { max = 255; - expects->array[expects->used].name.used = 0; + expects->array[expects->used].key.used = 0; expects->array[expects->used].value.used = 0; - status = f_string_dynamic_append(object, &expects->array[expects->used].name); + status = f_string_dynamic_append(object, &expects->array[expects->used].key); assert_true(F_status_is_error_not(status)); - status = f_string_dynamic_terminate_after(&expects->array[expects->used].name); + status = f_string_dynamic_terminate_after(&expects->array[expects->used].key); assert_true(F_status_is_error_not(status)); status = f_memory_array_increase_by(max, sizeof(f_string_t), (void **) &expects->array[expects->used].value.string, &expects->array[expects->used].value.used, &expects->array[expects->used].value.size); diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.c new file mode 100644 index 0000000..acdeded --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_int16s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_int16s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_int16s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_int16s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_i16s.used = 0; + headers.array[0].value.type = f_abstruse_int16s_e; + is_a = &headers.array[0].value.is.a_i16s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_int16s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.h new file mode 100644 index 0000000..b0543d7 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int16s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_int16s_h +#define _TEST__FL_fss_payload_header_map__abstruse_int16s_h + +/** + * Test that the function works for abstruse_int16s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_int16s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_int16s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.c new file mode 100644 index 0000000..6ed1ea3 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_int32s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_int32s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_int32s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_int32s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_i32s.used = 0; + headers.array[0].value.type = f_abstruse_int32s_e; + is_a = &headers.array[0].value.is.a_i32s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_int32s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.h new file mode 100644 index 0000000..a53c963 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int32s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_int32s_h +#define _TEST__FL_fss_payload_header_map__abstruse_int32s_h + +/** + * Test that the function works for abstruse_int32s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_int32s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_int32s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.c new file mode 100644 index 0000000..0134de7 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_int64s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_int64s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_int64s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_int64s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_i64s.used = 0; + headers.array[0].value.type = f_abstruse_int64s_e; + is_a = &headers.array[0].value.is.a_i64s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_int64s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.h new file mode 100644 index 0000000..f59a7be --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int64s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_int64s_h +#define _TEST__FL_fss_payload_header_map__abstruse_int64s_h + +/** + * Test that the function works for abstruse_int64s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_int64s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_int64s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.c new file mode 100644 index 0000000..06f796c --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_int8s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_int8s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_int8s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_int8s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_i8s.used = 0; + headers.array[0].value.type = f_abstruse_int8s_e; + is_a = &headers.array[0].value.is.a_i8s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_int8s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.h new file mode 100644 index 0000000..bd758b9 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_int8s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_int8s_h +#define _TEST__FL_fss_payload_header_map__abstruse_int8s_h + +/** + * Test that the function works for abstruse_int8s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_int8s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_int8s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signed.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signed.c index 6127de9..49eb437 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signed.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signed.c @@ -80,10 +80,10 @@ void test__fl_fss_payload_header_map__abstruse_signed__works_combined(void **voi for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { - assert_int_equal(destinations.array[i].name.used, expects.array[i].name.used); + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); - assert_string_equal(destinations.array[i].name.string, expects.array[i].name.string); + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); } // for diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.c new file mode 100644 index 0000000..3acb6b1 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_signeds.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_signeds__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_signeds"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_number_signeds_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_signeds.used = 0; + headers.array[0].value.type = f_abstruse_signeds_e; + is_a = &headers.array[0].value.is.a_signeds; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_signeds", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.h new file mode 100644 index 0000000..77681ae --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_signeds.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_signeds_h +#define _TEST__FL_fss_payload_header_map__abstruse_signeds_h + +/** + * Test that the function works for abstruse_signeds type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_signeds__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_signeds_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.c new file mode 100644 index 0000000..a059492 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_uint16s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_uint16s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_uint16s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_uint16s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_u16s.used = 0; + headers.array[0].value.type = f_abstruse_uint16s_e; + is_a = &headers.array[0].value.is.a_u16s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_uint16s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.h new file mode 100644 index 0000000..9c146dd --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint16s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_uint16s_h +#define _TEST__FL_fss_payload_header_map__abstruse_uint16s_h + +/** + * Test that the function works for abstruse_uint16s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_uint16s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_uint16s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.c new file mode 100644 index 0000000..6c71bb9 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_uint32s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_uint32s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_uint32s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_uint32s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_u32s.used = 0; + headers.array[0].value.type = f_abstruse_uint32s_e; + is_a = &headers.array[0].value.is.a_u32s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_uint32s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.h new file mode 100644 index 0000000..ddfc74b --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint32s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_uint32s_h +#define _TEST__FL_fss_payload_header_map__abstruse_uint32s_h + +/** + * Test that the function works for abstruse_uint32s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_uint32s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_uint32s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.c new file mode 100644 index 0000000..192dcdc --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.c @@ -0,0 +1,150 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_uint64s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_uint64s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_uint64s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_uint64s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_u64s.used = 0; + headers.array[0].value.type = f_abstruse_uint64s_e; + is_a = &headers.array[0].value.is.a_u64s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + // atoll() cannot be used here due to needing an unsigned 64-bit and atoll() returns a signed 64-bit. + const f_number_signed_t number = strtoull(contents.array[is_a->used].string, 0, 10); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_uint64s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.h new file mode 100644 index 0000000..ee130fe --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint64s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_uint64s_h +#define _TEST__FL_fss_payload_header_map__abstruse_uint64s_h + +/** + * Test that the function works for abstruse_uint64s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_uint64s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_uint64s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.c new file mode 100644 index 0000000..26d210c --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_uint8s.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_uint8s__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_uint8s"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_uint8s_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_u8s.used = 0; + headers.array[0].value.type = f_abstruse_uint8s_e; + is_a = &headers.array[0].value.is.a_u8s; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_uint8s", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.h new file mode 100644 index 0000000..fc3087b --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_uint8s.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_uint8s_h +#define _TEST__FL_fss_payload_header_map__abstruse_uint8s_h + +/** + * Test that the function works for abstruse_uint8s type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_uint8s__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_uint8s_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigned.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigned.c index fce3590..6912e97 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigned.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigned.c @@ -80,10 +80,10 @@ void test__fl_fss_payload_header_map__abstruse_unsigned__works_combined(void **v for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { - assert_int_equal(destinations.array[i].name.used, expects.array[i].name.used); + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); - assert_string_equal(destinations.array[i].name.string, expects.array[i].name.string); + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); } // for diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.c b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.c new file mode 100644 index 0000000..772c304 --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.c @@ -0,0 +1,149 @@ +#include "test-fss.h" +#include "test-fss-payload_header_map-abstruse_unsigneds.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__fl_fss_payload_header_map__abstruse_unsigneds__works_combined(void **void_state) { + + // Note: Each line should probably be at max 255 characters. + // The payload begins with a digit on the first line representing the number of Content lines following the Object line. + // Following the digit is a single Object line. + // Following the Object line is a line for each Content designated by the first line (can be 0). + // Following this Content line (even if 0 lines) should be the end of the test file or the start of the next set for the next line in the headers file. + FILE *file_variables = data__file_open__named("variables", "payload", "combined-abstruse_unsigneds"); + FILE *file_headers = 0; + + assert_non_null(file_variables); + + f_abstruse_maps_t headers = f_abstruse_maps_t_initialize; + f_state_t state = f_state_t_initialize; + f_fss_payload_header_state_t data = f_fss_payload_header_state_t_initialize; + f_string_dynamic_t object = f_string_dynamic_t_initialize; + f_string_dynamics_t contents = f_string_dynamics_t_initialize; + f_string_dynamic_t cache = f_string_dynamic_t_initialize; + f_string_maps_t destinations = f_string_maps_t_initialize; + f_string_maps_t expects = f_string_maps_t_initialize; + f_number_unsigneds_t *is_a = 0; + + { + state.status = F_none; + state.data = &data; + data.cache = &cache; + + for (uint16_t at = 0; ; ++at) { + + if (help__read_line_object(file_variables, &object)) break; + if (help__read_line_contents__single(file_variables, &contents)) break; + + state.status = f_memory_array_increase(state.step_small, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size); + assert_true(F_status_is_error_not(state.status)); + + headers.array[0].key.used = 0; + headers.array[0].value.is.a_unsigneds.used = 0; + headers.array[0].value.type = f_abstruse_unsigneds_e; + is_a = &headers.array[0].value.is.a_unsigneds; + + state.status = f_string_dynamic_append(object, &headers.array[headers.used].key); + assert_int_equal(state.status, F_okay); + + state.status = f_memory_array_increase_by(contents.used, sizeof(f_number_signed_t), (void **) &is_a->array, &is_a->used, &is_a->size); + assert_true(F_status_is_error_not(state.status)); + + for (is_a->used = 0; is_a->used < contents.used; ) { + + const f_number_signed_t number = atoll(contents.array[is_a->used].string); + + if (!number) { + assert_int_equal(contents.array[is_a->used].string[0], '0'); + } + + is_a->array[is_a->used++] = number; + } // for + + if (object.string) free(object.string); + + object.string = 0; + object.used = 0; + object.size = 0; + + ++headers.used; + + file_headers = data__file_open__named_at("headers", "payload", "combined-abstruse_unsigneds", at); + assert_non_null(file_headers); + + help__read_line_object(file_headers, &object); + + for (;;) { + state.status = f_memory_array_increase(state.step_small, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size); + assert_true(F_status_is_error_not(state.status)); + + if (help__read_line_expects__single(file_headers, object, &expects)) break; + } // for + + fl_fss_payload_header_map(headers, &destinations, &state); + assert_int_equal(state.status, F_okay); + assert_int_equal(destinations.used, expects.used); + + for (f_number_unsigned_t i = 0; i < destinations.used; ++i) { + + assert_int_equal(destinations.array[i].key.used, expects.array[i].key.used); + assert_int_equal(destinations.array[i].value.used, expects.array[i].value.used); + + assert_string_equal(destinations.array[i].key.string, expects.array[i].key.string); + assert_string_equal(destinations.array[i].value.string, expects.array[i].value.string); + } // for + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + if (file_headers) fclose(file_headers); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); + + file_headers = 0; + + object.string = 0; + object.used = 0; + object.size = 0; + + cache.string = 0; + cache.used = 0; + cache.size = 0; + + contents.array = 0; + contents.used = 0; + contents.size = 0; + + headers.array = 0; + headers.used = 0; + headers.size = 0; + + destinations.array = 0; + destinations.used = 0; + destinations.size = 0; + + expects.array = 0; + expects.used = 0; + expects.size = 0; + } // for + } + + if (file_variables) fclose(file_variables); + if (file_headers) fclose(file_headers); + + if (object.string) free(object.string); + if (cache.string) free(cache.string); + + f_memory_arrays_resize(0, sizeof(f_string_dynamic_t), (void **) &contents.array, &contents.used, &contents.size, &f_string_dynamics_delete_callback); + f_memory_arrays_resize(0, sizeof(f_abstruse_map_t), (void **) &headers.array, &headers.used, &headers.size, &f_abstruse_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &destinations.array, &destinations.used, &destinations.size, &f_string_maps_delete_callback); + f_memory_arrays_resize(0, sizeof(f_string_map_t), (void **) &expects.array, &expects.used, &expects.size, &f_string_maps_delete_callback); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.h b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.h new file mode 100644 index 0000000..07bec2c --- /dev/null +++ b/level_1/fl_fss/tests/unit/c/test-fss-payload_header_map-abstruse_unsigneds.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 2 + * + * Project: FSS + * API Version: 0.6 + * Licenses: lgpl-2.1-or-later + * + * Test the fl_fss project. + */ +#ifndef _TEST__FL_fss_payload_header_map__abstruse_unsigneds_h +#define _TEST__FL_fss_payload_header_map__abstruse_unsigneds_h + +/** + * Test that the function works for abstruse_unsigneds type. + * + * @see fl_fss_payload_header_map() + */ +extern void test__fl_fss_payload_header_map__abstruse_unsigneds__works_combined(void **state); + +#endif // _TEST__FL_fss_payload_header_map__abstruse_unsigneds_h diff --git a/level_1/fl_fss/tests/unit/c/test-fss.c b/level_1/fl_fss/tests/unit/c/test-fss.c index a4b5b04..176819d 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss.c +++ b/level_1/fl_fss/tests/unit/c/test-fss.c @@ -60,8 +60,18 @@ int main(void) { cmocka_unit_test(test__fl_fss_extended_list_object_read__works), cmocka_unit_test(test__fl_fss_payload_header_map__returns_data_not), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int8s__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int16s__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int32s__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_int64s__works_combined), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signed__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_signeds__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint8s__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint16s__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint32s__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_uint64s__works_combined), cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_unsigned__works_combined), + cmocka_unit_test(test__fl_fss_payload_header_map__abstruse_unsigneds__works_combined), #ifndef _di_level_0_parameter_checking_ cmocka_unit_test(test__fl_fss_basic_content_read__parameter_checking), diff --git a/level_1/fl_fss/tests/unit/c/test-fss.h b/level_1/fl_fss/tests/unit/c/test-fss.h index 2e101a3..296f697 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss.h +++ b/level_1/fl_fss/tests/unit/c/test-fss.h @@ -61,8 +61,18 @@ #include "test-fss-extended_list_object_read.h" #include "test-fss-extended_list_object_write.h" #include "test-fss-payload_header_map.h" +#include "test-fss-payload_header_map-abstruse_int8s.h" +#include "test-fss-payload_header_map-abstruse_int16s.h" +#include "test-fss-payload_header_map-abstruse_int32s.h" +#include "test-fss-payload_header_map-abstruse_int64s.h" #include "test-fss-payload_header_map-abstruse_signed.h" +#include "test-fss-payload_header_map-abstruse_signeds.h" +#include "test-fss-payload_header_map-abstruse_uint8s.h" +#include "test-fss-payload_header_map-abstruse_uint16s.h" +#include "test-fss-payload_header_map-abstruse_uint32s.h" +#include "test-fss-payload_header_map-abstruse_uint64s.h" #include "test-fss-payload_header_map-abstruse_unsigned.h" +#include "test-fss-payload_header_map-abstruse_unsigneds.h" #ifdef __cplusplus extern "C" { -- 1.8.3.1