-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.cpp
More file actions
217 lines (181 loc) · 5.88 KB
/
Copy pathtesting.cpp
File metadata and controls
217 lines (181 loc) · 5.88 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#include <iostream>
#include <random>
#include "bigInt_t.h"
#include <string>
#include <cmath>
#include <sstream>
#include <fstream>
#include <iomanip>
const unsigned long long DF = 1000000;
// Function to generate a random integer in a given range
long long randomInt(long long min, long long max)
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<long long> dis(min, max);
return dis(gen);
}
// Function to generate a random floating-point number in a given range
double randomDouble(double min, double max)
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<double> dis(min, max);
return dis(gen);
}
void additionTest(bool W = true, bool D = true)
{
std::cin.tie(NULL);
std::cin.sync_with_stdio(false);
if(W)
{
for(unsigned long long i = 0; i < DF; ++i)
{
std::cout << "AW " << i << '/' << DF << std::endl;
long long int1 = randomInt(-500000, 500000);
long long int2 = randomInt(-500000, 500000);
long long expected = int1 + int2;
bigInt_t bigInt1 = int1;
bigInt_t bigInt2 = int2;
bigInt_t result = bigInt1 + bigInt2;
if(result != expected)
{
std::cout << "Result: " << result << std::endl << "Excepted: " << expected << std::endl;
std::cin.get();
}
}
}
if(D)
{
for (unsigned long long i = 0; i < DF; ++i)
{
std::cout << "AD " << i << '/' << DF << std::endl;
long double double1 = randomDouble(-500.000, 500.000);
long double double2 = randomDouble(-500.000, 500.000), e = double1 + double2;
bigInt_t bigInt1 = double1;
bigInt_t bigInt2 = double2;
bigInt_t result = bigInt1 + bigInt2;
}
}
}
void subtractionTest(bool W = true, bool D = true)
{
std::cin.tie(NULL);
std::cin.sync_with_stdio(false);
if(W)
{
for(unsigned long long i = 0; i < DF; ++i)
{
std::cout << "SW " << i << '/' << DF << std::endl;
long long int1 = randomInt(-500000, 500000);
long long int2 = randomInt(-500000, 500000);
long long expected = int1 - int2;
bigInt_t bigInt1 = int1;
bigInt_t bigInt2 = int2;
bigInt_t result = bigInt1 - bigInt2;
if(result != expected)
{
std::cout << "Result: " << result << std::endl << "Excepted: " << expected << std::endl;
std::cin.get();
}
}
}
if(D)
{
for(unsigned long long i = 0; i < DF; ++i)
{
std::cout << "SD " << i << '/' << DF << std::endl;
long double double1 = randomDouble(-500.0000, 500.0000);
long double double2 = randomDouble(-500.0000, 500.0000);
long double expected = double1 - double2;
bigInt_t bigInt1 = double1;
bigInt_t bigInt2 = double2;
bigInt_t result = bigInt1 - bigInt2;
}
}
}
void multiplicationTest(bool W = true, bool D = true)
{
std::cin.tie(NULL);
std::cin.sync_with_stdio(false);
std::fstream FILE1("t_1.txt"), FILE2("t_2.txt");
if(W)
{
for (unsigned long long i = 0; i < DF; ++i)
{
std::cout << "MW " << i << '/' << DF << std::endl;
long long int1 = randomInt(-500000, 500000);
long long int2 = randomInt(-500000, 500000);
long long expected = int1 * int2;
bigInt_t bigInt1 = int1;
bigInt_t bigInt2 = int2;
bigInt_t result = bigInt1 * bigInt2;
if(result != expected)
{
std::cout << "Result: " << result << std::endl << "Excepted: " << expected << std::endl;
std::cin.get();
}
}
}
if(D)
{
for(unsigned long long i = 0; i < DF; ++i)
{
std::cout << "MD " << i << '/' << DF << std::endl;
long double double1 = randomDouble(-500.000, 500.000);
long double double2 = randomDouble(-500.000, 500.000);
long double expected = double(double1 * double2);
bigInt_t bigInt1 = double1;
bigInt_t bigInt2 = double2;
bigInt_t result = bigInt1 * bigInt2;
}
}
}
void divisionTest(bool W = true, bool D = true)
{
std::cin.tie(NULL);
std::cin.sync_with_stdio(false);
if(W)
{
for(unsigned long long i = 0; i < DF; ++i)
{
std::cout << "DW " << i << '/' << DF << " ";
long long int1 = randomInt(-500000, 500000);
long long int2 = randomInt(-500000, 500000); // Avoid division by zero
long double expected = int1 / int2;
if(int1 == 0 || int2 == 0) continue;
bigInt_t bigInt1 = int1;
bigInt_t bigInt2 = int2;
bigInt_t result = bigInt1 / bigInt2;
}
}
if(D)
{
for(unsigned long long i = 0; i < DF; ++i)
{
std::cout << "DD " << i << '/' << DF << std::endl;
long double double1 = randomDouble(-500.000, 500.000);
long double double2 = randomDouble(-500.000, 500.000);
if(double1 == 0 || double2 == 0) continue;
double1 /= double2;
bigInt_t bigInt1 = double1;
bigInt_t bigInt2 = double2;
bigInt_t result = bigInt1 / bigInt2;
}
}
}
template<typename T>
std::string toString(const T num)
{
std::ostringstream S;
S << num;
std::string str = S.str();
return str;
}
int main()
{
std::cin.sync_with_stdio(false);
std::cin.tie(0);
system("pause");
return 0;
}