-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cpp
More file actions
88 lines (76 loc) · 2.81 KB
/
Test.cpp
File metadata and controls
88 lines (76 loc) · 2.81 KB
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
79
80
81
82
83
84
85
86
87
#include "doctest.h"
#include "mat.hpp"
using namespace ariel;
#include<string>
#include <algorithm>
using namespace std;
string nospaces(string input) {
std::erase(input, ' ');
std::erase(input, '\t');
std::erase(input, '\n');
std::erase(input, '\r');
return input;
}
//Good input
TEST_CASE("basic case ") {
CHECK(nospaces(mat(1, 1, '@', '-')) == nospaces("@"));}
TEST_CASE("odd number ") {
CHECK(nospaces(mat(9, 7, '@', '-')) == nospaces( "@@@@@@@@@\n"
"@-------@\n"
"@-@@@@@-@\n"
"@-@---@-@\n"
"@-@@@@@-@\n"
"@-------@\n"
"@@@@@@@@@"));
CHECK(nospaces(mat(5, 9, '$', '#')) == nospaces("$$$$$\n"
"$###$\n"
"$#$#$\n"
"$#$#$\n"
"$#$#$\n"
"$#$#$\n"
"$#$#$\n"
"$###$\n"
"$$$$$"));
CHECK(nospaces(mat(5, 1, '@', '-')) == nospaces("@@@@@\n"));
CHECK(nospaces(mat(3, 3, '@', '-')) == nospaces("@@@\n"
"@-@\n"
"@@@"));}
TEST_CASE("Various signs") {
CHECK(nospaces(mat(1, 5, '+', '-')) == nospaces( "@\n"
"@\n"
"@\n"
"@\n"
"@\n"));
CHECK(nospaces(mat(3, 3, '@', '@')) == nospaces("@@@\n"
"@@@\n"
"@@@"));}
TEST_CASE("Same length") {
string a = nospaces(mat(3, 5, '$', '+'));
CHECK(a.length() == 15);
}
//Bad input
TEST_CASE("not char") {
CHECK_THROWS(mat(10, 10, 1, 4));
CHECK_THROWS(mat(2, 1, '$', 2));
CHECK_THROWS(mat(1, 2, 4, '%'));
}
TEST_CASE("non positive numbers") {
CHECK_THROWS(mat(0, 0, '$', '%'));
CHECK_THROWS(mat(-1, 2, '$', '%'));
CHECK_THROWS(mat(0, -8, '$', '%'));
CHECK_THROWS(mat(-1, -8, '$', '%'));
}
TEST_CASE("not numbers") {
CHECK_THROWS(mat( '$', '%', '$', '%'));
CHECK_THROWS(mat( '$', 1, '$', '%'));
CHECK_THROWS(mat( 1, '%', '$', '%'));
}
TEST_CASE("even numbers") {
CHECK_THROWS(mat(8, 8, '$', '%'));
CHECK_THROWS(mat(2, 1, '$', '%'));
CHECK_THROWS(mat(1, 2, '$', '%'));
}
TEST_CASE("Difrent length") {
string a = nospaces(mat(3, 5, '$', '+'));
CHECK(a.length() == 16 );
}