From 55de1440506e74e454519b7bf7e62f01aceab8eb Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 2 Jan 2019 11:21:54 +0100 Subject: [PATCH] Added color format tests. --- src/tests/test_crash.cpp | 77 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/src/tests/test_crash.cpp b/src/tests/test_crash.cpp index b24b14b..9425017 100644 --- a/src/tests/test_crash.cpp +++ b/src/tests/test_crash.cpp @@ -60,6 +60,24 @@ SCENARIO("Please do not crash") REQUIRE(exception == false); } } + + WHEN("colors with uppercase hex digits") + { + try + { + Identiconpp identicon(1, 1, Identiconpp::algorithm::sigil, + "FF00FFFF"); + identicon.generate(digest); + } + catch (const std::exception &e) + { + exception = true; + } + THEN("Does not crash") + { + REQUIRE(exception == false); + } + } } } @@ -181,7 +199,64 @@ SCENARIO("Please crash") { Identiconpp identicon(1, 1, Identiconpp::algorithm::ltr_symmetric, - "ffffffff", { "000000f"}); + "ffffffff", { "000000f" }); + identicon.generate(digest); + } + catch (const std::exception &e) + { + exception = true; + } + THEN("Crashes") + { + REQUIRE(exception == true); + } + } + + WHEN("No foreground color") + { + try + { + Identiconpp identicon(1, 1, + Identiconpp::algorithm::ltr_symmetric, + "ffffffff", {}); + identicon.generate(digest); + } + catch (const std::exception &e) + { + exception = true; + } + THEN("Crashes") + { + REQUIRE(exception == true); + } + } + + WHEN("Non-hex digits in background color") + { + try + { + Identiconpp identicon(1, 1, + Identiconpp::algorithm::ltr_symmetric, + "ffffffgf"); + identicon.generate(digest); + } + catch (const std::exception &e) + { + exception = true; + } + THEN("Crashes") + { + REQUIRE(exception == true); + } + } + + WHEN("Non-hex digits in foreground color") + { + try + { + Identiconpp identicon(1, 1, + Identiconpp::algorithm::ltr_symmetric, + "ffffffff", { "g00000ff" }); identicon.generate(digest); } catch (const std::exception &e)