| 496 | } |
| 497 | |
| 498 | int |
| 499 | main(int argc, char * const argv[]) |
| 500 | { |
| 501 | char *buf; |
| 502 | char *flag_str, *scale_str; |
| 503 | size_t blen, buflen, errcnt, i, skipped, tested; |
| 504 | int r; |
| 505 | int includeNegScale; |
| 506 | int includeExabyteTests; |
| 507 | int verbose; |
| 508 | |
| 509 | buf = NULL; |
| 510 | buflen = 0; |
| 511 | includeNegScale = 0; |
| 512 | includeExabyteTests = 0; |
| 513 | verbose = 0; |
| 514 | |
| 515 | read_options(argc, argv, &buflen, &includeNegScale, |
| 516 | &includeExabyteTests, &verbose); |
| 517 | |
| 518 | errcnt = 0; |
| 519 | tested = 0; |
| 520 | skipped = 0; |
| 521 | |
| 522 | if (buflen != 4) |
| 523 | printf("Warning: buffer size %zu != 4, expect some results to differ.\n", buflen); |
| 524 | |
| 525 | printf("1..%zu\n", nitems(test_args)); |
| 526 | for (i = 0; i < nitems(test_args); i++) { |
| 527 | blen = (buflen > 0) ? buflen : test_args[i].buflen; |
| 528 | buf = realloc(buf, blen); |
| 529 | |
| 530 | if (test_args[i].scale < 0 && ! includeNegScale) { |
| 531 | skipped++; |
| 532 | testskipped(i + 1); |
| 533 | continue; |
| 534 | } |
| 535 | if (test_args[i].num >= halfExabyte && ! includeExabyteTests) { |
| 536 | skipped++; |
| 537 | testskipped(i + 1); |
| 538 | continue; |
| 539 | } |
| 540 | |
| 541 | r = humanize_number(buf, blen, test_args[i].num, "", |
| 542 | test_args[i].scale, test_args[i].flags); |
| 543 | flag_str = str_flags(test_args[i].flags, "[no flags]"); |
| 544 | scale_str = str_scale(test_args[i].scale); |
| 545 | |
| 546 | if (r != test_args[i].retval) { |
| 547 | if (verbose) |
| 548 | printf("wrong return value on index %zu, " |
| 549 | "buflen: %zu, got: %d + \"%s\", " |
| 550 | "expected %d + \"%s\"; num = %jd, " |
| 551 | "scale = %s, flags= %s.\n", |
| 552 | i, blen, r, buf, test_args[i].retval, |
| 553 | test_args[i].res, |
| 554 | (intmax_t)test_args[i].num, |
| 555 | scale_str, flag_str); |
nothing calls this directly
no test coverage detected