static void testDuplicates(struct Random* rand) { uint16_t randomShorts[8192]; uint16_t out[8192]; struct ReplayProtector rp = {.bitfield = 0}; Random_bytes(rand, (uint8_t*)randomShorts, sizeof(randomShorts)); uint32_t outIdx = 0; for (uint32_t i = 0; i < 1024; i++) { if (ReplayProtector_checkNonce((randomShorts[i] % (i + 20)), &rp)) { out[outIdx] = (randomShorts[i] % (i + 20)); outIdx++; } } for (uint32_t i = 0; i < outIdx; i++) { for (uint32_t j = i + 1; j < outIdx; j++) { Assert_always(out[i] != out[j]); } } } int main() { struct Allocator* alloc = MallocAllocator_new(4096); struct Random* rand = Random_new(alloc, NULL, NULL); for (int i = 0; i < CYCLES; i++) { testDuplicates(rand); } return 0; }
int main() { testSplines(); testDuplicates(); }