-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_tests.cpp
124 lines (109 loc) · 5.55 KB
/
generate_tests.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
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
/*
CS373 Spring 2023 Programming Assignment 4 Test Case Generator
by James Lefer
*/
#include <iostream>
#include <fstream>
#include <random>
#include <bitset>
#include <chrono>
#define CASES_PER_SET 10
int main(int argc, char const *argv[]){
std::ofstream output("test_cases.txt"/*, std::ios_base::app*/);
std::mt19937_64 rng( static_cast<unsigned int>( std::chrono::steady_clock::now().time_since_epoch().count() ) );
unsigned long long firsthalf;
unsigned long long secondhalf;
// reject because x = y
output << "Set0r\n";
for(auto i = 0; i < CASES_PER_SET; i++){
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << '\n';
}
// reject because x != y but xi != yi for every 1 <= i <= |x| (|x| == |y|)
output << "\nSet1r\n";
for(auto i = 0; i < CASES_PER_SET; i++){
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>(~firsthalf) << std::bitset<64>(~secondhalf) << '\n';
}
// reject because x != y but xi != yi for every 1 <= i <= |x| (|x| < |y|)
output << "\nSet2r\n";
for(auto i = 0; i < CASES_PER_SET; i++){
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>(~firsthalf) << std::bitset<64>(~secondhalf) << std::bitset<5>(secondhalf) << '\n';
}
// reject because x != y but xi != yi for every 1 <= i <= |y| (|x| > |y|)
output << "\nSet3r\n";
for(auto i = 0; i < CASES_PER_SET; i++){
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << std::bitset<5>(secondhalf);
output << '#' << std::bitset<64>(~firsthalf) << std::bitset<64>(~secondhalf) << '\n';
}
// accept where |x| == |y|
output << "\nSet4a\n";
for(auto i = 0; i < CASES_PER_SET / 2; i++){ // xi != yi for a singular i
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>(firsthalf ^ (1 << (firsthalf % 64))) << std::bitset<64>(secondhalf) << '\n';
}
for(auto i = 0; i < CASES_PER_SET / 2; i++){ // xi == yi for a singular i
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>((~firsthalf) ^ (1 << (firsthalf % 64))) << std::bitset<64>(~secondhalf) << '\n';
}
// accept where |x| < |y|
output << "\nSet5a\n";
for(auto i = 0; i < CASES_PER_SET / 2; i++){ // xi != yi for a singular i
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>(firsthalf ^ (1 << (firsthalf % 64))) << std::bitset<64>(secondhalf) << std::bitset<5>(secondhalf) << '\n';
}
for(auto i = 0; i < CASES_PER_SET / 2; i++){ // xi == yi for a singular i
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>((~firsthalf) ^ (1 << (firsthalf % 64))) << std::bitset<64>(~secondhalf) << std::bitset<5>(secondhalf) << '\n';
}
// accept where |x| < |y|, xi == xi for every 1 <= i <= |x|
output << "\nSet6a\n";
for(auto i = 0; i < CASES_PER_SET; i++){
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf);
output << '#' << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << std::bitset<5>(secondhalf) << '\n';
}
// accept where |x| > |y|
output << "\nSet7a\n";
for(auto i = 0; i < CASES_PER_SET / 2; i++){ // xi != yi for a singular i
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << std::bitset<5>(secondhalf);
output << '#' << std::bitset<64>(firsthalf ^ (1 << (firsthalf % 64))) << std::bitset<64>(secondhalf) << '\n';
}
for(auto i = 0; i < CASES_PER_SET / 2; i++){ // xi == yi for a singular i
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << std::bitset<5>(secondhalf);
output << '#' << std::bitset<64>((~firsthalf) ^ (1 << (firsthalf % 64))) << std::bitset<64>(~secondhalf) << '\n';
}
// accept where |x| > |y|, xi == xi for every 1 <= i <= |y|
output << "\nSet8a\n";
for(auto i = 0; i < CASES_PER_SET; i++){
firsthalf = static_cast<unsigned long long>(rng());
secondhalf = static_cast<unsigned long long>(rng());
output << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << std::bitset<5>(secondhalf);
output << '#' << std::bitset<64>(firsthalf) << std::bitset<64>(secondhalf) << '\n';
}
output.flush();
output.close();
return 0;
}