-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (37 loc) · 1.36 KB
/
main.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
#include "decimal.h"
int main() {
/*To test multiplication replace lines 26-33 with below and file name to decimal_multiplication_test.txt
std::stringstream linestream(line);
std::string decimal1, decimal2, result;
uint32_t scale_decimal1, scale_decimal2, scale_result;
linestream >> decimal1 >> scale_decimal1 >> decimal2 >> scale_decimal2 >> result >> scale_result;
Decimal d_1(decimal1, scale_decimal1);
Decimal d_2(decimal2, scale_decimal2);
Decimal d(result, scale_result);
d_1.SignedMultiplyWithDecimal(d_2, scale_decimal1);
*/
std::ifstream infile("decimal_division_test.txt");
if (!infile.is_open()) {
std::cout<<"exited before file opening";
return 0;
}
std::cout<<"file opened testing started";
int count = 0;
std::string line;
while (std::getline(infile, line)) {
std::stringstream linestream(line);
std::string decimal1, decimal2, result;
unsigned scale_decimal1, scale_decimal2, scale_result;
linestream >> decimal1 >> scale_decimal1 >> decimal2 >> scale_decimal2 >> result >> scale_result;
Decimal d_1(decimal1, scale_decimal1);
Decimal d_2(decimal2, scale_decimal2);
Decimal d(result, scale_result);
d_1.SignedDivideWithDecimal(d_2, scale_decimal2);
if(d==d_1) {
count++;
} else {
std::cout<<"found mismatch";
}
}
std::cout<<count<<" no of tests verified";
}