-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.cpp
78 lines (71 loc) · 3.16 KB
/
Test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "doctest.h"
#include "snowman.hpp"
using namespace ariel;
#include <string>
#include <algorithm>
using namespace std;
/**
* Returns the input string without the whitespace characters: space, newline and tab.
* Requires std=c++2a.
*/
string nospaces(string input) {
std::erase(input, ' ');
std::erase(input, '\t');
std::erase(input, '\n');
std::erase(input, '\r');
return input;
}
TEST_CASE("Good snowman code") {
CHECK(nospaces(snowman(11114411)) == nospaces("_===_\n(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(21114411)) == nospaces(" ___ \n.....\n(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(31114411)) == nospaces(" _ \n /_\\\n(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(41114411)) == nospaces(" ___ \n(_*_)\n(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(12114411)) == nospaces("_===_\n(...)\n( : )\n( : )"));
CHECK(nospaces(snowman(13114411)) == nospaces("_===_\n(._.)\n( : )\n( : )"));
CHECK(nospaces(snowman(14114411)) == nospaces("_===_\n(. .)\n( : )\n( : )"));
CHECK(nospaces(snowman(11214411)) == nospaces("_===_\n(o,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(11314411)) == nospaces("_===_\n(O,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(11414411)) == nospaces("_===_\n(-,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(11124411)) == nospaces("_===_\n(.,o)\n( : )\n( : )"));
CHECK(nospaces(snowman(11134411)) == nospaces("_===_\n(.,O)\n( : )\n( : )"));
CHECK(nospaces(snowman(11144411)) == nospaces("_===_\n(.,-)\n( : )\n( : )"));
CHECK(nospaces(snowman(11112411)) == nospaces("_===_\n\\(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(11113411)) == nospaces("_===_\n(.,.)\n/( : )\n( : )"));
CHECK(nospaces(snowman(11114411)) == nospaces("_===_\n(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(11114211)) == nospaces("_===_\n(.,.)/\n( : )\n( : )"));
CHECK(nospaces(snowman(11114311)) == nospaces("_===_\n(.,.)\n( : )\\n( : )"));
CHECK(nospaces(snowman(11114411)) == nospaces("_===_\n(.,.)\n( : )\n( : )"));
CHECK(nospaces(snowman(11114421)) == nospaces("_===_\n(.,.)\n(] [)\n( : )"));
CHECK(nospaces(snowman(11114431)) == nospaces("_===_\n(.,.)\n(> <)\n( : )"));
CHECK(nospaces(snowman(11114441)) == nospaces("_===_\n(.,.)\n( )\n( : )"));
CHECK(nospaces(snowman(11114412)) == nospaces("_===_\n(.,.)\n( : )\n(" ")"));
CHECK(nospaces(snowman(11114413)) == nospaces("_===_\n(.,.)\n( : )\n(___)"));
CHECK(nospaces(snowman(11114414)) == nospaces("_===_\n(.,.)\n( : )\n( )"));
/* Add more checks here */
}
TEST_CASE("Wrong amount of digits") {
CHECK_THROWS(snowman(1));
CHECK_THROWS(snowman(22));
CHECK_THROWS(snowman(333));
CHECK_THROWS(snowman(4444));
CHECK_THROWS(snowman(11111));
CHECK_THROWS(snowman(222222));
CHECK_THROWS(snowman(3333333));
CHECK_THROWS(snowman(111111111));
/* Add more checks here */
}
TEST_CASE("Negative digit") {
CHECK_THROWS(snowman(-1));
CHECK_THROWS(snowman(122-43333));
CHECK_THROWS(snowman(1111111-1));
}
TEST_CASE("Wrong digit") {
CHECK_THROWS(snowman(51111111));
CHECK_THROWS(snowman(19111111));
CHECK_THROWS(snowman(11711111));
CHECK_THROWS(snowman(11161111));
CHECK_THROWS(snowman(11118111));
CHECK_THROWS(snowman(11111011));
CHECK_THROWS(snowman(11111151));
CHECK_THROWS(snowman(11111118));
}