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