Added crash / don't crash tests.
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
ddd55f6221
commit
4b198ccd58
|
@ -0,0 +1,197 @@
|
||||||
|
#include <catch.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
#include <vector>
|
||||||
|
#include <Magick++/Image.h>
|
||||||
|
#include "identiconpp.hpp"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
SCENARIO("Please do not crash")
|
||||||
|
{
|
||||||
|
GIVEN("The digest: sha256(test@example.com)")
|
||||||
|
{
|
||||||
|
string digest = "973dfe463ec85785f5f95af5ba3906ee"
|
||||||
|
"db2d931c24e69824a89ea65dba4e813b";
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
WHEN("256 bits of entropy is required")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Identiconpp identicon(18, 28,
|
||||||
|
Identiconpp::algorithm::ltr_symmetric,
|
||||||
|
"ffffffff",
|
||||||
|
{
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff"
|
||||||
|
});
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Does not crash")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("sigil is fed exactly 8 bit of colors")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::vector<string> colors(256, "000000ff");
|
||||||
|
Identiconpp identicon(1, 1,
|
||||||
|
Identiconpp::algorithm::sigil,
|
||||||
|
"ffffffff", colors);
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Does not crash")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCENARIO("Please crash")
|
||||||
|
{
|
||||||
|
GIVEN("The digest: sha256(test@example.com)")
|
||||||
|
{
|
||||||
|
string digest = "973dfe463ec85785f5f95af5ba3906ee"
|
||||||
|
"db2d931c24e69824a89ea65dba4e813b";
|
||||||
|
bool exception = false;
|
||||||
|
|
||||||
|
WHEN("257 bits of entropy is required")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Identiconpp identicon(18, 28,
|
||||||
|
Identiconpp::algorithm::ltr_symmetric,
|
||||||
|
"ffffffff",
|
||||||
|
{
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff", "000000ff", "000000ff",
|
||||||
|
"000000ff"
|
||||||
|
});
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Crashes")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("sigil is fed more than 8 bit of colors")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::vector<string> colors(257, "000000ff");
|
||||||
|
Identiconpp identicon(1, 1,
|
||||||
|
Identiconpp::algorithm::sigil,
|
||||||
|
"ffffffff", colors);
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Crashes")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("background color has too many digits")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Identiconpp identicon(1, 1,
|
||||||
|
Identiconpp::algorithm::ltr_symmetric,
|
||||||
|
"ffffffffa");
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Crashes")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("background color has not enough digits")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Identiconpp identicon(1, 1,
|
||||||
|
Identiconpp::algorithm::ltr_symmetric,
|
||||||
|
"fffffff");
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Crashes")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("Foreground color has too many digits")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Identiconpp identicon(1, 1,
|
||||||
|
Identiconpp::algorithm::ltr_symmetric,
|
||||||
|
"ffffffff", { "000000ffa"});
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Crashes")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("Foreground color has not enough digits")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Identiconpp identicon(1, 1,
|
||||||
|
Identiconpp::algorithm::ltr_symmetric,
|
||||||
|
"ffffffff", { "000000f"});
|
||||||
|
identicon.generate(digest);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
THEN("Crashes")
|
||||||
|
{
|
||||||
|
REQUIRE(exception == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
#include "identiconpp.hpp"
|
#include "identiconpp.hpp"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
SCENARIO("ltr_asymmetric: Correct placement")
|
SCENARIO("ltr_asymmetric: Correct placement")
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "identiconpp.hpp"
|
#include "identiconpp.hpp"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
SCENARIO("ltr_symmetric: Correct placement")
|
SCENARIO("ltr_symmetric: Correct placement")
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "identiconpp.hpp"
|
#include "identiconpp.hpp"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
SCENARIO("sigil: Correct placement")
|
SCENARIO("sigil: Correct placement")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue