File: tst_error.c

package info (click to toggle)
g2clib 2.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,600 kB
  • sloc: ansic: 28,287; python: 76; sh: 46; makefile: 26
file content (73 lines) | stat: -rw-r--r-- 2,707 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * This is part of the NCEPLIBS-g2c project.
 *
 * This is a test for error handling.
 *
 * Ed Hartnett 8/30/22
 */

#include "grib2_int.h"

#define MAX_LEN 512

int
main()
{
    printf("Testing error handling.\n");

    if (strncmp(g2c_strerror(0), "No error", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-50), "GRIB2 header not found", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-51), "GRIB message is already complete.", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-52), "Name too long", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-53), "Invalid input", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-54), "Error reading file", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-55), "Bad ID", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-56), "Too many files open", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-57), "Out of memory", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-58), "Error decoding message", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-59), "No GRIB message found", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-60), "Error parsing XML", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-61), "Table or entry not found", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-62), "Not GRIB 2", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-63), "Cannot find section", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-64), "Cannot find end of GRIB message", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-65), "End of message in wrong place", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-66), "Invalid section number", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-67), "Error encoding/decoding JPEG data", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-68), "Error encoding/decoding PNG data", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-69), "Template not found", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-70), "Template problem", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-71), "Parameter not found", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-72), "Product not found", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(-73), "Bad type", MAX_LEN))
        return G2C_ERROR;
    if (strncmp(g2c_strerror(999), "Unknown Error", MAX_LEN))
        return G2C_ERROR;

    printf("SUCCESS!\n");
    return 0;
}