File: crypto_sort_uint32test.c

package info (click to toggle)
tinyssh 20250501-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,388 kB
  • sloc: ansic: 20,245; sh: 1,582; python: 1,449; makefile: 913
file content (34 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
#include "misc.h"
#include "crypto_uint32.h"
#include "crypto_sort_uint32.h"

static void test_321(void) {

    crypto_uint32 x[3] = {3, 2, 1};

    crypto_sort_uint32(x, 3);

    if (x[0] != 1) fail("crypto_sort_uint32() failure");
    if (x[1] != 2) fail("crypto_sort_uint32() failure");
    if (x[2] != 3) fail("crypto_sort_uint32() failure");
}

static void test_i(void) {

    crypto_uint32 x[5] = { (crypto_uint32) -1, (crypto_uint32) -2, 2, 1, 0};

    crypto_sort_uint32(x, 5);

    if (x[0] != 0) fail("crypto_sort_uint32() failure");
    if (x[1] != 1) fail("crypto_sort_uint32() failure");
    if (x[2] != 2) fail("crypto_sort_uint32() failure");
    if (x[3] != (crypto_uint32) -2) fail("crypto_sort_uint32() failure");
    if (x[4] != (crypto_uint32) -1) fail("crypto_sort_uint32() failure");
}

int main(void) {

    test_321();
    test_i();
    _exit(0);
}