Changeset 0860d9c for tests/collections
- Timestamp:
- Oct 5, 2023, 4:17:14 PM (15 months ago)
- Branches:
- master
- Children:
- 4d860ea3
- Parents:
- b67b632
- Location:
- tests/collections
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/collections/.expect/string-istream-manip.txt
rb67b632 r0860d9c 1 preS1 0123456 2 preS1 x 3 preS2 01234567 4 preS2 x 5 preS3 012345678 6 preS3 x 7 preS4 0123456789 8 preS4 x 9 preSMN1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 10 preSMN1 x 11 preSMN2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 12 preSMN2 x 13 preSMN3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 14 preSMN3 x 15 preSMN4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 16 preSMN4 x 17 preRMN1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 18 preRMN1 x 19 preRMN2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 20 preRMN2 x 21 preRMN3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 22 preRMN3 x 23 preRMN4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 24 preRMN4 x 25 preSMI1 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 26 preSMI1 "x" 27 preSMI2 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 28 preSMI2 "x" 29 preSMI3 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 30 preSMI3 "x" 31 preSMI4 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 32 preSMI4 "x" 33 preSME1 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 34 preSME1 "x" 35 preSME2 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 36 preSME2 "x" 37 preSME3 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 38 preSME3 "x" 39 preSME4 "...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... " 40 preSME4 "x" 41 preSMG1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 42 preSMG1 x 43 preSMG2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 44 preSMG2 x 45 preSMG3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 46 preSMG3 x 47 preSMG4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 48 preSMG4 x 49 preSMD1 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 50 preSMD1 x 51 preSMD2 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 52 preSMD2 x 53 preSMD3 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 54 preSMD3 x 55 preSMD4 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 56 preSMD4 x 1 57 1 yyyyyyyyyyyyyyyyyyyy 2 58 2 abcxxx -
tests/collections/.in/string-istream-manip.txt
rb67b632 r0860d9c 1 0123456 x 2 01234567 x 3 012345678 x 4 0123456789 x 5 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 x 6 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 x 7 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 x 8 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 x 9 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 x 10 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 x 11 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 x 12 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 x 13 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 14 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 15 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 16 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 17 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 18 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 19 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 20 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:... -x- 21 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456 22 x 23 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567 24 x 25 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678 26 x 27 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789 28 x 29 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456@x@ 30 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...01234567@x@ 31 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...012345678@x@ 32 ...:...:...:...|...:...:...:...|...:...:...:...|...:...:...:...#...:...:...:...|...:...:...:...|...:...:...:...|...:...0123456789@x@ 1 33 abc 2 34 cccccb -
tests/collections/string-istream-manip.cfa
rb67b632 r0860d9c 3 3 #include <collections/string.hfa> 4 4 #include <collections/string_res.hfa> 5 #include <stdio.h> 6 7 // No-op manipulators. 8 // Temporary hack while there are two code paths in the string implementation. 9 // (One for reading plain strings, the other for reading via a manipulator.) 10 // The test cases that use plainjane(-) are exercising the via-manipulator code path, 11 // just with trivial manipulation. 12 static _Istream_Sstr plainjane( string & s ) { return (_Istream_Sstr)@{ s, {{0p}, -1, {.flags.rwd : false}} }; } 13 static _Istream_Rstr plainjane( string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, -1, {.flags.rwd : false}} }; } 14 15 static void forceStringHeapFreeSpaceTo(int desiredSize) { 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 } 5 23 6 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 do { 41 forceStringHeapFreeSpaceTo(9); 42 sin | s; 43 sout | casename | s; 44 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 45 } 46 echoTillX("preS1"); 47 echoTillX("preS2"); 48 echoTillX("preS3"); 49 echoTillX("preS4"); 50 } 51 { 52 // SMN: string, manipulator for no-op 53 void echoTillX(const char * casename) { 54 string s; 55 do { 56 sin | plainjane( s ); 57 sout | casename | s; 58 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 59 } 60 echoTillX("preSMN1"); 61 echoTillX("preSMN2"); 62 echoTillX("preSMN3"); 63 echoTillX("preSMN4"); 64 } 65 { 66 // RMN: string_res, manipulator for no-op 67 void echoTillX(const char * casename) { 68 string_res s; 69 do { 70 sin | plainjane( s ); 71 sout | casename | s; 72 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 73 } 74 echoTillX("preRMN1"); 75 echoTillX("preRMN2"); 76 echoTillX("preRMN3"); 77 echoTillX("preRMN4"); 78 } 79 { 80 // SMI: string, manipulator `incl` 81 void echoTillX(const char * casename) { 82 string s; 83 do { 84 sin | skip("-\n"); 85 sin | incl( ".:|# x", s ); 86 sout | casename | " \"" | s | "\""; 87 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 88 } 89 echoTillX("preSMI1"); 90 echoTillX("preSMI2"); 91 echoTillX("preSMI3"); 92 echoTillX("preSMI4"); 93 } 94 { 95 // SME: string, manipulator `excl` 96 void echoTillX(const char * casename) { 97 string s; 98 do { 99 sin | skip("-\n"); 100 sin | excl( "-\n", s ); 101 sout | casename | " \"" | s | "\""; 102 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 103 } 104 echoTillX("preSME1"); 105 echoTillX("preSME2"); 106 echoTillX("preSME3"); 107 echoTillX("preSME4"); 108 } 109 sin | skip("-\n"); 110 { 111 // SMG: string, manipulator `getline` 112 void echoTillX(const char * casename) { 113 string s; 114 do { 115 sin | getline( s ); 116 sout | casename | s; 117 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 118 } 119 echoTillX("preSMG1"); 120 echoTillX("preSMG2"); 121 echoTillX("preSMG3"); 122 echoTillX("preSMG4"); 123 } 124 { 125 // SMD: string, manipulator (`getline` with custom) delimiter 126 void echoTillX(const char * casename) { 127 string s; 128 do { 129 sin | getline( s, '@' ); 130 sout | casename | s; 131 } while ( size(s) > 0 && s[size(s)-1] != 'x' ); 132 sin | skip(" \n"); 133 } 134 echoTillX("preSMD1"); 135 echoTillX("preSMD2"); 136 echoTillX("preSMD3"); 137 echoTillX("preSMD4"); 138 } 139 7 140 /* Keep harmonized with io/manipulatorsInput */ 8 141 { … … 31 164 sin | "\n"; 32 165 } 166 // Full repeat on string_res layer assures the full manipulator vocabulary is supported there. 33 167 { 34 168 string_res s = "yyyyyyyyyyyyyyyyyyyy";
Note: See TracChangeset
for help on using the changeset viewer.