Changeset 33807a1e
- Timestamp:
- Mar 15, 2024, 10:00:40 PM (9 months ago)
- Branches:
- master
- Children:
- 3ad5c50
- Parents:
- 54af365
- Location:
- tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/.expect/ato.x64.txt
r54af365 r33807a1e 3 3 -123 -123 4 4 123 123 5 -123 -123 6 123 123 7 -123.456 -123.456 8 -123.456789012346 -123.4567890123456 9 -123.456789012345679 -123.45678901234567890123456789 10 -123.456-123.456i -123.456-123.456i 11 -123.456789012346+123.456789012346i -123.4567890123456+123.4567890123456i 12 123.456789012345679-123.456789012345679i 123.45678901234567890123456789-123.45678901234567890123456789i 13 123.45678901234-123.456789i 123.45678901234 -123.4567890i 5 14 -123 -123 6 15 123 123 16 -123 -123 17 123 123 18 -123 -123 19 123 123 7 20 -123.456 -123.456 8 21 -123.456789012346 -123.4567890123456 9 -123.456789012345679 -123.45678901234567890123456789 22 -123.456789012345679 -123.45678901234567890123456789 23 -123.456-123.456i -123.456-123.456i 24 -123.456789012346+123.456789012346i -123.4567890123456+123.4567890123456i 25 123.456789012345679-123.456789012345679i 123.45678901234567890123456789-123.45678901234567890123456789i 26 123.45678901234-123.456789i 123.45678901234 -123.4567890i 27 invalid argument 2.0fred 28 invalid argument 2 3x 29 -123 -123 30 123 123 31 -123 -123 32 123 123 33 -123 -123 34 123 123 35 -123.456 -123.456 36 -123.456789012346 -123.4567890123456 37 -123.456789012345679 -123.45678901234567890123456789 10 38 -123.456-123.456i -123.456-123.456i 11 39 -123.456789012346+123.456789012346i -123.4567890123456+123.4567890123456i 12 40 123.456789012345679-123.456789012345679i 123.45678901234567890123456789-123.45678901234567890123456789i 13 41 123.45678901234-123.456789i 123.45678901234-123.4567890i 14 -123 -123 15 123 123 16 -123 -123 17 123 123 18 -123 -123 19 123 123 20 -123.456 -123.456 21 -123.456789012346 -123.4567890123456 22 -123.456789012345679 -123.45678901234567890123456789 23 -123.456-123.456i -123.456-123.456i 24 0.+0.i 2 3 25 -123.456789012346+123.456789012346i -123.4567890123456+123.4567890123456i 26 123.456789012345679-123.456789012345679i 123.45678901234567890123456789-123.45678901234567890123456789i 27 123.45678901234-123.456789i 123.45678901234-123.4567890i 42 invalid argument 2.0fred 43 invalid argument 2 3x -
tests/ato.cfa
r54af365 r33807a1e 10 10 // Created On : Thu Feb 4 08:10:57 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 4 21:33:53 201813 // Update Count : 9212 // Last Modified On : Fri Mar 15 17:58:35 2024 13 // Update Count : 145 14 14 // 15 15 … … 18 18 19 19 int main( void ) { 20 // ato 21 20 22 const char * sptr = "-123"; 21 23 int i = ato( sptr ); … … 32 34 sout | uli | sptr; 33 35 34 sptr = " -123";36 sptr = " -123 "; // spaces allowed 35 37 long long int lli = ato( sptr ); 36 38 sout | lli | sptr; 37 sptr = " 123";39 sptr = " 123 "; // spaces allowed 38 40 unsigned long long int ulli = ato( sptr ); 39 41 sout | ulli | sptr; … … 45 47 double d = ato( sptr ); 46 48 sout | d | sptr; 47 sptr = " -123.45678901234567890123456789";49 sptr = " -123.45678901234567890123456789 "; // spaces allowed 48 50 long double ld = ato( sptr ); 49 51 sout | ld | sptr; … … 58 60 long double _Complex ldc = ato( sptr ); 59 61 sout | ldc | sptr; 60 sptr = " 123.45678901234-123.4567890i";62 sptr = " 123.45678901234 -123.4567890i "; // spaces allowed 61 63 long double _Complex ldc2 = ato( sptr ); 62 64 sout | ldc2 | sptr; 63 65 66 // strto 64 67 65 68 sptr = "-123"; 66 i = strto( sptr, 0 , 10 );69 i = strto( sptr, 0p, 10 ); 67 70 sout | i | sptr; 68 71 sptr = "123"; 69 ui = strto( sptr, 0 , 10 );72 ui = strto( sptr, 0p, 10 ); 70 73 sout | ui | sptr; 71 74 72 75 sptr = "-123"; 73 li = strto( sptr, 0 , 10 );76 li = strto( sptr, 0p, 10 ); 74 77 sout | li | sptr; 75 78 sptr = "123"; 76 uli = strto( sptr, 0 , 10 );79 uli = strto( sptr, 0p, 10 ); 77 80 sout | uli | sptr; 78 81 79 sptr = " -123";80 lli = strto( sptr, 0 , 10 );82 sptr = " -123 "; // spaces allowed 83 lli = strto( sptr, 0p, 10 ); 81 84 sout | lli | sptr; 82 sptr = " 123";83 ulli = strto( sptr, 0 , 10 );85 sptr = " 123 "; // spaces allowed 86 ulli = strto( sptr, 0p, 10 ); 84 87 sout | ulli | sptr; 85 88 86 89 sptr = "-123.456"; 87 f = strto( sptr, 0 );90 f = strto( sptr, 0p ); 88 91 sout | f | sptr; 89 92 sptr = "-123.4567890123456"; 90 d = strto( sptr, 0 );93 d = strto( sptr, 0p ); 91 94 sout | d | sptr; 92 sptr = " -123.45678901234567890123456789";93 ld = strto( sptr, 0 );95 sptr = " -123.45678901234567890123456789 "; // spaces allowed 96 ld = strto( sptr, 0p ); 94 97 sout | ld | sptr; 95 98 96 99 sptr = "-123.456-123.456i"; 97 fc = strto( sptr, 0 );100 fc = strto( sptr, 0p ); 98 101 sout | fc | sptr; 99 100 char * eptr = 0;101 // sptr = "2fred";102 // fc = strto( sptr, &eptr );103 // sout | fc | sptr | eptr;104 105 sptr = "2 3";106 fc = strto( sptr, &eptr );107 sout | fc | sptr | eptr;108 109 102 sptr = "-123.4567890123456+123.4567890123456i"; 110 dc = strto( sptr, 0 );103 dc = strto( sptr, 0p ); 111 104 sout | dc | sptr; 112 105 sptr = "123.45678901234567890123456789-123.45678901234567890123456789i"; 113 ldc = strto( sptr, 0 ); 106 ldc = strto( sptr, 0p ); 107 sout | ldc | sptr; 108 sptr = " 123.45678901234 -123.4567890i "; // spaces allowed 109 ldc2 = strto( sptr, 0p ); 110 sout | ldc2 | sptr; 111 112 sptr = "2.0fred"; 113 char * eptr = 0p; 114 errno = 0; // reset 115 f = strto( sptr, &eptr ); 116 if ( errno == ERANGE ) sout | "out of range"; 117 if ( eptr == sptr || // conversion failed, no characters generated 118 *eptr != '\0' ) sout | "invalid argument" | sptr; // not at end of str ? 119 else assert( false ); 120 121 sptr = "2 3x"; 122 eptr = 0p; 123 errno = 0; // reset 124 fc = strto( sptr, &eptr ); 125 if ( errno == ERANGE ) sout | "out of range"; 126 if ( eptr == sptr || // conversion failed, no characters generated 127 *eptr != '\0' ) sout | "invalid argument" | sptr; // not at end of str ? 128 else assert( false ); 129 130 // convert 131 132 sptr = "-123"; 133 i = convert( sptr ); 134 sout | i | sptr; 135 sptr = "123"; 136 ui = convert( sptr ); 137 sout | ui | sptr; 138 139 sptr = "-123"; 140 li = convert( sptr ); 141 sout | li | sptr; 142 sptr = "123"; 143 uli = convert( sptr ); 144 sout | uli | sptr; 145 146 sptr = " -123 "; // spaces allowed 147 lli = convert( sptr ); 148 sout | lli | sptr; 149 sptr = " 123 "; // spaces allowed 150 ulli = convert( sptr ); 151 sout | ulli | sptr; 152 153 sptr = "-123.456"; 154 f = convert( sptr ); 155 sout | f | sptr; 156 sptr = "-123.4567890123456"; 157 d = convert( sptr ); 158 sout | d | sptr; 159 sptr = " -123.45678901234567890123456789 "; // spaces allowed 160 ld = convert( sptr ); 161 sout | ld | sptr; 162 163 sptr = "-123.456-123.456i"; 164 fc = convert( sptr ); 165 sout | fc | sptr; 166 sptr = "-123.4567890123456+123.4567890123456i"; 167 dc = convert( sptr ); 168 sout | dc | sptr; 169 sptr = "123.45678901234567890123456789-123.45678901234567890123456789i"; 170 ldc = convert( sptr ); 114 171 sout | ldc | sptr; 115 172 sptr = "123.45678901234-123.4567890i"; 116 ldc2 = strto( sptr, 0);173 ldc2 = convert( sptr ); 117 174 sout | ldc2 | sptr; 175 176 sptr = "2.0fred"; 177 try { 178 f = convert( sptr ); 179 assert( false ); 180 } catch( invalid_argument * ) { 181 sout | "invalid argument" | sptr; 182 } // try 183 184 sptr = "2 3x"; 185 try { 186 fc = convert( sptr ); 187 assert( false ); 188 } catch( invalid_argument * ) { 189 sout | "invalid argument" | sptr; 190 } // try 118 191 } // main 119 192
Note: See TracChangeset
for help on using the changeset viewer.