00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 # include <config.h>
00034 #endif
00035
00036 #include <uves_utils.h>
00037 #include <uves_dfs.h>
00038 #include <uves_utils_cpl.h>
00039 #include <uves_utils_polynomial.h>
00040 #include <uves_utils_wrappers.h>
00041 #include <uves_error.h>
00042
00043 #include <cpl_test.h>
00044 #include <cpl.h>
00045 #include <string.h>
00046 #include <stdlib.h>
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifdef VERBOSE
00061
00062 #define test_data(r,f,m) \
00063 printf(m); \
00064 fflush(stdout); \
00065 fflush(stderr); \
00066 r = f; \
00067 if (!r) { \
00068 printf("Failure\n"); \
00069 \
00070 return 1; \
00071 } \
00072 printf("OK\n")
00073
00074 #else
00075
00076 #define test_data(r,f,m) \
00077 r = f; \
00078 if (!r) { \
00079 printf(m); \
00080 printf("Failure\n"); \
00081 \
00082 return 1; \
00083 }
00084
00085 #endif
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #ifdef VERBOSE
00096
00097 #define test(f,m) \
00098 printf(m); \
00099 fflush(stdout); \
00100 fflush(stderr); \
00101 if (f) { \
00102 printf("Failure\n"); \
00103 \
00104 return 1; \
00105 } \
00106 printf("OK\n")
00107
00108 #else
00109
00110 #define test(f,m) \
00111 if (f) { \
00112 printf(m); \
00113 printf("Failure\n"); \
00114 \
00115 return 1; \
00116 }
00117
00118 #endif
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 #ifdef VERBOSE
00129
00130 #define test_failure(e,f,m) \
00131 printf(m); \
00132 fflush(stdout); \
00133 fflush(stderr); \
00134 if (f != e) { \
00135 printf("\n"); \
00136 printf(" Received error: \"%s\"\n", cpl_error_get_message()); \
00137 cpl_error_set("cpl_table-test", e); \
00138 printf(" Expected error: \"%s\"\n", cpl_error_get_message()); \
00139 \
00140 return 1; \
00141 } \
00142 cpl_error_reset(); \
00143 printf("OK\n")
00144
00145 #else
00146
00147 #define test_failure(e,f,m) \
00148 if (f != e) { \
00149 printf(m); \
00150 printf("\n"); \
00151 printf(" Received error: \"%s\"\n", cpl_error_get_message()); \
00152 cpl_error_set("cpl_table-test", e); \
00153 printf(" Expected error: \"%s\"\n", cpl_error_get_message()); \
00154 \
00155 return 1; \
00156 } \
00157 cpl_error_reset()
00158
00159 #endif
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 #ifdef VERBOSE
00171
00172 #define test_ivalue(e,f,m) \
00173 printf(m); \
00174 fflush(stdout); \
00175 fflush(stderr); \
00176 itest = f; \
00177 if (itest != e) { \
00178 printf("Received %d, expected %d\n", itest, e); \
00179 \
00180 return 1; \
00181 } \
00182 printf("OK\n")
00183
00184 #else
00185
00186 #define test_ivalue(e,f,m) \
00187 itest = f; \
00188 if (itest != e) { \
00189 printf(m); \
00190 printf("Received %d, expected %d\n", itest, e); \
00191 \
00192 return 1; \
00193 }
00194
00195 #endif
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 #ifdef VERBOSE
00207
00208 #define test_pvalue(e,f,m) \
00209 printf(m); \
00210 fflush(stdout); \
00211 fflush(stderr); \
00212 ptest = f; \
00213 if (ptest != e) { \
00214 printf("Received %p, expected %p\n", ptest, e); \
00215 \
00216 return 1; \
00217 } \
00218 printf("OK\n")
00219
00220 #else
00221
00222 #define test_pvalue(e,f,m) \
00223 ptest = f; \
00224 if (ptest != e) { \
00225 printf(m); \
00226 printf("Received %p, expected %p\n", ptest, e); \
00227 \
00228 return 1; \
00229 }
00230
00231 #endif
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 #ifdef VERBOSE
00243
00244 #define test_fvalue(e,t,f,m) \
00245 printf(m); \
00246 fflush(stdout); \
00247 fflush(stderr); \
00248 ftest = f; \
00249 if (fabs(ftest - (e)) > t) { \
00250 printf("Received %f, expected %f\n", ftest, e); \
00251 \
00252 return 1; \
00253 } \
00254 printf("OK\n")
00255
00256 #else
00257
00258 #define test_fvalue(e,t,f,m) \
00259 ftest = f; \
00260 if (fabs(ftest - (e)) > t) { \
00261 printf(m); \
00262 printf("Received %f, expected %f\n", ftest, e); \
00263 \
00264 return 1; \
00265 }
00266
00267 #endif
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 #ifdef VERBOSE
00278
00279 #define test_svalue(e,f,m) \
00280 printf(m); \
00281 fflush(stdout); \
00282 fflush(stderr); \
00283 stest = f; \
00284 if (strcmp(e,stest)) { \
00285 printf("Received %s, expected %s\n", stest, e); \
00286 \
00287 return 1; \
00288 } \
00289 printf("OK\n")
00290
00291 #else
00292
00293 #define test_svalue(e,f,m) \
00294 stest = f; \
00295 if (strcmp(e,stest)) { \
00296 printf(m); \
00297 printf("Received %s, expected %s\n", stest, e); \
00298 \
00299 return 1; \
00300 }
00301
00302 #endif
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00320
00322 #define MAX_SIZE 4096
00323 static void
00324 uves_filter_cosmic_test(void)
00325 {
00326
00327
00328 const char* src_dir="/media/disk/uves/valentina/";
00329
00330 const char* input="PA1_D2B_001.fits";
00331
00332 char cosmic_name[MAX_SIZE];
00333 char filter_name[MAX_SIZE];
00334 char clean_name[MAX_SIZE];
00335 char mask_name[MAX_SIZE];
00336 const double sky=150.;
00337 const double gain=1.84;
00338 const double ron=4.1;
00339 const int ns=4;
00340 int sx=0;
00341 int sy=0;
00342
00343 const double rc=2;
00344 cpl_frame* frm=NULL;
00345 cpl_image* inp=NULL;
00346 cpl_image* flt=NULL;
00347 cpl_image* out=NULL;
00348 cpl_image* msk=NULL;
00349 cpl_propertylist* h=NULL;
00350 sprintf(cosmic_name,"%s%s",src_dir,input);
00351 sprintf(filter_name,"%s","filter.fits");
00352 sprintf(clean_name,"%s","cleaned.fits");
00353 sprintf(mask_name,"%s","mask.fits");
00354 check_nomsg(frm=cpl_frame_new());
00355 check_nomsg(cpl_frame_set_filename(frm,cosmic_name));
00356 check_nomsg(cpl_frame_set_type(frm,CPL_FRAME_TYPE_IMAGE));
00357 check_nomsg(cpl_frame_set_group(frm,CPL_FRAME_GROUP_RAW));
00358
00359 check_nomsg(inp=cpl_image_load(cosmic_name,CPL_TYPE_FLOAT,0,0));
00360 check_nomsg(h=cpl_propertylist_load(cosmic_name,0));
00361 check_nomsg(sx=cpl_image_get_size_x(inp));
00362 check_nomsg(sy=cpl_image_get_size_y(inp));
00363
00364 check_nomsg(msk=cpl_image_new(sx,sy,CPL_TYPE_INT));
00365
00366 check_nomsg(uves_rcosmic(inp,&flt,&out,&msk,sky,ron,gain,ns,rc));
00367 check_nomsg(cpl_image_save(flt,filter_name,CPL_BPP_IEEE_FLOAT,
00368 h,CPL_IO_DEFAULT));
00369 check_nomsg(cpl_image_save(msk,mask_name,CPL_BPP_IEEE_FLOAT,
00370 h,CPL_IO_DEFAULT));
00371 check_nomsg(cpl_image_save(out,clean_name,CPL_BPP_IEEE_FLOAT,
00372 h,CPL_IO_DEFAULT));
00373
00374
00375 cleanup:
00376 uves_free_frame(&frm);
00377 cpl_propertylist_delete(h);
00378 uves_free_image(&inp);
00379 uves_free_image(&out);
00380 uves_free_image(&flt);
00381 uves_free_image(&msk);
00382
00383 return;
00384 }
00385
00386
00387 static void
00388 uves_find_property_test(void)
00389 {
00390 uves_propertylist *header = uves_propertylist_new();
00391
00392 uves_propertylist_append_int(header, "INTVAL", 3);
00393 uves_propertylist_append_double(header, "HELLO", 98.12);
00394 uves_propertylist_append_int(header, "INTVAL", 3);
00395 uves_propertylist_append_double(header, "HELLO", 98.12);
00396 uves_propertylist_append_int(header, "INTVAL", 3);
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 uves_free_propertylist(&header);
00410
00411 return;
00412 }
00413
00414 static void
00415 uves_average_reject_test(void)
00416 {
00417 cpl_table *table = cpl_table_new(100);
00418 int i;
00419
00420 cpl_table_new_column(table, "X", CPL_TYPE_DOUBLE);
00421 cpl_table_set_double(table, "X", 0, 100);
00422 cpl_table_set_double(table, "X", 1, 101);
00423 cpl_table_set_double(table, "X", 2, 2000);
00424 cpl_table_set_double(table, "X", 3, 98);
00425 cpl_table_set_double(table, "X", 4, 103);
00426 cpl_table_set_double(table, "X", 5, 102);
00427 cpl_table_set_double(table, "X", 6, 100);
00428 cpl_table_set_double(table, "X", 7, 103);
00429 cpl_table_set_double(table, "X", 8, 100);
00430 cpl_table_set_double(table, "X", 9, 99);
00431
00432 srand(0);
00433 for (i = 10; i < 100; i++)
00434 {
00435 cpl_table_set_double(table, "X", i, 100 + 3*uves_gaussrand());
00436
00437 }
00438 {
00439 double kappa = 4.0;
00440 double expected_avg = 100;
00441 double tolerance = 3.0;
00442
00443 cpl_test( 2000 - 100 > kappa * cpl_table_get_column_stdev(table, "X"));
00444
00445 cpl_test_abs( uves_average_reject(table, "X", "temp", kappa),
00446 expected_avg, tolerance);
00447 }
00448 cpl_test_eq( cpl_table_get_nrow(table), 99);
00449 cpl_test_abs( cpl_table_get_double(table, "X", 0, NULL), 100, 0.1);
00450 cpl_test_abs( cpl_table_get_double(table, "X", 1, NULL), 101, 0.1);
00451 cpl_test_abs( cpl_table_get_double(table, "X", 2, NULL), 98, 0.1);
00452 cpl_test_abs( cpl_table_get_double(table, "X", 3, NULL), 103, 0.1);
00453
00454 uves_free_table(&table);
00455
00456 return;
00457 }
00458
00459 static void
00460 uves_polynomial_fit_2d_test(void)
00461 {
00462 unsigned size = 4;
00463 cpl_bivector *xy_pos = cpl_bivector_new(size);
00464 cpl_vector *values = cpl_vector_new(size);
00465 cpl_vector *sigmas = NULL;
00466 int deg1 = 0;
00467 int deg2 = 0;
00468 polynomial *solution;
00469
00470
00471 cpl_bivector_get_x_data(xy_pos)[0] = 1;
00472 cpl_bivector_get_x_data(xy_pos)[1] = 2;
00473 cpl_bivector_get_x_data(xy_pos)[2] = 3;
00474 cpl_bivector_get_x_data(xy_pos)[3] = 4;
00475
00476 cpl_bivector_get_y_data(xy_pos)[0] = 4;
00477 cpl_bivector_get_y_data(xy_pos)[1] = 3;
00478 cpl_bivector_get_y_data(xy_pos)[2] = 2;
00479 cpl_bivector_get_y_data(xy_pos)[3] = 1;
00480
00481 cpl_vector_get_data(values)[0] = 17;
00482 cpl_vector_get_data(values)[1] = 17;
00483 cpl_vector_get_data(values)[2] = 17;
00484 cpl_vector_get_data(values)[3] = 17;
00485
00486 solution = uves_polynomial_fit_2d(xy_pos, values, sigmas,
00487 deg1, deg2,
00488 NULL, NULL, NULL);
00489
00490 cpl_test(solution != NULL);
00491 cpl_test_abs(uves_polynomial_evaluate_2d(solution, 1, 1), 17, 0.001);
00492
00493
00494
00495 deg1 = 1;
00496 deg2 = 1;
00497 cpl_bivector_get_x_data(xy_pos)[0] = 1;
00498 cpl_bivector_get_x_data(xy_pos)[1] = 1;
00499 cpl_bivector_get_x_data(xy_pos)[2] = 1;
00500 cpl_bivector_get_x_data(xy_pos)[3] = 1;
00501
00502 cpl_bivector_get_y_data(xy_pos)[0] = 1;
00503 cpl_bivector_get_y_data(xy_pos)[1] = 1;
00504 cpl_bivector_get_y_data(xy_pos)[2] = 1;
00505 cpl_bivector_get_y_data(xy_pos)[3] = 1;
00506
00507
00508 uves_polynomial_delete(&solution);
00509 solution = uves_polynomial_fit_2d(xy_pos, values, sigmas,
00510 deg1, deg2,
00511 NULL, NULL, NULL);
00512
00513 cpl_test(cpl_error_get_code() == CPL_ERROR_SINGULAR_MATRIX);
00514 uves_error_reset();
00515 cpl_test(solution == NULL);
00516
00517
00518
00519 uves_polynomial_delete(&solution);
00520 uves_free_bivector(&xy_pos);
00521 uves_free_vector(&values);
00522
00523 return;
00524 }
00525
00526
00527
00528 static int table_erase_selected(void)
00529 {
00530
00531 int nrows = 10;
00532 int i, j, k, null, error;
00533 int pp;
00534 int itest;
00535 double ftest;
00536 const char *stest;
00537 void *ptest;
00538 char message[80];
00539
00540 int *iArray;
00541 float *fArray;
00542 double *dArray;
00543 double *ddArray;
00544 char **sArray;
00545
00546 int icheck[25];
00547 float fcheck[25];
00548 double dcheck[25];
00549 const char *scheck[25];
00550
00551 const char *unit;
00552 const char *names[2];
00553 int reverse[2];
00554
00555 cpl_table *table;
00556 cpl_table *copia;
00557 cpl_array *array;
00558
00559 uves_propertylist *reflist;
00560
00561
00562
00563
00564
00565
00566 iArray = cpl_malloc(nrows * sizeof(int));
00567 fArray = cpl_malloc(nrows * sizeof(float));
00568 dArray = cpl_malloc(nrows * sizeof(double));
00569 ddArray = cpl_malloc(nrows * sizeof(double));
00570 sArray = cpl_malloc(nrows * sizeof(char *));
00571
00572 iArray[0] = 5;
00573 iArray[1] = 0;
00574 iArray[2] = 2;
00575 iArray[3] = 8;
00576 iArray[4] = 9;
00577 iArray[5] = 3;
00578 iArray[6] = 7;
00579 iArray[7] = 1;
00580 iArray[8] = 4;
00581 iArray[9] = 6;
00582
00583 fArray[0] = 5.1;
00584 fArray[1] = 0.1;
00585 fArray[2] = 2.1;
00586 fArray[3] = 8.1;
00587 fArray[4] = 9.1;
00588 fArray[5] = 3.1;
00589 fArray[6] = 7.1;
00590 fArray[7] = 1.1;
00591 fArray[8] = 4.1;
00592 fArray[9] = 6.1;
00593
00594 ddArray[0] = dArray[0] = 5.11;
00595 ddArray[1] = dArray[1] = 0.11;
00596 ddArray[2] = dArray[2] = 2.11;
00597 ddArray[3] = dArray[3] = 8.11;
00598 ddArray[4] = dArray[4] = 9.11;
00599 ddArray[5] = dArray[5] = 3.11;
00600 ddArray[6] = dArray[6] = 7.11;
00601 ddArray[7] = dArray[7] = 1.11;
00602 ddArray[8] = dArray[8] = 4.11;
00603 ddArray[9] = dArray[9] = 6.11;
00604
00605 sArray[0] = cpl_strdup("caaa");
00606 sArray[1] = cpl_strdup("abcd");
00607 sArray[2] = cpl_strdup("aaaa");
00608 sArray[3] = cpl_strdup("daaa");
00609 sArray[4] = cpl_strdup("acde");
00610 sArray[5] = cpl_strdup("baaa");
00611 sArray[6] = cpl_strdup("aaaa");
00612 sArray[7] = cpl_strdup("acde");
00613 sArray[8] = cpl_strdup(" sss");
00614 sArray[9] = cpl_strdup("daaa");
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 test_data(table, cpl_table_new(0), "Creating a table without rows... ");
00626
00627 test(cpl_table_new_column(table, "Int", CPL_TYPE_INT),
00628 "Creating empty Integer column... ");
00629 test(cpl_table_new_column(table, "Float", CPL_TYPE_FLOAT),
00630 "Creating empty Float column... ");
00631 test(cpl_table_new_column(table, "Double", CPL_TYPE_DOUBLE),
00632 "Creating empty Double column... ");
00633 test(cpl_table_new_column(table, "String", CPL_TYPE_STRING),
00634 "Creating empty String column... ");
00635 test(cpl_table_new_column_array(table, "AInt",
00636 CPL_TYPE_INT | CPL_TYPE_POINTER, 0),
00637 "Creating empty IntegerArray column... ");
00638 test(cpl_table_new_column_array(table, "AFloat",
00639 CPL_TYPE_FLOAT | CPL_TYPE_POINTER, 0),
00640 "Creating empty FloatArray column... ");
00641 test(cpl_table_new_column_array(table, "ADouble",
00642 CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, 0),
00643 "Creating empty DoubleArray column... ");
00644
00645 test_ivalue(0, cpl_table_get_nrow(table), "Check zero table length... ");
00646 test_ivalue(7, cpl_table_get_ncol(table), "Check zero table width... ");
00647
00648 test_ivalue(0, cpl_table_get_column_depth(table, "Double"),
00649 "Check \"Double\" depth... ");
00650
00651 test_ivalue(0, cpl_table_get_column_depth(table, "AInt"),
00652 "Check \"AInt\" depth... ");
00653
00654 test(cpl_table_set_size(table, 1), "Expanding table to one row... ");
00655
00656 test_ivalue(1, cpl_table_get_nrow(table), "Check table with one row... ");
00657
00658 test(cpl_table_set_size(table, 0), "Deleting all rows from table... ");
00659
00660 test_ivalue(0, cpl_table_get_nrow(table),
00661 "Check again zero table length... ");
00662
00663 test(cpl_table_erase_column(table, "Double"),
00664 "Delete zero-column \"Double\"... ");
00665
00666 test_ivalue(6, cpl_table_get_ncol(table), "Check zero-column removal... ");
00667
00668 test(cpl_table_erase_column(table, "AInt"),
00669 "Delete zero-column \"AInt\"... ");
00670
00671 test_ivalue(5, cpl_table_get_ncol(table),
00672 "Check zero-column array removal... ");
00673
00674 test_pvalue(NULL, cpl_table_get_data_float(table, "Float"),
00675 "Check NULL pointer to column Float... ");
00676
00677 test_failure(CPL_ERROR_NULL_INPUT,
00678 cpl_table_erase_selected(NULL),
00679 "Erase selected on NULL table... ");
00680
00681 test(cpl_table_erase_selected(table),
00682 "Erase selected on empty table... ");
00683
00684 test_failure(CPL_ERROR_NULL_INPUT,
00685 cpl_table_set_column_unit(NULL, "Float", "arcsec"),
00686 "Try to assign unit to NULL table... ");
00687
00688 test_failure(CPL_ERROR_NULL_INPUT,
00689 cpl_table_set_column_unit(table, NULL, "arcsec"),
00690 "Try to assign unit to NULL column... ");
00691
00692 test_failure(CPL_ERROR_DATA_NOT_FOUND,
00693 cpl_table_set_column_unit(table, "Double", "arcsec"),
00694 "Try to assign unit to non existing column... ");
00695
00696 test(cpl_table_set_column_unit(table, "Float", "arcsec"),
00697 "Assign unit 'arcsec' to column Float... ");
00698
00699 if (strcmp(unit = (char *)cpl_table_get_column_unit(table, "Float"),
00700 "arcsec")) {
00701 printf("Check column unit... ");
00702 printf("Expected \"arcsec\", obtained \"%s\"\n", unit);
00703
00704 return 1;
00705 }
00706
00707 test(cpl_table_set_column_unit(table, "Float", NULL),
00708 "Assign unit NULL to column Float... ");
00709
00710 test_pvalue(NULL, (char *)cpl_table_get_column_unit(table, "Float"),
00711 "Get unit NULL from column Float... ");
00712
00713 test(cpl_table_set_size(table, 1), "Expanding again table to one row... ");
00714
00715 test(cpl_table_erase_invalid_rows(table), "Pruning table to zero... ");
00716
00717 test_ivalue(1, cpl_table_get_nrow(table),
00718 "Checking zero-table length after pruning... ");
00719
00720 test_ivalue(0, cpl_table_get_ncol(table),
00721 "Checking zero-table width after pruning... ");
00722
00723 cpl_table_delete(table);
00724
00725
00726
00727
00728
00729
00730
00731 test_data(table, cpl_table_new(nrows), "Creating the test table... ");
00732
00733 test(cpl_table_wrap_int(table, iArray, "Integer"),
00734 "Wrapping the Integer column... ");
00735
00736
00737
00738 cpl_table_unwrap(table, "Integer");
00739
00740 test(cpl_table_wrap_int(table, iArray, "Integer"),
00741 "Creating the Integer column... ");
00742
00743 test(cpl_table_wrap_double(table, dArray, "Double"),
00744 "Creating the Double column... ");
00745
00746 test(cpl_table_wrap_double(table, ddArray, "DoubleDouble"),
00747 "Creating the DoubleDouble column... ");
00748
00749 test(cpl_table_wrap_string(table, sArray, "String"),
00750 "Creating the String column... ");
00751
00752 test(cpl_table_new_column(table, "Float", CPL_TYPE_FLOAT),
00753 "Creating the Float column... ");
00754
00755 for (i = 0; i < nrows; i++) {
00756 sprintf(message, "Writing to row %d of the Float column... ", i);
00757 test(cpl_table_set_float(table, "Float", i, fArray[i]), message);
00758 }
00759
00760 test(cpl_table_new_column_array(table, "AInt",
00761 CPL_TYPE_INT | CPL_TYPE_POINTER, 2),
00762 "Creating the ArrayInt column... ");
00763
00764 test(cpl_table_new_column_array(table, "AFloat", CPL_TYPE_FLOAT, 2),
00765 "Creating the ArrayFloat column... ");
00766
00767 test(cpl_table_new_column_array(table, "ADouble",
00768 CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, 2),
00769 "Creating the ArrayDouble column... ");
00770
00771 test_ivalue(2, cpl_table_get_column_depth(table, "AInt"),
00772 "Check \"AInt\" depth (2)... ");
00773
00774 k = 0;
00775 array = cpl_array_new(2, CPL_TYPE_INT);
00776 for (i = 0; i < nrows; i++) {
00777 for (j = 0; j < 2; j++) {
00778 sprintf(message,
00779 "Writing element %d of array %d of the AInt column... ", j, i);
00780 k++;
00781 test(cpl_array_set_int(array, j, k), message);
00782 }
00783 sprintf(message, "Setting array at position %d of the AInt column... ", i);
00784 test(cpl_table_set_array(table, "AInt", i, array), message);
00785 }
00786 cpl_array_delete(array);
00787
00788 k = 0;
00789 for (i = 0; i < nrows; i++) {
00790 sprintf(message, "Getting array %d of the AInt column... ", i);
00791 test_data(array, (cpl_array *)cpl_table_get_array(table, "AInt", i),
00792 message);
00793 for (j = 0; j < 2; j++) {
00794 sprintf(message,
00795 "Reading element %d of array %d of the AInt column... ", j, i);
00796 k++;
00797 test_ivalue(k, cpl_array_get_int(array, j, NULL), message);
00798 }
00799 }
00800
00801 k = 0;
00802 array = cpl_array_new(2, CPL_TYPE_FLOAT);
00803 for (i = 0; i < nrows; i++) {
00804 for (j = 0; j < 2; j++) {
00805 sprintf(message,
00806 "Writing element %d of array %d of the AFloat column... ", j, i);
00807 k++;
00808 test(cpl_array_set_float(array, j, k), message);
00809 }
00810 sprintf(message,
00811 "Setting array at position %d of the AFloat column... ", i);
00812 test(cpl_table_set_array(table, "AFloat", i, array), message);
00813 }
00814 cpl_array_delete(array);
00815
00816 k = 0;
00817 for (i = 0; i < nrows; i++) {
00818 sprintf(message, "Getting array %d of the AFloat column... ", i);
00819 test_data(array, (cpl_array *)cpl_table_get_array(table, "AFloat", i),
00820 message);
00821 for (j = 0; j < 2; j++) {
00822 sprintf(message,
00823 "Reading element %d of array %d of the AFloat column... ", j, i);
00824 k++;
00825 test_fvalue((float)k, 0.0001,
00826 cpl_array_get_float(array, j, NULL), message);
00827 }
00828 }
00829
00830 k = 0;
00831 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
00832 for (i = 0; i < nrows; i++) {
00833 for (j = 0; j < 2; j++) {
00834 sprintf(message,
00835 "Writing element %d of array %d of the ADouble column... ", j, i);
00836 k++;
00837 test(cpl_array_set_double(array, j, k), message);
00838 }
00839 sprintf(message,
00840 "Setting array at position %d of the ADouble column... ", i);
00841 test(cpl_table_set_array(table, "ADouble", i, array), message);
00842 }
00843 cpl_array_delete(array);
00844
00845 k = 0;
00846 for (i = 0; i < nrows; i++) {
00847 sprintf(message, "Getting array %d of the ADouble column... ", i);
00848 test_data(array, (cpl_array *)cpl_table_get_array(table, "ADouble", i),
00849 message);
00850 for (j = 0; j < 2; j++) {
00851 sprintf(message,
00852 "Reading element %d of array %d of the ADouble column... ", j, i);
00853 k++;
00854 test_fvalue((float)k, 0.0001,
00855 cpl_array_get_double(array, j, NULL), message);
00856 }
00857 }
00858
00859 test_ivalue(2, cpl_table_get_column_depth(table, "AInt"),
00860 "Check \"AInt\" depth (3)... ");
00861
00862 test_data(array, (cpl_array *)cpl_table_get_array(table, "AInt", 0),
00863 "Get AInt array");
00864 test_ivalue(CPL_TYPE_INT, cpl_array_get_type(array),
00865 "Array AInt must be int... ");
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00913
00914
00915
00916
00917
00918 test_ivalue(10, cpl_table_get_nrow(table), "Check table length (1)... ");
00919 test_ivalue(8, cpl_table_get_ncol(table), "Check table width... ");
00920
00921 test_failure(CPL_ERROR_DATA_NOT_FOUND,
00922 cpl_table_erase_column(table, "Diable"),
00923 "Trying to delete a not existing column... ");
00924
00925 test(cpl_table_erase_column(table, "DoubleDouble"),
00926 "Delete column \"DoubleDouble\"... ");
00927
00928 test_ivalue(7, cpl_table_get_ncol(table), "Check again table width... ");
00929
00930 test_ivalue(CPL_TYPE_INT, cpl_table_get_column_type(table, "Integer"),
00931 "Column Integer must be int... ");
00932 test_ivalue(CPL_TYPE_DOUBLE, cpl_table_get_column_type(table, "Double"),
00933 "Column Double must be double... ");
00934 test_ivalue(CPL_TYPE_STRING, cpl_table_get_column_type(table, "String"),
00935 "Column String must be char*... ");
00936 test_ivalue(CPL_TYPE_FLOAT, cpl_table_get_column_type(table, "Float"),
00937 "Column Float must be float... ");
00938 test_ivalue((CPL_TYPE_INT | CPL_TYPE_POINTER),
00939 cpl_table_get_column_type(table, "AInt"),
00940 "Column AInt must be arrays of int... ");
00941 test_ivalue((CPL_TYPE_DOUBLE | CPL_TYPE_POINTER),
00942 cpl_table_get_column_type(table, "ADouble"),
00943 "Column Double must be arrays of double... ");
00944 test_ivalue((CPL_TYPE_FLOAT | CPL_TYPE_POINTER),
00945 cpl_table_get_column_type(table, "AFloat"),
00946 "Column Float must be arrays of float... ");
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956 copia = cpl_table_new(5);
00957
00958 test(cpl_table_copy_structure(copia, table),
00959 "Creating a new cpl_table modeled on an existing cpl_table... ");
00960
00961 test_ivalue(5, cpl_table_get_nrow(copia), "Check table length (2)... ");
00962 test_ivalue(7, cpl_table_get_ncol(copia), "Check table width... ");
00963
00964 test(cpl_table_compare_structure(table, copia),
00965 "Tables must have the same structure... ");
00966 cpl_table_erase_column(copia, "Double");
00967 test_ivalue(1, cpl_table_compare_structure(table, copia),
00968 "Deleting column Double - now tables must have different structure... ");
00969 test(cpl_table_new_column(copia, "Double", CPL_TYPE_DOUBLE),
00970 "Creating again the Double column... ");
00971 test(cpl_table_compare_structure(table, copia),
00972 "Tables must have the same structure again... ");
00973
00974 test(cpl_table_fill_column_window_int(copia, "Integer", 0, 5, -1),
00975 "Fill column Integer of new table... ");
00976 test(cpl_table_fill_column_window_double(copia, "Double", 0, 5, -1.11),
00977 "Fill column Double of new table... ");
00978 test(cpl_table_fill_column_window_float(copia, "Float", 0, 5, -1.1),
00979 "Fill column Float of new table... ");
00980 test(cpl_table_fill_column_window_string(copia, "String", 0, 5, "extra"),
00981 "Fill column String of new table... ");
00982
00983 array = cpl_array_new(2, CPL_TYPE_INT);
00984 for (j = 0; j < 2; j++)
00985 cpl_array_set_int(array, j, j);
00986 test(cpl_table_fill_column_window_array(copia, "AInt", 0, 5, array),
00987 "Fill column AInt of new table... ");
00988 cpl_array_delete(array);
00989
00990 array = cpl_array_new(2, CPL_TYPE_FLOAT);
00991 for (j = 0; j < 2; j++)
00992 cpl_array_set_float(array, j, j);
00993 test(cpl_table_fill_column_window_array(copia, "AFloat", 0, 5, array),
00994 "Fill column AFloat of new table... ");
00995 cpl_array_delete(array);
00996
00997 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
00998 for (j = 0; j < 2; j++)
00999 cpl_array_set_double(array, j, j);
01000 test(cpl_table_fill_column_window_array(copia, "ADouble", 0, 5, array),
01001 "Fill column ADouble of new table... ");
01002 cpl_array_delete(array);
01003
01004 test(cpl_table_insert(table, copia, 15),
01005 "Appending new table to old table... ");
01006 test(cpl_table_insert(table, copia, 5),
01007 "Inserting new table in old table... ");
01008 test(cpl_table_insert(table, copia, 0),
01009 "Prepending new table to old table... ");
01010
01011 cpl_table_delete(copia);
01012
01014 cpl_table_fill_invalid_int(table, "Integer", 320);
01015 cpl_table_fill_invalid_int(table, "AInt", 320);
01016 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01017 cpl_table_delete(table);
01018 table = cpl_table_load("test_table.tfits", 1, 1);
01019
01020
01021 test_ivalue(25, cpl_table_get_nrow(table), "Check table length (3)... ");
01022
01023 icheck[0] = -1;
01024 icheck[1] = -1;
01025 icheck[2] = -1;
01026 icheck[3] = -1;
01027 icheck[4] = -1;
01028 icheck[5] = 5;
01029 icheck[6] = 0;
01030 icheck[7] = 2;
01031 icheck[8] = 8;
01032 icheck[9] = 9;
01033 icheck[10] = -1;
01034 icheck[11] = -1;
01035 icheck[12] = -1;
01036 icheck[13] = -1;
01037 icheck[14] = -1;
01038 icheck[15] = 3;
01039 icheck[16] = 7;
01040 icheck[17] = 1;
01041 icheck[18] = 4;
01042 icheck[19] = 6;
01043 icheck[20] = -1;
01044 icheck[21] = -1;
01045 icheck[22] = -1;
01046 icheck[23] = -1;
01047 icheck[24] = -1;
01048
01049 error = 0;
01050
01051 for (i = 0; i < 25; i++) {
01052 if (cpl_table_get_int(table, "Integer", i, NULL) != icheck[i]) {
01053 error = 1;
01054 break;
01055 }
01056 }
01057
01058 if (error) {
01059 printf("Check Integer column... ");
01060 printf("Failure\n");
01061
01062 return 1;
01063 }
01064
01065 dcheck[0] = -1.1100;
01066 dcheck[1] = -1.1100;
01067 dcheck[2] = -1.1100;
01068 dcheck[3] = -1.1100;
01069 dcheck[4] = -1.1100;
01070 dcheck[5] = 5.1100;
01071 dcheck[6] = 0.1100;
01072 dcheck[7] = 2.1100;
01073 dcheck[8] = 8.1100;
01074 dcheck[9] = 9.1100;
01075 dcheck[10] = -1.1100;
01076 dcheck[11] = -1.1100;
01077 dcheck[12] = -1.1100;
01078 dcheck[13] = -1.1100;
01079 dcheck[14] = -1.1100;
01080 dcheck[15] = 3.1100;
01081 dcheck[16] = 7.1100;
01082 dcheck[17] = 1.1100;
01083 dcheck[18] = 4.1100;
01084 dcheck[19] = 6.1100;
01085 dcheck[20] = -1.1100;
01086 dcheck[21] = -1.1100;
01087 dcheck[22] = -1.1100;
01088 dcheck[23] = -1.1100;
01089 dcheck[24] = -1.1100;
01090
01091 error = 0;
01092
01093 for (i = 0; i < 25; i++) {
01094 if (fabs(cpl_table_get_double(table, "Double", i, NULL) - dcheck[i])
01095 > 0.00001) {
01096 error = 1;
01097 break;
01098 }
01099 }
01100
01101 if (error) {
01102 printf("Check Double column... ");
01103 printf("Failure\n");
01104
01105 return 1;
01106 }
01107
01108 scheck[0] = "extra";
01109 scheck[1] = "extra";
01110 scheck[2] = "extra";
01111 scheck[3] = "extra";
01112 scheck[4] = "extra";
01113 scheck[5] = "caaa";
01114 scheck[6] = "abcd";
01115 scheck[7] = "aaaa";
01116 scheck[8] = "daaa";
01117 scheck[9] = "acde";
01118 scheck[10] = "extra";
01119 scheck[11] = "extra";
01120 scheck[12] = "extra";
01121 scheck[13] = "extra";
01122 scheck[14] = "extra";
01123 scheck[15] = "baaa";
01124 scheck[16] = "aaaa";
01125 scheck[17] = "acde";
01126 scheck[18] = " sss";
01127 scheck[19] = "daaa";
01128 scheck[20] = "extra";
01129 scheck[21] = "extra";
01130 scheck[22] = "extra";
01131 scheck[23] = "extra";
01132 scheck[24] = "extra";
01133
01134 error = 0;
01135
01136 for (i = 0; i < 25; i++) {
01137 if (strcmp(cpl_table_get_string(table, "String", i), scheck[i])) {
01138 error = 1;
01139 break;
01140 }
01141 }
01142
01143 if (error) {
01144 printf("Check String column... ");
01145 printf("Failure\n");
01146
01147 return 1;
01148 }
01149
01150 fcheck[0] = -1.10;
01151 fcheck[1] = -1.10;
01152 fcheck[2] = -1.10;
01153 fcheck[3] = -1.10;
01154 fcheck[4] = -1.10;
01155 fcheck[5] = 5.10;
01156 fcheck[6] = 0.10;
01157 fcheck[7] = 2.10;
01158 fcheck[8] = 8.10;
01159 fcheck[9] = 9.10;
01160 fcheck[10] = -1.10;
01161 fcheck[11] = -1.10;
01162 fcheck[12] = -1.10;
01163 fcheck[13] = -1.10;
01164 fcheck[14] = -1.10;
01165 fcheck[15] = 3.10;
01166 fcheck[16] = 7.10;
01167 fcheck[17] = 1.10;
01168 fcheck[18] = 4.10;
01169 fcheck[19] = 6.10;
01170 fcheck[20] = -1.10;
01171 fcheck[21] = -1.10;
01172 fcheck[22] = -1.10;
01173 fcheck[23] = -1.10;
01174 fcheck[24] = -1.10;
01175
01176 error = 0;
01177
01178 for (i = 0; i < 25; i++) {
01179 if (fabs(cpl_table_get_float(table, "Float", i, NULL) - fcheck[i])
01180 > 0.00001) {
01181 error = 1;
01182 break;
01183 }
01184 }
01185
01186 if (error) {
01187 printf("Check Float column... ");
01188 printf("Failure\n");
01189
01190 return 1;
01191 }
01192
01193 test(cpl_table_set_invalid(table, "Integer", 0),
01194 "Set Integer 0 to NULL... ");
01195 test(cpl_table_set_invalid(table, "Integer", 5),
01196 "Set Integer 5 to NULL... ");
01197 test(cpl_table_set_invalid(table, "Integer", 24),
01198 "Set Integer 24 to NULL... ");
01199
01200 test(cpl_table_set_invalid(table, "AInt", 0),
01201 "Set AInt 0 to NULL... ");
01202 test(cpl_table_set_invalid(table, "AFloat", 5),
01203 "Set AFloat 5 to NULL... ");
01204 test(cpl_table_set_invalid(table, "ADouble", 24),
01205 "Set ADouble 24 to NULL... ");
01206
01208 cpl_table_fill_invalid_int(table, "Integer", 320);
01209 cpl_table_fill_invalid_int(table, "AInt", 320);
01210 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01211 cpl_table_delete(table);
01212 table = cpl_table_load("test_table.tfits", 1, 1);
01213
01214
01215 test_ivalue(3, cpl_table_count_invalid(table, "Integer"),
01216 "Count Integer written NULLs... ");
01217 test_ivalue(1, cpl_table_count_invalid(table, "AInt"),
01218 "Count AInt written NULLs... ");
01219 test_ivalue(1, cpl_table_count_invalid(table, "AFloat"),
01220 "Count AFloat written NULLs... ");
01221 test_ivalue(1, cpl_table_count_invalid(table, "ADouble"),
01222 "Count ADouble written NULLs... ");
01223
01224 error = 0;
01225
01226 for (i = 0; i < 25; i++) {
01227 cpl_table_get_int(table, "Integer", i, &null);
01228 if (!null) {
01229 if (cpl_table_get_int(table, "Integer", i, &null) != icheck[i]) {
01230 error = 1;
01231 break;
01232 }
01233 }
01234 else if (i != 0 && i != 5 && i != 24) {
01235 error = 1;
01236 break;
01237 }
01238 }
01239
01240 if (error) {
01241 printf("Check Integer column... ");
01242 printf("Failure\n");
01243
01244 return 1;
01245 }
01246
01247 test(cpl_table_set_int(table, "Integer", 0, -1),
01248 "Set Integer 0 to -1... ");
01249 test(cpl_table_set_int(table, "Integer", 5, 5),
01250 "Set Integer 5 to 5... ");
01251 test(cpl_table_set_int(table, "Integer", 24, -1),
01252 "Set Integer 24 to -1... ");
01253
01254 array = cpl_array_new(2, CPL_TYPE_INT);
01255 for (j = 0; j < 2; j++)
01256 cpl_array_set_int(array, j, j);
01257 test(cpl_table_set_array(table, "AInt", 0, array),
01258 "Set a valid array to AInt 0... ");
01259 cpl_array_delete(array);
01260 test_ivalue(0, cpl_table_count_invalid(table, "AInt"),
01261 "No invalid elements in AInt... ");
01262
01263 array = cpl_array_new(2, CPL_TYPE_FLOAT);
01264 for (j = 0; j < 2; j++)
01265 cpl_array_set_float(array, j, j);
01266 test(cpl_table_set_array(table, "AFloat", 5, array),
01267 "Set a valid array to AFloat 5... ");
01268 cpl_array_delete(array);
01269 test_ivalue(0, cpl_table_count_invalid(table, "AFloat"),
01270 "No invalid elements in AFloat... ");
01271
01272 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
01273 for (j = 0; j < 2; j++)
01274 cpl_array_set_double(array, j, j);
01275 test(cpl_table_set_array(table, "ADouble", 24, array),
01276 "Set a valid array to ADouble 24... ");
01277 cpl_array_delete(array);
01278 test_ivalue(0, cpl_table_count_invalid(table, "ADouble"),
01279 "No invalid elements in ADouble... ");
01280
01282 cpl_table_fill_invalid_int(table, "Integer", 320);
01283 cpl_table_fill_invalid_int(table, "AInt", 320);
01284 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01285 cpl_table_delete(table);
01286 table = cpl_table_load("test_table.tfits", 1, 1);
01287
01288
01289 test_ivalue(0, cpl_table_count_invalid(table, "Integer"),
01290 "Count NULLs... ");
01291
01292 error = 0;
01293
01294 for (i = 0; i < 25; i++) {
01295 cpl_table_get_int(table, "Integer", i, &null);
01296 if (!null) {
01297 if (cpl_table_get_int(table, "Integer", i, &null) != icheck[i]) {
01298 error = 1;
01299 break;
01300 }
01301 }
01302 else {
01303 error = 1;
01304 break;
01305 }
01306 }
01307
01308 if (error) {
01309 printf("Check Integer column... ");
01310 printf("Failure\n");
01311
01312 return 1;
01313 }
01314
01315 test(cpl_table_set_invalid(table, "Double", 0), "Set Double 0 to NULL... ");
01316 test(cpl_table_set_invalid(table, "Double", 5), "Set Double 5 to NULL... ");
01317 test(cpl_table_set_invalid(table, "Double", 24), "Set Double 24 to NULL... ");
01318
01320 cpl_table_fill_invalid_int(table, "Integer", 320);
01321 cpl_table_fill_invalid_int(table, "AInt", 320);
01322 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01323 cpl_table_delete(table);
01324 table = cpl_table_load("test_table.tfits", 1, 1);
01325
01326
01327 test_ivalue(3, cpl_table_count_invalid(table, "Double"),
01328 "Count written NULLs... ");
01329
01330 error = 0;
01331
01332 for (i = 0; i < 25; i++) {
01333 cpl_table_get_double(table, "Double", i, &null);
01334 if (!null) {
01335 if (cpl_table_get_double(table, "Double", i, &null) != dcheck[i]) {
01336 error = 1;
01337 break;
01338 }
01339 }
01340 else if (i != 0 && i != 5 && i != 24) {
01341 error = 1;
01342 break;
01343 }
01344 }
01345
01346 if (error) {
01347 printf("Check Double column... ");
01348 printf("Failure\n");
01349
01350 return 1;
01351 }
01352
01353 test(cpl_table_set_double(table, "Double", 0, -1.11),
01354 "Set Double 0 to -1.11... ");
01355 test(cpl_table_set_double(table, "Double", 5, 5.11),
01356 "Set Double 5 to 5.11... ");
01357 test(cpl_table_set_double(table, "Double", 24, -1.11),
01358 "Set Double 24 to -1.11... ");
01359
01361 cpl_table_fill_invalid_int(table, "Integer", 320);
01362 cpl_table_fill_invalid_int(table, "AInt", 320);
01363 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01364 cpl_table_delete(table);
01365 table = cpl_table_load("test_table.tfits", 1, 1);
01366
01367
01368 test_ivalue(0, cpl_table_count_invalid(table, "Double"),
01369 "Count NULLs... ");
01370
01371 error = 0;
01372
01373 for (i = 0; i < 25; i++) {
01374 cpl_table_get_double(table, "Double", i, &null);
01375 if (!null) {
01376 if (fabs(cpl_table_get_double(table, "Double", i, &null)-dcheck[i])
01377 > 0.00001) {
01378 error = 1;
01379 break;
01380 }
01381 }
01382 else {
01383 error = 1;
01384 break;
01385 }
01386 }
01387
01388 if (error) {
01389 printf("Check Double column... ");
01390 printf("Failure\n");
01391
01392 return 1;
01393 }
01394
01395
01396 test(cpl_table_set_invalid(table, "String", 0), "Set String 0 to NULL... ");
01397 test(cpl_table_set_invalid(table, "String", 5), "Set String 5 to NULL... ");
01398 test(cpl_table_set_invalid(table, "String", 24), "Set String 24 to NULL... ");
01399
01401 cpl_table_fill_invalid_int(table, "Integer", 320);
01402 cpl_table_fill_invalid_int(table, "AInt", 320);
01403 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01404 cpl_table_delete(table);
01405 table = cpl_table_load("test_table.tfits", 1, 1);
01406
01407
01408 test_ivalue(3, cpl_table_count_invalid(table, "String"),
01409 "Count written NULLs... ");
01410
01411 error = 0;
01412
01413 for (i = 0; i < 25; i++) {
01414 if (cpl_table_get_string(table, "String", i)) {
01415 if (strcmp(cpl_table_get_string(table, "String", i), scheck[i])) {
01416 error = 1;
01417 break;
01418 }
01419 }
01420 else if (i != 0 && i != 5 && i != 24) {
01421 error = 1;
01422 break;
01423 }
01424 }
01425
01426 if (error) {
01427 printf("Check String column... ");
01428 printf("Failure\n");
01429
01430 return 1;
01431 }
01432
01433 test(cpl_table_set_string(table, "String", 0, "extra"),
01434 "Set String 0 to \"extra\"... ");
01435 test(cpl_table_set_string(table, "String", 5, "caaa"),
01436 "Set String 5 to \"caaa\"... ");
01437 test(cpl_table_set_string(table, "String", 24, "extra"),
01438 "Set String 24 to \"extra\"... ");
01439
01441 cpl_table_fill_invalid_int(table, "Integer", 320);
01442 cpl_table_fill_invalid_int(table, "AInt", 320);
01443 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01444 cpl_table_delete(table);
01445 table = cpl_table_load("test_table.tfits", 1, 1);
01446
01447
01448 test_ivalue(0, cpl_table_count_invalid(table, "String"),
01449 "Count NULLs... ");
01450
01451 error = 0;
01452
01453 for (i = 0; i < 25; i++) {
01454 if (cpl_table_get_string(table, "String", i)) {
01455 if (strcmp(cpl_table_get_string(table, "String", i), scheck[i])) {
01456 error = 1;
01457 break;
01458 }
01459 }
01460 else {
01461 error = 1;
01462 break;
01463 }
01464 }
01465
01466 if (error) {
01467 printf("Check String column... ");
01468 printf("Failure\n");
01469
01470 return 1;
01471 }
01472
01473
01474 test(cpl_table_set_invalid(table, "Float", 0), "Set Float 0 to NULL... ");
01475 test(cpl_table_set_invalid(table, "Float", 5), "Set Float 5 to NULL... ");
01476 test(cpl_table_set_invalid(table, "Float", 24), "Set Float 24 to NULL... ");
01477
01479 cpl_table_fill_invalid_int(table, "Integer", 320);
01480 cpl_table_fill_invalid_int(table, "AInt", 320);
01481 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01482 cpl_table_delete(table);
01483 table = cpl_table_load("test_table.tfits", 1, 1);
01484
01485
01486 test_ivalue(3, cpl_table_count_invalid(table, "Float"),
01487 "Count written NULLs... ");
01488
01489 error = 0;
01490
01491 for (i = 0; i < 25; i++) {
01492 cpl_table_get_float(table, "Float", i, &null);
01493 if (!null) {
01494 if (cpl_table_get_float(table, "Float", i, &null) != fcheck[i]) {
01495 error = 1;
01496 break;
01497 }
01498 }
01499 else if (i != 0 && i != 5 && i != 24) {
01500 error = 1;
01501 break;
01502 }
01503 }
01504
01505 if (error) {
01506 printf("Check Float column... ");
01507 printf("Failure\n");
01508
01509 return 1;
01510 }
01511
01512 test(cpl_table_set_float(table, "Float", 0, -1.1),
01513 "Set Float 0 to -1.1... ");
01514 test(cpl_table_set_float(table, "Float", 5, 5.1),
01515 "Set Float 5 to 5.1... ");
01516 test(cpl_table_set_float(table, "Float", 24, -1.1),
01517 "Set Float 24 to -1.1... ");
01518
01520 cpl_table_fill_invalid_int(table, "Integer", 320);
01521 cpl_table_fill_invalid_int(table, "AInt", 320);
01522 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01523 cpl_table_delete(table);
01524 table = cpl_table_load("test_table.tfits", 1, 1);
01525
01526
01527 test_ivalue(0, cpl_table_count_invalid(table, "Float"),
01528 "Count NULLs... ");
01529
01530 error = 0;
01531
01532 for (i = 0; i < 25; i++) {
01533 cpl_table_get_float(table, "Float", i, &null);
01534 if (!null) {
01535 if (fabs(cpl_table_get_float(table, "Float", i, &null)-fcheck[i])
01536 > 0.00001) {
01537 error = 1;
01538 break;
01539 }
01540 }
01541 else {
01542 error = 1;
01543 break;
01544 }
01545 }
01546
01547 if (error) {
01548 printf("Check Float column... ");
01549 printf("Failure\n");
01550
01551 return 1;
01552 }
01553
01554
01555
01556 test(cpl_table_set_column_invalid(table, "Integer", 0, 3),
01557 "Set Integer 0-2 to NULL... ");
01558 test(cpl_table_set_column_invalid(table, "Integer", 5, 3),
01559 "Set Integer 5-7 to NULL... ");
01560 test(cpl_table_set_column_invalid(table, "Integer", 20, 20),
01561 "Set Integer 20 till end to NULL... ");
01562
01563 test(cpl_table_set_column_invalid(table, "AInt", 0, 3),
01564 "Set AInt 0-2 to NULL... ");
01565 test(cpl_table_set_column_invalid(table, "AInt", 5, 3),
01566 "Set AInt 5-7 to NULL... ");
01567 test(cpl_table_set_column_invalid(table, "AInt", 20, 20),
01568 "Set AInt 20 till end to NULL... ");
01569
01571 cpl_table_fill_invalid_int(table, "Integer", 320);
01572 cpl_table_fill_invalid_int(table, "AInt", 320);
01573 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01574 cpl_table_delete(table);
01575 table = cpl_table_load("test_table.tfits", 1, 1);
01576
01577
01578 test_ivalue(11, cpl_table_count_invalid(table, "Integer"),
01579 "Count Integer NULLs... ");
01580
01581 test_ivalue(11, cpl_table_count_invalid(table, "AInt"),
01582 "Count AInt NULLs... ");
01583
01584 error = 0;
01585
01586 for (i = 0; i < 25; i++) {
01587 cpl_table_get_int(table, "Integer", i, &null);
01588 if (!null) {
01589 if (cpl_table_get_int(table, "Integer", i, &null) != icheck[i]) {
01590 error = 1;
01591 break;
01592 }
01593 }
01594 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
01595 error = 1;
01596 break;
01597 }
01598 }
01599
01600 if (error) {
01601 printf("Check Integer column... ");
01602 printf("Failure\n");
01603
01604 return 1;
01605 }
01606
01607 test(cpl_table_set_column_invalid(table, "Double", 0, 3),
01608 "Set Double 0-2 to NULL... ");
01609 test(cpl_table_set_column_invalid(table, "Double", 5, 3),
01610 "Set Double 5-7 to NULL... ");
01611 test(cpl_table_set_column_invalid(table, "Double", 20, 20),
01612 "Set Double 20 till end to NULL... ");
01613
01615 cpl_table_fill_invalid_int(table, "Integer", 320);
01616 cpl_table_fill_invalid_int(table, "AInt", 320);
01617 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01618 cpl_table_delete(table);
01619 table = cpl_table_load("test_table.tfits", 1, 1);
01620
01621
01622 test_ivalue(11, cpl_table_count_invalid(table, "Double"),
01623 "Count written NULLs... ");
01624
01625 error = 0;
01626
01627 for (i = 0; i < 25; i++) {
01628 cpl_table_get_double(table, "Double", i, &null);
01629 if (!null) {
01630 if (fabs(cpl_table_get_double(table, "Double", i, &null)-dcheck[i])
01631 > 0.000001) {
01632 error = 1;
01633 break;
01634 }
01635 }
01636 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
01637 error = 1;
01638 break;
01639 }
01640 }
01641
01642 if (error) {
01643 printf("Check Double column... ");
01644 printf("Failure\n");
01645
01646 return 1;
01647 }
01648
01649
01650 test(cpl_table_set_column_invalid(table, "Float", 0, 3),
01651 "Set Float 0-2 to NULL... ");
01652 test(cpl_table_set_column_invalid(table, "Float", 5, 3),
01653 "Set Float 5-7 to NULL... ");
01654 test(cpl_table_set_column_invalid(table, "Float", 20, 20),
01655 "Set Float 20 till end to NULL... ");
01656
01658 cpl_table_fill_invalid_int(table, "Integer", 320);
01659 cpl_table_fill_invalid_int(table, "AInt", 320);
01660 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01661 cpl_table_delete(table);
01662 table = cpl_table_load("test_table.tfits", 1, 1);
01663
01664
01665 test_ivalue(11, cpl_table_count_invalid(table, "Float"),
01666 "Count written NULLs... ");
01667
01668 error = 0;
01669
01670 for (i = 0; i < 25; i++) {
01671 cpl_table_get_float(table, "Float", i, &null);
01672 if (!null) {
01673 if (fabs(cpl_table_get_float(table, "Float", i, &null)-fcheck[i])
01674 > 0.000001) {
01675 error = 1;
01676 break;
01677 }
01678 }
01679 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
01680 error = 1;
01681 break;
01682 }
01683 }
01684
01685 if (error) {
01686 printf("Check Float column... ");
01687 printf("Failure\n");
01688
01689 return 1;
01690 }
01691
01692
01693 test(cpl_table_set_column_invalid(table, "String", 0, 3),
01694 "Set String 0-2 to NULL... ");
01695 test(cpl_table_set_column_invalid(table, "String", 5, 3),
01696 "Set String 5-7 to NULL... ");
01697 test(cpl_table_set_column_invalid(table, "String", 20, 20),
01698 "Set String 20 till end to NULL... ");
01699
01701 cpl_table_fill_invalid_int(table, "Integer", 320);
01702 cpl_table_fill_invalid_int(table, "AInt", 320);
01703 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01704 cpl_table_delete(table);
01705 table = cpl_table_load("test_table.tfits", 1, 1);
01706
01707
01708 test_ivalue(11, cpl_table_count_invalid(table, "String"),
01709 "Count written NULLs... ");
01710
01711 error = 0;
01712
01713 for (i = 0; i < 25; i++) {
01714 if (cpl_table_get_string(table, "String", i)) {
01715 if (strcmp(cpl_table_get_string(table, "String", i), scheck[i])) {
01716 error = 1;
01717 break;
01718 }
01719 }
01720 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
01721 error = 1;
01722 break;
01723 }
01724 }
01725
01726 if (error) {
01727 printf("Check String column... ");
01728 printf("Failure\n");
01729
01730 return 1;
01731 }
01732
01733 test(cpl_table_erase_window(table, 21, 4), "Delete last 4 table rows... ");
01734
01735 test(cpl_table_erase_window(table, 7, 4),
01736 "Delete table rows from 7 to 10... ");
01737
01738 test(cpl_table_erase_window(table, 3, 3),
01739 "Delete table rows from 3 to 5... ");
01740
01741 test(cpl_table_erase_window(table, 0, 2), "Delete first two table rows... ");
01742
01743 test_ivalue(12, cpl_table_get_nrow(table), "Check table length (4)... ");
01744
01745 test_ivalue(3, cpl_table_count_invalid(table, "Integer"),
01746 "Count Integer NULLs... ");
01747
01748 test_ivalue(3, cpl_table_count_invalid(table, "Double"),
01749 "Count Double NULLs... ");
01750
01751 test_ivalue(3, cpl_table_count_invalid(table, "String"),
01752 "Count String NULLs... ");
01753
01754 test_ivalue(3, cpl_table_count_invalid(table, "Float"),
01755 "Count Float NULLs... ");
01756
01757 test_ivalue(3, cpl_table_count_invalid(table, "AInt"),
01758 "Count AInt NULLs... ");
01759
01760 test_ivalue(0, cpl_table_count_invalid(table, "ADouble"),
01761 "Count ADouble NULLs... ");
01762
01763 test_ivalue(0, cpl_table_count_invalid(table, "AFloat"),
01764 "Count AFloat NULLs... ");
01765
01766 test(cpl_table_insert_window(table, 20, 5),
01767 "Append 5 NULLs at table end... ");
01768
01769 test(cpl_table_insert_window(table, 6, 4),
01770 "Insert segment of 4 NULLs at row 6... ");
01771
01772 test(cpl_table_insert_window(table, 1, 2),
01773 "Insert segment of 2 NULLs at row 1... ");
01774
01775 test_ivalue(23, cpl_table_get_nrow(table), "Check table length (5)... ");
01776
01777 test_ivalue(14, cpl_table_count_invalid(table, "Integer"),
01778 "Count Integer NULLs... ");
01779
01780 test_ivalue(14, cpl_table_count_invalid(table, "Double"),
01781 "Count Double NULLs... ");
01782
01783 test_ivalue(14, cpl_table_count_invalid(table, "String"),
01784 "Count String NULLs... ");
01785
01786 test_ivalue(14, cpl_table_count_invalid(table, "Float"),
01787 "Count Float NULLs... ");
01788
01789 test(cpl_table_fill_column_window_int(table, "Integer", 0, 2, 999),
01790 "Write 999 in \"Integer\" column from 0 to 1... ");
01791
01792 test(cpl_table_fill_column_window_int(table, "Integer", 3, 3, 999),
01793 "Write 999 in \"Integer\" column from 3 to 5... ");
01794
01795 test(cpl_table_fill_column_window_int(table, "Integer", 7, 4, 999),
01796 "Write 999 in \"Integer\" column from 7 to 10... ");
01797
01798 test(cpl_table_fill_column_window_int(table, "Integer", 20, 7, 999),
01799 "Write 999 in \"Integer\" column from 20 to end... ");
01800
01801 test(cpl_table_fill_column_window_float(table, "Float", 0, 2, 999.99),
01802 "Write 999.99 in \"Float\" column from 0 to 1... ");
01803
01804 test(cpl_table_fill_column_window_float(table, "Float", 3, 3, 999.99),
01805 "Write 999.99 in \"Float\" column from 3 to 5... ");
01806
01807 test(cpl_table_fill_column_window_float(table, "Float", 7, 4, 999.99),
01808 "Write 999.99 in \"Float\" column from 7 to 10... ");
01809
01810 test(cpl_table_fill_column_window_float(table, "Float", 20, 7, 999.99),
01811 "Write 999.99 in \"Float\" column from 20 to end... ");
01812
01813 test(cpl_table_fill_column_window_double(table, "Double", 0, 2, 999.88),
01814 "Write 999.88 in \"Double\" column from 0 to 1... ");
01815
01816 test(cpl_table_fill_column_window_double(table, "Double", 3, 3, 999.88),
01817 "Write 999.88 in \"Double\" column from 3 to 5... ");
01818
01819 test(cpl_table_fill_column_window_double(table, "Double", 7, 4, 999.88),
01820 "Write 999.88 in \"Double\" column from 7 to 10... ");
01821
01822 test(cpl_table_fill_column_window_double(table, "Double", 20, 7, 999.88),
01823 "Write 999.88 in \"Double\" column from 20 to end... ");
01824
01825 test(cpl_table_fill_column_window_string(table, "String", 0, 2, "999"),
01826 "Write \"999\" in \"String\" column from 0 to 1... ");
01827
01828 test(cpl_table_fill_column_window_string(table, "String", 3, 3, "999"),
01829 "Write \"999\" in \"String\" column from 3 to 5... ");
01830
01831 test(cpl_table_fill_column_window_string(table, "String", 7, 4, "999"),
01832 "Write \"999\" in \"String\" column from 7 to 10... ");
01833
01834 test(cpl_table_fill_column_window_string(table, "String", 20, 7, "999"),
01835 "Write \"999\" in \"String\" column from 20 to end... ");
01836
01838 cpl_table_fill_invalid_int(table, "Integer", 320);
01839 cpl_table_fill_invalid_int(table, "AInt", 320);
01840 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01841 cpl_table_delete(table);
01842 table = cpl_table_load("test_table.tfits", 1, 1);
01843
01844
01845 test_ivalue(23, cpl_table_get_nrow(table), "Check table length (6)... ");
01846
01847 test_ivalue(5, cpl_table_count_invalid(table, "Integer"),
01848 "Count Integer NULLs... ");
01849
01850 test_ivalue(5, cpl_table_count_invalid(table, "Float"),
01851 "Count Float NULLs... ");
01852
01853 test_ivalue(5, cpl_table_count_invalid(table, "Double"),
01854 "Count Double NULLs... ");
01855
01856 test_ivalue(5, cpl_table_count_invalid(table, "String"),
01857 "Count String NULLs... ");
01858
01859 test_ivalue(14, cpl_table_count_invalid(table, "AInt"),
01860 "Count AInt NULLs... ");
01861
01862 test_ivalue(11, cpl_table_count_invalid(table, "AFloat"),
01863 "Count AFloat NULLs... ");
01864
01865 test_ivalue(11, cpl_table_count_invalid(table, "ADouble"),
01866 "Count ADouble NULLs... ");
01867
01868 test_ivalue(0, cpl_table_is_valid(table, "Integer", 2),
01869 "Check that third element of \"Integer\" is NULL... ");
01870
01871 test_ivalue(1, cpl_table_is_valid(table, "Double", 0),
01872 "Check that first element of \"Double\" is not NULL... ");
01873
01874 test_ivalue(1, cpl_table_is_valid(table, "String", 0),
01875 "Check that first element of \"String\" is not NULL... ");
01876
01877 test_ivalue(0, cpl_table_is_valid(table, "String", 2),
01878 "Check that third element of \"String\" is NULL... ");
01879
01880 test_ivalue(0, cpl_table_is_valid(table, "AInt", 17),
01881 "Check that third element of \"AInt\" is NULL... ");
01882
01883 test_ivalue(1, cpl_table_is_valid(table, "ADouble", 17),
01884 "Check that first element of \"ADouble\" is not NULL... ");
01885
01886 test_ivalue(1, cpl_table_is_valid(table, "AFloat", 17),
01887 "Check that third element of \"AFloat\" is NULL... ");
01888
01889 test_data(copia, cpl_table_duplicate(table), "Duplicate table... ");
01890
01891 test(cpl_table_duplicate_column(table, "New Integer", table, "Integer"),
01892 "Duplicate \"Integer\" column within same table... ");
01893
01894 test(cpl_table_duplicate_column(table, "New Float", table, "Float"),
01895 "Duplicate \"Float\" column within same table... ");
01896
01897 test(cpl_table_duplicate_column(table, "New Double", table, "Double"),
01898 "Duplicate \"Double\" column within same table... ");
01899
01900 test(cpl_table_duplicate_column(table, "New String", table, "String"),
01901 "Duplicate \"String\" column within same table... ");
01902
01903 test(cpl_table_duplicate_column(table, "New AInt", table, "AInt"),
01904 "Duplicate \"AInt\" column within same table... ");
01905
01906 test(cpl_table_duplicate_column(table, "New AFloat", table, "AFloat"),
01907 "Duplicate \"AFloat\" column within same table... ");
01908
01909 test(cpl_table_duplicate_column(table, "New ADouble", table, "ADouble"),
01910 "Duplicate \"ADouble\" column within same table... ");
01911
01912 test_ivalue(5, cpl_table_count_invalid(table, "New Integer"),
01913 "Count New Integer NULLs... ");
01914
01915 test_ivalue(5, cpl_table_count_invalid(table, "New Float"),
01916 "Count New Float NULLs... ");
01917
01918 test_ivalue(5, cpl_table_count_invalid(table, "New Double"),
01919 "Count New Double NULLs... ");
01920
01921 test_ivalue(5, cpl_table_count_invalid(table, "New String"),
01922 "Count New String NULLs... ");
01923
01924 test_ivalue(14, cpl_table_count_invalid(table, "New AInt"),
01925 "Count New AInt NULLs... ");
01926
01927 test_ivalue(11, cpl_table_count_invalid(table, "New AFloat"),
01928 "Count New AFloat NULLs... ");
01929
01930 test_ivalue(11, cpl_table_count_invalid(table, "New ADouble"),
01931 "Count New ADouble NULLs... ");
01932
01933 test(cpl_table_move_column(copia, "New Integer", table),
01934 "Moving column \"New Integer\" to another table... ");
01935
01936 test(cpl_table_move_column(copia, "New Float", table),
01937 "Moving column \"New Float\" to another table... ");
01938
01939 test(cpl_table_move_column(copia, "New Double", table),
01940 "Moving column \"New Double\" to another table... ");
01941
01942 test(cpl_table_move_column(copia, "New String", table),
01943 "Moving column \"New String\" to another table... ");
01944
01945 test_failure(CPL_ERROR_ILLEGAL_OUTPUT,
01946 cpl_table_name_column(copia, "New String", "String"),
01947 "Try illegal column renaming... ");
01948
01949 test(cpl_table_name_column(copia, "New Integer", "Old Integer"),
01950 "Try legal column renaming... ");
01951
01953 cpl_table_fill_invalid_int(table, "Integer", 320);
01954 cpl_table_fill_invalid_int(table, "AInt", 320);
01955 cpl_table_fill_invalid_int(table, "New AInt", 320);
01956 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
01957 cpl_table_delete(table);
01958 table = cpl_table_load("test_table.tfits", 1, 1);
01959
01960
01961 test_ivalue(!0, cpl_table_has_column(copia, "Old Integer"),
01962 "Check if column \"Old Integer\" exists... ");
01963
01964 test_svalue("Integer", cpl_table_get_column_name(copia),
01965 "Check name column 1... ");
01966
01967 test_svalue("Double", cpl_table_get_column_name(NULL),
01968 "Check name column 2... ");
01969
01970 test_svalue("String", cpl_table_get_column_name(NULL),
01971 "Check name column 3... ");
01972
01973 test_svalue("Float", cpl_table_get_column_name(NULL),
01974 "Check name column 4... ");
01975
01976 test_svalue("AInt", cpl_table_get_column_name(NULL),
01977 "Check name column 5... ");
01978
01979 test_svalue("AFloat", cpl_table_get_column_name(NULL),
01980 "Check name column 6... ");
01981
01982 test_svalue("ADouble", cpl_table_get_column_name(NULL),
01983 "Check name column 7... ");
01984
01985 test_svalue("Old Integer", cpl_table_get_column_name(NULL),
01986 "Check name column 8... ");
01987
01988 test_svalue("New Float", cpl_table_get_column_name(NULL),
01989 "Check name column 9... ");
01990
01991 test_svalue("New Double", cpl_table_get_column_name(NULL),
01992 "Check name column 10... ");
01993
01994 test_svalue("New String", cpl_table_get_column_name(NULL),
01995 "Check name column 11... ");
01996
01997 test_pvalue(NULL, (void *)cpl_table_get_column_name(NULL),
01998 "Check if no more colums... ");
01999
02000 cpl_table_delete(copia);
02001
02002
02003 test(cpl_table_set_size(table, 30), "Expanding table to 30 rows... ");
02004
02005
02006
02007
02008
02009
02010
02011
02012 test_ivalue(12, cpl_table_count_invalid(table, "Integer"),
02013 "Count \"Integer\" NULLs... ");
02014
02015 test_ivalue(12, cpl_table_count_invalid(table, "String"),
02016 "Count \"String\" NULLs... ");
02017
02018 test(cpl_table_set_size(table, 22), "Truncating table to 22 rows... ");
02019
02020
02021
02022
02023
02024
02025
02026
02027
02029 cpl_table_fill_invalid_int(table, "Integer", 320);
02030 cpl_table_fill_invalid_int(table, "AInt", 320);
02031 cpl_table_fill_invalid_int(table, "New AInt", 320);
02032 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
02033 cpl_table_delete(table);
02034 table = cpl_table_load("test_table.tfits", 1, 1);
02035
02036
02037 test_ivalue(5, cpl_table_count_invalid(table, "Integer"),
02038 "Count \"Integer\" NULLs (2)... ");
02039
02040 test_ivalue(5, cpl_table_count_invalid(table, "String"),
02041 "Count \"String\" NULLs (2)... ");
02042
02043 test_data(copia, cpl_table_extract(table, 0, 5),
02044 "Creating subtable from rows 0-5 of original... ");
02045
02046 test_ivalue(1, cpl_table_count_invalid(copia, "Integer"),
02047 "Count \"Integer\" NULLs... ");
02048
02049 test_ivalue(1, cpl_table_count_invalid(copia, "String"),
02050 "Count \"String\" NULLs... ");
02051
02052 cpl_table_delete(copia);
02053
02054 test_data(copia, cpl_table_extract(table, 8, 5),
02055 "Creating subtable from rows 8-5 of original... ");
02056
02057 test_ivalue(1, cpl_table_count_invalid(copia, "Float"),
02058 "Count \"Float\" NULLs... ");
02059
02060 test_ivalue(1, cpl_table_count_invalid(copia, "String"),
02061 "Count \"String\" NULLs... ");
02062
02063 cpl_table_delete(copia);
02064
02065 test_data(copia, cpl_table_extract(table, 15, 30),
02066 "Creating subtable from rows 15 till end of original... ");
02067
02068 test_ivalue(3, cpl_table_count_invalid(copia, "Double"),
02069 "Count \"Double\" NULLs... ");
02070
02071 test_ivalue(3, cpl_table_count_invalid(copia, "String"),
02072 "Count \"String\" NULLs... ");
02073
02074 cpl_table_delete(copia);
02075
02076 test(cpl_table_cast_column(table, "Float", "FloatToInt", CPL_TYPE_INT),
02077 "Casting float column to integer colum... ");
02078
02080 cpl_table_fill_invalid_int(table, "Integer", 320);
02081 cpl_table_fill_invalid_int(table, "FloatToInt", -2);
02082 cpl_table_fill_invalid_int(table, "AInt", 320);
02083 cpl_table_fill_invalid_int(table, "New AInt", 320);
02084 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
02085 cpl_table_delete(table);
02086 table = cpl_table_load("test_table.tfits", 1, 1);
02087
02088
02089 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 0, NULL),
02090 "Check element 1 of casted column... ");
02091 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 1, NULL),
02092 "Check element 2 of casted column... ");
02093 test_ivalue(0, cpl_table_is_valid(table, "FloatToInt", 2),
02094 "Check element 3 of casted column... ");
02095 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 3, NULL),
02096 "Check element 4 of casted column... ");
02097 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 4, NULL),
02098 "Check element 5 of casted column... ");
02099 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 5, NULL),
02100 "Check element 6 of casted column... ");
02101 test_ivalue(-1, cpl_table_get_int(table, "FloatToInt", 6, NULL),
02102 "Check element 7 of casted column... ");
02103 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 7, NULL),
02104 "Check element 8 of casted column... ");
02105 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 8, NULL),
02106 "Check element 9 of casted column... ");
02107 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 9, NULL),
02108 "Check element 10 of casted column... ");
02109 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 10, NULL),
02110 "Check element 11 of casted column... ");
02111 test_ivalue(0, cpl_table_is_valid(table, "FloatToInt", 11),
02112 "Check element 12 of casted column... ");
02113 test_ivalue(3, cpl_table_get_int(table, "FloatToInt", 12, NULL),
02114 "Check element 13 of casted column... ");
02115 test_ivalue(7, cpl_table_get_int(table, "FloatToInt", 13, NULL),
02116 "Check element 14 of casted column... ");
02117 test_ivalue(1, cpl_table_get_int(table, "FloatToInt", 14, NULL),
02118 "Check element 15 of casted column... ");
02119 test_ivalue(4, cpl_table_get_int(table, "FloatToInt", 15, NULL),
02120 "Check element 16 of casted column... ");
02121 test_ivalue(6, cpl_table_get_int(table, "FloatToInt", 16, NULL),
02122 "Check element 17 of casted column... ");
02123 test_ivalue(0, cpl_table_is_valid(table, "FloatToInt", 17),
02124 "Check element 18 of casted column... ");
02125 test_ivalue(0, cpl_table_is_valid(table, "FloatToInt", 18),
02126 "Check element 19 of casted column... ");
02127 test_ivalue(0, cpl_table_is_valid(table, "FloatToInt", 19),
02128 "Check element 20 of casted column... ");
02129 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 20, NULL),
02130 "Check element 21 of casted column... ");
02131 test_ivalue(999, cpl_table_get_int(table, "FloatToInt", 21, NULL),
02132 "Check element 22 of casted column... ");
02133
02134 test(cpl_table_erase_column(table, "FloatToInt"),
02135 "Delete casted column... ");
02136
02137 test(cpl_table_cast_column(table, "Integer", "IntToFloat", CPL_TYPE_FLOAT),
02138 "Casting integer column to float colum... ");
02139
02141 cpl_table_fill_invalid_int(table, "Integer", 320);
02142 cpl_table_fill_invalid_int(table, "AInt", 320);
02143 cpl_table_fill_invalid_int(table, "New AInt", 320);
02144 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
02145 cpl_table_delete(table);
02146 table = cpl_table_load("test_table.tfits", 1, 1);
02147
02148
02149 test_fvalue(999.0, 0.00001,
02150 cpl_table_get_float(table, "IntToFloat", 0, NULL),
02151 "Check element 1 of casted column (2)... ");
02152 test_fvalue(999.0, 0.00001,
02153 cpl_table_get_float(table, "IntToFloat", 1, NULL),
02154 "Check element 2 of casted column (2)... ");
02155 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 2),
02156 "Check element 3 of casted column (2)... ");
02157 test_fvalue(999.0, 0.00001,
02158 cpl_table_get_float(table, "IntToFloat", 3, NULL),
02159 "Check element 4 of casted column (2)... ");
02160 test_fvalue(999.0, 0.00001,
02161 cpl_table_get_float(table, "IntToFloat", 4, NULL),
02162 "Check element 5 of casted column (2)... ");
02163 test_fvalue(999.0, 0.00001,
02164 cpl_table_get_float(table, "IntToFloat", 5, NULL),
02165 "Check element 6 of casted column (2)... ");
02166 test_fvalue(-1.0, 0.00001,
02167 cpl_table_get_float(table, "IntToFloat", 6, NULL),
02168 "Check element 7 of casted column (2)... ");
02169 test_fvalue(999.0, 0.00001,
02170 cpl_table_get_float(table, "IntToFloat", 7, NULL),
02171 "Check element 8 of casted column (2)... ");
02172 test_fvalue(999.0, 0.00001,
02173 cpl_table_get_float(table, "IntToFloat", 8, NULL),
02174 "Check element 9 of casted column (2)... ");
02175 test_fvalue(999.0, 0.00001,
02176 cpl_table_get_float(table, "IntToFloat", 9, NULL),
02177 "Check element 10 of casted column (2)... ");
02178 test_fvalue(999.0, 0.00001,
02179 cpl_table_get_float(table, "IntToFloat", 10, NULL),
02180 "Check element 11 of casted column (2)... ");
02181 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 11),
02182 "Check element 12 of casted column (2)... ");
02183 test_fvalue(3.0, 0.00001,
02184 cpl_table_get_float(table, "IntToFloat", 12, NULL),
02185 "Check element 13 of casted column (2)... ");
02186 test_fvalue(7.0, 0.00001,
02187 cpl_table_get_float(table, "IntToFloat", 13, NULL),
02188 "Check element 14 of casted column (2)... ");
02189 test_fvalue(1.0, 0.00001,
02190 cpl_table_get_float(table, "IntToFloat", 14, NULL),
02191 "Check element 15 of casted column (2)... ");
02192 test_fvalue(4.0, 0.00001,
02193 cpl_table_get_float(table, "IntToFloat", 15, NULL),
02194 "Check element 16 of casted column (2)... ");
02195 test_fvalue(6.0, 0.00001,
02196 cpl_table_get_float(table, "IntToFloat", 16, NULL),
02197 "Check element 17 of casted column (2)... ");
02198 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 17),
02199 "Check element 18 of casted column (2)... ");
02200 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 18),
02201 "Check element 19 of casted column (2)... ");
02202 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 19),
02203 "Check element 20 of casted column (2)... ");
02204 test_fvalue(999.0, 0.00001,
02205 cpl_table_get_float(table, "IntToFloat", 20, NULL),
02206 "Check element 21 of casted column (2)... ");
02207 test_fvalue(999.0, 0.00001,
02208 cpl_table_get_float(table, "IntToFloat", 21, NULL),
02209 "Check element 22 of casted column (2)... ");
02210
02211 test(cpl_table_shift_column(table, "IntToFloat", 1),
02212 "Shift new column one position down... ");
02213
02214 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 0),
02215 "Check element 1 of shifted column... ");
02216 test_fvalue(999.0, 0.00001,
02217 cpl_table_get_float(table, "IntToFloat", 1, NULL),
02218 "Check element 2 of shifted column... ");
02219 test_fvalue(999.0, 0.00001,
02220 cpl_table_get_float(table, "IntToFloat", 2, NULL),
02221 "Check element 3 of shifted column... ");
02222 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 3),
02223 "Check element 4 of shifted column... ");
02224 test_fvalue(999.0, 0.00001,
02225 cpl_table_get_float(table, "IntToFloat", 4, NULL),
02226 "Check element 5 of shifted column... ");
02227 test_fvalue(999.0, 0.00001,
02228 cpl_table_get_float(table, "IntToFloat", 5, NULL),
02229 "Check element 6 of shifted column... ");
02230 test_fvalue(999.0, 0.00001,
02231 cpl_table_get_float(table, "IntToFloat", 6, NULL),
02232 "Check element 7 of shifted column... ");
02233 test_fvalue(-1.0, 0.00001,
02234 cpl_table_get_float(table, "IntToFloat", 7, NULL),
02235 "Check element 8 of shifted column... ");
02236 test_fvalue(999.0, 0.00001,
02237 cpl_table_get_float(table, "IntToFloat", 8, NULL),
02238 "Check element 9 of shifted column... ");
02239 test_fvalue(999.0, 0.00001,
02240 cpl_table_get_float(table, "IntToFloat", 9, NULL),
02241 "Check element 10 of shifted column... ");
02242 test_fvalue(999.0, 0.00001,
02243 cpl_table_get_float(table, "IntToFloat", 10, NULL),
02244 "Check element 11 of shifted column... ");
02245 test_fvalue(999.0, 0.00001,
02246 cpl_table_get_float(table, "IntToFloat", 11, NULL),
02247 "Check element 12 of shifted column... ");
02248 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 12),
02249 "Check element 13 of shifted column... ");
02250 test_fvalue(3.0, 0.00001,
02251 cpl_table_get_float(table, "IntToFloat", 13, NULL),
02252 "Check element 14 of shifted column... ");
02253 test_fvalue(7.0, 0.00001,
02254 cpl_table_get_float(table, "IntToFloat", 14, NULL),
02255 "Check element 15 of shifted column... ");
02256 test_fvalue(1.0, 0.00001,
02257 cpl_table_get_float(table, "IntToFloat", 15, NULL),
02258 "Check element 16 of shifted column... ");
02259 test_fvalue(4.0, 0.00001,
02260 cpl_table_get_float(table, "IntToFloat", 16, NULL),
02261 "Check element 17 of shifted column... ");
02262 test_fvalue(6.0, 0.00001,
02263 cpl_table_get_float(table, "IntToFloat", 17, NULL),
02264 "Check element 18 of shifted column... ");
02265 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 18),
02266 "Check element 19 of shifted column... ");
02267 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 19),
02268 "Check element 20 of shifted column... ");
02269 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 20),
02270 "Check element 21 of shifted column... ");
02271 test_fvalue(999.0, 0.00001,
02272 cpl_table_get_float(table, "IntToFloat", 21, NULL),
02273 "Check element 22 of shifted column... ");
02274
02275 test(cpl_table_add_columns(table, "Integer", "IntToFloat"),
02276 "Sum \"IntToFloat\" to \"Integer\"... ");
02277
02279 cpl_table_fill_invalid_int(table, "Integer", 320);
02280 cpl_table_fill_invalid_int(table, "AInt", 320);
02281 cpl_table_fill_invalid_int(table, "New AInt", 320);
02282 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
02283 cpl_table_delete(table);
02284 table = cpl_table_load("test_table.tfits", 1, 1);
02285
02286
02287 test_ivalue(0, cpl_table_is_valid(table, "Integer", 0),
02288 "Check element 1 of \"Integer\" += \"IntToFloat\"... ");
02289 test_ivalue(1998, cpl_table_get_int(table, "Integer", 1, NULL),
02290 "Check element 2 of \"Integer\" += \"IntToFloat\"... ");
02291 test_ivalue(0, cpl_table_is_valid(table, "Integer", 2),
02292 "Check element 3 of \"Integer\" += \"IntToFloat\"... ");
02293 test_ivalue(0, cpl_table_is_valid(table, "Integer", 3),
02294 "Check element 4 of \"Integer\" += \"IntToFloat\"... ");
02295 test_ivalue(1998, cpl_table_get_int(table, "Integer", 4, NULL),
02296 "Check element 5 of \"Integer\" += \"IntToFloat\"... ");
02297 test_ivalue(1998, cpl_table_get_int(table, "Integer", 5, NULL),
02298 "Check element 6 of \"Integer\" += \"IntToFloat\"... ");
02299 test_ivalue(998, cpl_table_get_int(table, "Integer", 6, NULL),
02300 "Check element 7 of \"Integer\" += \"IntToFloat\"... ");
02301 test_ivalue(998, cpl_table_get_int(table, "Integer", 7, NULL),
02302 "Check element 8 of \"Integer\" += \"IntToFloat\"... ");
02303 test_ivalue(1998, cpl_table_get_int(table, "Integer", 8, NULL),
02304 "Check element 9 of \"Integer\" += \"IntToFloat\"... ");
02305 test_ivalue(1998, cpl_table_get_int(table, "Integer", 9, NULL),
02306 "Check element 10 of \"Integer\" += \"IntToFloat\"... ");
02307 test_ivalue(1998, cpl_table_get_int(table, "Integer", 10, NULL),
02308 "Check element 11 of \"Integer\" += \"IntToFloat\"... ");
02309 test_ivalue(0, cpl_table_is_valid(table, "Integer", 11),
02310 "Check element 12 of \"Integer\" += \"IntToFloat\"... ");
02311 test_ivalue(0, cpl_table_is_valid(table, "Integer", 12),
02312 "Check element 13 of \"Integer\" += \"IntToFloat\"... ");
02313 test_ivalue(10, cpl_table_get_int(table, "Integer", 13, NULL),
02314 "Check element 14 of \"Integer\" += \"IntToFloat\"... ");
02315 test_ivalue(8, cpl_table_get_int(table, "Integer", 14, NULL),
02316 "Check element 15 of \"Integer\" += \"IntToFloat\"... ");
02317 test_ivalue(5, cpl_table_get_int(table, "Integer", 15, NULL),
02318 "Check element 16 of \"Integer\" += \"IntToFloat\"... ");
02319 test_ivalue(10, cpl_table_get_int(table, "Integer", 16, NULL),
02320 "Check element 17 of \"Integer\" += \"IntToFloat\"... ");
02321 test_ivalue(0, cpl_table_is_valid(table, "Integer", 17),
02322 "Check element 18 of \"Integer\" += \"IntToFloat\"... ");
02323 test_ivalue(0, cpl_table_is_valid(table, "Integer", 18),
02324 "Check element 19 of \"Integer\" += \"IntToFloat\"... ");
02325 test_ivalue(0, cpl_table_is_valid(table, "Integer", 19),
02326 "Check element 20 of \"Integer\" += \"IntToFloat\"... ");
02327 test_ivalue(0, cpl_table_is_valid(table, "Integer", 20),
02328 "Check element 21 of \"Integer\" += \"IntToFloat\"... ");
02329 test_ivalue(1998, cpl_table_get_int(table, "Integer", 21, NULL),
02330 "Check element 22 of \"Integer\" += \"IntToFloat\"... ");
02331
02332 test(cpl_table_subtract_columns(table, "Integer", "IntToFloat"),
02333 "Subtract \"IntToFloat\" from \"Integer\"... ");
02334
02335 test(cpl_table_subtract_columns(table, "IntToFloat", "Integer"),
02336 "Subtract \"Integer\" from \"IntToFloat\"... ");
02337
02338 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 0),
02339 "Check element 1 of \"IntToFloat\" -= \"Integer\"... ");
02340 test_fvalue(0.0, 0.00001,
02341 cpl_table_get_float(table, "IntToFloat", 1, NULL),
02342 "Check element 2 of \"IntToFloat\" -= \"Integer\"... ");
02343 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 2),
02344 "Check element 3 of \"IntToFloat\" -= \"Integer\"... ");
02345 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 3),
02346 "Check element 4 of \"IntToFloat\" -= \"Integer\"... ");
02347 test_fvalue(0.0, 0.00001,
02348 cpl_table_get_float(table, "IntToFloat", 4, NULL),
02349 "Check element 5 of \"IntToFloat\" -= \"Integer\"... ");
02350 test_fvalue(0.0, 0.00001,
02351 cpl_table_get_float(table, "IntToFloat", 5, NULL),
02352 "Check element 6 of \"IntToFloat\" -= \"Integer\"... ");
02353 test_fvalue(1000.0, 0.00001,
02354 cpl_table_get_float(table, "IntToFloat", 6, NULL),
02355 "Check element 7 of \"IntToFloat\" -= \"Integer\"... ");
02356 test_fvalue(-1000.0, 0.00001,
02357 cpl_table_get_float(table, "IntToFloat", 7, NULL),
02358 "Check element 8 of \"IntToFloat\" -= \"Integer\"... ");
02359 test_fvalue(0.0, 0.00001,
02360 cpl_table_get_float(table, "IntToFloat", 8, NULL),
02361 "Check element 9 of \"IntToFloat\" -= \"Integer\"... ");
02362 test_fvalue(0.0, 0.00001,
02363 cpl_table_get_float(table, "IntToFloat", 9, NULL),
02364 "Check element 10 of \"IntToFloat\" -= \"Integer\"... ");
02365 test_fvalue(0.0, 0.00001,
02366 cpl_table_get_float(table, "IntToFloat", 10, NULL),
02367 "Check element 11 of \"IntToFloat\" -= \"Integer\"... ");
02368 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 11),
02369 "Check element 12 of \"IntToFloat\" -= \"Integer\"... ");
02370 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 12),
02371 "Check element 13 of \"IntToFloat\" -= \"Integer\"... ");
02372 test_fvalue(-4.0, 0.00001,
02373 cpl_table_get_float(table, "IntToFloat", 13, NULL),
02374 "Check element 14 of \"IntToFloat\" -= \"Integer\"... ");
02375 test_fvalue(6.0, 0.00001,
02376 cpl_table_get_float(table, "IntToFloat", 14, NULL),
02377 "Check element 15 of \"IntToFloat\" -= \"Integer\"... ");
02378 test_fvalue(-3.0, 0.00001,
02379 cpl_table_get_float(table, "IntToFloat", 15, NULL),
02380 "Check element 16 of \"IntToFloat\" -= \"Integer\"... ");
02381 test_fvalue(-2.0, 0.00001,
02382 cpl_table_get_float(table, "IntToFloat", 16, NULL),
02383 "Check element 17 of \"IntToFloat\" -= \"Integer\"... ");
02384 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 17),
02385 "Check element 18 of \"IntToFloat\" -= \"Integer\"... ");
02386 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 18),
02387 "Check element 19 of \"IntToFloat\" -= \"Integer\"... ");
02388 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 19),
02389 "Check element 20 of \"IntToFloat\" -= \"Integer\"... ");
02390 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 20),
02391 "Check element 21 of \"IntToFloat\" -= \"Integer\"... ");
02392 test_fvalue(0.0, 0.00001,
02393 cpl_table_get_float(table, "IntToFloat", 21, NULL),
02394 "Check element 22 of \"IntToFloat\" -= \"Integer\"... ");
02395
02396 test(cpl_table_multiply_columns(table, "IntToFloat", "Double"),
02397 "Multiply double column with float column... ");
02398
02399 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 0),
02400 "Check element 1 of \"IntToFloat\" *= \"Double\"... ");
02401 test_fvalue(0.0, 0.00001,
02402 cpl_table_get_float(table, "IntToFloat", 1, NULL),
02403 "Check element 2 of \"IntToFloat\" *= \"Double\"... ");
02404 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 2),
02405 "Check element 3 of \"IntToFloat\" *= \"Double\"... ");
02406 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 3),
02407 "Check element 4 of \"IntToFloat\" *= \"Double\"... ");
02408 test_fvalue(0.0, 0.00001,
02409 cpl_table_get_float(table, "IntToFloat", 4, NULL),
02410 "Check element 5 of \"IntToFloat\" *= \"Double\"... ");
02411 test_fvalue(0.0, 0.00001,
02412 cpl_table_get_float(table, "IntToFloat", 5, NULL),
02413 "Check element 6 of \"IntToFloat\" *= \"Double\"... ");
02414 test_fvalue(-1110.0, 0.00001,
02415 cpl_table_get_float(table, "IntToFloat", 6, NULL),
02416 "Check element 7 of \"IntToFloat\" *= \"Double\"... ");
02417 test_fvalue(-999880.0, 0.00001,
02418 cpl_table_get_float(table, "IntToFloat", 7, NULL),
02419 "Check element 8 of \"IntToFloat\" *= \"Double\"... ");
02420 test_fvalue(0.0, 0.00001,
02421 cpl_table_get_float(table, "IntToFloat", 8, NULL),
02422 "Check element 9 of \"IntToFloat\" *= \"Double\"... ");
02423 test_fvalue(0.0, 0.00001,
02424 cpl_table_get_float(table, "IntToFloat", 9, NULL),
02425 "Check element 10 of \"IntToFloat\" *= \"Double\"... ");
02426 test_fvalue(0.0, 0.00001,
02427 cpl_table_get_float(table, "IntToFloat", 10, NULL),
02428 "Check element 11 of \"IntToFloat\" *= \"Double\"... ");
02429 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 11),
02430 "Check element 12 of \"IntToFloat\" *= \"Double\"... ");
02431 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 12),
02432 "Check element 13 of \"IntToFloat\" *= \"Double\"... ");
02433 test_fvalue(-28.44, 0.00001,
02434 cpl_table_get_float(table, "IntToFloat", 13, NULL),
02435 "Check element 14 of \"IntToFloat\" *= \"Double\"... ");
02436 test_fvalue(6.66, 0.00001,
02437 cpl_table_get_float(table, "IntToFloat", 14, NULL),
02438 "Check element 15 of \"IntToFloat\" *= \"Double\"... ");
02439 test_fvalue(-12.33, 0.00001,
02440 cpl_table_get_float(table, "IntToFloat", 15, NULL),
02441 "Check element 16 of \"IntToFloat\" *= \"Double\"... ");
02442 test_fvalue(-12.22, 0.00001,
02443 cpl_table_get_float(table, "IntToFloat", 16, NULL),
02444 "Check element 17 of \"IntToFloat\" *= \"Double\"... ");
02445 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 17),
02446 "Check element 18 of \"IntToFloat\" *= \"Double\"... ");
02447 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 18),
02448 "Check element 19 of \"IntToFloat\" *= \"Double\"... ");
02449 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 19),
02450 "Check element 20 of \"IntToFloat\" *= \"Double\"... ");
02451 test_ivalue(0, cpl_table_is_valid(table, "IntToFloat", 20),
02452 "Check element 21 of \"IntToFloat\" *= \"Double\"... ");
02453 test_fvalue(0.0, 0.00001,
02454 cpl_table_get_float(table, "IntToFloat", 21, NULL),
02455 "Check element 22 of \"IntToFloat\" *= \"Double\"... ");
02456
02457 test(cpl_table_divide_columns(table, "Float", "IntToFloat"),
02458 "Divide float column with float column... ");
02459
02460 test_ivalue(0, cpl_table_is_valid(table, "Float", 0),
02461 "Check element 1 of \"Float\" /= \"IntToFloat\"... ");
02462 test_ivalue(0, cpl_table_is_valid(table, "Float", 1),
02463 "Check element 2 of \"Float\" /= \"IntToFloat\"... ");
02464 test_ivalue(0, cpl_table_is_valid(table, "Float", 2),
02465 "Check element 3 of \"Float\" /= \"IntToFloat\"... ");
02466 test_ivalue(0, cpl_table_is_valid(table, "Float", 3),
02467 "Check element 4 of \"Float\" /= \"IntToFloat\"... ");
02468 test_ivalue(0, cpl_table_is_valid(table, "Float", 4),
02469 "Check element 5 of \"Float\" /= \"IntToFloat\"... ");
02470 test_ivalue(0, cpl_table_is_valid(table, "Float", 5),
02471 "Check element 6 of \"Float\" /= \"IntToFloat\"... ");
02472 test_fvalue(0.000991, 0.0000001,
02473 cpl_table_get_float(table, "Float", 6, NULL),
02474 "Check element 7 of \"Float\" /= \"IntToFloat\"... ");
02475 test_fvalue(-0.0010001, 0.0000001,
02476 cpl_table_get_float(table, "Float", 7, NULL),
02477 "Check element 8 of \"Float\" /= \"IntToFloat\"... ");
02478 test_ivalue(0, cpl_table_is_valid(table, "Float", 8),
02479 "Check element 9 of \"Float\" /= \"IntToFloat\"... ");
02480 test_ivalue(0, cpl_table_is_valid(table, "Float", 9),
02481 "Check element 10 of \"Float\" /= \"IntToFloat\"... ");
02482 test_ivalue(0, cpl_table_is_valid(table, "Float", 10),
02483 "Check element 11 of \"Float\" /= \"IntToFloat\"... ");
02484 test_ivalue(0, cpl_table_is_valid(table, "Float", 11),
02485 "Check element 12 of \"Float\" /= \"IntToFloat\"... ");
02486 test_ivalue(0, cpl_table_is_valid(table, "Float", 12),
02487 "Check element 13 of \"Float\" /= \"IntToFloat\"... ");
02488 test_fvalue(-0.2496484, 0.0000001,
02489 cpl_table_get_float(table, "Float", 13, NULL),
02490 "Check element 14 of \"Float\" /= \"IntToFloat\"... ");
02491 test_fvalue(0.1651652, 0.0000001,
02492 cpl_table_get_float(table, "Float", 14, NULL),
02493 "Check element 15 of \"Float\" /= \"IntToFloat\"... ");
02494 test_fvalue(-0.3325223, 0.0000001,
02495 cpl_table_get_float(table, "Float", 15, NULL),
02496 "Check element 16 of \"Float\" /= \"IntToFloat\"... ");
02497 test_fvalue(-0.4991817, 0.0000001,
02498 cpl_table_get_float(table, "Float", 16, NULL),
02499 "Check element 17 of \"Float\" /= \"IntToFloat\"... ");
02500 test_ivalue(0, cpl_table_is_valid(table, "Float", 17),
02501 "Check element 18 of \"Float\" /= \"IntToFloat\"... ");
02502 test_ivalue(0, cpl_table_is_valid(table, "Float", 18),
02503 "Check element 19 of \"Float\" /= \"IntToFloat\"... ");
02504 test_ivalue(0, cpl_table_is_valid(table, "Float", 19),
02505 "Check element 20 of \"Float\" /= \"IntToFloat\"... ");
02506 test_ivalue(0, cpl_table_is_valid(table, "Float", 20),
02507 "Check element 21 of \"Float\" /= \"IntToFloat\"... ");
02508 test_ivalue(0, cpl_table_is_valid(table, "Float", 21),
02509 "Check element 22 of \"Float\" /= \"IntToFloat\"... ");
02510
02511 test(cpl_table_add_scalar(table, "Float", 1),
02512 "Add integer constant to \"Float\"... ");
02513
02514 test_ivalue(0, cpl_table_is_valid(table, "Float", 0),
02515 "Check element 1 of adding 1 to \"Float\"... ");
02516 test_ivalue(0, cpl_table_is_valid(table, "Float", 1),
02517 "Check element 2 of adding 1 to \"Float\"... ");
02518 test_ivalue(0, cpl_table_is_valid(table, "Float", 2),
02519 "Check element 3 of adding 1 to \"Float\"... ");
02520 test_ivalue(0, cpl_table_is_valid(table, "Float", 3),
02521 "Check element 4 of adding 1 to \"Float\"... ");
02522 test_ivalue(0, cpl_table_is_valid(table, "Float", 4),
02523 "Check element 5 of adding 1 to \"Float\"... ");
02524 test_ivalue(0, cpl_table_is_valid(table, "Float", 5),
02525 "Check element 6 of adding 1 to \"Float\"... ");
02526 test_fvalue(1.000991, 0.0000001,
02527 cpl_table_get_float(table, "Float", 6, NULL),
02528 "Check element 7 of adding 1 to \"Float\"... ");
02529 test_fvalue(1-0.0010001, 0.0000001,
02530 cpl_table_get_float(table, "Float", 7, NULL),
02531 "Check element 8 of adding 1 to \"Float\"... ");
02532 test_ivalue(0, cpl_table_is_valid(table, "Float", 8),
02533 "Check element 9 of adding 1 to \"Float\"... ");
02534 test_ivalue(0, cpl_table_is_valid(table, "Float", 9),
02535 "Check element 10 of adding 1 to \"Float\"... ");
02536 test_ivalue(0, cpl_table_is_valid(table, "Float", 10),
02537 "Check element 11 of adding 1 to \"Float\"... ");
02538 test_ivalue(0, cpl_table_is_valid(table, "Float", 11),
02539 "Check element 12 of adding 1 to \"Float\"... ");
02540 test_ivalue(0, cpl_table_is_valid(table, "Float", 12),
02541 "Check element 13 of adding 1 to \"Float\"... ");
02542 test_fvalue(1-0.2496484, 0.0000001,
02543 cpl_table_get_float(table, "Float", 13, NULL),
02544 "Check element 14 of adding 1 to \"Float\"... ");
02545 test_fvalue(1.1651652, 0.0000001,
02546 cpl_table_get_float(table, "Float", 14, NULL),
02547 "Check element 15 of adding 1 to \"Float\"... ");
02548 test_fvalue(1-0.3325223, 0.0000001,
02549 cpl_table_get_float(table, "Float", 15, NULL),
02550 "Check element 16 of adding 1 to \"Float\"... ");
02551 test_fvalue(1-0.4991817, 0.0000001,
02552 cpl_table_get_float(table, "Float", 16, NULL),
02553 "Check element 17 of adding 1 to \"Float\"... ");
02554 test_ivalue(0, cpl_table_is_valid(table, "Float", 17),
02555 "Check element 18 of adding 1 to \"Float\"... ");
02556 test_ivalue(0, cpl_table_is_valid(table, "Float", 18),
02557 "Check element 19 of adding 1 to \"Float\"... ");
02558 test_ivalue(0, cpl_table_is_valid(table, "Float", 19),
02559 "Check element 20 of adding 1 to \"Float\"... ");
02560 test_ivalue(0, cpl_table_is_valid(table, "Float", 20),
02561 "Check element 21 of adding 1 to \"Float\"... ");
02562 test_ivalue(0, cpl_table_is_valid(table, "Float", 21),
02563 "Check element 22 of adding 1 to \"Float\"... ");
02564
02565 test(cpl_table_set_column_invalid(table, "Float", 0,
02566 cpl_table_get_nrow(table)),
02567 "Set \"Float\" column to NULL... ");
02568
02569 test_data(copia, cpl_table_duplicate(table), "Duplicate table... ");
02570
02571 test(cpl_table_erase_invalid_rows(table), "Pruning table... ");
02572
02573 test_ivalue(18, cpl_table_get_nrow(table),
02574 "Checking table length after pruning... ");
02575
02576 test_ivalue(10, cpl_table_get_ncol(table),
02577 "Checking table width after pruning... ");
02578
02579 test(cpl_table_erase_invalid(copia), "Cleaning table... ");
02580
02581 test_ivalue(8, cpl_table_get_nrow(copia),
02582 "Checking table length after cleaning... ");
02583
02584 test_ivalue(10, cpl_table_get_ncol(copia),
02585 "Checking table width after cleaning... ");
02586
02587 cpl_table_delete(copia);
02588
02589 test(cpl_table_name_column(table, "IntToFloat", "Float"),
02590 "Renaming \"IntToFloat\" to \"Float\"... ");
02591
02592 test(cpl_table_set_column_invalid(table, "Integer", 7, 2),
02593 "Set NULLs in \"Integer\" column... ");
02594
02595 test(cpl_table_set_invalid(table, "Float", 7),
02596 "Set NULL in \"Float\" column... ");
02597
02598 test(cpl_table_set_invalid(table, "Float", 9),
02599 "Set another NULL in \"Float\" column... ");
02600
02601 test(cpl_table_set_invalid(table, "Double", 7),
02602 "Set NULL in \"Double\" column... ");
02603
02604 test(cpl_table_set_invalid(table, "String", 7),
02605 "Set NULL in \"String\" column... ");
02606
02607 test(cpl_table_new_column(table, "Sequence", CPL_TYPE_INT),
02608 "Creating the \"Sequence\" column... ");
02609
02610 for (i = 0; i < 18; i++) {
02611 sprintf(message, "Writing to row %d of the \"Sequence\" column... ", i);
02612 test(cpl_table_set_int(table, "Sequence", i, i), message);
02613 }
02614
02615
02616
02617
02618 names[0] = "Integer";
02619
02620 reflist = uves_propertylist_new();
02621 uves_propertylist_append_bool(reflist, names[0], 0);
02622
02623
02624
02625
02626
02627
02628 test(uves_table_sort(table, reflist),
02629 "Sorting by increasing values of the \"Integer\" column... ");
02630
02631 uves_propertylist_delete(reflist);
02632
02634 cpl_table_fill_invalid_int(table, "Integer", 320);
02635 cpl_table_fill_invalid_int(table, "AInt", 320);
02636 cpl_table_fill_invalid_int(table, "New AInt", 320);
02637 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
02638 cpl_table_delete(table);
02639 table = cpl_table_load("test_table.tfits", 1, 1);
02640
02641
02642 test_ivalue(18, cpl_table_get_nrow(table),
02643 "Checking table length after sorting... ");
02644
02645 test_ivalue(11, cpl_table_get_ncol(table),
02646 "Checking table width after sorting... ");
02647
02648 test_ivalue(7, cpl_table_count_invalid(table, "Integer"),
02649 "Count \"Integer\" NULLs after sorting... ");
02650
02651 test_ivalue(7, cpl_table_count_invalid(table, "Float"),
02652 "Count \"Float\" NULLs after sorting... ");
02653
02654 test_ivalue(2, cpl_table_count_invalid(table, "Double"),
02655 "Count \"Double\" NULLs after sorting... ");
02656
02657 test_ivalue(2, cpl_table_count_invalid(table, "String"),
02658 "Count \"String\" NULLs after sorting... ");
02659
02660 for (i = 0; i < 7; i++) {
02661 sprintf(message, "Check element %d of sorted \"Integer\"... ", i + 1);
02662 test_ivalue(0, cpl_table_is_valid(table, "Integer", i), message);
02663 }
02664
02665 test_ivalue(-1, cpl_table_get_int(table, "Integer", 7, NULL),
02666 "Check element 7 of sorted \"Integer\"... ");
02667
02668 test_ivalue(1, cpl_table_get_int(table, "Integer", 8, NULL),
02669 "Check element 8 of sorted \"Integer\"... ");
02670
02671 test_ivalue(4, cpl_table_get_int(table, "Integer", 9, NULL),
02672 "Check element 9 of sorted \"Integer\"... ");
02673
02674 test_ivalue(6, cpl_table_get_int(table, "Integer", 10, NULL),
02675 "Check element 10 of sorted \"Integer\"... ");
02676
02677 test_ivalue(7, cpl_table_get_int(table, "Integer", 11, NULL),
02678 "Check element 11 of sorted \"Integer\"... ");
02679
02680 for (i = 12; i < 18; i++) {
02681 sprintf(message, "Check element %d of sorted \"Integer\"... ", i + 1);
02682 test_ivalue(999, cpl_table_get_int(table, "Integer", i, NULL),
02683 message);
02684 }
02685
02686 test_fvalue(999.88, 0.00001,
02687 cpl_table_get_double(table, "Double", 0, NULL),
02688 "Check element 1 of sorted \"Double\"... ");
02689
02690 test_fvalue(999.88, 0.00001,
02691 cpl_table_get_double(table, "Double", 1, NULL),
02692 "Check element 2 of sorted \"Double\"... ");
02693
02694 test_ivalue(0, cpl_table_is_valid(table, "Double", 2),
02695 "Check element 3 of sorted \"Double\"... ");
02696
02697 test_fvalue(999.88, 0.00001,
02698 cpl_table_get_double(table, "Double", 3, NULL),
02699 "Check element 4 of sorted \"Double\"... ");
02700
02701 test_fvalue(3.11, 0.00001,
02702 cpl_table_get_double(table, "Double", 4, NULL),
02703 "Check element 5 of sorted \"Double\"... ");
02704
02705 test_ivalue(0, cpl_table_is_valid(table, "Double", 5),
02706 "Check element 6 of sorted \"Double\"... ");
02707
02708 test_fvalue(999.88, 0.00001,
02709 cpl_table_get_double(table, "Double", 6, NULL),
02710 "Check element 7 of sorted \"Double\"... ");
02711
02712 test_fvalue(-1.11, 0.00001,
02713 cpl_table_get_double(table, "Double", 7, NULL),
02714 "Check element 8 of sorted \"Double\"... ");
02715
02716 test_fvalue(1.11, 0.00001,
02717 cpl_table_get_double(table, "Double", 8, NULL),
02718 "Check element 9 of sorted \"Double\"... ");
02719
02720 test_fvalue(4.11, 0.00001,
02721 cpl_table_get_double(table, "Double", 9, NULL),
02722 "Check element 10 of sorted \"Double\"... ");
02723
02724 test_fvalue(6.11, 0.00001,
02725 cpl_table_get_double(table, "Double", 10, NULL),
02726 "Check element 11 of sorted \"Double\"... ");
02727
02728 test_fvalue(7.11, 0.00001,
02729 cpl_table_get_double(table, "Double", 11, NULL),
02730 "Check element 12 of sorted \"Double\"... ");
02731
02732 for (i = 12; i < 18; i++) {
02733 sprintf(message, "Check element %d of sorted \"Double\"... ", i + 1);
02734 test_fvalue(999.88, 0.00001,
02735 cpl_table_get_double(table, "Double", i, NULL), message);
02736 }
02737
02738 test_svalue("999", cpl_table_get_string(table, "String", 0),
02739 "Check element 1 of sorted \"String\"... ");
02740
02741 test_svalue("999", cpl_table_get_string(table, "String", 1),
02742 "Check element 2 of sorted \"String\"... ");
02743
02744 test_ivalue(0, cpl_table_is_valid(table, "String", 2),
02745 "Check element 3 of sorted \"String\"... ");
02746
02747 test_svalue("999", cpl_table_get_string(table, "String", 3),
02748 "Check element 4 of sorted \"String\"... ");
02749
02750 test_svalue("baaa", cpl_table_get_string(table, "String", 4),
02751 "Check element 5 of sorted \"String\"... ");
02752
02753 test_ivalue(0, cpl_table_is_valid(table, "String", 5),
02754 "Check element 6 of sorted \"String\"... ");
02755
02756 test_svalue("999", cpl_table_get_string(table, "String", 6),
02757 "Check element 7 of sorted \"String\"... ");
02758
02759 test_svalue("extra", cpl_table_get_string(table, "String", 7),
02760 "Check element 8 of sorted \"String\"... ");
02761
02762 test_svalue("acde", cpl_table_get_string(table, "String", 8),
02763 "Check element 9 of sorted \"String\"... ");
02764
02765 test_svalue(" sss", cpl_table_get_string(table, "String", 9),
02766 "Check element 10 of sorted \"String\"... ");
02767
02768 test_svalue("daaa", cpl_table_get_string(table, "String", 10),
02769 "Check element 11 of sorted \"String\"... ");
02770
02771 test_svalue("aaaa", cpl_table_get_string(table, "String", 11),
02772 "Check element 11 of sorted \"String\"... ");
02773
02774 for (i = 12; i < 18; i++) {
02775 sprintf(message, "Check element %d of sorted \"String\"... ", i + 1);
02776 test_svalue("999", cpl_table_get_string(table, "String", i), message);
02777 }
02778
02779
02780 test_ivalue(0, cpl_table_is_valid(table, "Float", 0),
02781 "Check element 1 of sorted \"Float\"... ");
02782
02783 test_ivalue(0, cpl_table_is_valid(table, "Float", 1),
02784 "Check element 2 of sorted \"Float\"... ");
02785
02786 test_ivalue(0, cpl_table_is_valid(table, "Float", 2),
02787 "Check element 3 of sorted \"Float\"... ");
02788
02789 test_fvalue(0.0, 0.00001, cpl_table_get_float(table, "Float", 3, NULL),
02790 "Check element 4 of sorted \"Float\"... ");
02791
02792 test_ivalue(0, cpl_table_is_valid(table, "Float", 4),
02793 "Check element 5 of sorted \"Float\"... ");
02794
02795 test_ivalue(0, cpl_table_is_valid(table, "Float", 5),
02796 "Check element 6 of sorted \"Float\"... ");
02797
02798 test_ivalue(0, cpl_table_is_valid(table, "Float", 6),
02799 "Check element 7 of sorted \"Float\"... ");
02800
02801 test_fvalue(-1110.0, 0.00001,
02802 cpl_table_get_float(table, "Float", 7, NULL),
02803 "Check element 8 of sorted \"Float\"... ");
02804
02805 test_fvalue(6.66, 0.00001,
02806 cpl_table_get_float(table, "Float", 8, NULL),
02807 "Check element 9 of sorted \"Float\"... ");
02808
02809 test_fvalue(-12.33, 0.00001,
02810 cpl_table_get_float(table, "Float", 9, NULL),
02811 "Check element 10 of sorted \"Float\"... ");
02812
02813 test_fvalue(-12.22, 0.00001,
02814 cpl_table_get_float(table, "Float", 10, NULL),
02815 "Check element 11 of sorted \"Float\"... ");
02816
02817 test_fvalue(-28.44, 0.00001,
02818 cpl_table_get_float(table, "Float", 11, NULL),
02819 "Check element 12 of sorted \"Float\"... ");
02820
02821 test_fvalue(0.0, 0.00001,
02822 cpl_table_get_float(table, "Float", 12, NULL),
02823 "Check element 13 of sorted \"Float\"... ");
02824
02825 test_fvalue(0.0, 0.00001,
02826 cpl_table_get_float(table, "Float", 13, NULL),
02827 "Check element 14 of sorted \"Float\"... ");
02828
02829 test_fvalue(0.0, 0.00001,
02830 cpl_table_get_float(table, "Float", 14, NULL),
02831 "Check element 15 of sorted \"Float\"... ");
02832
02833 test_fvalue(-999880.0, 0.00001,
02834 cpl_table_get_float(table, "Float", 15, NULL),
02835 "Check element 16 of sorted \"Float\"... ");
02836
02837 test_ivalue(0, cpl_table_is_valid(table, "Float", 16),
02838 "Check element 17 of sorted \"Float\"... ");
02839
02840 test_fvalue(0.0, 0.00001,
02841 cpl_table_get_float(table, "Float", 17, NULL),
02842 "Check element 18 of sorted \"Float\"... ");
02843
02844 names[0] = "Sequence";
02845
02846 reflist = uves_propertylist_new();
02847 uves_propertylist_append_bool(reflist, names[0], 0);
02848
02849 test(uves_table_sort(table, reflist), "Undo table sorting... ");
02850
02851 uves_propertylist_delete(reflist);
02852
02853 names[0] = "Integer";
02854 reverse[0] = 1;
02855
02856 reflist = uves_propertylist_new();
02857 uves_propertylist_append_bool(reflist, names[0], 1);
02858
02859 test(uves_table_sort(table, reflist),
02860 "Sorting by decreasing values of the \"Integer\" column... ");
02861
02862
02863
02864
02865
02866
02867
02868 uves_propertylist_delete(reflist);
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887 test_fvalue(999.000000, 0.001, cpl_table_get_column_median(table, "Integer"),
02888 "Median of Integer...");
02889 test_fvalue(0.000000, 0.001, cpl_table_get_column_median(table, "Float"),
02890 "Median of Float...");
02891 test_fvalue(999.880000, 0.001, cpl_table_get_column_median(table, "Double"),
02892 "Median of Double...");
02893 test_fvalue(8.000000, 0.001, cpl_table_get_column_median(table, "Sequence"),
02894 "Median of Sequence...");
02895 test_fvalue(546.454545, 0.001, cpl_table_get_column_mean(table, "Integer"),
02896 "Mean of Integer...");
02897 test_fvalue(-91003.302727, 0.001, cpl_table_get_column_mean(table, "Float"),
02898 "Mean of Float...");
02899 test_fvalue(626.202500, 0.001, cpl_table_get_column_mean(table, "Double"),
02900 "Mean of Double...");
02901 test_fvalue(8.500000, 0.001, cpl_table_get_column_mean(table, "Sequence"),
02902 "Mean of Sequence...");
02903 test_fvalue(519.939489, 0.001, cpl_table_get_column_stdev(table, "Integer"),
02904 "Stdev of Integer...");
02905 test_fvalue(301440.480937, 0.001, cpl_table_get_column_stdev(table, "Float"),
02906 "Stdev of Float...");
02907 test_fvalue(498.239830, 0.001, cpl_table_get_column_stdev(table, "Double"),
02908 "Stdev of Double...");
02909 test_fvalue(5.338539, 0.001, cpl_table_get_column_stdev(table, "Sequence"),
02910 "Stdev of Sequence...");
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927
02929 cpl_table_fill_invalid_int(table, "Integer", 320);
02930 cpl_table_fill_invalid_int(table, "AInt", 320);
02931 cpl_table_fill_invalid_int(table, "New AInt", 320);
02932 check_nomsg(cpl_table_save(table, NULL, NULL, "test_table.tfits", CPL_IO_DEFAULT));
02933 cpl_table_delete(table);
02934 table = cpl_table_load("test_table.tfits", 1, 1);
02935
02936
02937 test_ivalue(18, cpl_table_get_nrow(table),
02938 "Checking table length after decreasing sorting... ");
02939
02940 test_ivalue(11, cpl_table_get_ncol(table),
02941 "Checking table width after decreasing sorting... ");
02942
02943 test_ivalue(7, cpl_table_count_invalid(table, "Integer"),
02944 "Count \"Integer\" NULLs after decreasing sorting... ");
02945
02946 test_ivalue(7, cpl_table_count_invalid(table, "Float"),
02947 "Count \"Float\" NULLs after decreasing sorting... ");
02948
02949 test_ivalue(2, cpl_table_count_invalid(table, "Double"),
02950 "Count \"Double\" NULLs after decreasing sorting... ");
02951
02952 test_ivalue(2, cpl_table_count_invalid(table, "String"),
02953 "Count \"String\" NULLs after decreasing sorting... ");
02954
02955 for (i = 0; i < 7; i++) {
02956 sprintf(message, "Check element %d of sorted \"Integer\"... ", i + 1);
02957 test_ivalue(0, cpl_table_is_valid(table, "Integer", i), message);
02958 }
02959
02960 for (i = 7; i < 13; i++) {
02961 sprintf(message, "Check element %d of sorted \"Integer\"... ", i + 1);
02962 test_ivalue(999, cpl_table_get_int(table, "Integer", i, NULL),
02963 message);
02964 }
02965
02966 test_ivalue(7, cpl_table_get_int(table, "Integer", 13, NULL),
02967 "Check element 13 of sorted \"Integer\"... ");
02968
02969 test_ivalue(6, cpl_table_get_int(table, "Integer", 14, NULL),
02970 "Check element 14 of sorted \"Integer\"... ");
02971
02972 test_ivalue(4, cpl_table_get_int(table, "Integer", 15, NULL),
02973 "Check element 15 of sorted \"Integer\"... ");
02974
02975 test_ivalue(1, cpl_table_get_int(table, "Integer", 16, NULL),
02976 "Check element 16 of sorted \"Integer\"... ");
02977
02978 test_ivalue(-1, cpl_table_get_int(table, "Integer", 17, NULL),
02979 "Check element 17 of sorted \"Integer\"... ");
02980
02981
02982 test_fvalue(999.88, 0.00001,
02983 cpl_table_get_double(table, "Double", 0, NULL),
02984 "Check element 1 of sorted \"Double\"... ");
02985
02986 test_fvalue(999.88, 0.00001,
02987 cpl_table_get_double(table, "Double", 1, NULL),
02988 "Check element 2 of sorted \"Double\"... ");
02989
02990 test_ivalue(0, cpl_table_is_valid(table, "Double", 2),
02991 "Check element 3 of sorted \"Double\"... ");
02992
02993 test_fvalue(999.88, 0.00001,
02994 cpl_table_get_double(table, "Double", 3, NULL),
02995 "Check element 4 of sorted \"Double\"... ");
02996
02997 test_fvalue(3.11, 0.00001,
02998 cpl_table_get_double(table, "Double", 4, NULL),
02999 "Check element 5 of sorted \"Double\"... ");
03000
03001 test_ivalue(0, cpl_table_is_valid(table, "Double", 5),
03002 "Check element 6 of sorted \"Double\"... ");
03003
03004 test_fvalue(999.88, 0.00001,
03005 cpl_table_get_double(table, "Double", 6, NULL),
03006 "Check element 7 of sorted \"Double\"... ");
03007
03008 for (i = 7; i < 13; i++) {
03009 sprintf(message, "Check element %d of sorted \"Double\"... ", i + 1);
03010 test_fvalue(999.88, 0.00001,
03011 cpl_table_get_double(table, "Double", i, NULL), message);
03012 }
03013
03014 test_fvalue(7.11, 0.00001,
03015 cpl_table_get_double(table, "Double", 13, NULL),
03016 "Check element 14 of sorted \"Double\"... ");
03017
03018 test_fvalue(6.11, 0.00001,
03019 cpl_table_get_double(table, "Double", 14, NULL),
03020 "Check element 15 of sorted \"Double\"... ");
03021
03022 test_fvalue(4.11, 0.00001,
03023 cpl_table_get_double(table, "Double", 15, NULL),
03024 "Check element 16 of sorted \"Double\"... ");
03025
03026 test_fvalue(1.11, 0.00001,
03027 cpl_table_get_double(table, "Double", 16, NULL),
03028 "Check element 17 of sorted \"Double\"... ");
03029
03030 test_fvalue(-1.11, 0.00001,
03031 cpl_table_get_double(table, "Double", 17, NULL),
03032 "Check element 18 of sorted \"Double\"... ");
03033
03034
03035 test_svalue("999", cpl_table_get_string(table, "String", 0),
03036 "Check element 1 of sorted \"String\"... ");
03037
03038 test_svalue("999", cpl_table_get_string(table, "String", 1),
03039 "Check element 2 of sorted \"String\"... ");
03040
03041 test_ivalue(0, cpl_table_is_valid(table, "String", 2),
03042 "Check element 3 of sorted \"String\"... ");
03043
03044 test_svalue("999", cpl_table_get_string(table, "String", 3),
03045 "Check element 4 of sorted \"String\"... ");
03046
03047 test_svalue("baaa", cpl_table_get_string(table, "String", 4),
03048 "Check element 5 of sorted \"String\"... ");
03049
03050 test_ivalue(0, cpl_table_is_valid(table, "String", 5),
03051 "Check element 6 of sorted \"String\"... ");
03052
03053 test_svalue("999", cpl_table_get_string(table, "String", 6),
03054 "Check element 7 of sorted \"String\"... ");
03055
03056 for (i = 7; i < 13; i++) {
03057 sprintf(message, "Check element %d of sorted \"String\"... ", i + 1);
03058 test_svalue("999", cpl_table_get_string(table, "String", i), message);
03059 }
03060
03061 test_svalue("aaaa", cpl_table_get_string(table, "String", 13),
03062 "Check element 14 of sorted \"String\"... ");
03063
03064 test_svalue("daaa", cpl_table_get_string(table, "String", 14),
03065 "Check element 15 of sorted \"String\"... ");
03066
03067 test_svalue(" sss", cpl_table_get_string(table, "String", 15),
03068 "Check element 16 of sorted \"String\"... ");
03069
03070 test_svalue("acde", cpl_table_get_string(table, "String", 16),
03071 "Check element 17 of sorted \"String\"... ");
03072
03073 test_svalue("extra", cpl_table_get_string(table, "String", 17),
03074 "Check element 18 of sorted \"String\"... ");
03075
03076
03077 test_ivalue(0, cpl_table_is_valid(table, "Float", 0),
03078 "Check element 1 of sorted \"Float\"... ");
03079
03080 test_ivalue(0, cpl_table_is_valid(table, "Float", 1),
03081 "Check element 2 of sorted \"Float\"... ");
03082
03083 test_ivalue(0, cpl_table_is_valid(table, "Float", 2),
03084 "Check element 3 of sorted \"Float\"... ");
03085
03086 test_fvalue(0.0, 0.00001, cpl_table_get_float(table, "Float", 3, NULL),
03087 "Check element 4 of sorted \"Float\"... ");
03088
03089 test_ivalue(0, cpl_table_is_valid(table, "Float", 4),
03090 "Check element 5 of sorted \"Float\"... ");
03091
03092 test_ivalue(0, cpl_table_is_valid(table, "Float", 5),
03093 "Check element 6 of sorted \"Float\"... ");
03094
03095 test_ivalue(0, cpl_table_is_valid(table, "Float", 6),
03096 "Check element 7 of sorted \"Float\"... ");
03097
03098 test_fvalue(0.0, 0.00001,
03099 cpl_table_get_float(table, "Float", 7, NULL),
03100 "Check element 8 of sorted \"Float\"... ");
03101
03102 test_fvalue(0.0, 0.00001,
03103 cpl_table_get_float(table, "Float", 8, NULL),
03104 "Check element 9 of sorted \"Float\"... ");
03105
03106 test_fvalue(0.0, 0.00001,
03107 cpl_table_get_float(table, "Float", 9, NULL),
03108 "Check element 10 of sorted \"Float\"... ");
03109
03110 test_fvalue(-999880.0, 0.00001,
03111 cpl_table_get_float(table, "Float", 10, NULL),
03112 "Check element 11 of sorted \"Float\"... ");
03113
03114 test_ivalue(0, cpl_table_is_valid(table, "Float", 11),
03115 "Check element 12 of sorted \"Float\"... ");
03116
03117 test_fvalue(0.0, 0.00001,
03118 cpl_table_get_float(table, "Float", 12, NULL),
03119 "Check element 13 of sorted \"Float\"... ");
03120
03121 test_fvalue(-28.44, 0.00001,
03122 cpl_table_get_float(table, "Float", 13, NULL),
03123 "Check element 14 of sorted \"Float\"... ");
03124
03125 test_fvalue(-12.22, 0.00001,
03126 cpl_table_get_float(table, "Float", 14, NULL),
03127 "Check element 15 of sorted \"Float\"... ");
03128
03129 test_fvalue(-12.33, 0.00001,
03130 cpl_table_get_float(table, "Float", 15, NULL),
03131 "Check element 16 of sorted \"Float\"... ");
03132
03133 test_fvalue(6.66, 0.00001,
03134 cpl_table_get_float(table, "Float", 16, NULL),
03135 "Check element 17 of sorted \"Float\"... ");
03136
03137 test_fvalue(-1110.0, 0.00001,
03138 cpl_table_get_float(table, "Float", 17, NULL),
03139 "Check element 18 of sorted \"Float\"... ");
03140
03141 cpl_table_delete(table);
03142 cpl_free(fArray);
03143
03144
03145
03146
03147
03148 nrows = 7;
03149
03150 table = cpl_table_new(nrows);
03151 cpl_table_new_column(table, "Int", CPL_TYPE_INT);
03152 cpl_table_new_column(table, "Float", CPL_TYPE_FLOAT);
03153 cpl_table_new_column(table, "Double", CPL_TYPE_DOUBLE);
03154
03155 for (i = 0; i < nrows; i++) {
03156 cpl_table_set_int(table, "Int", i, i);
03157 cpl_table_set_float(table, "Float", i, i);
03158 cpl_table_set_double(table, "Double", i, i);
03159 }
03160
03161 cpl_table_exponential_column(table, "Int", 2);
03162 cpl_table_exponential_column(table, "Float", 2);
03163 cpl_table_exponential_column(table, "Double", 2);
03164
03165 pp = 1;
03166 for (i = 0; i < nrows; i++) {
03167 test_ivalue(pp, cpl_table_get_int(table,
03168 "Int", i, NULL), "Check expo Int... ");
03169 test_fvalue((float)pp, 0.00001, cpl_table_get_float(table,
03170 "Float", i, NULL), "Check expo Float... ");
03171 test_fvalue((float)pp, 0.00001, cpl_table_get_double(table,
03172 "Double", i, NULL), "Check expo Double... ");
03173 pp *= 2;
03174 }
03175
03176 cpl_table_logarithm_column(table, "Int", 2);
03177 cpl_table_logarithm_column(table, "Float", 2);
03178 cpl_table_logarithm_column(table, "Double", 2);
03179
03180 for (i = 0; i < nrows; i++) {
03181 test_ivalue(i, cpl_table_get_int(table,
03182 "Int", i, NULL), "Check log Int... ");
03183 test_fvalue((float)i, 0.00001, cpl_table_get_float(table,
03184 "Float", i, NULL), "Check log Float... ");
03185 test_fvalue((float)i, 0.00001, cpl_table_get_double(table,
03186 "Double", i, NULL), "Check log Double... ");
03187 }
03188
03189 cpl_table_power_column(table, "Int", 2);
03190 cpl_table_power_column(table, "Float", 2);
03191 cpl_table_power_column(table, "Double", 2);
03192
03193 for (i = 0; i < nrows; i++) {
03194 test_ivalue(i*i, cpl_table_get_int(table,
03195 "Int", i, NULL), "Check pow Int... ");
03196 test_fvalue((float)i*i, 0.00001, cpl_table_get_float(table,
03197 "Float", i, NULL), "Check pow Float... ");
03198 test_fvalue((float)i*i, 0.00001, cpl_table_get_double(table,
03199 "Double", i, NULL), "Check pow Double... ");
03200 }
03201
03202 cpl_table_power_column(table, "Int", 0.5);
03203 cpl_table_power_column(table, "Float", 0.5);
03204 cpl_table_power_column(table, "Double", 0.5);
03205
03206 for (i = 0; i < nrows; i++) {
03207 test_ivalue(i, cpl_table_get_int(table,
03208 "Int", i, NULL), "Check sqrt Int... ");
03209 test_fvalue((float)i, 0.00001, cpl_table_get_float(table,
03210 "Float", i, NULL), "Check sqrt Float... ");
03211 test_fvalue((float)i, 0.00001, cpl_table_get_double(table,
03212 "Double", i, NULL), "Check sqrt Double... ");
03213 }
03214
03215 cpl_table_delete(table);
03216
03217
03218
03219
03220
03221
03222 nrows = 7;
03223
03224 table = cpl_table_new(nrows);
03225 cpl_table_new_column(table, "Int", CPL_TYPE_INT);
03226 cpl_table_new_column(table, "String", CPL_TYPE_STRING);
03227
03228 unit = "abcd\0efgh\0ijkl\0mnop\0qrst\0uvwx\0yz";
03229
03230 for (i = 0; i < nrows; i++) {
03231 cpl_table_set_int(table, "Int", i, i);
03232 cpl_table_set_string(table, "String", i, unit + i*5);
03233 }
03234
03235 cpl_table_duplicate_column(table, "Int2", table, "Int");
03236 cpl_table_multiply_columns(table, "Int2", "Int2");
03237 cpl_table_cast_column(table, "Int", "Float", CPL_TYPE_FLOAT);
03238
03239 #ifdef VERBOSE
03240
03241 printf("\nThis is the test table:\n\n");
03242 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03243
03244 printf("\nNow erase all selected:\n\n");
03245
03246 #endif
03247
03248 copia = cpl_table_duplicate(table);
03249 test_ivalue(7, cpl_table_count_selected(copia), "Check all selected... ");
03250 cpl_table_erase_selected(copia);
03251 #ifdef VERBOSE
03252 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03253 #endif
03254 test_ivalue(0, cpl_table_get_nrow(copia),
03255 "Check length erase all selected... ");
03256 cpl_table_delete(copia);
03257
03258 #ifdef VERBOSE
03259
03260 printf("\nThis is the test table:\n\n");
03261 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03262
03263 printf("\nNow delete all Int >= Int2:\n\n");
03264
03265 #endif
03266
03267 copia = cpl_table_duplicate(table);
03268 cpl_table_and_selected(copia, "Int", CPL_NOT_LESS_THAN, "Int2");
03269 test_ivalue(2, cpl_table_count_selected(copia),
03270 "Check Int >= Int2 selected... ");
03271 cpl_table_erase_selected(copia);
03272 #ifdef VERBOSE
03273 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03274 #endif
03275 test_ivalue(5, cpl_table_get_nrow(copia),
03276 "Check length erase all Int >= Int2... ");
03277 cpl_table_delete(copia);
03278
03279 #ifdef VERBOSE
03280
03281 printf("\nThis is the test table:\n\n");
03282 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03283
03284 printf("\nNow delete all Int > 3:\n\n");
03285
03286 #endif
03287
03288 copia = cpl_table_duplicate(table);
03289 cpl_table_and_selected_int(copia, "Int", CPL_GREATER_THAN, 3);
03290 test_ivalue(3, cpl_table_count_selected(copia),
03291 "Check Int > 3 selected... ");
03292 cpl_table_erase_selected(copia);
03293 #ifdef VERBOSE
03294 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03295 #endif
03296 test_ivalue(4, cpl_table_get_nrow(copia),
03297 "Check length erase all Int > 3... ");
03298 cpl_table_delete(copia);
03299
03300 #ifdef VERBOSE
03301
03302 printf("\nThis is the test table:\n\n");
03303 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03304
03305 printf("\nNow delete all Int2 > Float:\n\n");
03306
03307 #endif
03308
03309 copia = cpl_table_duplicate(table);
03310 cpl_table_and_selected(copia, "Int2", CPL_GREATER_THAN, "Float");
03311 test_ivalue(5, cpl_table_count_selected(copia),
03312 "Check Int2 > Float selected... ");
03313 cpl_table_erase_selected(copia);
03314 #ifdef VERBOSE
03315 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03316 #endif
03317 test_ivalue(2, cpl_table_get_nrow(copia),
03318 "Check length erase all Int2 > Float... ");
03319 cpl_table_delete(copia);
03320
03321 #ifdef VERBOSE
03322
03323 printf("\nThis is the test table:\n\n");
03324 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03325
03326 printf("\nNow delete all String == \"^[a-l].*\":\n\n");
03327
03328 #endif
03329
03330 copia = cpl_table_duplicate(table);
03331 cpl_table_and_selected_string(copia, "String", CPL_EQUAL_TO, "^[a-l].*");
03332 test_ivalue(3, cpl_table_count_selected(copia),
03333 "Check String == \"^[a-l].*\" selected... ");
03334 cpl_table_erase_selected(copia);
03335 #ifdef VERBOSE
03336 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03337 #endif
03338 test_ivalue(4, cpl_table_get_nrow(copia),
03339 "Check length erase all String == \"^[a-l].*\"... ");
03340 cpl_table_delete(copia);
03341
03342 #ifdef VERBOSE
03343
03344 printf("\nThis is the test table:\n\n");
03345 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03346
03347 printf("\nNow delete all String > \"carlo\":\n\n");
03348
03349 #endif
03350
03351 copia = cpl_table_duplicate(table);
03352 cpl_table_and_selected_string(copia, "String", CPL_GREATER_THAN, "carlo");
03353 test_ivalue(6, cpl_table_count_selected(copia),
03354 "Check String > \"carlo\" selected... ");
03355 cpl_table_erase_selected(copia);
03356 #ifdef VERBOSE
03357 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03358 #endif
03359 test_ivalue(1, cpl_table_get_nrow(copia),
03360 "Check length erase all String > \"carlo\"... ");
03361 cpl_table_delete(copia);
03362
03363 #ifdef VERBOSE
03364
03365 printf("\nThis is the test table:\n\n");
03366 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03367
03368 printf("\nNow delete all String > \"tattoo\" and Int == 3:\n\n");
03369
03370 #endif
03371
03372 copia = cpl_table_duplicate(table);
03373 cpl_table_and_selected_string(copia, "String", CPL_GREATER_THAN, "tattoo");
03374 cpl_table_or_selected_int(copia, "Int", CPL_EQUAL_TO, 3);
03375 test_ivalue(3, cpl_table_count_selected(copia),
03376 "Check String > \"tattoo\" and Int == 3 selected... ");
03377 cpl_table_erase_selected(copia);
03378 #ifdef VERBOSE
03379 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03380 #endif
03381 test_ivalue(4, cpl_table_get_nrow(copia),
03382 "Check length erase all String > \"tattoo\" and Int == 3... ");
03383 cpl_table_delete(copia);
03384
03385 #ifdef VERBOSE
03386
03387 printf("\nNow keep all String > \"tattoo\" and Int == 3:\n\n");
03388
03389 #endif
03390
03391 copia = cpl_table_duplicate(table);
03392 cpl_table_and_selected_string(copia, "String", CPL_GREATER_THAN, "tattoo");
03393 cpl_table_or_selected_int(copia, "Int", CPL_EQUAL_TO, 3);
03394 cpl_table_not_selected(copia);
03395 test_ivalue(4, cpl_table_count_selected(copia),
03396 "Check String > \"tattoo\" and Int == 3 rejected... ");
03397 cpl_table_erase_selected(copia);
03398 #ifdef VERBOSE
03399 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03400 #endif
03401 test_ivalue(3, cpl_table_get_nrow(copia),
03402 "Check length keep all String > \"tattoo\" and Int == 3... ");
03403 cpl_table_delete(copia);
03404
03405 #ifdef VERBOSE
03406
03407 printf("\nThis is the test table:\n\n");
03408 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03409
03410 printf("\nNow delete rows 0, 2, and 6:\n\n");
03411
03412 #endif
03413
03414 copia = cpl_table_duplicate(table);
03415 cpl_table_unselect_all(copia);
03416 cpl_table_select_row(copia, 0);
03417 cpl_table_select_row(copia, 2);
03418 cpl_table_select_row(copia, 6);
03419 test_ivalue(3, cpl_table_count_selected(copia),
03420 "Check rows 0, 2, and 6 selected... ");
03421 cpl_table_erase_selected(copia);
03422 #ifdef VERBOSE
03423 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03424 #endif
03425 test_ivalue(4, cpl_table_get_nrow(copia),
03426 "Check length erase rows 0, 2, and 6... ");
03427 cpl_table_delete(copia);
03428
03429 #ifdef VERBOSE
03430
03431 printf("\nNow keep rows 0, 2, and 6:\n\n");
03432
03433 #endif
03434
03435 copia = cpl_table_duplicate(table);
03436 cpl_table_unselect_row(copia, 0);
03437 cpl_table_unselect_row(copia, 2);
03438 cpl_table_unselect_row(copia, 6);
03439 test_ivalue(4, cpl_table_count_selected(copia),
03440 "Check rows 0, 2, and 6 rejected... ");
03441 cpl_table_erase_selected(copia);
03442 #ifdef VERBOSE
03443 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03444 #endif
03445 test_ivalue(3, cpl_table_get_nrow(copia),
03446 "Check length erase rows 0, 2, and 6... ");
03447 cpl_table_delete(copia);
03448
03449 #ifdef VERBOSE
03450
03451 printf("\nThis is the test table:\n\n");
03452 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03453
03454 printf("\nNow delete first 3 rows:\n\n");
03455
03456 #endif
03457
03458 copia = cpl_table_duplicate(table);
03459 cpl_table_and_selected_window(copia, 0, 3);
03460 test_ivalue(3, cpl_table_count_selected(copia),
03461 "Check first 3 rows selected... ");
03462 cpl_table_erase_selected(copia);
03463 #ifdef VERBOSE
03464 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03465 #endif
03466 test_ivalue(4, cpl_table_get_nrow(copia),
03467 "Check length erase first 3 rows... ");
03468 cpl_table_delete(copia);
03469
03470 #ifdef VERBOSE
03471
03472 printf("\nNow delete last 2 rows:\n\n");
03473
03474 #endif
03475
03476 copia = cpl_table_duplicate(table);
03477 cpl_table_and_selected_window(copia, 5, 2);
03478 test_ivalue(2, cpl_table_count_selected(copia),
03479 "Check last 2 rows selected... ");
03480 cpl_table_erase_selected(copia);
03481 #ifdef VERBOSE
03482 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03483 #endif
03484 test_ivalue(5, cpl_table_get_nrow(copia),
03485 "Check length erase last 2 rows... ");
03486 cpl_table_delete(copia);
03487
03488 #ifdef VERBOSE
03489
03490 printf("\nNow delete rows from 2 to 3:\n\n");
03491
03492 #endif
03493
03494 copia = cpl_table_duplicate(table);
03495 cpl_table_and_selected_window(copia, 2, 2);
03496 test_ivalue(2, cpl_table_count_selected(copia),
03497 "Check middle 2 rows selected... ");
03498 cpl_table_erase_selected(copia);
03499 #ifdef VERBOSE
03500 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03501 #endif
03502 test_ivalue(5, cpl_table_get_nrow(copia),
03503 "Check length erase rows from 2 to 3... ");
03504 cpl_table_delete(copia);
03505
03506 #ifdef VERBOSE
03507
03508 printf("\nNow delete rows from 1 to 3 and row 6:\n\n");
03509
03510 #endif
03511
03512 copia = cpl_table_duplicate(table);
03513 cpl_table_and_selected_window(copia, 1, 3);
03514 cpl_table_or_selected_window(copia, 6, 1);
03515 test_ivalue(4, cpl_table_count_selected(copia),
03516 "Check rows 1 to 3 and row 6 rejected... ");
03517 cpl_table_erase_selected(copia);
03518 #ifdef VERBOSE
03519 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03520 #endif
03521 test_ivalue(3, cpl_table_get_nrow(copia),
03522 "Check length erase rows from 1 to 3 and row 6... ");
03523 cpl_table_delete(copia);
03524
03525
03526 copia = cpl_table_duplicate(table);
03527 for (i = 0; i < nrows; i++) {
03528 cpl_table_set_invalid(copia, "Int", i);
03529 }
03530
03531 cpl_table_unselect_row(copia, nrows-1);
03532
03533 cpl_table_erase_selected(copia);
03534 #ifdef VERBOSE
03535 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03536 #endif
03537 test_ivalue(1, cpl_table_get_nrow(copia),
03538 "Check length erase last row, only invalid values... ");
03539 cpl_table_delete(copia);
03540
03541
03542 copia = cpl_table_duplicate(table);
03543
03544 cpl_table_cast_column(copia, "Int", "Double", CPL_TYPE_DOUBLE);
03545
03546 test(cpl_table_new_column_array(copia, "ADouble",
03547 CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, 2),
03548 "Creating the ArrayDouble column... ");
03549
03550 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
03551 test(cpl_table_set_array(copia, "ADouble", 1, array),
03552 "Set a valid array to ADouble 1... ");
03553 test(cpl_table_set_array(copia, "ADouble", 2, array),
03554 "Set a valid array to ADouble 2... ");
03555 cpl_array_delete(array);
03556
03557 cpl_table_unselect_row(copia, 0);
03558 cpl_table_unselect_row(copia, 2);
03559 cpl_table_set_invalid(copia, "Int", 6);
03560 cpl_table_set_invalid(copia, "Int2", 0);
03561 cpl_table_set_invalid(copia, "Int2", 1);
03562 cpl_table_set_invalid(copia, "Double", 0);
03563 cpl_table_set_invalid(copia, "Double", 1);
03564
03565 cpl_table_erase_selected(copia);
03566 #ifdef VERBOSE
03567 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
03568 #endif
03569 test_ivalue(2, cpl_table_get_nrow(copia),
03570 "Check length erase valid/invalid values... ");
03571 test_ivalue(0, cpl_table_is_valid(copia, "Int2", 0),
03572 "Check that first element of \"Int2\" is still NULL... ");
03573 test_ivalue(1, cpl_table_is_valid(copia, "Int2", 1),
03574 "Check that first element of \"Int2\" is now valid... ");
03575
03576 cpl_table_unselect_row(copia, 0);
03577 cpl_table_unselect_row(copia, 1);
03578 cpl_table_erase_selected(copia);
03579 test_ivalue(2, cpl_table_count_selected(copia),
03580 "Check that rows are selected... ");
03581
03582 cpl_table_delete(copia);
03583
03584 cpl_table_delete(table);
03585
03586
03587
03588 table = cpl_table_new(4);
03589 cpl_table_new_column(table, "S", CPL_TYPE_STRING);
03590 cpl_table_new_column(table, "D", CPL_TYPE_DOUBLE);
03591
03592 cpl_table_set_double(table, "D", 0, 43.04);
03593 cpl_table_set_double(table, "D", 1, 43.04);
03594 cpl_table_set_double(table, "D", 2, 43.04);
03595 cpl_table_set_double(table, "D", 3, 43.04);
03596 cpl_table_set_invalid(table, "D", 3);
03597
03598 cpl_table_set_string(table, "S", 0, "type");
03599 cpl_table_set_string(table, "S", 1, "type");
03600 cpl_table_set_string(table, "S", 2, "type");
03601 cpl_table_set_string(table, "S", 3, "type");
03602 cpl_table_set_invalid(table, "S", 1);
03603
03604 #ifdef VERBOSE
03605 cpl_table_dump(table, 0, 4, stdout);
03606 #endif
03607
03608 cpl_table_select_all(table);
03609 test_ivalue(4, cpl_table_count_selected(table), "A...");
03610 cpl_table_and_selected_invalid(table, "D");
03611 test_ivalue(1, cpl_table_count_selected(table), "B...");
03612
03613 cpl_table_select_all(table);
03614 test_ivalue(4, cpl_table_count_selected(table), "C...");
03615
03616
03617 uves_table_and_selected_invalid(table, "S");
03618
03619 test_ivalue(1, cpl_table_count_selected(table), "D...");
03620
03621 cpl_table_delete(table);
03622
03623
03624
03625
03626
03627
03628 nrows = 100;
03629
03630 table = cpl_table_new(nrows);
03631 cpl_table_new_column(table, "Int", CPL_TYPE_INT);
03632
03633 for (i = 0; i < nrows; i++)
03634 cpl_table_set_int(table, "Int", i, i + 1);
03635
03636 cpl_table_cast_column(table, "Int", "Double", CPL_TYPE_DOUBLE);
03637
03638 test(cpl_table_divide_columns(table, "Double", "Int"),
03639 "Divide double column with integer column... ");
03640
03641 for (i = 0; i < nrows; i++) {
03642 sprintf(message, "Check element %d of result column... ", i);
03643 test_fvalue(1.0, 0.00001, cpl_table_get_double(table, "Double", i, NULL),
03644 message);
03645 }
03646
03647 #ifdef VERBOSE
03648 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
03649 #endif
03650
03651 cpl_table_delete(table);
03652
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666 cleanup:
03667 return cpl_error_get_code();
03668
03669 }
03670
03671
03672
03673
03677
03678
03679 int main(void)
03680 {
03681 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
03682
03683 cpl_test_eq(0, table_erase_selected());
03684 uves_find_property_test();
03685 uves_average_reject_test();
03686 uves_polynomial_fit_2d_test();
03687
03688
03689
03690 return cpl_test_end(0);
03691 }
03692