This repository was archived by the owner on Jan 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
129 lines (112 loc) · 4.66 KB
/
main.cpp
File metadata and controls
129 lines (112 loc) · 4.66 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
#include "Fraction.h"
#include <cassert>
void test_equals(const Fraction &a, const Fraction &b);
void test_smallerEqual(const Fraction &a, const Fraction &b);
void test_smaller(const Fraction &a, const Fraction &b);
void test_largerEqual(const Fraction &a, const Fraction &b);
void test_larger(const Fraction &a, const Fraction &b);
void test_addEquals(const Fraction &a, const Fraction &b, const Fraction &result);
void test_subtractEquals(const Fraction &a, const Fraction &b, const Fraction &result);
void test_multiplyEquals(const Fraction &a, const Fraction &b, const Fraction &result);
void test_divideEquals(const Fraction &a, const Fraction &b, const Fraction &result);
void test_prefixIncrement(const Fraction &a, const Fraction &result);
void test_postfixIncrement(const Fraction &a, const Fraction &result);
void test_prefixDecrement(const Fraction &a, const Fraction &result);
void test_postfixDecrement(const Fraction &a, const Fraction &result);
void test_add(const Fraction &a, const Fraction &b, const Fraction &result);
void test_subtract(const Fraction &a, const Fraction &b, const Fraction &result);
void test_multiply(const Fraction &a, const Fraction &b, const Fraction &result);
void test_divide(const Fraction &a, const Fraction &b, const Fraction &result);
void test_invert(const Fraction &a, const Fraction &result);
void test_io();
int main () {
test_equals(Fraction(99, 63), Fraction(99, 63));
test_smallerEqual(Fraction(11, 56), Fraction(11, 56));
test_smaller(Fraction(15, 38), Fraction(15, 37));
test_largerEqual(Fraction(74, 21), Fraction(74, 21));
test_larger(Fraction(24, 10), Fraction(24, 11));
test_addEquals(Fraction(82, 108), Fraction(8, 27), Fraction(19, 18));
test_subtractEquals(Fraction(82, 108), Fraction(8, 27), Fraction(25,54));
test_multiplyEquals(Fraction(52, 44), Fraction(20, 81), Fraction(260, 891));
test_divideEquals(Fraction(54, 86), Fraction(52, 43), Fraction(27, 52));
test_prefixIncrement(Fraction(78, 20), Fraction(98, 20));
test_postfixIncrement(Fraction(78, 20), Fraction(98, 20));
test_prefixDecrement(Fraction(82, 67), Fraction(15, 67));
test_postfixDecrement(Fraction(82, 67), Fraction(15, 67));
test_add(Fraction(82, 108), Fraction(8, 27), Fraction(19, 18));
test_subtract(Fraction(82, 108), Fraction(8, 27), Fraction(25,54));
test_multiply(Fraction(52, 44), Fraction(20, 81), Fraction(260, 891));
test_divide(Fraction(54, 86), Fraction(52, 43), Fraction(27, 52));
test_invert(Fraction(14, 95), Fraction(95, 14));
test_io();
}
void test_equals(const Fraction &a, const Fraction &b) {
assert(a == b);
}
void test_smallerEqual(const Fraction &a, const Fraction &b) {
assert(a <= b);
}
void test_smaller(const Fraction &a, const Fraction &b) {
assert(a < b);
}
void test_largerEqual(const Fraction &a, const Fraction &b) {
assert(a >= b);
}
void test_larger(const Fraction &a, const Fraction &b) {
assert(a > b);
}
void test_addEquals(const Fraction &a, const Fraction &b, const Fraction &result) {
Fraction temp(a);
assert((temp += b) == result);
}
void test_subtractEquals(const Fraction &a, const Fraction &b, const Fraction &result) {
Fraction temp(a);
assert((temp -= b) == result);
}
void test_multiplyEquals(const Fraction &a, const Fraction &b, const Fraction &result) {
Fraction temp(a);
assert((temp *= b) == result);
}
void test_divideEquals(const Fraction &a, const Fraction &b, const Fraction &result) {
Fraction temp(a);
assert((temp /= b) == result);
}
void test_prefixIncrement(const Fraction &a, const Fraction &result) {
Fraction temp(a);
assert(++temp == result);
}
void test_postfixIncrement(const Fraction &a, const Fraction &result) {
Fraction temp(a);
temp++;
assert(temp == result);
}
void test_prefixDecrement(const Fraction &a, const Fraction &result) {
Fraction temp(a);
assert(--temp == result);
}
void test_postfixDecrement(const Fraction &a, const Fraction &result) {
Fraction temp(a);
temp--;
assert(temp == result);
}
void test_add(const Fraction &a, const Fraction &b, const Fraction &result) {
assert(a + b == result);
}
void test_subtract(const Fraction &a, const Fraction &b, const Fraction &result) {
assert(a - b == result);
}
void test_multiply(const Fraction &a, const Fraction &b, const Fraction &result) {
assert(a * b == result);
}
void test_divide(const Fraction &a, const Fraction &b, const Fraction &result) {
assert(a / b == result);
}
void test_invert(const Fraction &a, const Fraction &result) {
assert(~a == result);
}
void test_io() {
std::cout << "IO Tests" << std::endl;
Fraction x;
std::cin >> x;
std::cout << std::endl << x << std::endl;
}