File: randommodtest.c

package info (click to toggle)
tinyssh 20230101-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,244 kB
  • sloc: ansic: 12,106; sh: 1,168; python: 479; makefile: 42
file content (27 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
20140416
Jan Mojzis
Public domain.
*/

#include <stdio.h>
#include <unistd.h>
#include "fail.h"
#include "randommod.h"

int main(void) {

    long long i, r;

    if (randommod(-1) != 0) fail("failure");
    if (randommod(0) != 0) fail("failure");
    if (randommod(1) != 0) fail("failure");
    for (i = 2; i < 10; ++i) {
        r = randommod(i);
        if (r > i - 1 || r < 0) fail("failure");
    }
    for (i = 18014398509481984ULL; i < 18014398509481994ULL; ++i) {
        if (randommod(i) == randommod(i)) fail("failure");
    }
    _exit(0);
}