| 294 | } |
| 295 | |
| 296 | int main(int argc, const char **argv) |
| 297 | { |
| 298 | char buf[512]; |
| 299 | |
| 300 | av_log_set_callback(mock_av_log); |
| 301 | |
| 302 | check_sorted_cmds_array(); |
| 303 | |
| 304 | for (int i = 1; i < argc; i++) |
| 305 | check_script(1, argv[i]); |
| 306 | |
| 307 | // Detect unclosed expressions. |
| 308 | check_script(0, "M 0 (1*(t+1)"); |
| 309 | |
| 310 | // Invalid command. |
| 311 | check_script(0, "save invalid 1 2"); |
| 312 | |
| 313 | // Invalid constant. |
| 314 | check_script(0, "setlinecap unknown m 10 20"); |
| 315 | |
| 316 | // Missing arguments. |
| 317 | check_script(0, "M 0 1 2"); |
| 318 | |
| 319 | // Invalid variable names. |
| 320 | check_script(0, "setvar ba^d 0"); |
| 321 | |
| 322 | // Reserved names. |
| 323 | check_script(0, "setvar cx 0"); |
| 324 | |
| 325 | // Max number of user variables. |
| 326 | memset(buf, 0, sizeof(buf)); |
| 327 | for (int i = 0; i < USER_VAR_COUNT; i++) { |
| 328 | av_strlcatf(buf, sizeof(buf), " setvar v%d %d", i, i); |
| 329 | } |
| 330 | av_strlcatf(buf, sizeof(buf), " M (v0) (v%d) 1 (unknown_var)", USER_VAR_COUNT - 1); |
| 331 | check_script(0, buf); |
| 332 | |
| 333 | // Too many variables. |
| 334 | memset(buf, 0, sizeof(buf)); |
| 335 | for (int i = 0; i < USER_VAR_COUNT + 1; i++) { |
| 336 | av_strlcatf(buf, sizeof(buf), " setvar v%d %d", i + 1, i); |
| 337 | } |
| 338 | check_script(0, buf); |
| 339 | |
| 340 | // Invalid procedure names. |
| 341 | check_script(0, "call a"); |
| 342 | check_script(0, "proc a { call b } call a"); |
| 343 | |
| 344 | // Invalid arguments list. |
| 345 | check_script(0, "proc p0 a1 a2 a3 a4 a5 a6 a7 a8 { break }"); |
| 346 | check_script(0, "proc p0 a1 a2 { break } call p0 break"); |
| 347 | check_script(0, "proc p0 a1 a2 { break } call p0 1 2 3"); |
| 348 | |
| 349 | // Long expressions. |
| 350 | memset(buf, 0, sizeof(buf)); |
| 351 | strncat(buf, "M 0 (1", sizeof(buf) - 1); |
| 352 | for (int i = 0; i < 100; i++) { |
| 353 | strncat(buf, " + n", sizeof(buf) - 1); |
no test coverage detected