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