Changeset 39421
- Timestamp:
- Mar 1, 2016, 11:38:17 AM (10 years ago)
- Location:
- branches/eam_branches/ohana.20160226/src/libfits/test
- Files:
-
- 5 edited
-
imagecomp.c (modified) (2 diffs)
-
keywords.c (modified) (6 diffs)
-
ricetest.c (modified) (5 diffs)
-
tablecomp.c (modified) (12 diffs)
-
zlib.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20160226/src/libfits/test/imagecomp.c
r38553 r39421 17 17 static int NY = 10; 18 18 19 int main ( int argc, char **argv) {19 int main (void) { 20 20 21 21 plan_tests (3*3*234); … … 196 196 } 197 197 198 int Ztile[2] = {NX, NY};199 ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, ( int *) &Ztile, zcmptype), "compressed image");198 unsigned long int Ztile[2] = {NX, NY}; 199 ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, (unsigned long int *) &Ztile, zcmptype), "compressed image"); 200 200 // ok (gfits_compress_image (&rawheader, &rawmatrix, &ftable, NULL, zcmptype), "compressed image"); 201 201 ok (gfits_uncompress_image (&outheader, &outmatrix, &ftable), "uncompressed image"); -
branches/eam_branches/ohana.20160226/src/libfits/test/keywords.c
r39321 r39421 15 15 tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; } 16 16 17 int main ( int argc, char **argv) {17 int main (void) { 18 18 19 19 plan_tests (14); … … 21 21 diag ("libfits keyword tests"); 22 22 23 int i, err;24 double srcbuf[NSRC], tgtbuf[NTGT], outbuf[NOUT];25 26 23 { 27 24 … … 96 93 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 97 94 98 ok (gfits_modify (&header, "D_LONG3", "%Ld", 1, (long long) 0x100), "wrote a keyword"); 99 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 95 // this is not ISO C99: 96 // ok (gfits_modify (&header, "D_LONG3", "%Ld", 1, (long long) 0x100), "wrote a keyword"); 97 // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 100 98 101 99 // set one of each of the few numerical types (unsigned ints) … … 109 107 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 110 108 111 ok (gfits_modify (&header, "DU_LONG3", "%Lu", 1, (long long) 0x100), "wrote a keyword");112 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");109 // ok (gfits_modify (&header, "DU_LONG3", "%Lu", 1, (long long) 0x100), "wrote a keyword"); 110 // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 113 111 114 112 ok (gfits_modify (&header, "D_SHORT", "%hd", 1, 0x20), "wrote a keyword"); … … 229 227 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 230 228 231 ok (gfits_scan (&header, "D_LONG3", "%Ld", 1, &Kvalue), "read a keyword");232 ok (Kvalue == 0x100, "got the right value");233 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");229 // ok (gfits_scan (&header, "D_LONG3", "%Ld", 1, &Kvalue), "read a keyword"); 230 // ok (Kvalue == 0x100, "got the right value"); 231 // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 234 232 235 233 // set one of each of the few numerical types (unsigned ints) … … 246 244 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 247 245 248 ok (gfits_scan (&header, "DU_LONG3", "%Lu", 1, &Ulonglong), "read a keyword");249 ok (Ulonglong == 0x100, "got the right value");250 ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good");246 // ok (gfits_scan (&header, "DU_LONG3", "%Lu", 1, &Ulonglong), "read a keyword"); 247 // ok (Ulonglong == 0x100, "got the right value"); 248 // ptr = gfits_header_field (&header, "END", 1); ok (ptr, "END still good"); 251 249 252 250 ok (gfits_scan (&header, "D_SHORT", "%hd", 1, &Ishort), "read a keyword"); -
branches/eam_branches/ohana.20160226/src/libfits/test/ricetest.c
r38404 r39421 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 # include <gfits_compress.h> 3 4 # include "tap_ohana.h" 4 5 … … 6 7 # define NBYTE 4*NPIX 7 8 8 int main ( int argc, char **argv) {9 int main (void) { 9 10 10 11 plan_tests (45); … … 12 13 diag ("libfits ricetest.c tests"); 13 14 14 // buffers to store max array15 char rawdata[NBYTE];16 char cmpdata[NBYTE];17 char outdata[NBYTE];18 19 15 // ok (1, "failure"); 20 16 21 17 if (1) { 18 // buffers to store max array 19 char rawdata[NBYTE]; 20 unsigned char outdata[NBYTE]; 21 unsigned char cmpdata[NBYTE]; 22 22 char *rawvalue = (char *) rawdata; 23 23 char *outvalue = (char *) outdata; … … 46 46 47 47 if (1) { 48 // buffers to store max array 49 char rawdata[NBYTE]; 50 unsigned short outdata[NBYTE]; 51 unsigned char cmpdata[NBYTE]; 52 48 53 short *rawvalue = (short *) rawdata; 49 54 short *outvalue = (short *) outdata; … … 72 77 73 78 if (1) { 79 // buffers to store max array 80 char rawdata[NBYTE]; 81 unsigned int outdata[NBYTE]; 82 unsigned char cmpdata[NBYTE]; 83 74 84 int *rawvalue = (int *) rawdata; 75 85 int *outvalue = (int *) outdata; -
branches/eam_branches/ohana.20160226/src/libfits/test/tablecomp.c
r38553 r39421 10 10 char *cmptype[] = {"NONE", "NONE_1", "NONE_2", "GZIP_1", "GZIP_2", "RICE_1", "RICE_ONE", "AUTO", NULL}; 11 11 12 int main ( int argc, char **argv) {13 14 plan_tests (668 );12 int main (void) { 13 14 plan_tests (668+428); 15 15 16 16 diag ("libfits tablecomp.c tests"); … … 28 28 test_compress_empty (cmptype[i]); 29 29 ok (ohana_memcheck (TRUE), "no memory corruption"); 30 ohana_memdump (TRUE); 30 31 } 31 32 … … 89 90 ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table"); 90 91 92 if (0) { int ix, iy; 93 for (ix = 0; ix < 12; ix++) { 94 for (iy = 0; iy < 16; iy++) { 95 fprintf (stderr, "%x ", (int) cmptable.buffer[ix*16 + iy]); 96 } 97 } 98 } 99 100 Header rawheader; 101 FTable rawtable; 102 rawtable.header = &rawheader; 103 ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table"); 104 105 gfits_free_header (&cmpheader); 106 gfits_free_table (&cmptable); 107 108 outheader = &rawheader; 109 outtable = &rawtable; 110 } 111 112 char type[16]; 113 int Ncol; 114 off_t Nrow; 115 116 char *VAL_B_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_B", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"), "read byte table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 117 short *VAL_I_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_I", type, &Nrow, &Ncol); ok (!strcmp (type, "short"), "read short table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 118 int *VAL_J_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_J", type, &Nrow, &Ncol); ok (!strcmp (type, "int"), "read int table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 119 int64_t *VAL_K_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_K", type, &Nrow, &Ncol); ok (!strcmp (type, "int64_t"), "read int64_t table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 120 float *VAL_E_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_E", type, &Nrow, &Ncol); ok (!strcmp (type, "float"), "read float table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 121 double *VAL_D_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_D", type, &Nrow, &Ncol); ok (!strcmp (type, "double"), "read double table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 122 123 // count mismatched values 124 int NVAL_B_bad = 0; 125 int NVAL_I_bad = 0; 126 int NVAL_J_bad = 0; 127 int NVAL_K_bad = 0; 128 int NVAL_E_bad = 0; 129 int NVAL_D_bad = 0; 130 131 // for (i = 0; i < Nval; i++) { 132 // fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]); 133 // } 134 135 for (i = 0; i < Nval; i++) { 136 if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++; 137 if (VAL_I[i] != VAL_I_t[i]) NVAL_I_bad++; 138 if (VAL_J[i] != VAL_J_t[i]) NVAL_J_bad++; 139 if (VAL_K[i] != VAL_K_t[i]) NVAL_K_bad++; 140 if (VAL_E[i] != VAL_E_t[i]) NVAL_E_bad++; 141 if (VAL_D[i] != VAL_D_t[i]) NVAL_D_bad++; 142 } 143 144 ok (!NVAL_B_bad, "byte values match (input vs output)"); 145 ok (!NVAL_I_bad, "short values match (input vs output)"); 146 ok (!NVAL_J_bad, "int values match (input vs output)"); 147 ok (!NVAL_K_bad, "int64_t values match (input vs output)"); 148 ok (!NVAL_E_bad, "float values match (input vs output)"); 149 ok (!NVAL_D_bad, "double values match (input vs output)"); 150 151 free (VAL_B); 152 free (VAL_I); 153 free (VAL_J); 154 free (VAL_K); 155 free (VAL_E); 156 free (VAL_D); 157 158 free (VAL_B_t); 159 free (VAL_I_t); 160 free (VAL_J_t); 161 free (VAL_K_t); 162 free (VAL_E_t); 163 free (VAL_D_t); 164 165 gfits_free_header (&header); 166 gfits_free_table (&ftable); 167 if (zcmptype) { 168 gfits_free_header (outheader); 169 gfits_free_table (outtable); 170 } 171 return TRUE; 172 } 173 174 int test_compress_fullrange (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 175 176 Header header; 177 FTable ftable; 178 179 diag ("--- starting test_compress with zcmptype %s ---", zcmptype); 180 ok (gfits_init_header (&header), "inited the header"); 181 ok (gfits_init_table (&ftable), "inited the table"); 182 183 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 184 185 ok (gfits_define_bintable_column (&header, "B", "VAL_B", "byte", "none", 1.0, 0.0), "defined byte column"); 186 ok (gfits_define_bintable_column (&header, "I", "VAL_I", "short", "none", 1.0, 0.0), "defined short column"); 187 ok (gfits_define_bintable_column (&header, "J", "VAL_J", "int", "none", 1.0, 0.0), "defined int column"); 188 ok (gfits_define_bintable_column (&header, "K", "VAL_K", "long", "none", 1.0, 0.0), "defined long column"); 189 ok (gfits_define_bintable_column (&header, "E", "VAL_E", "float", "degree", 1.0, 0.0), "defined float column"); 190 ok (gfits_define_bintable_column (&header, "D", "VAL_D", "double", "degree", 1.0, 0.0), "defined double column"); 191 192 // generate the output array that carries the data 193 ok (gfits_create_table (&header, &ftable), "created the basic table"); 194 195 int Nval = 1000; 196 char *VAL_B; ALLOCATE (VAL_B, char, Nval); 197 short *VAL_I; ALLOCATE (VAL_I, short, Nval); 198 int *VAL_J; ALLOCATE (VAL_J, int, Nval); 199 int64_t *VAL_K; ALLOCATE (VAL_K, int64_t, Nval); 200 float *VAL_E; ALLOCATE (VAL_E, float, Nval); 201 double *VAL_D; ALLOCATE (VAL_D, double, Nval); 202 203 long A = time(NULL); 204 srand48(A); 205 206 int i; 207 for (i = 0; i < Nval; i++) { 208 VAL_B[i] = 0xff & lrand48(); 209 VAL_I[i] = 0xffff & lrand48(); 210 VAL_J[i] = 0xffffffff & lrand48(); 211 VAL_K[i] = (((int64_t)lrand48()) << 32) + (int64_t)lrand48(); 212 VAL_E[i] = FLT_MAX * (2.0*drand48() - 1.0); 213 VAL_D[i] = DBL_MAX * (2.0*drand48() - 1.0); 214 } 215 216 // add the columns to the output array 217 ok (gfits_set_bintable_column (&header, &ftable, "VAL_B", VAL_B, Nval), "set byte table column"); 218 ok (gfits_set_bintable_column (&header, &ftable, "VAL_I", VAL_I, Nval), "set short table column"); 219 ok (gfits_set_bintable_column (&header, &ftable, "VAL_J", VAL_J, Nval), "set int table column"); 220 ok (gfits_set_bintable_column (&header, &ftable, "VAL_K", VAL_K, Nval), "set long table column"); 221 ok (gfits_set_bintable_column (&header, &ftable, "VAL_E", VAL_E, Nval), "set float table column"); 222 ok (gfits_set_bintable_column (&header, &ftable, "VAL_D", VAL_D, Nval), "set double table column"); 223 224 Header *outheader = &header; 225 FTable *outtable = &ftable; 226 227 if (zcmptype) { 228 Header cmpheader; 229 FTable cmptable; 230 cmptable.header = &cmpheader; 231 ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table"); 232 91 233 Header rawheader; 92 234 FTable rawtable; … … 120 262 int NVAL_D_bad = 0; 121 263 122 // for (i = 0; i < Nval; i++) {123 // fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]);124 // }125 126 264 for (i = 0; i < Nval; i++) { 127 265 if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++; … … 140 278 ok (!NVAL_D_bad, "double values match (input vs output)"); 141 279 280 free (VAL_B); 281 free (VAL_I); 282 free (VAL_J); 283 free (VAL_K); 284 free (VAL_E); 285 free (VAL_D); 286 287 free (VAL_B_t); 288 free (VAL_I_t); 289 free (VAL_J_t); 290 free (VAL_K_t); 291 free (VAL_E_t); 292 free (VAL_D_t); 293 142 294 gfits_free_header (&header); 143 295 gfits_free_table (&ftable); … … 149 301 } 150 302 151 int test_compress_fullrange (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 303 int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 304 305 Header header; 306 FTable ftable; 307 308 diag ("--- starting test_compress with zcmptype %s ---", zcmptype); 309 ok (gfits_init_header (&header), "inited the header"); 310 ok (gfits_init_table (&ftable), "inited the table"); 311 312 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 313 314 ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column"); 315 316 // generate the output array that carries the data 317 ok (gfits_create_table (&header, &ftable), "created the basic table"); 318 319 int Nval = 1000; 320 short *SEQ; ALLOCATE (SEQ, short, Nval); 321 322 int i; 323 for (i = 0; i < Nval; i++) { 324 SEQ[i] = i; 325 } 326 327 // add the columns to the output array 328 ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short table column"); 329 330 Header *outheader = &header; 331 FTable *outtable = &ftable; 332 333 if (zcmptype) { 334 Header cmpheader; 335 FTable cmptable; 336 cmptable.header = &cmpheader; 337 ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table"); 338 339 Header rawheader; 340 FTable rawtable; 341 rawtable.header = &rawheader; 342 ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table"); 343 344 gfits_free_header (&cmpheader); 345 gfits_free_table (&cmptable); 346 347 outheader = &rawheader; 348 outtable = &rawtable; 349 } 350 351 char type[16]; 352 int Ncol; 353 off_t Nrow; 354 355 short *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"), "read short table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 356 357 // count mismatched values 358 int Nseq = 0; 359 for (i = 0; i < Nval; i++) { 360 if (SEQ[i] != SEQ_t[i]) Nseq++; 361 } 362 363 ok (!Nseq, "short values match (input vs output)"); 364 365 gfits_free_header (&header); 366 gfits_free_table (&ftable); 367 if (zcmptype) { 368 gfits_free_header (outheader); 369 gfits_free_table (outtable); 370 } 371 return TRUE; 372 } 373 374 int test_compress_empty (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 152 375 153 376 Header header; … … 170 393 ok (gfits_create_table (&header, &ftable), "created the basic table"); 171 394 172 int Nval = 1000;395 int Nval = 0; 173 396 char *VAL_B; ALLOCATE (VAL_B, char, Nval); 174 397 short *VAL_I; ALLOCATE (VAL_I, short, Nval); … … 178 401 double *VAL_D; ALLOCATE (VAL_D, double, Nval); 179 402 180 long A = time(NULL);181 srand48(A);182 183 403 int i; 184 404 for (i = 0; i < Nval; i++) { 185 VAL_B[i] = 0xff & lrand48();186 VAL_I[i] = 0xffff & lrand48();187 VAL_J[i] = 0xffffffff & lrand48();188 VAL_K[i] = (((int64_t)lrand48()) << 32) + (int64_t)lrand48();189 VAL_E[i] = FLT_MAX * (2.0*drand48() - 1.0);190 VAL_D[i] = DBL_MAX * (2.0*drand48() - 1.0);405 VAL_B[i] = (i % 255) - 128; 406 VAL_I[i] = i; 407 VAL_J[i] = 10000*i + 100*i; 408 VAL_K[i] = 10000*i + 330*i; 409 VAL_E[i] = 0.1*i; 410 VAL_D[i] = 1.001*i; 191 411 } 192 412 … … 206 426 FTable cmptable; 207 427 cmptable.header = &cmpheader; 208 ok (gfits_compress_table (&ftable, &cmptable, 10, zcmptype), "compressed table");428 ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table"); 209 429 210 430 Header rawheader; … … 239 459 int NVAL_D_bad = 0; 240 460 461 // for (i = 0; i < Nval; i++) { 462 // fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]); 463 // } 464 241 465 for (i = 0; i < Nval; i++) { 242 466 if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++; … … 255 479 ok (!NVAL_D_bad, "double values match (input vs output)"); 256 480 481 free (VAL_B); 482 free (VAL_I); 483 free (VAL_J); 484 free (VAL_K); 485 free (VAL_E); 486 free (VAL_D); 487 488 free (VAL_B_t); 489 free (VAL_I_t); 490 free (VAL_J_t); 491 free (VAL_K_t); 492 free (VAL_E_t); 493 free (VAL_D_t); 494 257 495 gfits_free_header (&header); 258 496 gfits_free_table (&ftable); … … 264 502 } 265 503 266 int test_compress_single_full (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 267 268 Header header; 269 FTable ftable; 270 271 diag ("--- starting test_compress with zcmptype %s ---", zcmptype); 272 ok (gfits_init_header (&header), "inited the header"); 273 ok (gfits_init_table (&ftable), "inited the table"); 274 275 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 276 277 ok (gfits_define_bintable_column (&header, "I", "SEQ", "seq", "none", 1.0, 0.0), "defined short column"); 278 279 // generate the output array that carries the data 280 ok (gfits_create_table (&header, &ftable), "created the basic table"); 281 282 int Nval = 1000; 283 short *SEQ; ALLOCATE (SEQ, short, Nval); 284 285 int i; 286 for (i = 0; i < Nval; i++) { 287 SEQ[i] = i; 288 } 289 290 // add the columns to the output array 291 ok (gfits_set_bintable_column (&header, &ftable, "SEQ", SEQ, Nval), "set short table column"); 292 293 Header *outheader = &header; 294 FTable *outtable = &ftable; 295 296 if (zcmptype) { 297 Header cmpheader; 298 FTable cmptable; 299 cmptable.header = &cmpheader; 300 ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table"); 301 302 Header rawheader; 303 FTable rawtable; 304 rawtable.header = &rawheader; 305 ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table"); 306 307 gfits_free_header (&cmpheader); 308 gfits_free_table (&cmptable); 309 310 outheader = &rawheader; 311 outtable = &rawtable; 312 } 313 314 char type[16]; 315 int Ncol; 316 off_t Nrow; 317 318 short *SEQ_t = gfits_get_bintable_column_data (outheader, outtable, "SEQ", type, &Nrow, &Ncol); ok (!strcmp (type, "short"), "read short table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 319 320 // count mismatched values 321 int Nseq = 0; 322 for (i = 0; i < Nval; i++) { 323 if (SEQ[i] != SEQ_t[i]) Nseq++; 324 } 325 326 ok (!Nseq, "short values match (input vs output)"); 327 328 gfits_free_header (&header); 329 gfits_free_table (&ftable); 330 if (zcmptype) { 331 gfits_free_header (outheader); 332 gfits_free_table (outtable); 333 } 334 return TRUE; 335 } 336 337 int test_compress_empty (char *zcmptype) { // test 2: make a table, compress, uncompress, compare : use compression "NONE" 338 339 Header header; 340 FTable ftable; 341 342 diag ("--- starting test_compress with zcmptype %s ---", zcmptype); 343 ok (gfits_init_header (&header), "inited the header"); 344 ok (gfits_init_table (&ftable), "inited the table"); 345 346 ok (gfits_create_table_header (&header, "BINTABLE", "TESTDATA"), "created the table header"); 347 348 ok (gfits_define_bintable_column (&header, "B", "VAL_B", "byte", "none", 1.0, 0.0), "defined byte column"); 349 ok (gfits_define_bintable_column (&header, "I", "VAL_I", "short", "none", 1.0, 0.0), "defined short column"); 350 ok (gfits_define_bintable_column (&header, "J", "VAL_J", "int", "none", 1.0, 0.0), "defined int column"); 351 ok (gfits_define_bintable_column (&header, "K", "VAL_K", "long", "none", 1.0, 0.0), "defined long column"); 352 ok (gfits_define_bintable_column (&header, "E", "VAL_E", "float", "degree", 1.0, 0.0), "defined float column"); 353 ok (gfits_define_bintable_column (&header, "D", "VAL_D", "double", "degree", 1.0, 0.0), "defined double column"); 354 355 // generate the output array that carries the data 356 ok (gfits_create_table (&header, &ftable), "created the basic table"); 357 358 int Nval = 0; 359 char *VAL_B; ALLOCATE (VAL_B, char, Nval); 360 short *VAL_I; ALLOCATE (VAL_I, short, Nval); 361 int *VAL_J; ALLOCATE (VAL_J, int, Nval); 362 int64_t *VAL_K; ALLOCATE (VAL_K, int64_t, Nval); 363 float *VAL_E; ALLOCATE (VAL_E, float, Nval); 364 double *VAL_D; ALLOCATE (VAL_D, double, Nval); 365 366 int i; 367 for (i = 0; i < Nval; i++) { 368 VAL_B[i] = (i % 255) - 128; 369 VAL_I[i] = i; 370 VAL_J[i] = 10000*i + 100*i; 371 VAL_K[i] = 10000*i + 330*i; 372 VAL_E[i] = 0.1*i; 373 VAL_D[i] = 1.001*i; 374 } 375 376 // add the columns to the output array 377 ok (gfits_set_bintable_column (&header, &ftable, "VAL_B", VAL_B, Nval), "set byte table column"); 378 ok (gfits_set_bintable_column (&header, &ftable, "VAL_I", VAL_I, Nval), "set short table column"); 379 ok (gfits_set_bintable_column (&header, &ftable, "VAL_J", VAL_J, Nval), "set int table column"); 380 ok (gfits_set_bintable_column (&header, &ftable, "VAL_K", VAL_K, Nval), "set long table column"); 381 ok (gfits_set_bintable_column (&header, &ftable, "VAL_E", VAL_E, Nval), "set float table column"); 382 ok (gfits_set_bintable_column (&header, &ftable, "VAL_D", VAL_D, Nval), "set double table column"); 383 384 Header *outheader = &header; 385 FTable *outtable = &ftable; 386 387 if (zcmptype) { 388 Header cmpheader; 389 FTable cmptable; 390 cmptable.header = &cmpheader; 391 ok (gfits_compress_table (&ftable, &cmptable, 0, zcmptype), "compressed table"); 392 393 Header rawheader; 394 FTable rawtable; 395 rawtable.header = &rawheader; 396 ok (gfits_uncompress_table (&cmptable, &rawtable), "uncompressed table"); 397 398 gfits_free_header (&cmpheader); 399 gfits_free_table (&cmptable); 400 401 outheader = &rawheader; 402 outtable = &rawtable; 403 } 404 405 char type[16]; 406 int Ncol; 407 off_t Nrow; 408 409 char *VAL_B_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_B", type, &Nrow, &Ncol); ok (!strcmp (type, "byte"), "read byte table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 410 short *VAL_I_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_I", type, &Nrow, &Ncol); ok (!strcmp (type, "short"), "read short table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 411 int *VAL_J_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_J", type, &Nrow, &Ncol); ok (!strcmp (type, "int"), "read int table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 412 int64_t *VAL_K_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_K", type, &Nrow, &Ncol); ok (!strcmp (type, "int64_t"), "read int64_t table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 413 float *VAL_E_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_E", type, &Nrow, &Ncol); ok (!strcmp (type, "float"), "read float table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 414 double *VAL_D_t = gfits_get_bintable_column_data (outheader, outtable, "VAL_D", type, &Nrow, &Ncol); ok (!strcmp (type, "double"), "read double table column"); ok (Nrow == Nval, "right number of rows"); ok (Ncol == 1, "right number of cols"); 415 416 // count mismatched values 417 int NVAL_B_bad = 0; 418 int NVAL_I_bad = 0; 419 int NVAL_J_bad = 0; 420 int NVAL_K_bad = 0; 421 int NVAL_E_bad = 0; 422 int NVAL_D_bad = 0; 423 424 // for (i = 0; i < Nval; i++) { 425 // fprintf (stderr, "%0llx : %0llx\n", (long long) VAL_K[i], (long long) VAL_K_t[i]); 426 // } 427 428 for (i = 0; i < Nval; i++) { 429 if (VAL_B[i] != VAL_B_t[i]) NVAL_B_bad++; 430 if (VAL_I[i] != VAL_I_t[i]) NVAL_I_bad++; 431 if (VAL_J[i] != VAL_J_t[i]) NVAL_J_bad++; 432 if (VAL_K[i] != VAL_K_t[i]) NVAL_K_bad++; 433 if (VAL_E[i] != VAL_E_t[i]) NVAL_E_bad++; 434 if (VAL_D[i] != VAL_D_t[i]) NVAL_D_bad++; 435 } 436 437 ok (!NVAL_B_bad, "byte values match (input vs output)"); 438 ok (!NVAL_I_bad, "short values match (input vs output)"); 439 ok (!NVAL_J_bad, "int values match (input vs output)"); 440 ok (!NVAL_K_bad, "int64_t values match (input vs output)"); 441 ok (!NVAL_E_bad, "float values match (input vs output)"); 442 ok (!NVAL_D_bad, "double values match (input vs output)"); 443 444 gfits_free_header (&header); 445 gfits_free_table (&ftable); 446 if (zcmptype) { 447 gfits_free_header (outheader); 448 gfits_free_table (outtable); 449 } 450 return TRUE; 451 } 452 453 504 -
branches/eam_branches/ohana.20160226/src/libfits/test/zlib.c
r38442 r39421 16 16 tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; } 17 17 18 int main ( int argc, char **argv) {18 int main (void) { 19 19 20 20 plan_tests (14); … … 30 30 { 31 31 z_stream zdn; 32 zdn.next_in = ( char *) srcbuf;32 zdn.next_in = (unsigned char *) srcbuf; 33 33 zdn.avail_in = NSRC * sizeof(double); 34 zdn.next_out = ( char *) tgtbuf;34 zdn.next_out = (unsigned char *) tgtbuf; 35 35 zdn.avail_out = NTGT * sizeof(double); 36 36 … … 83 83 { 84 84 z_stream zup; 85 zup.next_in = ( char *) tgtbuf;85 zup.next_in = (unsigned char *) tgtbuf; 86 86 zup.avail_in = NTGT * sizeof(double); 87 zup.next_out = ( char *) outbuf;87 zup.next_out = (unsigned char *) outbuf; 88 88 zup.avail_out = NOUT * sizeof(double); 89 89 … … 120 120 { 121 121 z_stream zdn; 122 zdn.next_in = ( char *) srcbuf;122 zdn.next_in = (unsigned char *) srcbuf; 123 123 zdn.avail_in = NSRC * sizeof(double); 124 zdn.next_out = ( char *) tgtbuf;124 zdn.next_out = (unsigned char *) tgtbuf; 125 125 zdn.avail_out = NTGT * sizeof(double); 126 126 … … 174 174 { 175 175 z_stream zup; 176 zup.next_in = ( char *) tgtbuf;176 zup.next_in = (unsigned char *) tgtbuf; 177 177 zup.avail_in = NTGT * sizeof(double); 178 zup.next_out = ( char *) outbuf;178 zup.next_out = (unsigned char *) outbuf; 179 179 zup.avail_out = NOUT * sizeof(double); 180 180
Note:
See TracChangeset
for help on using the changeset viewer.
