From 3910cbd80c16f2e58961167835b547f6ad458f1b Mon Sep 17 00:00:00 2001 From: "Zachary J. Fields" Date: Wed, 29 Jan 2025 08:19:09 -0600 Subject: [PATCH] chore: astyle (#164) --- test/src/_crcError_test.cpp | 199 ++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 113 deletions(-) diff --git a/test/src/_crcError_test.cpp b/test/src/_crcError_test.cpp index 04ca5fbf..7ccadde8 100644 --- a/test/src/_crcError_test.cpp +++ b/test/src/_crcError_test.cpp @@ -22,170 +22,143 @@ extern bool notecardFirmwareSupportsCrc; namespace { - SCENARIO("_crcError") - { - GIVEN("The Notecard firmware does NOT support CRC") { - notecardFirmwareSupportsCrc = false; +SCENARIO("_crcError") +{ + GIVEN("The Notecard firmware does NOT support CRC") { + notecardFirmwareSupportsCrc = false; - NoteSetFnDefault(malloc, free, NULL, NULL); + NoteSetFnDefault(malloc, free, NULL, NULL); - uint16_t seqNo = 1; + uint16_t seqNo = 1; - AND_GIVEN("An empty string") - { - char json[] = ""; + AND_GIVEN("An empty string") { + char json[] = ""; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("Invalid JSON") - { - char json[] = "{\"req\":"; + AND_GIVEN("Invalid JSON") { + char json[] = "{\"req\":"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("The Notecard returns an error message") { - char json[] = "{\"err\":\"cannot interpret JSON: bool being placed into a non-bool field {io}\"}"; + AND_GIVEN("The Notecard returns an error message") { + char json[] = "{\"err\":\"cannot interpret JSON: bool being placed into a non-bool field {io}\"}"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("No CRC field") - { - char json[] = "{\"req\": \"hub.sync\"}"; + AND_GIVEN("No CRC field") { + char json[] = "{\"req\": \"hub.sync\"}"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("The CRC field exists, but is not at the tail of the response") - { - char json[] = "{\"crc\":\"0009:10BAC79A\",\"req\": \"hub.sync\"}"; + AND_GIVEN("The CRC field exists, but is not at the tail of the response") { + char json[] = "{\"crc\":\"0009:10BAC79A\",\"req\": \"hub.sync\"}"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } } + } - GIVEN("The Notecard firmware supports CRC") { - notecardFirmwareSupportsCrc = true; + GIVEN("The Notecard firmware supports CRC") { + notecardFirmwareSupportsCrc = true; - NoteSetFnDefault(malloc, free, NULL, NULL); + NoteSetFnDefault(malloc, free, NULL, NULL); - uint16_t seqNo = 1; + uint16_t seqNo = 1; - AND_GIVEN("An empty string") - { - char json[] = ""; + AND_GIVEN("An empty string") { + char json[] = ""; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("Invalid JSON") - { - char json[] = "{\"req\":"; + AND_GIVEN("Invalid JSON") { + char json[] = "{\"req\":"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("The Notecard returns an error message") { - char json[] = "{\"err\":\"cannot interpret JSON: bool being placed into a non-bool field {io}\"}"; + AND_GIVEN("The Notecard returns an error message") { + char json[] = "{\"err\":\"cannot interpret JSON: bool being placed into a non-bool field {io}\"}"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("No CRC field") - { - char json[] = "{\"req\": \"hub.sync\"}"; + AND_GIVEN("No CRC field") { + char json[] = "{\"req\": \"hub.sync\"}"; - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } + } - AND_GIVEN("The CRC field exists, but is not at the tail of the response") - { - char json[] = "{\"crc\":\"0009:10BAC79A\",\"req\": \"hub.sync\"}"; + AND_GIVEN("The CRC field exists, but is not at the tail of the response") { + char json[] = "{\"crc\":\"0009:10BAC79A\",\"req\": \"hub.sync\"}"; - THEN("A CRC error SHALL be reported") - { - CHECK(_crcError(json, seqNo)); - } + THEN("A CRC error SHALL be reported") { + CHECK(_crcError(json, seqNo)); } + } - AND_GIVEN("Valid JSON and CRC field present") - { - WHEN("CRC doesn't match") - { - char json[] = "{\"req\":\"hub.sync\",\"crc\":\"0001:DEADBEEF\"}"; + AND_GIVEN("Valid JSON and CRC field present") { + WHEN("CRC doesn't match") { + char json[] = "{\"req\":\"hub.sync\",\"crc\":\"0001:DEADBEEF\"}"; - THEN("A CRC error SHALL be reported") - { - CHECK(_crcError(json, seqNo)); - } + THEN("A CRC error SHALL be reported") { + CHECK(_crcError(json, seqNo)); } + } - WHEN("Sequence number doesn't match") - { - char json[] = "{\"req\":\"hub.sync\",\"crc\":\"0009:10BAC79A\"}"; + WHEN("Sequence number doesn't match") { + char json[] = "{\"req\":\"hub.sync\",\"crc\":\"0009:10BAC79A\"}"; - THEN("A CRC error SHALL be reported") - { - CHECK(_crcError(json, seqNo)); - } + THEN("A CRC error SHALL be reported") { + CHECK(_crcError(json, seqNo)); } + } - WHEN("Everything matches") - { - char json[] = "{\"req\":\"hub.sync\"}"; - char *jsonWithCrc = _crcAdd(json, seqNo); - REQUIRE(jsonWithCrc != NULL); - - THEN("A CRC error SHALL NOT be reported") - { - CHECK(!_crcError(json, seqNo)); - } + WHEN("Everything matches") { + char json[] = "{\"req\":\"hub.sync\"}"; + char *jsonWithCrc = _crcAdd(json, seqNo); + REQUIRE(jsonWithCrc != NULL); - NoteFree(jsonWithCrc); + THEN("A CRC error SHALL NOT be reported") { + CHECK(!_crcError(json, seqNo)); } - AND_GIVEN("a trailing CRLF") - { - char json[] = "{\"req\":\"hub.sync\",\"crc\":\"0001:10BAC79A\"}\r\n"; + NoteFree(jsonWithCrc); + } + + AND_GIVEN("a trailing CRLF") { + char json[] = "{\"req\":\"hub.sync\",\"crc\":\"0001:10BAC79A\"}\r\n"; - THEN("A CRC error SHALL NOT be reported") - { - // Trailing \r\n should be ignored. - CHECK(!_crcError(json, seqNo)); - } + THEN("A CRC error SHALL NOT be reported") { + // Trailing \r\n should be ignored. + CHECK(!_crcError(json, seqNo)); } } } } } +} #endif // !NOTE_C_LOW_MEM