forked from jboydt/cinreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanual_test.cpp
More file actions
135 lines (122 loc) · 2.76 KB
/
manual_test.cpp
File metadata and controls
135 lines (122 loc) · 2.76 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// -- Andrew Mattly --
// 2/13/20 - xx/xx/xx
// Test functions for cinreader.hpp
// Manual check for cinreader allowing for inputs in every function.
#include <iostream>
#include <string>
#include <sstream>
#include "cinreader.hpp"
using namespace std;
void test_bool();
void test_char();
void test_double();
void test_float();
void test_integer();
void test_string();
void test_stream_string();
int main(){
test_bool();
test_char();
test_double();
test_float();
test_integer();
test_stream_string();
return 0;
}
void test_bool(){
CinReader reader;
cout << "testing bool: " <<endl;
bool bool1 = reader.readBool();
cout << "bool is: " << bool1 << endl;
}
void test_char(){
cout << "testing char: "<< endl;
CinReader reader;
bool loop(true);
char test_c = 'a';
while(loop){
cout <<"type 'z' to end loop" << endl;
test_c = reader.readChar();
cout << "char is: " << test_c << endl;
if(test_c == 'z'){
cout << "exiting" << endl;
loop = false;
}
}
}
void test_double(){
cout << "testing double: " << endl;
CinReader reader;
bool loop(true);
double test_d;
while(loop){
cout << "type 1.11 to end loop" << endl;
test_d = reader.readDouble();
cout << "double is: " << test_d << endl;
if(test_d == 1.11){
cout << "exiting double loop" << endl;
loop= false;
}
}
}
void test_float(){
cout << "testing float: " << endl;
CinReader reader;
bool loop(true);
float test_f;
while(loop){
cout << "type 2.22 to end loop" << endl;
test_f = reader.readFloat();
cout << "float is: " << test_f << endl;
if(test_f == 2.22f){
cout << "ending float loop" << endl;
loop = false;
}
}
}
void test_integer(){
CinReader reader;
cout << "testing integer: " << endl;
bool loop(true);
int test_i;
while(loop){
cout << "type 0 to end loop" << endl;
test_i = reader.readInt();
cout << "integer is: " << test_i << endl;
if(test_i == 0){
cout << "ending int loop" << endl;
loop = false;
}
}
}
void test_string(){
cout << "testing string: " << endl;
CinReader reader;
bool loop(true);
string test_s;
while(loop){
cout << "type 'null' to end loop" << endl;
test_s = reader.readString();
cout << "string is: " << test_s << endl;
if(test_s == "null"){
cout << "ending string loop" << endl;
loop = false;
}
}
}
void test_stream_string(){
cout << "testing string stream operation" << endl;
CinReader reader;
bool loop(true);
string test_s1;
string test_s2;
while(loop){
cout << "type 'null' to end loop" << endl;
reader >> test_s2;
cout << "string is: " << test_s2 << endl;
if(test_s2 == "null"){
cout << "ending string loop" << endl;
loop = false;
}
}
}