| 544 | } |
| 545 | |
| 546 | static void test_hasDuplicates(const char* name, int expected, sha256_midstate (*f)(uint_fast32_t), uint_fast32_t n) { |
| 547 | sha256_midstate hashes[n]; |
| 548 | |
| 549 | printf("Test %s\n", name); |
| 550 | for(uint_fast32_t i = 0; i < n; ++i) { |
| 551 | hashes[i] = f(i); |
| 552 | } |
| 553 | |
| 554 | int actual = simplicity_hasDuplicates(hashes, n); |
| 555 | if (expected == actual) { |
| 556 | successes++; |
| 557 | } else if (actual < 0) { |
| 558 | failures++; |
| 559 | printf("Unexpected failure of hasDuplicates\n"); |
| 560 | } else if (0 == expected) { |
| 561 | failures++; |
| 562 | printf("Expected no duplicate but found some.\n"); |
| 563 | } else { |
| 564 | failures++; |
| 565 | printf("Expected duplicates but found none.\n"); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | static void regression_tests(void) { |
| 570 | { |
no test coverage detected