diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c9154d55..49e3c991 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -146,7 +146,7 @@ add_test(i2cChunkedReceive_test) add_test(i2cChunkedTransmit_test) add_test(NoteBinaryReceive_test) add_test(NoteBinaryTransmit_test) -add_test(NoteBinaryRequiredRxBuffer_test) +add_test(NoteBinaryRequiredRxMaxBuffer_test) add_test(NoteBinaryReset_test) if(NOTE_C_COVERAGE) diff --git a/test/src/NoteBinaryReceive_test.cpp b/test/src/NoteBinaryReceive_test.cpp index 201fa8bd..4ac6f1d2 100644 --- a/test/src/NoteBinaryReceive_test.cpp +++ b/test/src/NoteBinaryReceive_test.cpp @@ -20,7 +20,7 @@ DEFINE_FFF_GLOBALS FAKE_VALUE_FUNC(J *, NoteNewRequest, const char *) -FAKE_VALUE_FUNC(const char *, NoteBinaryRequiredRxBuffer, size_t *) +FAKE_VALUE_FUNC(const char *, NoteBinaryRequiredRxMaxBuffer, size_t *) FAKE_VALUE_FUNC(J *, NoteRequestResponse, J *) FAKE_VALUE_FUNC(const char *, NoteChunkedReceive, uint8_t *, size_t *, bool, size_t, uint32_t *) @@ -43,15 +43,17 @@ size_t rawMsgLen = strlen(rawMsg); namespace { -SCENARIO("NoteBinaryReceive") +SCENARIO("NoteBinaryReceive all") { RESET_FAKE(NoteNewRequest); - RESET_FAKE(NoteBinaryRequiredRxBuffer); + RESET_FAKE(NoteBinaryRequiredRxMaxBuffer); RESET_FAKE(NoteRequestResponse); RESET_FAKE(NoteChunkedReceive); RESET_FAKE(NoteLockNote); RESET_FAKE(NoteUnlockNote); + const size_t offset = 0; + NoteSetFnDefault(malloc, free, NULL, NULL); // These fakes are the default. Tests below may override them to exercise @@ -59,7 +61,7 @@ SCENARIO("NoteBinaryReceive") NoteNewRequest_fake.custom_fake = [](const char *req) -> J* { return JCreateObject(); }; - NoteBinaryRequiredRxBuffer_fake.custom_fake = [](size_t *size) + NoteBinaryRequiredRxMaxBuffer_fake.custom_fake = [](size_t *size) -> const char * { *size = bufLen; @@ -76,8 +78,8 @@ SCENARIO("NoteBinaryReceive") return rsp; }; - GIVEN("NoteBinaryRequiredRxBuffer fails") { - NoteBinaryRequiredRxBuffer_fake.custom_fake = [](size_t *size) + GIVEN("NoteBinaryRequiredRxMaxBuffer fails") { + NoteBinaryRequiredRxMaxBuffer_fake.custom_fake = [](size_t *size) -> const char * { *size = 0; @@ -85,7 +87,7 @@ SCENARIO("NoteBinaryReceive") }; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -93,12 +95,12 @@ SCENARIO("NoteBinaryReceive") } } - GIVEN("NoteBinaryRequiredRxBuffer indicates there's no binary data") { - NoteBinaryRequiredRxBuffer_fake.custom_fake = NULL; - NoteBinaryRequiredRxBuffer_fake.return_val = "some error"; + GIVEN("NoteBinaryRequiredRxMaxBuffer indicates there's no binary data") { + NoteBinaryRequiredRxMaxBuffer_fake.custom_fake = NULL; + NoteBinaryRequiredRxMaxBuffer_fake.return_val = "some error"; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -107,7 +109,7 @@ SCENARIO("NoteBinaryReceive") } GIVEN("The receive buffer isn't big enough") { - NoteBinaryRequiredRxBuffer_fake.custom_fake = [](size_t *size) + NoteBinaryRequiredRxMaxBuffer_fake.custom_fake = [](size_t *size) -> const char * { *size = bufLen + 1; @@ -115,7 +117,7 @@ SCENARIO("NoteBinaryReceive") }; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -128,7 +130,7 @@ SCENARIO("NoteBinaryReceive") NoteNewRequest_fake.return_val = NULL; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -146,7 +148,7 @@ SCENARIO("NoteBinaryReceive") }; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -158,7 +160,7 @@ SCENARIO("NoteBinaryReceive") NoteChunkedReceive_fake.return_val = "some error"; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -176,7 +178,7 @@ SCENARIO("NoteBinaryReceive") }; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -207,7 +209,7 @@ SCENARIO("NoteBinaryReceive") }; WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("An error is returned") { CHECK(err != NULL); @@ -217,7 +219,7 @@ SCENARIO("NoteBinaryReceive") AND_GIVEN("The computed MD5 matches the status field") { WHEN("NoteBinaryReceive is called") { - const char *err = NoteBinaryReceive(buf, bufLen, &dataLen); + const char *err = NoteBinaryReceive(buf, bufLen, offset, &dataLen); THEN("No error is returned") { CHECK(err == NULL); diff --git a/test/src/NoteBinaryRequiredRxBuffer_test.cpp b/test/src/NoteBinaryRequiredRxMaxBuffer_test.cpp similarity index 80% rename from test/src/NoteBinaryRequiredRxBuffer_test.cpp rename to test/src/NoteBinaryRequiredRxMaxBuffer_test.cpp index 3ac263b8..9a1ccc80 100644 --- a/test/src/NoteBinaryRequiredRxBuffer_test.cpp +++ b/test/src/NoteBinaryRequiredRxMaxBuffer_test.cpp @@ -1,5 +1,5 @@ /*! - * @file NoteBinaryRequiredRxBuffer_test.cpp + * @file NoteBinaryRequiredRxMaxBuffer_test.cpp * * Written by the Blues Inc. team. * @@ -26,7 +26,7 @@ const size_t cobsLen = 10; namespace { -SCENARIO("NoteBinaryRequiredRxBuffer") +SCENARIO("NoteBinaryRequiredRxMaxBuffer") { RESET_FAKE(NoteRequestResponse); @@ -41,8 +41,8 @@ SCENARIO("NoteBinaryRequiredRxBuffer") return NULL; }; - WHEN("NoteBinaryRequiredRxBuffer is called") { - const char *err = NoteBinaryRequiredRxBuffer(&size); + WHEN("NoteBinaryRequiredRxMaxBuffer is called") { + const char *err = NoteBinaryRequiredRxMaxBuffer(&size); THEN("An error is returned") { CHECK(err != NULL); @@ -59,8 +59,8 @@ SCENARIO("NoteBinaryRequiredRxBuffer") return rsp; }; - WHEN("NoteBinaryRequiredRxBuffer is called") { - const char *err = NoteBinaryRequiredRxBuffer(&size); + WHEN("NoteBinaryRequiredRxMaxBuffer is called") { + const char *err = NoteBinaryRequiredRxMaxBuffer(&size); THEN("An error is returned") { CHECK(err != NULL); @@ -78,8 +78,8 @@ SCENARIO("NoteBinaryRequiredRxBuffer") return rsp; }; - WHEN("NoteBinaryRequiredRxBuffer is called") { - const char *err = NoteBinaryRequiredRxBuffer(&size); + WHEN("NoteBinaryRequiredRxMaxBuffer is called") { + const char *err = NoteBinaryRequiredRxMaxBuffer(&size); THEN("An error is not returned") { CHECK(err == NULL); @@ -101,8 +101,8 @@ SCENARIO("NoteBinaryRequiredRxBuffer") return rsp; }; - WHEN("NoteBinaryRequiredRxBuffer is called") { - const char *err = NoteBinaryRequiredRxBuffer(&size); + WHEN("NoteBinaryRequiredRxMaxBuffer is called") { + const char *err = NoteBinaryRequiredRxMaxBuffer(&size); THEN("An error is not returned") { CHECK(err == NULL);