| 149 | */ |
| 150 | |
| 151 | void execnt_unit_test() |
| 152 | { |
| 153 | #if !defined( NDEBUG ) |
| 154 | /* vc6 preprocessor is broken, so assert with these strings gets confused. |
| 155 | * Use a table instead. |
| 156 | */ |
| 157 | { |
| 158 | typedef struct test { char * command; int result; } test; |
| 159 | test tests[] = { |
| 160 | { "", 0 }, |
| 161 | { " ", 0 }, |
| 162 | { "x", 1 }, |
| 163 | { "\nx", 1 }, |
| 164 | { "x\n", 1 }, |
| 165 | { "\nx\n", 1 }, |
| 166 | { "\nx \n", 2 }, |
| 167 | { "\nx \n ", 2 }, |
| 168 | { " \n\t\t\v\r\r\n \t x \v \t\t\r\n\n\n \n\n\v\t", 8 }, |
| 169 | { "x\ny", -1 }, |
| 170 | { "x\n\n y", -1 }, |
| 171 | { "echo x > foo.bar", -1 }, |
| 172 | { "echo x < foo.bar", -1 }, |
| 173 | { "echo x | foo.bar", -1 }, |
| 174 | { "echo x \">\" foo.bar", 18 }, |
| 175 | { "echo x '<' foo.bar", 18 }, |
| 176 | { "echo x \"|\" foo.bar", 18 }, |
| 177 | { "echo x \\\">\\\" foo.bar", -1 }, |
| 178 | { "echo x \\\"<\\\" foo.bar", -1 }, |
| 179 | { "echo x \\\"|\\\" foo.bar", -1 }, |
| 180 | { "\"echo x > foo.bar\"", 18 }, |
| 181 | { "echo x \"'\"<' foo.bar", -1 }, |
| 182 | { "echo x \\\\\"<\\\\\" foo.bar", 22 }, |
| 183 | { "echo x \\x\\\"<\\\\\" foo.bar", -1 }, |
| 184 | { 0 } }; |
| 185 | test const * t; |
| 186 | for ( t = tests; t->command; ++t ) |
| 187 | assert( raw_command_length( t->command ) == t->result ); |
| 188 | } |
| 189 | |
| 190 | { |
| 191 | int const length = maxline() + 9; |
| 192 | char * const cmd = (char *)BJAM_MALLOC_ATOMIC( length + 1 ); |
| 193 | memset( cmd, 'x', length ); |
| 194 | cmd[ length ] = 0; |
| 195 | assert( raw_command_length( cmd ) == length ); |
| 196 | BJAM_FREE( cmd ); |
| 197 | } |
| 198 | #endif |
| 199 | } |
| 200 | |
| 201 | |
| 202 | /* |
no test coverage detected