source: tests/enum_tests/input.cfa@ a17f496

Last change on this file since a17f496 was 1e28e05, checked in by Peter A. Buhr <pabuhr@…>, 4 months ago

update enumerator input test

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#include <fstream.hfa>
2
3int main() {
4 { // enumerators small to large
5 enum(int) E { B, AB, AA, AAA, BBB };
6 E e;
7
8 try {
9 for ( 14 ) { // eums in input
10 try {
11 sin | e;
12 } catch( missing_data * ) {
13 sout | "missing data";
14 continue; // try again
15 } // try
16 sout | e | nonl;
17 } // for
18 } catch( end_of_file * ) {
19 abort( "enum test failure" );
20 } // try
21 sout | nl;
22 }
23 sout | nl;
24 { // enumerators large to small
25 enum(int) E { BBB, AAA, AA, AB, B };
26 E e;
27
28 try {
29 for ( 14 ) { // eums in input
30 try {
31 sin | e;
32 } catch( missing_data * ) {
33 sout | "missing data";
34 continue; // try again
35 } // try
36 sout | e | nonl;
37 } // for
38 } catch( end_of_file * ) {
39 abort( "enum test failure" );
40 } // try
41 sout | nl | nl;
42 }
43 { // enumerators small to large, overlapping patterns
44 enum(int) E { A, B, BB, AB, BA, AA, AAA, ABA, AAB, BBB, BBA, BAB };
45 E e;
46
47 try {
48 for ( 3 ) { // N rows
49 for ( countof( E ) ) { // eums in input
50 try {
51 sin | e;
52 } catch( missing_data * ) {
53 sout | "missing data";
54 continue; // try again
55 } // try
56 sout | e | nonl;
57 } // for
58 sout | nl;
59 } // for
60 } catch( end_of_file * ) {
61 abort( "enum test failure" );
62 } // try
63 sout | nl;
64 }
65 { // enumerators large to small, overlapping patterns
66 enum(int) E { BAB, BBA, BBB, AAB, ABA, AAA, AA, BA, AB, BB, B, A };
67 E e;
68
69 try {
70 for ( 3 ) { // N rows
71 for ( countof( E ) ) { // eums in input
72 try {
73 sin | e;
74 } catch( missing_data * ) {
75 sout | "missing data";
76 continue; // try again
77 } // try
78 sout | e | nonl;
79 } // for
80 sout | nl;
81 } // for
82 } catch( end_of_file * ) {
83 abort( "enum test failure" );
84 } // try
85 sout | nl;
86 }
87 { // general, end of file
88 enum(int) E { BBB = 3, AAA, AA, AB, B, CB, AC };
89 E e;
90
91 try {
92 for () {
93 try {
94 sin | e;
95 } catch( missing_data * ) {
96 sout | "missing data";
97 continue; // try again
98 } // try
99 sout | e | "= " | value( e ) | nonl;
100 } // for
101 } catch( end_of_file * ) {
102 } // try
103 }
104} // main
Note: See TracBrowser for help on using the repository browser.