Changes in tests/io2.cfa [dc8511c:200fcb3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/io2.cfa
rdc8511c r200fcb3 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:57:28201813 // Update Count : 10 412 // Last Modified On : Tue Dec 11 21:51:52 2018 13 // Update Count : 109 14 14 // 15 15 16 16 #include <fstream.hfa> 17 17 18 18 #define xstr(s) str(s) 19 19 #define str(s) #s 20 20 … … 41 41 char s1[size], s2[size]; 42 42 43 ifstream in = { xstr(IN_DIR) "io.data" }; 43 ifstream in = { xstr(IN_DIR) "io.data" }; // create / open file 44 44 45 sout | "input bacis types" | endl;45 sout | "input bacis types"; 46 46 in | b // boolean 47 47 | c | sc | usc // character … … 50 50 | fc | dc | ldc // floating-point complex 51 51 | cstr( s1 ) | cstr( s2, size ); // C string, length unchecked and checked 52 sout | endl;52 sout | nl; 53 53 54 sout | "output basic types" | endl;55 sout | b | endl // boolean56 | c | ' ' | sc | ' ' | usc | endl // character57 | si | usi | i | ui | li | uli | lli | ulli | endl // integral58 | f | d | ld | endl// floating point59 | fc | dc | ldc | endl;// complex60 sout | endl;54 sout | "output basic types"; 55 sout | b | nl // boolean 56 | c | ' ' | sc | ' ' | usc | nl // character 57 | si | usi | i | ui | li | uli | lli | ulli | nl // integral 58 | f | d | ld | nl // floating point 59 | fc | dc | ldc; // complex 60 sout | nl; 61 61 62 sout | "tuples" | endl;62 sout | "tuples"; 63 63 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ]; 64 sout | t1 | t2 | endl;// print tuple65 sout | endl;64 sout | t1 | t2; // print tuple 65 sout | nl; 66 66 67 sout | "toggle separator" | endl;68 sout | f | "" | d | "" | ld | endl // floating point without separator69 | sepDisable | fc | dc | ldc | endl// complex without separator70 | fc | sepOn | dc | ldc | endl // local separator add71 | sepEnable | fc | dc | ldc | endl // complex with separator72 | fc | sepOff | dc | ldc | endl// local separator removal73 | s1 | sepOff | s2 | endl // local separator removal74 | s1 | "" | s2 | endl;// local separator removal75 sout | endl;67 sout | "toggle separator"; 68 sout | f | "" | d | "" | ld | nl // floating point without separator 69 | sepDisable | fc | dc | ldc | nl // complex without separator 70 | fc | sepOn | dc | ldc | nl // local separator add 71 | sepEnable | fc | dc | ldc | nl // complex with separator 72 | fc | sepOff | dc | ldc | nl // local separator removal 73 | s1 | sepOff | s2 | nl // local separator removal 74 | s1 | "" | s2; // local separator removal 75 sout | nl; 76 76 77 sout | "change separator" | endl;78 sout | "from \"" | sep | "\"" ;77 sout | "change separator"; 78 sout | "from \"" | sep | "\"" | nonl; 79 79 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 80 sout | " to \"" | sep | "\"" | endl;81 sout | f | d | ld | endl82 | fc | dc | ldc | endl83 | s1 | s2 | endl84 | t1 | t2 | endl;// print tuple85 sout | endl;86 sout | "from \"" | sep | "\" " ;80 sout | " to \"" | sep | "\""; 81 sout | f | d | ld | nl 82 | fc | dc | ldc | nl 83 | s1 | s2 | nl 84 | t1 | t2; // print tuple 85 sout | nl; 86 sout | "from \"" | sep | "\" " | nonl; 87 87 sepSet( sout, " " ); // restore separator 88 sout | "to \"" | sep | "\"" | endl;89 sout | f | d | ld | endl90 | fc | dc | ldc | endl91 | s1 | s2 | endl92 | t1 | t2 | endl;// print tuple93 sout | endl;88 sout | "to \"" | sep | "\""; 89 sout | f | d | ld | nl 90 | fc | dc | ldc | nl 91 | s1 | s2 | nl 92 | t1 | t2; // print tuple 93 sout | nl; 94 94 95 sout | "check sepOn/sepOff" | endl;96 sout | sepOn | 1 | 2 | 3 | sepOn | endl;// no separator at start/end of line97 sout | 1 | sepOff | 2 | 3 | endl;// locally turn off implicit separator95 sout | "check sepOn/sepOff"; 96 sout | sepOn | 1 | 2 | 3 | sepOn; // no separator at start/end of line 97 sout | 1 | sepOff | 2 | 3; // locally turn off implicit separator 98 98 sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line 99 99 sout | 1 | 2 | 3 | "\n\n" | sepOn; // no separator at start of next line 100 sout | 1 | 2 | 3 | endl;101 sout | endl;100 sout | 1 | 2 | 3; 101 sout | nl; 102 102 103 sout | "check enable/disable" | endl;104 sout | sepDisable | 1 | 2 | 3 | endl;// globally turn off implicit separation105 sout | 1 | sepOn | 2 | 3 | endl;// locally turn on implicit separator106 sout | sepEnable | 1 | 2 | 3 | endl | sepDisable;// globally turn on/off implicit separation107 sout | 1 | 2 | 3 | endl | sepEnable;// globally turn on implicit separation108 sout | 1 | 2 | 3 | sepOn | sepDisable | endl;// ignore seperate at end of line109 sout | 1 | 2 | 3 | sepOn | sepEnable | endl;// separator at end of line110 sout | 1 | 2 | 3 | endl;111 sout | endl;103 sout | "check enable/disable"; 104 sout | sepDisable | 1 | 2 | 3; // globally turn off implicit separation 105 sout | 1 | sepOn | 2 | 3; // locally turn on implicit separator 106 sout | sepEnable | 1 | 2 | 3 | sepDisable; // globally turn on/off implicit separation 107 sout | 1 | 2 | 3 | sepEnable; // globally turn on implicit separation 108 sout | 1 | 2 | 3 | sepOn | sepDisable; // ignore seperate at end of line 109 sout | 1 | 2 | 3 | sepOn | sepEnable; // separator at end of line 110 sout | 1 | 2 | 3; 111 sout | nl; 112 112 113 // sout | fmt( d, "%8.3f" ) || endl; 114 // sout | endl; 113 // sout | fmt( d, "%8.3f" ); 115 114 116 115 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 117 sout | t1 | t2 | " \"" | sep | "\"" | endl;116 sout | t1 | t2 | " \"" | sep | "\""; 118 117 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 119 sout | t1 | t2 | " \"" | sep | "\"" | endl;120 sout | t1 | t2 | endl;// print tuple121 sout | endl;118 sout | t1 | t2 | " \"" | sep | "\""; 119 sout | t1 | t2; // print tuple 120 sout | nl; 122 121 123 122 [int, int, const char *, double] t3 = { 3, 4, "a", 7.2 }; 124 sout | [ 3, 4, "a", 7.2 ] | endl;125 sout | t3 | endl;123 sout | [ 3, 4, "a", 7.2 ]; 124 sout | t3; 126 125 sepSetTuple( sout, " " ); 127 sout | t3 | endl;128 sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3 | endl;126 sout | t3; 127 sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3; 129 128 sepSet( sout, "^" ); 130 129 sepSetTuple( sout, "-" ); 131 sout | t3 | 3 | 4 | t3 | endl;130 sout | t3 | 3 | 4 | t3; 132 131 } 133 132
Note: See TracChangeset
for help on using the changeset viewer.