@@ -15,6 +15,22 @@ typedef enum {
1515 TAG_TWO = 2 ,
1616} Tag ;
1717
18+ struct Entry {
19+ const char * name ;
20+ enum Color color ;
21+ enum Option opt ;
22+ };
23+
24+ static enum Color global_color = GREEN ;
25+ static enum Option global_opt = OPT_B ;
26+ static Tag global_tag = TAG_TWO ;
27+
28+ static struct Entry entries [3 ] = {
29+ {"first" , RED , OPT_NONE },
30+ {"second" , GREEN , OPT_A },
31+ {"third" , BLUE , OPT_C },
32+ };
33+
1834int as_int (enum Color c ) { return c ; }
1935
2036int classify_option (int option ) {
@@ -113,5 +129,16 @@ int main() {
113129 int extra = (int )RED + (int )GREEN + (int )BLUE ;
114130 assert (extra == 0 + 1 + 2 );
115131
132+ assert (global_color == GREEN );
133+ assert (global_opt == OPT_B );
134+ assert (global_tag == TAG_TWO );
135+
136+ assert (entries [0 ].color == RED );
137+ assert (entries [0 ].opt == OPT_NONE );
138+ assert (entries [1 ].color == GREEN );
139+ assert (entries [1 ].opt == OPT_A );
140+ assert (entries [2 ].color == BLUE );
141+ assert (entries [2 ].opt == OPT_C );
142+
116143 return 0 ;
117144}
0 commit comments