diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/lib/test-primes.c | |
parent | Initial commit. (diff) | |
download | dovecot-upstream.tar.xz dovecot-upstream.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/test-primes.c')
-rw-r--r-- | src/lib/test-primes.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/test-primes.c b/src/lib/test-primes.c new file mode 100644 index 0000000..fc792b4 --- /dev/null +++ b/src/lib/test-primes.c @@ -0,0 +1,24 @@ +/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */ + +#include "test-lib.h" +#include "primes.h" + +void test_primes(void) +{ + unsigned int i, j, num; + bool success; + + success = primes_closest(0) > 0; + for (num = 1; num < 1024; num++) { + if (primes_closest(num) < num) + success = FALSE; + } + for (i = 10; i < 32; i++) { + num = (1U << i) - 100; + for (j = 0; j < 200; j++, num++) { + if (primes_closest(num) < num) + success = FALSE; + } + } + test_out("primes_closest()", success); +} |