-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathenum.c
67 lines (51 loc) · 1.16 KB
/
enum.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
#include <stdio.h>
#include "tests.h"
enum number{zero, one, two, three};
enum
{
_ISupper = ((0) < 8 ? ((1 << (0)) << 8) : ((1 << (0)) >> 8)),
_ISalnum = ((11) < 8 ? ((1 << (11)) << 8) : ((1 << (11)) >> 8))
};
enum year{Jan, Feb, Mar, Apr, May, Jun, Jul,
Aug, Sep, Oct, Nov, Dec};
enum State {Working = 1, Failed = 0, Freezed = 0};
enum day {sunday = 1, monday, tuesday = 5,
wednesday, thursday = 10, friday, saturday};
enum state {WORKING = 0, FAILED, FREEZED};
enum state currState = 2;
enum state FindState() {return currState;}
// main function
int main()
{
plan(17);
// step 1
enum number n;
n = two;
is_eq(two ,2);
is_eq(n ,2);
// step 2
is_eq(_ISupper ,256);
is_eq(_ISalnum ,8 );
// step 3
for (int i=Jan; i < Feb; i++){
is_eq(i, Jan);
}
// step 4
is_eq( Working , 1);
is_eq( Failed , 0);
is_eq( Freezed , 0);
// step 5
enum day d = thursday;
is_eq( d , 10);
// step 6
is_eq( sunday , 1);
is_eq( monday , 2);
is_eq( tuesday , 5);
is_eq( wednesday , 6);
is_eq( thursday , 10);
is_eq( friday , 11);
is_eq( saturday , 12);
// step 7
is_eq( FindState() , FREEZED);
done_testing();
}