File: tst_spec.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 (79 lines) | stat: -rw-r--r-- 2,515 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
74
75
76
77
78
79
/* This is a test for the NCEPLIBS-g2c project. This test is for
 * the spectral compression functions.
 *
 * Ed Hartnett 11/1/21
 */

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

#define DATA_LEN 4
#define PACKED_LEN 200

/* Prototypes we are testing. */

int
main()
{
    printf("Testing spec functions.\n");
    /* printf("Testing specpack()/specunpack() calls..."); */
    /* { */
    /*     g2int height = 2, width = 2; */
    /*     g2int len = PACKED_LEN, ndpts = DATA_LEN; */
    /*     g2float fld[DATA_LEN] = {1.0, 2.0, 3.0, 0.0}; */
    /*     g2float fld_in[DATA_LEN]; */
    /*     unsigned char cpack[PACKED_LEN]; */
    /*     g2int lcpack = PACKED_LEN; */
    /*     g2int idrstmpl[10] = {0, 1, 1, 16, 0, 1, 2, 3, 4, 5, 6}; */
    /*     g2int JJ = 1, KK = 2, MM = 3; */
    /*     int i; */

    /*     /\* Pack the data. *\/ */
    /*     specpack(fld, ndpts, JJ, KK, MM, idrstmpl, cpack, &lcpack); */

    /*     /\* /\\* Unpack the data. *\\/ *\/ */
    /*     /\* if (jpcunpack(cpack, len, idrstmpl, ndpts, fld_in)) *\/ */
    /*     /\*     return G2C_ERROR; *\/ */

    /*     /\* for (i = 0; i < DATA_LEN; i++) *\/ */
    /*     /\* { *\/ */
    /*     /\*     /\\* printf("%g %g\n", fld[i], fld_in[i]); *\\/ *\/ */
    /*     /\*     if (fld[i] != fld_in[i]) *\/ */
    /*     /\* 	return G2C_ERROR; *\/ */
    /*     /\* } *\/ */
    /* } */
    /* printf("ok!\n"); */
    /* printf("Testing enc_jpeg2000() call..."); */
    /* { */
    /*     unsigned char data[4] = {1, 2, 3, 4}; */
    /*     g2int width = 2, height = 2, nbits = 4; */
    /*     g2int ltype = 0, ratio = 0, retry = 0, jpclen = 200; */
    /*     char outjpc[200]; */
    /*     g2int outfld[4]; */
    /*     /\* int i; *\/ */
    /*     int ret; */

    /*     /\* Encode some data. *\/ */
    /*     /\* 168 on Linux, but 133 on windows? *\/ */
    /*     if ((ret = enc_jpeg2000(data, width, height, nbits, ltype, ratio, retry, outjpc, jpclen)) < 133) */
    /*     { */
    /*         printf("%d\n", ret); */
    /*         return G2C_ERROR; */
    /*     } */

    /*     /\* Now decode it. *\/ */
    /*     if ((ret = dec_jpeg2000(outjpc, jpclen, outfld))) */
    /*     { */
    /*         printf("%d\n", ret); */
    /*         return G2C_ERROR; */
    /*     } */

    /*     /\* for (i = 0; i < 4; i++) *\/ */
    /*     /\*     if (cout[i] != data[i]) *\/ */
    /*     /\*         return G2C_ERROR; *\/ */
    /* } */
    /* printf("ok!\n"); */
    printf("SUCCESS!\n");
    return 0;
}