Added color tests
This commit is contained in:
parent
dbb15bee87
commit
4e5397a2a2
|
@ -6,7 +6,7 @@
|
|||
using std::string;
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
using std::string;
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
using std::string;
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue