Added tests for DeserializationError::f_str()

This commit is contained in:
Benoit Blanchon
2020-09-18 09:37:59 +02:00
parent 6a878ee444
commit c3504ddf0a
4 changed files with 48 additions and 12 deletions

View File

@ -165,3 +165,22 @@ TEST_CASE("Reader<const __FlashStringHelper*>") {
REQUIRE(buffer[6] == 'g');
}
}
static void testStringification(DeserializationError error,
std::string expected) {
const __FlashStringHelper* s = error.f_str();
CHECK(reinterpret_cast<const char*>(convertFlashToPtr(s)) == expected);
}
#define TEST_STRINGIFICATION(symbol) \
testStringification(DeserializationError::symbol, #symbol)
TEST_CASE("DeserializationError::f_str()") {
TEST_STRINGIFICATION(Ok);
TEST_STRINGIFICATION(EmptyInput);
TEST_STRINGIFICATION(IncompleteInput);
TEST_STRINGIFICATION(InvalidInput);
TEST_STRINGIFICATION(NoMemory);
TEST_STRINGIFICATION(NotSupported);
TEST_STRINGIFICATION(TooDeep);
}