68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
/*
|
|
* TestDisplay.cpp
|
|
*
|
|
* Created on: Aug 7, 2018
|
|
* Author: rhetenor
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "catch.hpp"
|
|
#include "fakeit.hpp"
|
|
|
|
#include "utility/LoggerFactory.h"
|
|
|
|
|
|
// testing purposes
|
|
#define private public
|
|
|
|
#include "Display.h"
|
|
|
|
using namespace flippR_driver::output;
|
|
using namespace fakeit;
|
|
|
|
SCENARIO("Creating a Display object", "")
|
|
{
|
|
GIVEN("Just a Display with 7 digits")
|
|
{
|
|
SevenDigitDisplay display(5,5);
|
|
WHEN("A content is set for the display")
|
|
{
|
|
std::string content_string = "1234567";
|
|
std::array<char,7> content;
|
|
std::copy(content_string.begin(), content_string.end(), content.data());
|
|
display.write_content(content);
|
|
THEN("This content should be set for the display")
|
|
{
|
|
REQUIRE(content == display.content);
|
|
}
|
|
}
|
|
WHEN("A score (12345) within the size of the display is written")
|
|
{
|
|
display.write_score(12345);
|
|
THEN("The content should look like: \" 12345\" ")
|
|
{
|
|
std::string content_string = "\0\012345";
|
|
std::array<char,7> content;
|
|
std::copy(content_string.begin(), content_string.end(), content.data());
|
|
|
|
REQUIRE(display.content == content);
|
|
}
|
|
}
|
|
WHEN("A score (12345678), which is longer than the digit is written")
|
|
{
|
|
display.write_score(12345678);
|
|
THEN("The content should look like: \"9999999\"-> highest number ")
|
|
{
|
|
std::string content_string = "9999999";
|
|
std::array<char,7> content;
|
|
std::copy(content_string.begin(), content_string.end(), content.data());
|
|
|
|
REQUIRE(display.content == content);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|