Increased test coverage

This commit is contained in:
Benoit Blanchon
2021-09-10 08:40:02 +02:00
parent 6a71f31820
commit e0cd5b6405
9 changed files with 147 additions and 49 deletions

View File

@ -15,6 +15,11 @@ static size_t print(StringWriter& writer, const char* s) {
return writer.write(reinterpret_cast<const uint8_t*>(s), strlen(s));
}
template <typename StringWriter>
static size_t print(StringWriter& writer, char c) {
return writer.write(static_cast<uint8_t>(c));
}
template <typename StringWriter, typename String>
void common_tests(StringWriter& writer, const String& output) {
SECTION("InitialState") {
@ -47,6 +52,7 @@ TEST_CASE("StaticStringWriter") {
SECTION("OverCapacity") {
REQUIRE(20 == print(writer, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
REQUIRE(0 == print(writer, "ABC"));
REQUIRE(0 == print(writer, 'D'));
REQUIRE("ABCDEFGHIJKLMNOPQRST" == std::string(output, 20));
}
}