File: test_chealpix.c

package info (click to toggle)
scamp 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 82,248 kB
  • sloc: ansic: 33,826; sh: 1,055; makefile: 299; python: 42
file content (36 lines) | stat: -rw-r--r-- 827 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
35
36
/**
 * test chealpix
 *
 * Here we are only testing "neighbors_nest" because this is the one we had
 * to implement from the C++ code.
 */

#include <assert.h>
#include <stdint.h>
#include <stdio.h>

#include "../src/chealpix.h"

int main(int argc, char **argv)
{
    long i;
    int j, k;
    int64_t nsides = 16;
    int64_t neigh[8], testneigh[8];

    FILE *fd = fopen("extra/test_chealpix.data", "r");

    for (i=0; i<nside2npix(nsides); i++) {
        neighbours_nest64(nsides, i, neigh);
        k = fscanf(fd, "%li:%li:%li:%li:%li:%li:%li:%li:\n",
                &testneigh[0],&testneigh[1],&testneigh[2],&testneigh[3],
                &testneigh[4],&testneigh[5],&testneigh[6],&testneigh[7]);
        assert(k == 8);

        for (j=0; j<8; j++)
            assert(neigh[j] == testneigh[j]);

    }

    return 0;
}