-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.c
153 lines (142 loc) · 2.52 KB
/
tests.c
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
unsigned fibonacci(unsigned num, unsigned arg1, unsigned arg2)
{
if(!num) return arg1;
--num;
return fibonacci(num, arg2, arg1+arg2);
}
long test(long testno, long arg1, long arg2)
{
int res = 0xC0DEDBAD;
int i1 = arg1;
int i2 = arg2;
unsigned u1 = arg1;
unsigned u2 = arg2;
float f1 = *(float*)&i1;
float f2 = *(float*)&i2;
short s1 = i1;
short s2 = i2;
signed char c1 = i1;
signed char c2 = i2;
float fres;
switch(testno)
{
case 1:
res = i1+i2;
break;
case 2:
res = i1-i2;
break;
case 3:
res = i1&i2;
break;
case 4:
res = i1|i2;
break;
case 5:
res = i1^i2;
break;
case 6:
res = i1*i2;
break;
case 7:
res = u1*u2;
break;
case 8:
res = i1%i2;
break;
case 9:
res = u1%u2;
break;
case 10:
res = i1/i2;
break;
case 11:
res = u1/u2;
break;
case 12:
res = s1 * s2;
break;
case 13:
res = c1 * c2;
break;
case 14:
res = ~(u1);
break;
case 15:
res = u1<<u2;
break;
case 16:
res = u1>>u2;
break;
case 17:
res = i1>>i2;
break;
case 18:
res = -i1;
break;
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
res = 0;
switch(testno)
{
case 19: if (i1 == i2) res = 1; break;
case 20: if (i1 != i2) res = 1; break;
case 21: if (i1 <= i2) res = 1; break;
case 22: if (i1 >= i2) res = 1; break;
case 23: if (i1 < i2) res = 1; break;
case 24: if (i1 > i2) res = 1; break;
}
break;
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
res = 0;
switch(testno)
{
case 25: if (u1 == u2) res = 1; break;
case 26: if (u1 != u2) res = 1; break;
case 27: if (u1 <= u2) res = 1; break;
case 28: if (u1 >= u2) res = 1; break;
case 29: if (u1 < u2) res = 1; break;
case 30: if (u1 > u2) res = 1; break;
}
break;
case 31:
res = fibonacci(testno, i1, i2);
case 100:
fres = f1/f2;
break;
case 101:
fres = f1*f2;
break;
case 102:
fres = f1+f2;
break;
case 103:
fres = f1-f2;
break;
case 104:
fres = -f1;
break;
case 105: if (f1 == f2) fres = 1; else fres = 0; break;
case 106: if (f1 != f2) fres = 1; else fres = 0; break;
case 107: if (f1 <= f2) fres = 1; else fres = 0; break;
case 108: if (f1 >= f2) fres = 1; else fres = 0; break;
case 109: if (f1 < f2) fres = 1; else fres = 0; break;
case 110: if (f1 > f2) fres = 1; else fres = 0; break;
case 111:
i1 = f1; i2 = f2; fres = i1+i2; break;
default:
break;
}
if(testno>=100)
res = *(int*)&fres;
return res;
}