Changeset 75e2286 for tests/collections
- Timestamp:
- Feb 11, 2024, 3:09:15 PM (10 months ago)
- Branches:
- master
- Children:
- da22726
- Parents:
- 7b93027e
- Location:
- tests/collections
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/collections/.expect/string-istream-manip.txt
r7b93027e r75e2286 70 70 14 71 71 15 72 16 get this line 73 17 @# this line 1)-{} 74 18 @# this line 1)-{} 75 19 abc 76 20 abc 77 21 d d 78 79 d 80 22 ZC44% 81 23 ZC44% 72 82 1 yyyyyyyyyyyyyyyyyyyy 73 83 2 abcxxx … … 85 95 14 86 96 15 97 16 get this line 98 17 @# this line 1)-{} 99 18 @# this line 1)-{} 100 19 abc 101 20 abc 102 21 d d 103 104 d 105 22 ZC44% 106 23 ZC44% -
tests/collections/.in/string-istream-manip.txt
r7b93027e r75e2286 38 38 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwwwaaaaaaaawwwwwwww 39 39 uuuuu 40 get this line 41 @# this line 1)-{}% 42 @# this line 2)-{}% 43 "abc" 44 'abc ' 45 { d d 46 47 d } 48 X ZC44%Y 49 X ZC55%Y 40 50 abc 41 51 cccccb … … 45 55 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwwwaaaaaaaawwwwwwww 46 56 uuuuu 57 get this line 58 @# this line 1)-{}% 59 @# this line 2)-{}% 60 "abc" 61 'abc ' 62 { d d 63 64 d } 65 X ZC44%Y 66 X ZC55%Y -
tests/collections/string-istream-manip.cfa
r7b93027e r75e2286 10 10 // The test cases that use plainjane(-) are exercising the via-manipulator code path, 11 11 // just with trivial manipulation. 12 static _Istream_Sstr plainjane( string 12 static _Istream_Sstr plainjane( string & s ) { return (_Istream_Sstr)@{ s, {{0p}, -1, {.flags.rwd : false}} }; } 13 13 static _Istream_Rstr plainjane( string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, -1, {.flags.rwd : false}} }; } 14 14 15 15 static void forceStringHeapFreeSpaceTo(int desiredSize) { 16 17 18 19 20 21 16 for (1_000_000) { 17 string x = "a"; 18 (void)x; 19 if (desiredSize == DEBUG_string_bytes_avail_until_gc(DEBUG_string_heap())) return; 20 } 21 sout | "Unable to force size" | desiredSize | "in 1,000,000 tries"; 22 22 } 23 23 24 24 int main() { 25 // These "pre" cases deal with issues analogous to the "pre" cases of io/manipulatorsInput. 26 // The acceptance criterion is simpler but driving the cases is harder. 27 // The tests just read strings and echo what they read; acceptance of simple echoing assures 28 // no spurious splitting merging. 29 // The lengths of the strings are chosen to match white-box knowledge of when the string layer 30 // has tor drive the cstring layer through a second iteration: 31 // - for no-manip, lengths are near the room at end of string heap 32 // (chosen target size of 9 showed the original bug on preS2, aligned with the other cases) 33 // - for manip, lengths are near the auxiliary buffer size of 128 34 // Only first case repeats for string_res; rest run only from the passthru string layer. 35 // Similarly, the manipulator breadth isn't checked at the cstring layer either. 36 { 37 // S: string, no manipulator 38 void echoTillX(const char * casename) { 39 string s; 40 // loop assumes behaviour not tested until main-case #15: 41 // on reading nothing, the prior string value is left alone 42 do { 43 s = ""; 44 forceStringHeapFreeSpaceTo(9); 45 sin | s; 46 sout | casename | s; 47 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 48 } 49 echoTillX("preS1"); 50 echoTillX("preS2"); 51 echoTillX("preS3"); 52 echoTillX("preS4"); 53 } 54 { 55 // SMN: string, manipulator for no-op 56 void echoTillX(const char * casename) { 57 string s; 58 do { 59 s = ""; 60 sin | plainjane( s ); 61 sout | casename | s; 62 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 63 } 64 echoTillX("preSMN1"); 65 echoTillX("preSMN2"); 66 echoTillX("preSMN3"); 67 echoTillX("preSMN4"); 68 } 69 { 70 // RMN: string_res, manipulator for no-op 71 void echoTillX(const char * casename) { 72 string_res s; 73 do { 74 s = ""; 75 sin | plainjane( s ); 76 sout | casename | s; 77 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 78 } 79 echoTillX("preRMN1"); 80 echoTillX("preRMN2"); 81 echoTillX("preRMN3"); 82 echoTillX("preRMN4"); 83 } 84 { 85 // SMI: string, manipulator `incl` 86 void echoTillX(const char * casename) { 87 string s; 88 do { 89 s = ""; 90 sin | skip("-\n"); 91 sin | incl( ".:|# x", s ); 92 sout | casename | " \"" | s | "\""; 93 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 94 } 95 echoTillX("preSMI1"); 96 echoTillX("preSMI2"); 97 echoTillX("preSMI3"); 98 echoTillX("preSMI4"); 99 } 100 { 101 // SME: string, manipulator `excl` 102 void echoTillX(const char * casename) { 103 string s; 104 do { 105 s = ""; 106 sin | skip("-\n"); 107 sin | excl( "-\n", s ); 108 sout | casename | " \"" | s | "\""; 109 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 110 } 111 echoTillX("preSME1"); 112 echoTillX("preSME2"); 113 echoTillX("preSME3"); 114 echoTillX("preSME4"); 115 } 116 sin | skip("-\n"); 117 { 118 // SMG: string, manipulator `getline` 119 void echoTillX(const char * casename) { 120 string s; 121 do { 122 s = ""; 123 sin | getline( s ); 124 sout | casename | s; 125 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 126 } 127 echoTillX("preSMG1"); 128 echoTillX("preSMG2"); 129 echoTillX("preSMG3"); 130 echoTillX("preSMG4"); 131 } 132 { 133 // SMD: string, manipulator (`getline` with custom) delimiter 134 void echoTillX(const char * casename) { 135 string s; 136 do { 137 s = ""; 138 sin | getline( s, '@' ); 139 sout | casename | s; 140 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 141 sin | skip(" \n"); 142 } 143 echoTillX("preSMD1"); 144 echoTillX("preSMD2"); 145 echoTillX("preSMD3"); 146 echoTillX("preSMD4"); 147 } 148 149 /* Keep harmonized with io/manipulatorsInput */ 150 { 151 string s = "yyyyyyyyyyyyyyyyyyyy"; 152 char sk[] = "abc"; 153 sin | "abc " | skip( sk ) | skip( 5 ); sout | "1" | s; 154 sin | s; sout | "2" | s; 155 sin | ignore( s ); sout | "3" | s; 156 sin | wdi( 8, s ); sout | "4" | s; 157 sin | ignore( wdi( 8, s ) ); sout | "5" | s; 158 159 sin | incl( "abc", s ); sout | "6" | s; 160 sin | excl( "abc", s ); sout | "7" | s; 161 sin | ignore( incl( "abc", s ) ); sout | "8" | s; 162 sin | ignore( excl( "abc", s ) ); sout | "9" | s; 163 sin | incl( "abc", wdi( 8, s ) ); sout | "10" | s; 164 sin | excl( "abc", wdi( 8, s ) ); sout | "11" | s; 165 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 166 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 25 // These "pre" cases deal with issues analogous to the "pre" cases of io/manipulatorsInput. 26 // The acceptance criterion is simpler but driving the cases is harder. 27 // The tests just read strings and echo what they read; acceptance of simple echoing assures 28 // no spurious splitting merging. 29 // The lengths of the strings are chosen to match white-box knowledge of when the string layer 30 // has tor drive the cstring layer through a second iteration: 31 // - for no-manip, lengths are near the room at end of string heap 32 // (chosen target size of 9 showed the original bug on preS2, aligned with the other cases) 33 // - for manip, lengths are near the auxiliary buffer size of 128 34 // Only first case repeats for string_res; rest run only from the passthru string layer. 35 // Similarly, the manipulator breadth isn't checked at the cstring layer either. 36 { 37 // S: string, no manipulator 38 void echoTillX(const char * casename) { 39 string s; 40 // loop assumes behaviour not tested until main-case #15: 41 // on reading nothing, the prior string value is left alone 42 do { 43 s = ""; 44 forceStringHeapFreeSpaceTo(9); 45 sin | s; 46 sout | casename | s; 47 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 48 } 49 echoTillX("preS1"); 50 echoTillX("preS2"); 51 echoTillX("preS3"); 52 echoTillX("preS4"); 53 } 54 { 55 // SMN: string, manipulator for no-op 56 void echoTillX(const char * casename) { 57 string s; 58 do { 59 s = ""; 60 sin | plainjane( s ); 61 sout | casename | s; 62 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 63 } 64 echoTillX("preSMN1"); 65 echoTillX("preSMN2"); 66 echoTillX("preSMN3"); 67 echoTillX("preSMN4"); 68 } 69 { 70 // RMN: string_res, manipulator for no-op 71 void echoTillX(const char * casename) { 72 string_res s; 73 do { 74 s = ""; 75 sin | plainjane( s ); 76 sout | casename | s; 77 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 78 } 79 echoTillX("preRMN1"); 80 echoTillX("preRMN2"); 81 echoTillX("preRMN3"); 82 echoTillX("preRMN4"); 83 } 84 { 85 // SMI: string, manipulator `incl` 86 void echoTillX(const char * casename) { 87 string s; 88 do { 89 s = ""; 90 sin | skip("-\n"); 91 sin | incl( ".:|# x", s ); 92 sout | casename | " \"" | s | "\""; 93 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 94 } 95 echoTillX("preSMI1"); 96 echoTillX("preSMI2"); 97 echoTillX("preSMI3"); 98 echoTillX("preSMI4"); 99 } 100 { 101 // SME: string, manipulator `excl` 102 void echoTillX(const char * casename) { 103 string s; 104 do { 105 s = ""; 106 sin | skip("-\n"); 107 sin | excl( "-\n", s ); 108 sout | casename | " \"" | s | "\""; 109 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 110 } 111 echoTillX("preSME1"); 112 echoTillX("preSME2"); 113 echoTillX("preSME3"); 114 echoTillX("preSME4"); 115 } 116 sin | skip("-\n"); 117 { 118 // SMG: string, manipulator `getline` 119 void echoTillX(const char * casename) { 120 string s; 121 do { 122 s = ""; 123 sin | getline( s ); 124 sout | casename | s; 125 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 126 } 127 echoTillX("preSMG1"); 128 echoTillX("preSMG2"); 129 echoTillX("preSMG3"); 130 echoTillX("preSMG4"); 131 } 132 { 133 // SMD: string, manipulator (`getline` with custom) delimiter 134 void echoTillX(const char * casename) { 135 string s; 136 do { 137 s = ""; 138 sin | getline( s, '@' ); 139 sout | casename | s; 140 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 141 sin | skip(" \n"); 142 } 143 echoTillX("preSMD1"); 144 echoTillX("preSMD2"); 145 echoTillX("preSMD3"); 146 echoTillX("preSMD4"); 147 } 148 // Keep harmonized with io/manipulatorsInput. 149 { 150 string s = "yyyyyyyyyyyyyyyyyyyy"; 151 char sk[] = "abc"; 152 sin | "abc " | skip( sk ) | skip( 5 ); sout | "1" | s; 153 sin | s; sout | "2" | s; 154 sin | ignore( s ); sout | "3" | s; 155 sin | wdi( 8, s ); sout | "4" | s; 156 sin | ignore( wdi( 8, s ) ); sout | "5" | s; 157 158 sin | incl( "abc", s ); sout | "6" | s; 159 sin | excl( "abc", s ); sout | "7" | s; 160 sin | ignore( incl( "abc", s ) ); sout | "8" | s; 161 sin | ignore( excl( "abc", s ) ); sout | "9" | s; 162 sin | incl( "abc", wdi( 8, s ) ); sout | "10" | s; 163 sin | excl( "abc", wdi( 8, s ) ); sout | "11" | s; 164 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 165 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 166 sin | nl; 167 168 s = "q"; 169 sin | incl( "abc", s ); sout | "14" | s; 170 s = "q"; 171 sin | excl( "u", s ); sout | "15" | s; 172 sin | skip( "u" ) | nl; 173 174 sin | getline( s ); sout | "16" | s; 175 sin | getline( s, '%' ) | nl; sout | "17" | s; 176 sin | ignore( getline( s, '%' ) ) | nl; sout | "18" | s; 177 178 sin | quoted( s ); sout | "19" | s; 179 sin | quoted( s, '\'' ); sout | "20" | s; 180 sin | quoted( s, '{', '}' ); sout | "21" | s; 181 sin | quoted( s, 'X', 'Y' ); sout | "22" | s; 182 sin | ignore( quoted( s, 'X', 'Y' ) ); sout | "23" | s; 183 sin | nl; 184 } 185 // Full repeat on string_res layer assures the full manipulator vocabulary is supported there. 186 { 187 string_res s = "yyyyyyyyyyyyyyyyyyyy"; 188 char sk[] = "abc"; 189 sin | "abc " | skip( sk ) | skip( 5 ); sout | "1" | s; 190 sin | s; sout | "2" | s; 191 sin | ignore( s ); sout | "3" | s; 192 sin | wdi( 8, s ); sout | "4" | s; 193 sin | ignore( wdi( 8, s ) ); sout | "5" | s; 194 195 sin | incl( "abc", s ); sout | "6" | s; 196 sin | excl( "abc", s ); sout | "7" | s; 197 sin | ignore( incl( "abc", s ) ); sout | "8" | s; 198 sin | ignore( excl( "abc", s ) ); sout | "9" | s; 199 sin | incl( "abc", wdi( 8, s ) ); sout | "10" | s; 200 sin | excl( "abc", wdi( 8, s ) ); sout | "11" | s; 201 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 202 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 167 203 sin | "\n"; 168 204 169 205 s = "q"; 170 sin | incl( "abc", s ); 171 s = "q"; 172 sin | excl( "u", s ); 206 sin | incl( "abc", s ); sout | "14" | s; 207 s = "q"; 208 sin | excl( "u", s ); sout | "15" | s; 173 209 sin | skip( "u" ); 174 210 sin | "\n"; 175 } 176 // Full repeat on string_res layer assures the full manipulator vocabulary is supported there. 177 { 178 string_res s = "yyyyyyyyyyyyyyyyyyyy"; 179 char sk[] = "abc"; 180 sin | "abc " | skip( sk ) | skip( 5 ); sout | "1" | s; 181 sin | s; sout | "2" | s; 182 sin | ignore( s ); sout | "3" | s; 183 sin | wdi( 8, s ); sout | "4" | s; 184 sin | ignore( wdi( 8, s ) ); sout | "5" | s; 185 186 sin | incl( "abc", s ); sout | "6" | s; 187 sin | excl( "abc", s ); sout | "7" | s; 188 sin | ignore( incl( "abc", s ) ); sout | "8" | s; 189 sin | ignore( excl( "abc", s ) ); sout | "9" | s; 190 sin | incl( "abc", wdi( 8, s ) ); sout | "10" | s; 191 sin | excl( "abc", wdi( 8, s ) ); sout | "11" | s; 192 sin | ignore( incl( "abc", wdi( 8, s ) ) ); sout | "12" | s; 193 sin | ignore( excl( "abc", wdi( 8, s ) ) ); sout | "13" | s; 194 sin | "\n"; 195 196 s = "q"; 197 sin | incl( "abc", s ); sout | "14" | s; 198 s = "q"; 199 sin | excl( "u", s ); sout | "15" | s; 200 sin | skip( "u" ); 201 sin | "\n"; 202 } 211 sin | getline( s ); sout | "16" | s; 212 sin | getline( s, '%' ) | nl; sout | "17" | s; 213 sin | ignore( getline( s, '%' ) ) | nl; sout | "18" | s; 214 215 sin | quoted( s ); sout | "19" | s; 216 sin | quoted( s, '\'' ); sout | "20" | s; 217 sin | quoted( s, '{', '}' ); sout | "21" | s; 218 sin | quoted( s, 'X', 'Y' ); sout | "22" | s; 219 sin | ignore( quoted( s, 'X', 'Y' ) ); sout | "23" | s; 220 } 203 221 }
Note: See TracChangeset
for help on using the changeset viewer.