File: tst_getdim.c

package info (click to toggle)
g2clib 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,524 kB
  • sloc: ansic: 28,287; python: 76; sh: 46; makefile: 26
file content (44 lines) | stat: -rw-r--r-- 1,495 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
37
38
39
40
41
42
43
44
/* This is a test for the NCEPLIBS-g2c project. This test is for
 * the getdim function.
 *
 * Ed Hartnett 10/28/21
 */

#include "grib2_int.h"
#include <stdio.h>
#include <stdlib.h>

#define SEC3_LEN 72

/* Prototypes for some functions tested in this program. */
g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan);
g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm);

int
main()
{
    printf("Testing getdim function.\n");
    printf("Testing getdim() call...");
    {
        g2int width, height, iscan;
        unsigned char csec3[SEC3_LEN] = {
            0x00, 0x00, 0x00, 0x48, /* len of sect 3 (72) */
            0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
            0x03, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
            0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00,
            0x00, 0x0c, 0x0d, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00,
            0x00, 0x00, 0x11, 0x12};

        getdim(csec3, &width, &height, &iscan);
        /* printf("%ld %ld %ld\n", width, height, iscan); */
        if (width != 7 || height != 8 || iscan != 18)
            return G2C_ERROR;

        /* Try the getpoly() function. */
        g2int jj, kk, mm;
        getpoly(csec3, &jj, &kk, &mm);
    }
    printf("ok!\n");
    printf("SUCCESS!\n");
    return 0;
}