File: tst_seekgb.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 (59 lines) | stat: -rw-r--r-- 1,326 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* This is a test for the NCEPLIBS-g2c project. This test is for
 * seekgb.c.
 *
 * Ed Hartnett 12/9/21
 */

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

#define GRIB2_FILE "data/gdaswave.t00z.wcoast.0p16.f000.grib2"
#define GRIB2_INDEX_FILE "data/gdaswave.t00z.wcoast.0p16.f000.grib2.idx"

int
main()
{
    printf("Testing seekgb.\n");
    printf("Testing simple seekgb() call...");
    {
        FILE *f;
        g2int lskip, lgrib;

        /* Open test data file. */
        if (!(f = fopen(GRIB2_FILE, "r")))
            return G2C_ERROR;

        /* Run seekgb() on data file. */
        seekgb(f, 0, 16, &lskip, &lgrib);

        /* Check results. */
        if (lgrib != 15254 || lskip)
            return G2C_ERROR;

        /* Close test data file. */
        fclose(f);
    }
    printf("ok!\n");
    printf("Testing seekgb() call on non-data file...");
    {
        FILE *f;
        g2int lskip, lgrib;

        /* Open test data file. */
        if (!(f = fopen(GRIB2_INDEX_FILE, "r")))
            return G2C_ERROR;

        /* Run seekgb() on non-data file. */
        seekgb(f, 0, 16, &lskip, &lgrib);

        /* Check results. */
        if (lgrib != 0)
            return G2C_ERROR;

        /* Close test data file. */
        fclose(f);
    }
    printf("ok!\n");
    printf("SUCCESS!\n");
    return 0;
}