diff --git a/src/tests/test_ltr_asymmetric.cpp b/src/tests/test_ltr_asymmetric.cpp index 8f9eb1f..caaffc3 100644 --- a/src/tests/test_ltr_asymmetric.cpp +++ b/src/tests/test_ltr_asymmetric.cpp @@ -6,7 +6,7 @@ using std::string; #include -SCENARIO("ltr_asymmetric") +SCENARIO("ltr_asymmetric: Correct placement") { GIVEN("An identicon instance with 2x2 dots") { @@ -86,3 +86,80 @@ SCENARIO("ltr_asymmetric") } } } + +SCENARIO("ltr_asymmetric: Correct color") +{ + GIVEN("An identicon instance with 5 foreground colors") + { + Identiconpp identicon(1, 1, Identiconpp::algorithm::ltr_asymmetric, + "ffffffff", + { + "ff0000ff", + "ffff00ff", + "00ff00ff", + "00ffffff", + "0000ffff" + }); + Magick::Image img; + Magick::Color white("#ffffffff"); + Magick::Color red("#ff0000ff"); + Magick::Color yellow("#ffff00ff"); + Magick::Color green("#00ff00ff"); + Magick::Color cyan("#00ffffff"); + Magick::Color blue("#0000ffff"); + + WHEN("Digest is \"0\"") + { // 0000 + img = identicon.generate("0", 1); + THEN("Is white") + { + REQUIRE(img.pixelColor(0, 0) == white); + } + } + + WHEN("Digest is \"8\"") + { // 1000 + img = identicon.generate("8", 1); + THEN("Is red") + { + REQUIRE(img.pixelColor(0, 0) == red); + } + } + + WHEN("Digest is \"9\"") + { // 1001 + img = identicon.generate("9", 1); + THEN("Is yellow") + { + REQUIRE(img.pixelColor(0, 0) == yellow); + } + } + + WHEN("Digest is \"a\"") + { // 1010 + img = identicon.generate("a", 1); + THEN("Is green") + { + REQUIRE(img.pixelColor(0, 0) == green); + } + } + + WHEN("Digest is \"b\"") + { // 1011 + img = identicon.generate("b", 1); + THEN("Is cyan") + { + REQUIRE(img.pixelColor(0, 0) == cyan); + } + } + + WHEN("Digest is \"c\"") + { // 1100 + img = identicon.generate("c", 1); + THEN("Is blue") + { + REQUIRE(img.pixelColor(0, 0) == blue); + } + } + } +} diff --git a/src/tests/test_ltr_symmetric.cpp b/src/tests/test_ltr_symmetric.cpp index 0580e12..d176705 100644 --- a/src/tests/test_ltr_symmetric.cpp +++ b/src/tests/test_ltr_symmetric.cpp @@ -6,7 +6,7 @@ using std::string; #include -SCENARIO("ltr_symmetric") +SCENARIO("ltr_symmetric: Correct placement") { GIVEN("An identicon instance with 2x2 dots") { @@ -86,3 +86,80 @@ SCENARIO("ltr_symmetric") } } } + +SCENARIO("ltr_symmetric: Correct color") +{ + GIVEN("An identicon instance with 5 foreground colors") + { + Identiconpp identicon(1, 1, Identiconpp::algorithm::ltr_symmetric, + "ffffffff", + { + "ff0000ff", + "ffff00ff", + "00ff00ff", + "00ffffff", + "0000ffff" + }); + Magick::Image img; + Magick::Color white("#ffffffff"); + Magick::Color red("#ff0000ff"); + Magick::Color yellow("#ffff00ff"); + Magick::Color green("#00ff00ff"); + Magick::Color cyan("#00ffffff"); + Magick::Color blue("#0000ffff"); + + WHEN("Digest is \"0\"") + { // 0000 + img = identicon.generate("0", 1); + THEN("Is white") + { + REQUIRE(img.pixelColor(0, 0) == white); + } + } + + WHEN("Digest is \"8\"") + { // 1000 + img = identicon.generate("8", 1); + THEN("Is red") + { + REQUIRE(img.pixelColor(0, 0) == red); + } + } + + WHEN("Digest is \"9\"") + { // 1001 + img = identicon.generate("9", 1); + THEN("Is yellow") + { + REQUIRE(img.pixelColor(0, 0) == yellow); + } + } + + WHEN("Digest is \"a\"") + { // 1010 + img = identicon.generate("a", 1); + THEN("Is green") + { + REQUIRE(img.pixelColor(0, 0) == green); + } + } + + WHEN("Digest is \"b\"") + { // 1011 + img = identicon.generate("b", 1); + THEN("Is cyan") + { + REQUIRE(img.pixelColor(0, 0) == cyan); + } + } + + WHEN("Digest is \"c\"") + { // 1100 + img = identicon.generate("c", 1); + THEN("Is blue") + { + REQUIRE(img.pixelColor(0, 0) == blue); + } + } + } +} diff --git a/src/tests/test_sigil.cpp b/src/tests/test_sigil.cpp index 1d710fe..2a9a06a 100644 --- a/src/tests/test_sigil.cpp +++ b/src/tests/test_sigil.cpp @@ -6,7 +6,7 @@ using std::string; #include -SCENARIO("sigil") +SCENARIO("sigil: Correct placement") { GIVEN("An identicon instance with 2x2 dots") { @@ -86,3 +86,80 @@ SCENARIO("sigil") } } } + +SCENARIO("sigil: Correct color") +{ + GIVEN("An identicon instance with 5 foreground colors") + { + Identiconpp identicon(1, 1, Identiconpp::algorithm::sigil, + "ffffffff", + { + "ff0000ff", + "ffff00ff", + "00ff00ff", + "00ffffff", + "0000ffff" + }); + Magick::Image img; + Magick::Color white("#ffffffff"); + Magick::Color red("#ff0000ff"); + Magick::Color yellow("#ffff00ff"); + Magick::Color green("#00ff00ff"); + Magick::Color cyan("#00ffffff"); + Magick::Color blue("#0000ffff"); + + WHEN("Digest is \"000\"") + { // 0000 0000 0000 + img = identicon.generate("000", 1); + THEN("Is white") + { + REQUIRE(img.pixelColor(0, 0) == white); + } + } + + WHEN("Digest is \"008\"") + { // 0000 0000 1000 + img = identicon.generate("008", 1); + THEN("Is red") + { + REQUIRE(img.pixelColor(0, 0) == red); + } + } + + WHEN("Digest is \"108\"") + { // 0001 0000 1000 + img = identicon.generate("108", 1); + THEN("Is yellow") + { + REQUIRE(img.pixelColor(0, 0) == yellow); + } + } + + WHEN("Digest is \"208\"") + { // 0010 0000 1000 + img = identicon.generate("208", 1); + THEN("Is green") + { + REQUIRE(img.pixelColor(0, 0) == green); + } + } + + WHEN("Digest is \"308\"") + { // 0011 0000 1000 + img = identicon.generate("308", 1); + THEN("Is cyan") + { + REQUIRE(img.pixelColor(0, 0) == cyan); + } + } + + WHEN("Digest is \"408\"") + { // 0100 0000 1000 + img = identicon.generate("408", 1); + THEN("Is blue") + { + REQUIRE(img.pixelColor(0, 0) == blue); + } + } + } +}