36 #include <uves_utils.h>
38 #include <uves_utils_cpl.h>
39 #include <uves_utils_polynomial.h>
40 #include <uves_utils_wrappers.h>
41 #include <uves_error.h>
62 #define test_data(r,f,m) \
68 printf("Failure\n"); \
76 #define test_data(r,f,m) \
80 printf("Failure\n"); \
102 printf("Failure\n"); \
113 printf("Failure\n"); \
130 #define test_failure(e,f,m) \
136 printf(" Received error: \"%s\"\n", cpl_error_get_message()); \
137 cpl_error_set("cpl_table-test", e); \
138 printf(" Expected error: \"%s\"\n", cpl_error_get_message()); \
147 #define test_failure(e,f,m) \
151 printf(" Received error: \"%s\"\n", cpl_error_get_message()); \
152 cpl_error_set("cpl_table-test", e); \
153 printf(" Expected error: \"%s\"\n", cpl_error_get_message()); \
172 #define test_ivalue(e,f,m) \
178 printf("Received %d, expected %d\n", itest, e); \
186 #define test_ivalue(e,f,m) \
190 printf("Received %d, expected %d\n", itest, e); \
208 #define test_pvalue(e,f,m) \
214 printf("Received %p, expected %p\n", ptest, e); \
222 #define test_pvalue(e,f,m) \
226 printf("Received %p, expected %p\n", ptest, e); \
244 #define test_fvalue(e,t,f,m) \
249 if (fabs(ftest - (e)) > t) { \
250 printf("Received %f, expected %f\n", ftest, e); \
258 #define test_fvalue(e,t,f,m) \
260 if (fabs(ftest - (e)) > t) { \
262 printf("Received %f, expected %f\n", ftest, e); \
279 #define test_svalue(e,f,m) \
284 if (strcmp(e,stest)) { \
285 printf("Received %s, expected %s\n", stest, e); \
293 #define test_svalue(e,f,m) \
295 if (strcmp(e,stest)) { \
297 printf("Received %s, expected %s\n", stest, e); \
322 #define MAX_SIZE 4096
324 uves_filter_cosmic_test(
void)
328 const char* src_dir=
"/media/disk/uves/valentina/";
330 const char* input=
"PA1_D2B_001.fits";
332 char cosmic_name[MAX_SIZE];
333 char filter_name[MAX_SIZE];
334 char clean_name[MAX_SIZE];
335 char mask_name[MAX_SIZE];
336 const double sky=150.;
337 const double gain=1.84;
338 const double ron=4.1;
349 cpl_propertylist* h=NULL;
350 sprintf(cosmic_name,
"%s%s",src_dir,input);
351 sprintf(filter_name,
"%s",
"filter.fits");
352 sprintf(clean_name,
"%s",
"cleaned.fits");
353 sprintf(mask_name,
"%s",
"mask.fits");
355 check_nomsg(cpl_frame_set_filename(frm,cosmic_name));
356 check_nomsg(cpl_frame_set_type(frm,CPL_FRAME_TYPE_IMAGE));
357 check_nomsg(cpl_frame_set_group(frm,CPL_FRAME_GROUP_RAW));
359 check_nomsg(inp=cpl_image_load(cosmic_name,CPL_TYPE_FLOAT,0,0));
360 check_nomsg(h=cpl_propertylist_load(cosmic_name,0));
364 check_nomsg(msk=cpl_image_new(sx,sy,CPL_TYPE_INT));
367 check_nomsg(cpl_image_save(flt,filter_name,CPL_BPP_IEEE_FLOAT,
369 check_nomsg(cpl_image_save(msk,mask_name,CPL_BPP_IEEE_FLOAT,
371 check_nomsg(cpl_image_save(out,clean_name,CPL_BPP_IEEE_FLOAT,
376 uves_free_frame(&frm);
377 cpl_propertylist_delete(h);
378 uves_free_image(&inp);
379 uves_free_image(&out);
380 uves_free_image(&flt);
381 uves_free_image(&msk);
388 uves_find_property_test(
void)
392 uves_propertylist_append_int(header,
"INTVAL", 3);
393 uves_propertylist_append_double(header,
"HELLO", 98.12);
394 uves_propertylist_append_int(header,
"INTVAL", 3);
395 uves_propertylist_append_double(header,
"HELLO", 98.12);
396 uves_propertylist_append_int(header,
"INTVAL", 3);
409 uves_free_propertylist(&header);
415 uves_average_reject_test(
void)
417 cpl_table *table = cpl_table_new(100);
420 cpl_table_new_column(table,
"X", CPL_TYPE_DOUBLE);
421 cpl_table_set_double(table,
"X", 0, 100);
422 cpl_table_set_double(table,
"X", 1, 101);
423 cpl_table_set_double(table,
"X", 2, 2000);
424 cpl_table_set_double(table,
"X", 3, 98);
425 cpl_table_set_double(table,
"X", 4, 103);
426 cpl_table_set_double(table,
"X", 5, 102);
427 cpl_table_set_double(table,
"X", 6, 100);
428 cpl_table_set_double(table,
"X", 7, 103);
429 cpl_table_set_double(table,
"X", 8, 100);
430 cpl_table_set_double(table,
"X", 9, 99);
433 for (i = 10; i < 100; i++)
440 double expected_avg = 100;
441 double tolerance = 3.0;
443 cpl_test( 2000 - 100 > kappa * cpl_table_get_column_stdev(table,
"X"));
446 expected_avg, tolerance);
448 cpl_test_eq( cpl_table_get_nrow(table), 99);
449 cpl_test_abs( cpl_table_get_double(table,
"X", 0, NULL), 100, 0.1);
450 cpl_test_abs( cpl_table_get_double(table,
"X", 1, NULL), 101, 0.1);
451 cpl_test_abs( cpl_table_get_double(table,
"X", 2, NULL), 98, 0.1);
452 cpl_test_abs( cpl_table_get_double(table,
"X", 3, NULL), 103, 0.1);
454 uves_free_table(&table);
460 uves_polynomial_fit_2d_test(
void)
463 cpl_bivector *xy_pos = cpl_bivector_new(size);
464 cpl_vector *values = cpl_vector_new(size);
465 cpl_vector *sigmas = NULL;
471 cpl_bivector_get_x_data(xy_pos)[0] = 1;
472 cpl_bivector_get_x_data(xy_pos)[1] = 2;
473 cpl_bivector_get_x_data(xy_pos)[2] = 3;
474 cpl_bivector_get_x_data(xy_pos)[3] = 4;
476 cpl_bivector_get_y_data(xy_pos)[0] = 4;
477 cpl_bivector_get_y_data(xy_pos)[1] = 3;
478 cpl_bivector_get_y_data(xy_pos)[2] = 2;
479 cpl_bivector_get_y_data(xy_pos)[3] = 1;
481 cpl_vector_get_data(values)[0] = 17;
482 cpl_vector_get_data(values)[1] = 17;
483 cpl_vector_get_data(values)[2] = 17;
484 cpl_vector_get_data(values)[3] = 17;
490 cpl_test(solution != NULL);
497 cpl_bivector_get_x_data(xy_pos)[0] = 1;
498 cpl_bivector_get_x_data(xy_pos)[1] = 1;
499 cpl_bivector_get_x_data(xy_pos)[2] = 1;
500 cpl_bivector_get_x_data(xy_pos)[3] = 1;
502 cpl_bivector_get_y_data(xy_pos)[0] = 1;
503 cpl_bivector_get_y_data(xy_pos)[1] = 1;
504 cpl_bivector_get_y_data(xy_pos)[2] = 1;
505 cpl_bivector_get_y_data(xy_pos)[3] = 1;
513 cpl_test(cpl_error_get_code() == CPL_ERROR_SINGULAR_MATRIX);
515 cpl_test(solution == NULL);
520 uves_free_bivector(&xy_pos);
521 uves_free_vector(&values);
532 int i, j, k, null, error;
549 const char *scheck[25];
552 const char *names[2];
566 iArray = cpl_malloc(nrows *
sizeof(
int));
567 fArray = cpl_malloc(nrows *
sizeof(
float));
568 dArray = cpl_malloc(nrows *
sizeof(
double));
569 ddArray = cpl_malloc(nrows *
sizeof(
double));
570 sArray = cpl_malloc(nrows *
sizeof(
char *));
594 ddArray[0] = dArray[0] = 5.11;
595 ddArray[1] = dArray[1] = 0.11;
596 ddArray[2] = dArray[2] = 2.11;
597 ddArray[3] = dArray[3] = 8.11;
598 ddArray[4] = dArray[4] = 9.11;
599 ddArray[5] = dArray[5] = 3.11;
600 ddArray[6] = dArray[6] = 7.11;
601 ddArray[7] = dArray[7] = 1.11;
602 ddArray[8] = dArray[8] = 4.11;
603 ddArray[9] = dArray[9] = 6.11;
605 sArray[0] = cpl_strdup(
"caaa");
606 sArray[1] = cpl_strdup(
"abcd");
607 sArray[2] = cpl_strdup(
"aaaa");
608 sArray[3] = cpl_strdup(
"daaa");
609 sArray[4] = cpl_strdup(
"acde");
610 sArray[5] = cpl_strdup(
"baaa");
611 sArray[6] = cpl_strdup(
"aaaa");
612 sArray[7] = cpl_strdup(
"acde");
613 sArray[8] = cpl_strdup(
" sss");
614 sArray[9] = cpl_strdup(
"daaa");
625 test_data(table, cpl_table_new(0),
"Creating a table without rows... ");
627 test(cpl_table_new_column(table,
"Int", CPL_TYPE_INT),
628 "Creating empty Integer column... ");
629 test(cpl_table_new_column(table,
"Float", CPL_TYPE_FLOAT),
630 "Creating empty Float column... ");
631 test(cpl_table_new_column(table,
"Double", CPL_TYPE_DOUBLE),
632 "Creating empty Double column... ");
633 test(cpl_table_new_column(table,
"String", CPL_TYPE_STRING),
634 "Creating empty String column... ");
635 test(cpl_table_new_column_array(table,
"AInt",
636 CPL_TYPE_INT | CPL_TYPE_POINTER, 0),
637 "Creating empty IntegerArray column... ");
638 test(cpl_table_new_column_array(table,
"AFloat",
639 CPL_TYPE_FLOAT | CPL_TYPE_POINTER, 0),
640 "Creating empty FloatArray column... ");
641 test(cpl_table_new_column_array(table,
"ADouble",
642 CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, 0),
643 "Creating empty DoubleArray column... ");
645 test_ivalue(0, cpl_table_get_nrow(table),
"Check zero table length... ");
646 test_ivalue(7, cpl_table_get_ncol(table),
"Check zero table width... ");
648 test_ivalue(0, cpl_table_get_column_depth(table,
"Double"),
649 "Check \"Double\" depth... ");
651 test_ivalue(0, cpl_table_get_column_depth(table,
"AInt"),
652 "Check \"AInt\" depth... ");
654 test(cpl_table_set_size(table, 1),
"Expanding table to one row... ");
656 test_ivalue(1, cpl_table_get_nrow(table),
"Check table with one row... ");
658 test(cpl_table_set_size(table, 0),
"Deleting all rows from table... ");
660 test_ivalue(0, cpl_table_get_nrow(table),
661 "Check again zero table length... ");
663 test(cpl_table_erase_column(table,
"Double"),
664 "Delete zero-column \"Double\"... ");
666 test_ivalue(6, cpl_table_get_ncol(table),
"Check zero-column removal... ");
668 test(cpl_table_erase_column(table,
"AInt"),
669 "Delete zero-column \"AInt\"... ");
671 test_ivalue(5, cpl_table_get_ncol(table),
672 "Check zero-column array removal... ");
674 test_pvalue(NULL, cpl_table_get_data_float(table,
"Float"),
675 "Check NULL pointer to column Float... ");
677 test_failure(CPL_ERROR_NULL_INPUT,
678 cpl_table_erase_selected(NULL),
679 "Erase selected on NULL table... ");
681 test(cpl_table_erase_selected(table),
682 "Erase selected on empty table... ");
684 test_failure(CPL_ERROR_NULL_INPUT,
685 cpl_table_set_column_unit(NULL,
"Float",
"arcsec"),
686 "Try to assign unit to NULL table... ");
688 test_failure(CPL_ERROR_NULL_INPUT,
689 cpl_table_set_column_unit(table, NULL,
"arcsec"),
690 "Try to assign unit to NULL column... ");
692 test_failure(CPL_ERROR_DATA_NOT_FOUND,
693 cpl_table_set_column_unit(table,
"Double",
"arcsec"),
694 "Try to assign unit to non existing column... ");
696 test(cpl_table_set_column_unit(table,
"Float",
"arcsec"),
697 "Assign unit 'arcsec' to column Float... ");
699 if (strcmp(unit = (
char *)cpl_table_get_column_unit(table,
"Float"),
701 printf(
"Check column unit... ");
702 printf(
"Expected \"arcsec\", obtained \"%s\"\n", unit);
707 test(cpl_table_set_column_unit(table,
"Float", NULL),
708 "Assign unit NULL to column Float... ");
710 test_pvalue(NULL, (
char *)cpl_table_get_column_unit(table,
"Float"),
711 "Get unit NULL from column Float... ");
713 test(cpl_table_set_size(table, 1),
"Expanding again table to one row... ");
715 test(cpl_table_erase_invalid_rows(table),
"Pruning table to zero... ");
717 test_ivalue(1, cpl_table_get_nrow(table),
718 "Checking zero-table length after pruning... ");
720 test_ivalue(0, cpl_table_get_ncol(table),
721 "Checking zero-table width after pruning... ");
723 cpl_table_delete(table);
731 test_data(table, cpl_table_new(nrows),
"Creating the test table... ");
733 test(cpl_table_wrap_int(table, iArray,
"Integer"),
734 "Wrapping the Integer column... ");
738 cpl_table_unwrap(table,
"Integer");
740 test(cpl_table_wrap_int(table, iArray,
"Integer"),
741 "Creating the Integer column... ");
743 test(cpl_table_wrap_double(table, dArray,
"Double"),
744 "Creating the Double column... ");
746 test(cpl_table_wrap_double(table, ddArray,
"DoubleDouble"),
747 "Creating the DoubleDouble column... ");
749 test(cpl_table_wrap_string(table, sArray,
"String"),
750 "Creating the String column... ");
752 test(cpl_table_new_column(table,
"Float", CPL_TYPE_FLOAT),
753 "Creating the Float column... ");
755 for (i = 0; i < nrows; i++) {
756 sprintf(message,
"Writing to row %d of the Float column... ", i);
757 test(cpl_table_set_float(table,
"Float", i, fArray[i]), message);
760 test(cpl_table_new_column_array(table,
"AInt",
761 CPL_TYPE_INT | CPL_TYPE_POINTER, 2),
762 "Creating the ArrayInt column... ");
764 test(cpl_table_new_column_array(table,
"AFloat", CPL_TYPE_FLOAT, 2),
765 "Creating the ArrayFloat column... ");
767 test(cpl_table_new_column_array(table,
"ADouble",
768 CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, 2),
769 "Creating the ArrayDouble column... ");
771 test_ivalue(2, cpl_table_get_column_depth(table,
"AInt"),
772 "Check \"AInt\" depth (2)... ");
775 array = cpl_array_new(2, CPL_TYPE_INT);
776 for (i = 0; i < nrows; i++) {
777 for (j = 0; j < 2; j++) {
779 "Writing element %d of array %d of the AInt column... ", j, i);
781 test(cpl_array_set_int(array, j, k), message);
783 sprintf(message,
"Setting array at position %d of the AInt column... ", i);
784 test(cpl_table_set_array(table,
"AInt", i, array), message);
786 cpl_array_delete(array);
789 for (i = 0; i < nrows; i++) {
790 sprintf(message,
"Getting array %d of the AInt column... ", i);
791 test_data(array, (cpl_array *)cpl_table_get_array(table,
"AInt", i),
793 for (j = 0; j < 2; j++) {
795 "Reading element %d of array %d of the AInt column... ", j, i);
797 test_ivalue(k, cpl_array_get_int(array, j, NULL), message);
802 array = cpl_array_new(2, CPL_TYPE_FLOAT);
803 for (i = 0; i < nrows; i++) {
804 for (j = 0; j < 2; j++) {
806 "Writing element %d of array %d of the AFloat column... ", j, i);
808 test(cpl_array_set_float(array, j, k), message);
811 "Setting array at position %d of the AFloat column... ", i);
812 test(cpl_table_set_array(table,
"AFloat", i, array), message);
814 cpl_array_delete(array);
817 for (i = 0; i < nrows; i++) {
818 sprintf(message,
"Getting array %d of the AFloat column... ", i);
819 test_data(array, (cpl_array *)cpl_table_get_array(table,
"AFloat", i),
821 for (j = 0; j < 2; j++) {
823 "Reading element %d of array %d of the AFloat column... ", j, i);
825 test_fvalue((
float)k, 0.0001,
826 cpl_array_get_float(array, j, NULL), message);
831 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
832 for (i = 0; i < nrows; i++) {
833 for (j = 0; j < 2; j++) {
835 "Writing element %d of array %d of the ADouble column... ", j, i);
837 test(cpl_array_set_double(array, j, k), message);
840 "Setting array at position %d of the ADouble column... ", i);
841 test(cpl_table_set_array(table,
"ADouble", i, array), message);
843 cpl_array_delete(array);
846 for (i = 0; i < nrows; i++) {
847 sprintf(message,
"Getting array %d of the ADouble column... ", i);
848 test_data(array, (cpl_array *)cpl_table_get_array(table,
"ADouble", i),
850 for (j = 0; j < 2; j++) {
852 "Reading element %d of array %d of the ADouble column... ", j, i);
854 test_fvalue((
float)k, 0.0001,
855 cpl_array_get_double(array, j, NULL), message);
859 test_ivalue(2, cpl_table_get_column_depth(table,
"AInt"),
860 "Check \"AInt\" depth (3)... ");
862 test_data(array, (cpl_array *)cpl_table_get_array(table,
"AInt", 0),
864 test_ivalue(CPL_TYPE_INT, cpl_array_get_type(array),
865 "Array AInt must be int... ");
918 test_ivalue(10, cpl_table_get_nrow(table),
"Check table length (1)... ");
919 test_ivalue(8, cpl_table_get_ncol(table),
"Check table width... ");
921 test_failure(CPL_ERROR_DATA_NOT_FOUND,
922 cpl_table_erase_column(table,
"Diable"),
923 "Trying to delete a not existing column... ");
925 test(cpl_table_erase_column(table,
"DoubleDouble"),
926 "Delete column \"DoubleDouble\"... ");
928 test_ivalue(7, cpl_table_get_ncol(table),
"Check again table width... ");
930 test_ivalue(CPL_TYPE_INT, cpl_table_get_column_type(table,
"Integer"),
931 "Column Integer must be int... ");
932 test_ivalue(CPL_TYPE_DOUBLE, cpl_table_get_column_type(table,
"Double"),
933 "Column Double must be double... ");
934 test_ivalue(CPL_TYPE_STRING, cpl_table_get_column_type(table,
"String"),
935 "Column String must be char*... ");
936 test_ivalue(CPL_TYPE_FLOAT, cpl_table_get_column_type(table,
"Float"),
937 "Column Float must be float... ");
938 test_ivalue((CPL_TYPE_INT | CPL_TYPE_POINTER),
939 cpl_table_get_column_type(table,
"AInt"),
940 "Column AInt must be arrays of int... ");
941 test_ivalue((CPL_TYPE_DOUBLE | CPL_TYPE_POINTER),
942 cpl_table_get_column_type(table,
"ADouble"),
943 "Column Double must be arrays of double... ");
944 test_ivalue((CPL_TYPE_FLOAT | CPL_TYPE_POINTER),
945 cpl_table_get_column_type(table,
"AFloat"),
946 "Column Float must be arrays of float... ");
956 copia = cpl_table_new(5);
958 test(cpl_table_copy_structure(copia, table),
959 "Creating a new cpl_table modeled on an existing cpl_table... ");
961 test_ivalue(5, cpl_table_get_nrow(copia),
"Check table length (2)... ");
962 test_ivalue(7, cpl_table_get_ncol(copia),
"Check table width... ");
964 test(cpl_table_compare_structure(table, copia),
965 "Tables must have the same structure... ");
966 cpl_table_erase_column(copia,
"Double");
967 test_ivalue(1, cpl_table_compare_structure(table, copia),
968 "Deleting column Double - now tables must have different structure... ");
969 test(cpl_table_new_column(copia,
"Double", CPL_TYPE_DOUBLE),
970 "Creating again the Double column... ");
971 test(cpl_table_compare_structure(table, copia),
972 "Tables must have the same structure again... ");
974 test(cpl_table_fill_column_window_int(copia,
"Integer", 0, 5, -1),
975 "Fill column Integer of new table... ");
976 test(cpl_table_fill_column_window_double(copia,
"Double", 0, 5, -1.11),
977 "Fill column Double of new table... ");
978 test(cpl_table_fill_column_window_float(copia,
"Float", 0, 5, -1.1),
979 "Fill column Float of new table... ");
980 test(cpl_table_fill_column_window_string(copia,
"String", 0, 5,
"extra"),
981 "Fill column String of new table... ");
983 array = cpl_array_new(2, CPL_TYPE_INT);
984 for (j = 0; j < 2; j++)
985 cpl_array_set_int(array, j, j);
986 test(cpl_table_fill_column_window_array(copia,
"AInt", 0, 5, array),
987 "Fill column AInt of new table... ");
988 cpl_array_delete(array);
990 array = cpl_array_new(2, CPL_TYPE_FLOAT);
991 for (j = 0; j < 2; j++)
992 cpl_array_set_float(array, j, j);
993 test(cpl_table_fill_column_window_array(copia,
"AFloat", 0, 5, array),
994 "Fill column AFloat of new table... ");
995 cpl_array_delete(array);
997 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
998 for (j = 0; j < 2; j++)
999 cpl_array_set_double(array, j, j);
1000 test(cpl_table_fill_column_window_array(copia,
"ADouble", 0, 5, array),
1001 "Fill column ADouble of new table... ");
1002 cpl_array_delete(array);
1004 test(cpl_table_insert(table, copia, 15),
1005 "Appending new table to old table... ");
1006 test(cpl_table_insert(table, copia, 5),
1007 "Inserting new table in old table... ");
1008 test(cpl_table_insert(table, copia, 0),
1009 "Prepending new table to old table... ");
1011 cpl_table_delete(copia);
1014 cpl_table_fill_invalid_int(table,
"Integer", 320);
1015 cpl_table_fill_invalid_int(table,
"AInt", 320);
1016 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1017 cpl_table_delete(table);
1018 table = cpl_table_load(
"test_table.tfits", 1, 1);
1021 test_ivalue(25, cpl_table_get_nrow(table),
"Check table length (3)... ");
1051 for (i = 0; i < 25; i++) {
1052 if (cpl_table_get_int(table,
"Integer", i, NULL) != icheck[i]) {
1059 printf(
"Check Integer column... ");
1060 printf(
"Failure\n");
1065 dcheck[0] = -1.1100;
1066 dcheck[1] = -1.1100;
1067 dcheck[2] = -1.1100;
1068 dcheck[3] = -1.1100;
1069 dcheck[4] = -1.1100;
1075 dcheck[10] = -1.1100;
1076 dcheck[11] = -1.1100;
1077 dcheck[12] = -1.1100;
1078 dcheck[13] = -1.1100;
1079 dcheck[14] = -1.1100;
1080 dcheck[15] = 3.1100;
1081 dcheck[16] = 7.1100;
1082 dcheck[17] = 1.1100;
1083 dcheck[18] = 4.1100;
1084 dcheck[19] = 6.1100;
1085 dcheck[20] = -1.1100;
1086 dcheck[21] = -1.1100;
1087 dcheck[22] = -1.1100;
1088 dcheck[23] = -1.1100;
1089 dcheck[24] = -1.1100;
1093 for (i = 0; i < 25; i++) {
1094 if (fabs(cpl_table_get_double(table,
"Double", i, NULL) - dcheck[i])
1102 printf(
"Check Double column... ");
1103 printf(
"Failure\n");
1108 scheck[0] =
"extra";
1109 scheck[1] =
"extra";
1110 scheck[2] =
"extra";
1111 scheck[3] =
"extra";
1112 scheck[4] =
"extra";
1118 scheck[10] =
"extra";
1119 scheck[11] =
"extra";
1120 scheck[12] =
"extra";
1121 scheck[13] =
"extra";
1122 scheck[14] =
"extra";
1123 scheck[15] =
"baaa";
1124 scheck[16] =
"aaaa";
1125 scheck[17] =
"acde";
1126 scheck[18] =
" sss";
1127 scheck[19] =
"daaa";
1128 scheck[20] =
"extra";
1129 scheck[21] =
"extra";
1130 scheck[22] =
"extra";
1131 scheck[23] =
"extra";
1132 scheck[24] =
"extra";
1136 for (i = 0; i < 25; i++) {
1137 if (strcmp(cpl_table_get_string(table,
"String", i), scheck[i])) {
1144 printf(
"Check String column... ");
1145 printf(
"Failure\n");
1178 for (i = 0; i < 25; i++) {
1179 if (fabs(cpl_table_get_float(table,
"Float", i, NULL) - fcheck[i])
1187 printf(
"Check Float column... ");
1188 printf(
"Failure\n");
1193 test(cpl_table_set_invalid(table,
"Integer", 0),
1194 "Set Integer 0 to NULL... ");
1195 test(cpl_table_set_invalid(table,
"Integer", 5),
1196 "Set Integer 5 to NULL... ");
1197 test(cpl_table_set_invalid(table,
"Integer", 24),
1198 "Set Integer 24 to NULL... ");
1200 test(cpl_table_set_invalid(table,
"AInt", 0),
1201 "Set AInt 0 to NULL... ");
1202 test(cpl_table_set_invalid(table,
"AFloat", 5),
1203 "Set AFloat 5 to NULL... ");
1204 test(cpl_table_set_invalid(table,
"ADouble", 24),
1205 "Set ADouble 24 to NULL... ");
1208 cpl_table_fill_invalid_int(table,
"Integer", 320);
1209 cpl_table_fill_invalid_int(table,
"AInt", 320);
1210 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1211 cpl_table_delete(table);
1212 table = cpl_table_load(
"test_table.tfits", 1, 1);
1215 test_ivalue(3, cpl_table_count_invalid(table,
"Integer"),
1216 "Count Integer written NULLs... ");
1217 test_ivalue(1, cpl_table_count_invalid(table,
"AInt"),
1218 "Count AInt written NULLs... ");
1219 test_ivalue(1, cpl_table_count_invalid(table,
"AFloat"),
1220 "Count AFloat written NULLs... ");
1221 test_ivalue(1, cpl_table_count_invalid(table,
"ADouble"),
1222 "Count ADouble written NULLs... ");
1226 for (i = 0; i < 25; i++) {
1227 cpl_table_get_int(table,
"Integer", i, &null);
1229 if (cpl_table_get_int(table,
"Integer", i, &null) != icheck[i]) {
1234 else if (i != 0 && i != 5 && i != 24) {
1241 printf(
"Check Integer column... ");
1242 printf(
"Failure\n");
1247 test(cpl_table_set_int(table,
"Integer", 0, -1),
1248 "Set Integer 0 to -1... ");
1249 test(cpl_table_set_int(table,
"Integer", 5, 5),
1250 "Set Integer 5 to 5... ");
1251 test(cpl_table_set_int(table,
"Integer", 24, -1),
1252 "Set Integer 24 to -1... ");
1254 array = cpl_array_new(2, CPL_TYPE_INT);
1255 for (j = 0; j < 2; j++)
1256 cpl_array_set_int(array, j, j);
1257 test(cpl_table_set_array(table,
"AInt", 0, array),
1258 "Set a valid array to AInt 0... ");
1259 cpl_array_delete(array);
1260 test_ivalue(0, cpl_table_count_invalid(table,
"AInt"),
1261 "No invalid elements in AInt... ");
1263 array = cpl_array_new(2, CPL_TYPE_FLOAT);
1264 for (j = 0; j < 2; j++)
1265 cpl_array_set_float(array, j, j);
1266 test(cpl_table_set_array(table,
"AFloat", 5, array),
1267 "Set a valid array to AFloat 5... ");
1268 cpl_array_delete(array);
1269 test_ivalue(0, cpl_table_count_invalid(table,
"AFloat"),
1270 "No invalid elements in AFloat... ");
1272 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
1273 for (j = 0; j < 2; j++)
1274 cpl_array_set_double(array, j, j);
1275 test(cpl_table_set_array(table,
"ADouble", 24, array),
1276 "Set a valid array to ADouble 24... ");
1277 cpl_array_delete(array);
1278 test_ivalue(0, cpl_table_count_invalid(table,
"ADouble"),
1279 "No invalid elements in ADouble... ");
1282 cpl_table_fill_invalid_int(table,
"Integer", 320);
1283 cpl_table_fill_invalid_int(table,
"AInt", 320);
1284 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1285 cpl_table_delete(table);
1286 table = cpl_table_load(
"test_table.tfits", 1, 1);
1289 test_ivalue(0, cpl_table_count_invalid(table,
"Integer"),
1294 for (i = 0; i < 25; i++) {
1295 cpl_table_get_int(table,
"Integer", i, &null);
1297 if (cpl_table_get_int(table,
"Integer", i, &null) != icheck[i]) {
1309 printf(
"Check Integer column... ");
1310 printf(
"Failure\n");
1315 test(cpl_table_set_invalid(table,
"Double", 0),
"Set Double 0 to NULL... ");
1316 test(cpl_table_set_invalid(table,
"Double", 5),
"Set Double 5 to NULL... ");
1317 test(cpl_table_set_invalid(table,
"Double", 24),
"Set Double 24 to NULL... ");
1320 cpl_table_fill_invalid_int(table,
"Integer", 320);
1321 cpl_table_fill_invalid_int(table,
"AInt", 320);
1322 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1323 cpl_table_delete(table);
1324 table = cpl_table_load(
"test_table.tfits", 1, 1);
1327 test_ivalue(3, cpl_table_count_invalid(table,
"Double"),
1328 "Count written NULLs... ");
1332 for (i = 0; i < 25; i++) {
1333 cpl_table_get_double(table,
"Double", i, &null);
1335 if (cpl_table_get_double(table,
"Double", i, &null) != dcheck[i]) {
1340 else if (i != 0 && i != 5 && i != 24) {
1347 printf(
"Check Double column... ");
1348 printf(
"Failure\n");
1353 test(cpl_table_set_double(table,
"Double", 0, -1.11),
1354 "Set Double 0 to -1.11... ");
1355 test(cpl_table_set_double(table,
"Double", 5, 5.11),
1356 "Set Double 5 to 5.11... ");
1357 test(cpl_table_set_double(table,
"Double", 24, -1.11),
1358 "Set Double 24 to -1.11... ");
1361 cpl_table_fill_invalid_int(table,
"Integer", 320);
1362 cpl_table_fill_invalid_int(table,
"AInt", 320);
1363 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1364 cpl_table_delete(table);
1365 table = cpl_table_load(
"test_table.tfits", 1, 1);
1368 test_ivalue(0, cpl_table_count_invalid(table,
"Double"),
1373 for (i = 0; i < 25; i++) {
1374 cpl_table_get_double(table,
"Double", i, &null);
1376 if (fabs(cpl_table_get_double(table,
"Double", i, &null)-dcheck[i])
1389 printf(
"Check Double column... ");
1390 printf(
"Failure\n");
1396 test(cpl_table_set_invalid(table,
"String", 0),
"Set String 0 to NULL... ");
1397 test(cpl_table_set_invalid(table,
"String", 5),
"Set String 5 to NULL... ");
1398 test(cpl_table_set_invalid(table,
"String", 24),
"Set String 24 to NULL... ");
1401 cpl_table_fill_invalid_int(table,
"Integer", 320);
1402 cpl_table_fill_invalid_int(table,
"AInt", 320);
1403 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1404 cpl_table_delete(table);
1405 table = cpl_table_load(
"test_table.tfits", 1, 1);
1408 test_ivalue(3, cpl_table_count_invalid(table,
"String"),
1409 "Count written NULLs... ");
1413 for (i = 0; i < 25; i++) {
1414 if (cpl_table_get_string(table,
"String", i)) {
1415 if (strcmp(cpl_table_get_string(table,
"String", i), scheck[i])) {
1420 else if (i != 0 && i != 5 && i != 24) {
1427 printf(
"Check String column... ");
1428 printf(
"Failure\n");
1433 test(cpl_table_set_string(table,
"String", 0,
"extra"),
1434 "Set String 0 to \"extra\"... ");
1435 test(cpl_table_set_string(table,
"String", 5,
"caaa"),
1436 "Set String 5 to \"caaa\"... ");
1437 test(cpl_table_set_string(table,
"String", 24,
"extra"),
1438 "Set String 24 to \"extra\"... ");
1441 cpl_table_fill_invalid_int(table,
"Integer", 320);
1442 cpl_table_fill_invalid_int(table,
"AInt", 320);
1443 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1444 cpl_table_delete(table);
1445 table = cpl_table_load(
"test_table.tfits", 1, 1);
1448 test_ivalue(0, cpl_table_count_invalid(table,
"String"),
1453 for (i = 0; i < 25; i++) {
1454 if (cpl_table_get_string(table,
"String", i)) {
1455 if (strcmp(cpl_table_get_string(table,
"String", i), scheck[i])) {
1467 printf(
"Check String column... ");
1468 printf(
"Failure\n");
1474 test(cpl_table_set_invalid(table,
"Float", 0),
"Set Float 0 to NULL... ");
1475 test(cpl_table_set_invalid(table,
"Float", 5),
"Set Float 5 to NULL... ");
1476 test(cpl_table_set_invalid(table,
"Float", 24),
"Set Float 24 to NULL... ");
1479 cpl_table_fill_invalid_int(table,
"Integer", 320);
1480 cpl_table_fill_invalid_int(table,
"AInt", 320);
1481 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1482 cpl_table_delete(table);
1483 table = cpl_table_load(
"test_table.tfits", 1, 1);
1486 test_ivalue(3, cpl_table_count_invalid(table,
"Float"),
1487 "Count written NULLs... ");
1491 for (i = 0; i < 25; i++) {
1492 cpl_table_get_float(table,
"Float", i, &null);
1494 if (cpl_table_get_float(table,
"Float", i, &null) != fcheck[i]) {
1499 else if (i != 0 && i != 5 && i != 24) {
1506 printf(
"Check Float column... ");
1507 printf(
"Failure\n");
1512 test(cpl_table_set_float(table,
"Float", 0, -1.1),
1513 "Set Float 0 to -1.1... ");
1514 test(cpl_table_set_float(table,
"Float", 5, 5.1),
1515 "Set Float 5 to 5.1... ");
1516 test(cpl_table_set_float(table,
"Float", 24, -1.1),
1517 "Set Float 24 to -1.1... ");
1520 cpl_table_fill_invalid_int(table,
"Integer", 320);
1521 cpl_table_fill_invalid_int(table,
"AInt", 320);
1522 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1523 cpl_table_delete(table);
1524 table = cpl_table_load(
"test_table.tfits", 1, 1);
1527 test_ivalue(0, cpl_table_count_invalid(table,
"Float"),
1532 for (i = 0; i < 25; i++) {
1533 cpl_table_get_float(table,
"Float", i, &null);
1535 if (fabs(cpl_table_get_float(table,
"Float", i, &null)-fcheck[i])
1548 printf(
"Check Float column... ");
1549 printf(
"Failure\n");
1556 test(cpl_table_set_column_invalid(table,
"Integer", 0, 3),
1557 "Set Integer 0-2 to NULL... ");
1558 test(cpl_table_set_column_invalid(table,
"Integer", 5, 3),
1559 "Set Integer 5-7 to NULL... ");
1560 test(cpl_table_set_column_invalid(table,
"Integer", 20, 20),
1561 "Set Integer 20 till end to NULL... ");
1563 test(cpl_table_set_column_invalid(table,
"AInt", 0, 3),
1564 "Set AInt 0-2 to NULL... ");
1565 test(cpl_table_set_column_invalid(table,
"AInt", 5, 3),
1566 "Set AInt 5-7 to NULL... ");
1567 test(cpl_table_set_column_invalid(table,
"AInt", 20, 20),
1568 "Set AInt 20 till end to NULL... ");
1571 cpl_table_fill_invalid_int(table,
"Integer", 320);
1572 cpl_table_fill_invalid_int(table,
"AInt", 320);
1573 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1574 cpl_table_delete(table);
1575 table = cpl_table_load(
"test_table.tfits", 1, 1);
1578 test_ivalue(11, cpl_table_count_invalid(table,
"Integer"),
1579 "Count Integer NULLs... ");
1581 test_ivalue(11, cpl_table_count_invalid(table,
"AInt"),
1582 "Count AInt NULLs... ");
1586 for (i = 0; i < 25; i++) {
1587 cpl_table_get_int(table,
"Integer", i, &null);
1589 if (cpl_table_get_int(table,
"Integer", i, &null) != icheck[i]) {
1594 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
1601 printf(
"Check Integer column... ");
1602 printf(
"Failure\n");
1607 test(cpl_table_set_column_invalid(table,
"Double", 0, 3),
1608 "Set Double 0-2 to NULL... ");
1609 test(cpl_table_set_column_invalid(table,
"Double", 5, 3),
1610 "Set Double 5-7 to NULL... ");
1611 test(cpl_table_set_column_invalid(table,
"Double", 20, 20),
1612 "Set Double 20 till end to NULL... ");
1615 cpl_table_fill_invalid_int(table,
"Integer", 320);
1616 cpl_table_fill_invalid_int(table,
"AInt", 320);
1617 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1618 cpl_table_delete(table);
1619 table = cpl_table_load(
"test_table.tfits", 1, 1);
1622 test_ivalue(11, cpl_table_count_invalid(table,
"Double"),
1623 "Count written NULLs... ");
1627 for (i = 0; i < 25; i++) {
1628 cpl_table_get_double(table,
"Double", i, &null);
1630 if (fabs(cpl_table_get_double(table,
"Double", i, &null)-dcheck[i])
1636 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
1643 printf(
"Check Double column... ");
1644 printf(
"Failure\n");
1650 test(cpl_table_set_column_invalid(table,
"Float", 0, 3),
1651 "Set Float 0-2 to NULL... ");
1652 test(cpl_table_set_column_invalid(table,
"Float", 5, 3),
1653 "Set Float 5-7 to NULL... ");
1654 test(cpl_table_set_column_invalid(table,
"Float", 20, 20),
1655 "Set Float 20 till end to NULL... ");
1658 cpl_table_fill_invalid_int(table,
"Integer", 320);
1659 cpl_table_fill_invalid_int(table,
"AInt", 320);
1660 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1661 cpl_table_delete(table);
1662 table = cpl_table_load(
"test_table.tfits", 1, 1);
1665 test_ivalue(11, cpl_table_count_invalid(table,
"Float"),
1666 "Count written NULLs... ");
1670 for (i = 0; i < 25; i++) {
1671 cpl_table_get_float(table,
"Float", i, &null);
1673 if (fabs(cpl_table_get_float(table,
"Float", i, &null)-fcheck[i])
1679 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
1686 printf(
"Check Float column... ");
1687 printf(
"Failure\n");
1693 test(cpl_table_set_column_invalid(table,
"String", 0, 3),
1694 "Set String 0-2 to NULL... ");
1695 test(cpl_table_set_column_invalid(table,
"String", 5, 3),
1696 "Set String 5-7 to NULL... ");
1697 test(cpl_table_set_column_invalid(table,
"String", 20, 20),
1698 "Set String 20 till end to NULL... ");
1701 cpl_table_fill_invalid_int(table,
"Integer", 320);
1702 cpl_table_fill_invalid_int(table,
"AInt", 320);
1703 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1704 cpl_table_delete(table);
1705 table = cpl_table_load(
"test_table.tfits", 1, 1);
1708 test_ivalue(11, cpl_table_count_invalid(table,
"String"),
1709 "Count written NULLs... ");
1713 for (i = 0; i < 25; i++) {
1714 if (cpl_table_get_string(table,
"String", i)) {
1715 if (strcmp(cpl_table_get_string(table,
"String", i), scheck[i])) {
1720 else if ((i > 2 && i < 5) || (i > 7 && i < 20)) {
1727 printf(
"Check String column... ");
1728 printf(
"Failure\n");
1733 test(cpl_table_erase_window(table, 21, 4),
"Delete last 4 table rows... ");
1735 test(cpl_table_erase_window(table, 7, 4),
1736 "Delete table rows from 7 to 10... ");
1738 test(cpl_table_erase_window(table, 3, 3),
1739 "Delete table rows from 3 to 5... ");
1741 test(cpl_table_erase_window(table, 0, 2),
"Delete first two table rows... ");
1743 test_ivalue(12, cpl_table_get_nrow(table),
"Check table length (4)... ");
1745 test_ivalue(3, cpl_table_count_invalid(table,
"Integer"),
1746 "Count Integer NULLs... ");
1748 test_ivalue(3, cpl_table_count_invalid(table,
"Double"),
1749 "Count Double NULLs... ");
1751 test_ivalue(3, cpl_table_count_invalid(table,
"String"),
1752 "Count String NULLs... ");
1754 test_ivalue(3, cpl_table_count_invalid(table,
"Float"),
1755 "Count Float NULLs... ");
1757 test_ivalue(3, cpl_table_count_invalid(table,
"AInt"),
1758 "Count AInt NULLs... ");
1760 test_ivalue(0, cpl_table_count_invalid(table,
"ADouble"),
1761 "Count ADouble NULLs... ");
1763 test_ivalue(0, cpl_table_count_invalid(table,
"AFloat"),
1764 "Count AFloat NULLs... ");
1766 test(cpl_table_insert_window(table, 20, 5),
1767 "Append 5 NULLs at table end... ");
1769 test(cpl_table_insert_window(table, 6, 4),
1770 "Insert segment of 4 NULLs at row 6... ");
1772 test(cpl_table_insert_window(table, 1, 2),
1773 "Insert segment of 2 NULLs at row 1... ");
1775 test_ivalue(23, cpl_table_get_nrow(table),
"Check table length (5)... ");
1777 test_ivalue(14, cpl_table_count_invalid(table,
"Integer"),
1778 "Count Integer NULLs... ");
1780 test_ivalue(14, cpl_table_count_invalid(table,
"Double"),
1781 "Count Double NULLs... ");
1783 test_ivalue(14, cpl_table_count_invalid(table,
"String"),
1784 "Count String NULLs... ");
1786 test_ivalue(14, cpl_table_count_invalid(table,
"Float"),
1787 "Count Float NULLs... ");
1789 test(cpl_table_fill_column_window_int(table,
"Integer", 0, 2, 999),
1790 "Write 999 in \"Integer\" column from 0 to 1... ");
1792 test(cpl_table_fill_column_window_int(table,
"Integer", 3, 3, 999),
1793 "Write 999 in \"Integer\" column from 3 to 5... ");
1795 test(cpl_table_fill_column_window_int(table,
"Integer", 7, 4, 999),
1796 "Write 999 in \"Integer\" column from 7 to 10... ");
1798 test(cpl_table_fill_column_window_int(table,
"Integer", 20, 7, 999),
1799 "Write 999 in \"Integer\" column from 20 to end... ");
1801 test(cpl_table_fill_column_window_float(table,
"Float", 0, 2, 999.99),
1802 "Write 999.99 in \"Float\" column from 0 to 1... ");
1804 test(cpl_table_fill_column_window_float(table,
"Float", 3, 3, 999.99),
1805 "Write 999.99 in \"Float\" column from 3 to 5... ");
1807 test(cpl_table_fill_column_window_float(table,
"Float", 7, 4, 999.99),
1808 "Write 999.99 in \"Float\" column from 7 to 10... ");
1810 test(cpl_table_fill_column_window_float(table,
"Float", 20, 7, 999.99),
1811 "Write 999.99 in \"Float\" column from 20 to end... ");
1813 test(cpl_table_fill_column_window_double(table,
"Double", 0, 2, 999.88),
1814 "Write 999.88 in \"Double\" column from 0 to 1... ");
1816 test(cpl_table_fill_column_window_double(table,
"Double", 3, 3, 999.88),
1817 "Write 999.88 in \"Double\" column from 3 to 5... ");
1819 test(cpl_table_fill_column_window_double(table,
"Double", 7, 4, 999.88),
1820 "Write 999.88 in \"Double\" column from 7 to 10... ");
1822 test(cpl_table_fill_column_window_double(table,
"Double", 20, 7, 999.88),
1823 "Write 999.88 in \"Double\" column from 20 to end... ");
1825 test(cpl_table_fill_column_window_string(table,
"String", 0, 2,
"999"),
1826 "Write \"999\" in \"String\" column from 0 to 1... ");
1828 test(cpl_table_fill_column_window_string(table,
"String", 3, 3,
"999"),
1829 "Write \"999\" in \"String\" column from 3 to 5... ");
1831 test(cpl_table_fill_column_window_string(table,
"String", 7, 4,
"999"),
1832 "Write \"999\" in \"String\" column from 7 to 10... ");
1834 test(cpl_table_fill_column_window_string(table,
"String", 20, 7,
"999"),
1835 "Write \"999\" in \"String\" column from 20 to end... ");
1838 cpl_table_fill_invalid_int(table,
"Integer", 320);
1839 cpl_table_fill_invalid_int(table,
"AInt", 320);
1840 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1841 cpl_table_delete(table);
1842 table = cpl_table_load(
"test_table.tfits", 1, 1);
1845 test_ivalue(23, cpl_table_get_nrow(table),
"Check table length (6)... ");
1847 test_ivalue(5, cpl_table_count_invalid(table,
"Integer"),
1848 "Count Integer NULLs... ");
1850 test_ivalue(5, cpl_table_count_invalid(table,
"Float"),
1851 "Count Float NULLs... ");
1853 test_ivalue(5, cpl_table_count_invalid(table,
"Double"),
1854 "Count Double NULLs... ");
1856 test_ivalue(5, cpl_table_count_invalid(table,
"String"),
1857 "Count String NULLs... ");
1859 test_ivalue(14, cpl_table_count_invalid(table,
"AInt"),
1860 "Count AInt NULLs... ");
1862 test_ivalue(11, cpl_table_count_invalid(table,
"AFloat"),
1863 "Count AFloat NULLs... ");
1865 test_ivalue(11, cpl_table_count_invalid(table,
"ADouble"),
1866 "Count ADouble NULLs... ");
1868 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 2),
1869 "Check that third element of \"Integer\" is NULL... ");
1871 test_ivalue(1, cpl_table_is_valid(table,
"Double", 0),
1872 "Check that first element of \"Double\" is not NULL... ");
1874 test_ivalue(1, cpl_table_is_valid(table,
"String", 0),
1875 "Check that first element of \"String\" is not NULL... ");
1877 test_ivalue(0, cpl_table_is_valid(table,
"String", 2),
1878 "Check that third element of \"String\" is NULL... ");
1880 test_ivalue(0, cpl_table_is_valid(table,
"AInt", 17),
1881 "Check that third element of \"AInt\" is NULL... ");
1883 test_ivalue(1, cpl_table_is_valid(table,
"ADouble", 17),
1884 "Check that first element of \"ADouble\" is not NULL... ");
1886 test_ivalue(1, cpl_table_is_valid(table,
"AFloat", 17),
1887 "Check that third element of \"AFloat\" is NULL... ");
1889 test_data(copia, cpl_table_duplicate(table),
"Duplicate table... ");
1891 test(cpl_table_duplicate_column(table,
"New Integer", table,
"Integer"),
1892 "Duplicate \"Integer\" column within same table... ");
1894 test(cpl_table_duplicate_column(table,
"New Float", table,
"Float"),
1895 "Duplicate \"Float\" column within same table... ");
1897 test(cpl_table_duplicate_column(table,
"New Double", table,
"Double"),
1898 "Duplicate \"Double\" column within same table... ");
1900 test(cpl_table_duplicate_column(table,
"New String", table,
"String"),
1901 "Duplicate \"String\" column within same table... ");
1903 test(cpl_table_duplicate_column(table,
"New AInt", table,
"AInt"),
1904 "Duplicate \"AInt\" column within same table... ");
1906 test(cpl_table_duplicate_column(table,
"New AFloat", table,
"AFloat"),
1907 "Duplicate \"AFloat\" column within same table... ");
1909 test(cpl_table_duplicate_column(table,
"New ADouble", table,
"ADouble"),
1910 "Duplicate \"ADouble\" column within same table... ");
1912 test_ivalue(5, cpl_table_count_invalid(table,
"New Integer"),
1913 "Count New Integer NULLs... ");
1915 test_ivalue(5, cpl_table_count_invalid(table,
"New Float"),
1916 "Count New Float NULLs... ");
1918 test_ivalue(5, cpl_table_count_invalid(table,
"New Double"),
1919 "Count New Double NULLs... ");
1921 test_ivalue(5, cpl_table_count_invalid(table,
"New String"),
1922 "Count New String NULLs... ");
1924 test_ivalue(14, cpl_table_count_invalid(table,
"New AInt"),
1925 "Count New AInt NULLs... ");
1927 test_ivalue(11, cpl_table_count_invalid(table,
"New AFloat"),
1928 "Count New AFloat NULLs... ");
1930 test_ivalue(11, cpl_table_count_invalid(table,
"New ADouble"),
1931 "Count New ADouble NULLs... ");
1933 test(cpl_table_move_column(copia,
"New Integer", table),
1934 "Moving column \"New Integer\" to another table... ");
1936 test(cpl_table_move_column(copia,
"New Float", table),
1937 "Moving column \"New Float\" to another table... ");
1939 test(cpl_table_move_column(copia,
"New Double", table),
1940 "Moving column \"New Double\" to another table... ");
1942 test(cpl_table_move_column(copia,
"New String", table),
1943 "Moving column \"New String\" to another table... ");
1945 test_failure(CPL_ERROR_ILLEGAL_OUTPUT,
1946 cpl_table_name_column(copia,
"New String",
"String"),
1947 "Try illegal column renaming... ");
1949 test(cpl_table_name_column(copia,
"New Integer",
"Old Integer"),
1950 "Try legal column renaming... ");
1953 cpl_table_fill_invalid_int(table,
"Integer", 320);
1954 cpl_table_fill_invalid_int(table,
"AInt", 320);
1955 cpl_table_fill_invalid_int(table,
"New AInt", 320);
1956 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
1957 cpl_table_delete(table);
1958 table = cpl_table_load(
"test_table.tfits", 1, 1);
1961 test_ivalue(!0, cpl_table_has_column(copia,
"Old Integer"),
1962 "Check if column \"Old Integer\" exists... ");
1964 test_svalue(
"Integer", cpl_table_get_column_name(copia),
1965 "Check name column 1... ");
1967 test_svalue(
"Double", cpl_table_get_column_name(NULL),
1968 "Check name column 2... ");
1970 test_svalue(
"String", cpl_table_get_column_name(NULL),
1971 "Check name column 3... ");
1973 test_svalue(
"Float", cpl_table_get_column_name(NULL),
1974 "Check name column 4... ");
1976 test_svalue(
"AInt", cpl_table_get_column_name(NULL),
1977 "Check name column 5... ");
1979 test_svalue(
"AFloat", cpl_table_get_column_name(NULL),
1980 "Check name column 6... ");
1982 test_svalue(
"ADouble", cpl_table_get_column_name(NULL),
1983 "Check name column 7... ");
1985 test_svalue(
"Old Integer", cpl_table_get_column_name(NULL),
1986 "Check name column 8... ");
1988 test_svalue(
"New Float", cpl_table_get_column_name(NULL),
1989 "Check name column 9... ");
1991 test_svalue(
"New Double", cpl_table_get_column_name(NULL),
1992 "Check name column 10... ");
1994 test_svalue(
"New String", cpl_table_get_column_name(NULL),
1995 "Check name column 11... ");
1997 test_pvalue(NULL, (
void *)cpl_table_get_column_name(NULL),
1998 "Check if no more colums... ");
2000 cpl_table_delete(copia);
2003 test(cpl_table_set_size(table, 30),
"Expanding table to 30 rows... ");
2012 test_ivalue(12, cpl_table_count_invalid(table,
"Integer"),
2013 "Count \"Integer\" NULLs... ");
2015 test_ivalue(12, cpl_table_count_invalid(table,
"String"),
2016 "Count \"String\" NULLs... ");
2018 test(cpl_table_set_size(table, 22),
"Truncating table to 22 rows... ");
2029 cpl_table_fill_invalid_int(table,
"Integer", 320);
2030 cpl_table_fill_invalid_int(table,
"AInt", 320);
2031 cpl_table_fill_invalid_int(table,
"New AInt", 320);
2032 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
2033 cpl_table_delete(table);
2034 table = cpl_table_load(
"test_table.tfits", 1, 1);
2037 test_ivalue(5, cpl_table_count_invalid(table,
"Integer"),
2038 "Count \"Integer\" NULLs (2)... ");
2040 test_ivalue(5, cpl_table_count_invalid(table,
"String"),
2041 "Count \"String\" NULLs (2)... ");
2043 test_data(copia, cpl_table_extract(table, 0, 5),
2044 "Creating subtable from rows 0-5 of original... ");
2046 test_ivalue(1, cpl_table_count_invalid(copia,
"Integer"),
2047 "Count \"Integer\" NULLs... ");
2049 test_ivalue(1, cpl_table_count_invalid(copia,
"String"),
2050 "Count \"String\" NULLs... ");
2052 cpl_table_delete(copia);
2054 test_data(copia, cpl_table_extract(table, 8, 5),
2055 "Creating subtable from rows 8-5 of original... ");
2057 test_ivalue(1, cpl_table_count_invalid(copia,
"Float"),
2058 "Count \"Float\" NULLs... ");
2060 test_ivalue(1, cpl_table_count_invalid(copia,
"String"),
2061 "Count \"String\" NULLs... ");
2063 cpl_table_delete(copia);
2065 test_data(copia, cpl_table_extract(table, 15, 30),
2066 "Creating subtable from rows 15 till end of original... ");
2068 test_ivalue(3, cpl_table_count_invalid(copia,
"Double"),
2069 "Count \"Double\" NULLs... ");
2071 test_ivalue(3, cpl_table_count_invalid(copia,
"String"),
2072 "Count \"String\" NULLs... ");
2074 cpl_table_delete(copia);
2076 test(cpl_table_cast_column(table,
"Float",
"FloatToInt", CPL_TYPE_INT),
2077 "Casting float column to integer colum... ");
2080 cpl_table_fill_invalid_int(table,
"Integer", 320);
2081 cpl_table_fill_invalid_int(table,
"FloatToInt", -2);
2082 cpl_table_fill_invalid_int(table,
"AInt", 320);
2083 cpl_table_fill_invalid_int(table,
"New AInt", 320);
2084 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
2085 cpl_table_delete(table);
2086 table = cpl_table_load(
"test_table.tfits", 1, 1);
2089 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 0, NULL),
2090 "Check element 1 of casted column... ");
2091 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 1, NULL),
2092 "Check element 2 of casted column... ");
2093 test_ivalue(0, cpl_table_is_valid(table,
"FloatToInt", 2),
2094 "Check element 3 of casted column... ");
2095 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 3, NULL),
2096 "Check element 4 of casted column... ");
2097 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 4, NULL),
2098 "Check element 5 of casted column... ");
2099 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 5, NULL),
2100 "Check element 6 of casted column... ");
2101 test_ivalue(-1, cpl_table_get_int(table,
"FloatToInt", 6, NULL),
2102 "Check element 7 of casted column... ");
2103 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 7, NULL),
2104 "Check element 8 of casted column... ");
2105 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 8, NULL),
2106 "Check element 9 of casted column... ");
2107 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 9, NULL),
2108 "Check element 10 of casted column... ");
2109 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 10, NULL),
2110 "Check element 11 of casted column... ");
2111 test_ivalue(0, cpl_table_is_valid(table,
"FloatToInt", 11),
2112 "Check element 12 of casted column... ");
2113 test_ivalue(3, cpl_table_get_int(table,
"FloatToInt", 12, NULL),
2114 "Check element 13 of casted column... ");
2115 test_ivalue(7, cpl_table_get_int(table,
"FloatToInt", 13, NULL),
2116 "Check element 14 of casted column... ");
2117 test_ivalue(1, cpl_table_get_int(table,
"FloatToInt", 14, NULL),
2118 "Check element 15 of casted column... ");
2119 test_ivalue(4, cpl_table_get_int(table,
"FloatToInt", 15, NULL),
2120 "Check element 16 of casted column... ");
2121 test_ivalue(6, cpl_table_get_int(table,
"FloatToInt", 16, NULL),
2122 "Check element 17 of casted column... ");
2123 test_ivalue(0, cpl_table_is_valid(table,
"FloatToInt", 17),
2124 "Check element 18 of casted column... ");
2125 test_ivalue(0, cpl_table_is_valid(table,
"FloatToInt", 18),
2126 "Check element 19 of casted column... ");
2127 test_ivalue(0, cpl_table_is_valid(table,
"FloatToInt", 19),
2128 "Check element 20 of casted column... ");
2129 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 20, NULL),
2130 "Check element 21 of casted column... ");
2131 test_ivalue(999, cpl_table_get_int(table,
"FloatToInt", 21, NULL),
2132 "Check element 22 of casted column... ");
2134 test(cpl_table_erase_column(table,
"FloatToInt"),
2135 "Delete casted column... ");
2137 test(cpl_table_cast_column(table,
"Integer",
"IntToFloat", CPL_TYPE_FLOAT),
2138 "Casting integer column to float colum... ");
2141 cpl_table_fill_invalid_int(table,
"Integer", 320);
2142 cpl_table_fill_invalid_int(table,
"AInt", 320);
2143 cpl_table_fill_invalid_int(table,
"New AInt", 320);
2144 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
2145 cpl_table_delete(table);
2146 table = cpl_table_load(
"test_table.tfits", 1, 1);
2149 test_fvalue(999.0, 0.00001,
2150 cpl_table_get_float(table,
"IntToFloat", 0, NULL),
2151 "Check element 1 of casted column (2)... ");
2152 test_fvalue(999.0, 0.00001,
2153 cpl_table_get_float(table,
"IntToFloat", 1, NULL),
2154 "Check element 2 of casted column (2)... ");
2155 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 2),
2156 "Check element 3 of casted column (2)... ");
2157 test_fvalue(999.0, 0.00001,
2158 cpl_table_get_float(table,
"IntToFloat", 3, NULL),
2159 "Check element 4 of casted column (2)... ");
2160 test_fvalue(999.0, 0.00001,
2161 cpl_table_get_float(table,
"IntToFloat", 4, NULL),
2162 "Check element 5 of casted column (2)... ");
2163 test_fvalue(999.0, 0.00001,
2164 cpl_table_get_float(table,
"IntToFloat", 5, NULL),
2165 "Check element 6 of casted column (2)... ");
2166 test_fvalue(-1.0, 0.00001,
2167 cpl_table_get_float(table,
"IntToFloat", 6, NULL),
2168 "Check element 7 of casted column (2)... ");
2169 test_fvalue(999.0, 0.00001,
2170 cpl_table_get_float(table,
"IntToFloat", 7, NULL),
2171 "Check element 8 of casted column (2)... ");
2172 test_fvalue(999.0, 0.00001,
2173 cpl_table_get_float(table,
"IntToFloat", 8, NULL),
2174 "Check element 9 of casted column (2)... ");
2175 test_fvalue(999.0, 0.00001,
2176 cpl_table_get_float(table,
"IntToFloat", 9, NULL),
2177 "Check element 10 of casted column (2)... ");
2178 test_fvalue(999.0, 0.00001,
2179 cpl_table_get_float(table,
"IntToFloat", 10, NULL),
2180 "Check element 11 of casted column (2)... ");
2181 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 11),
2182 "Check element 12 of casted column (2)... ");
2183 test_fvalue(3.0, 0.00001,
2184 cpl_table_get_float(table,
"IntToFloat", 12, NULL),
2185 "Check element 13 of casted column (2)... ");
2186 test_fvalue(7.0, 0.00001,
2187 cpl_table_get_float(table,
"IntToFloat", 13, NULL),
2188 "Check element 14 of casted column (2)... ");
2189 test_fvalue(1.0, 0.00001,
2190 cpl_table_get_float(table,
"IntToFloat", 14, NULL),
2191 "Check element 15 of casted column (2)... ");
2192 test_fvalue(4.0, 0.00001,
2193 cpl_table_get_float(table,
"IntToFloat", 15, NULL),
2194 "Check element 16 of casted column (2)... ");
2195 test_fvalue(6.0, 0.00001,
2196 cpl_table_get_float(table,
"IntToFloat", 16, NULL),
2197 "Check element 17 of casted column (2)... ");
2198 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 17),
2199 "Check element 18 of casted column (2)... ");
2200 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 18),
2201 "Check element 19 of casted column (2)... ");
2202 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 19),
2203 "Check element 20 of casted column (2)... ");
2204 test_fvalue(999.0, 0.00001,
2205 cpl_table_get_float(table,
"IntToFloat", 20, NULL),
2206 "Check element 21 of casted column (2)... ");
2207 test_fvalue(999.0, 0.00001,
2208 cpl_table_get_float(table,
"IntToFloat", 21, NULL),
2209 "Check element 22 of casted column (2)... ");
2211 test(cpl_table_shift_column(table,
"IntToFloat", 1),
2212 "Shift new column one position down... ");
2214 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 0),
2215 "Check element 1 of shifted column... ");
2216 test_fvalue(999.0, 0.00001,
2217 cpl_table_get_float(table,
"IntToFloat", 1, NULL),
2218 "Check element 2 of shifted column... ");
2219 test_fvalue(999.0, 0.00001,
2220 cpl_table_get_float(table,
"IntToFloat", 2, NULL),
2221 "Check element 3 of shifted column... ");
2222 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 3),
2223 "Check element 4 of shifted column... ");
2224 test_fvalue(999.0, 0.00001,
2225 cpl_table_get_float(table,
"IntToFloat", 4, NULL),
2226 "Check element 5 of shifted column... ");
2227 test_fvalue(999.0, 0.00001,
2228 cpl_table_get_float(table,
"IntToFloat", 5, NULL),
2229 "Check element 6 of shifted column... ");
2230 test_fvalue(999.0, 0.00001,
2231 cpl_table_get_float(table,
"IntToFloat", 6, NULL),
2232 "Check element 7 of shifted column... ");
2233 test_fvalue(-1.0, 0.00001,
2234 cpl_table_get_float(table,
"IntToFloat", 7, NULL),
2235 "Check element 8 of shifted column... ");
2236 test_fvalue(999.0, 0.00001,
2237 cpl_table_get_float(table,
"IntToFloat", 8, NULL),
2238 "Check element 9 of shifted column... ");
2239 test_fvalue(999.0, 0.00001,
2240 cpl_table_get_float(table,
"IntToFloat", 9, NULL),
2241 "Check element 10 of shifted column... ");
2242 test_fvalue(999.0, 0.00001,
2243 cpl_table_get_float(table,
"IntToFloat", 10, NULL),
2244 "Check element 11 of shifted column... ");
2245 test_fvalue(999.0, 0.00001,
2246 cpl_table_get_float(table,
"IntToFloat", 11, NULL),
2247 "Check element 12 of shifted column... ");
2248 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 12),
2249 "Check element 13 of shifted column... ");
2250 test_fvalue(3.0, 0.00001,
2251 cpl_table_get_float(table,
"IntToFloat", 13, NULL),
2252 "Check element 14 of shifted column... ");
2253 test_fvalue(7.0, 0.00001,
2254 cpl_table_get_float(table,
"IntToFloat", 14, NULL),
2255 "Check element 15 of shifted column... ");
2256 test_fvalue(1.0, 0.00001,
2257 cpl_table_get_float(table,
"IntToFloat", 15, NULL),
2258 "Check element 16 of shifted column... ");
2259 test_fvalue(4.0, 0.00001,
2260 cpl_table_get_float(table,
"IntToFloat", 16, NULL),
2261 "Check element 17 of shifted column... ");
2262 test_fvalue(6.0, 0.00001,
2263 cpl_table_get_float(table,
"IntToFloat", 17, NULL),
2264 "Check element 18 of shifted column... ");
2265 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 18),
2266 "Check element 19 of shifted column... ");
2267 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 19),
2268 "Check element 20 of shifted column... ");
2269 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 20),
2270 "Check element 21 of shifted column... ");
2271 test_fvalue(999.0, 0.00001,
2272 cpl_table_get_float(table,
"IntToFloat", 21, NULL),
2273 "Check element 22 of shifted column... ");
2275 test(cpl_table_add_columns(table,
"Integer",
"IntToFloat"),
2276 "Sum \"IntToFloat\" to \"Integer\"... ");
2279 cpl_table_fill_invalid_int(table,
"Integer", 320);
2280 cpl_table_fill_invalid_int(table,
"AInt", 320);
2281 cpl_table_fill_invalid_int(table,
"New AInt", 320);
2282 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
2283 cpl_table_delete(table);
2284 table = cpl_table_load(
"test_table.tfits", 1, 1);
2287 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 0),
2288 "Check element 1 of \"Integer\" += \"IntToFloat\"... ");
2289 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 1, NULL),
2290 "Check element 2 of \"Integer\" += \"IntToFloat\"... ");
2291 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 2),
2292 "Check element 3 of \"Integer\" += \"IntToFloat\"... ");
2293 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 3),
2294 "Check element 4 of \"Integer\" += \"IntToFloat\"... ");
2295 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 4, NULL),
2296 "Check element 5 of \"Integer\" += \"IntToFloat\"... ");
2297 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 5, NULL),
2298 "Check element 6 of \"Integer\" += \"IntToFloat\"... ");
2299 test_ivalue(998, cpl_table_get_int(table,
"Integer", 6, NULL),
2300 "Check element 7 of \"Integer\" += \"IntToFloat\"... ");
2301 test_ivalue(998, cpl_table_get_int(table,
"Integer", 7, NULL),
2302 "Check element 8 of \"Integer\" += \"IntToFloat\"... ");
2303 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 8, NULL),
2304 "Check element 9 of \"Integer\" += \"IntToFloat\"... ");
2305 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 9, NULL),
2306 "Check element 10 of \"Integer\" += \"IntToFloat\"... ");
2307 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 10, NULL),
2308 "Check element 11 of \"Integer\" += \"IntToFloat\"... ");
2309 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 11),
2310 "Check element 12 of \"Integer\" += \"IntToFloat\"... ");
2311 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 12),
2312 "Check element 13 of \"Integer\" += \"IntToFloat\"... ");
2313 test_ivalue(10, cpl_table_get_int(table,
"Integer", 13, NULL),
2314 "Check element 14 of \"Integer\" += \"IntToFloat\"... ");
2315 test_ivalue(8, cpl_table_get_int(table,
"Integer", 14, NULL),
2316 "Check element 15 of \"Integer\" += \"IntToFloat\"... ");
2317 test_ivalue(5, cpl_table_get_int(table,
"Integer", 15, NULL),
2318 "Check element 16 of \"Integer\" += \"IntToFloat\"... ");
2319 test_ivalue(10, cpl_table_get_int(table,
"Integer", 16, NULL),
2320 "Check element 17 of \"Integer\" += \"IntToFloat\"... ");
2321 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 17),
2322 "Check element 18 of \"Integer\" += \"IntToFloat\"... ");
2323 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 18),
2324 "Check element 19 of \"Integer\" += \"IntToFloat\"... ");
2325 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 19),
2326 "Check element 20 of \"Integer\" += \"IntToFloat\"... ");
2327 test_ivalue(0, cpl_table_is_valid(table,
"Integer", 20),
2328 "Check element 21 of \"Integer\" += \"IntToFloat\"... ");
2329 test_ivalue(1998, cpl_table_get_int(table,
"Integer", 21, NULL),
2330 "Check element 22 of \"Integer\" += \"IntToFloat\"... ");
2332 test(cpl_table_subtract_columns(table,
"Integer",
"IntToFloat"),
2333 "Subtract \"IntToFloat\" from \"Integer\"... ");
2335 test(cpl_table_subtract_columns(table,
"IntToFloat",
"Integer"),
2336 "Subtract \"Integer\" from \"IntToFloat\"... ");
2338 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 0),
2339 "Check element 1 of \"IntToFloat\" -= \"Integer\"... ");
2340 test_fvalue(0.0, 0.00001,
2341 cpl_table_get_float(table,
"IntToFloat", 1, NULL),
2342 "Check element 2 of \"IntToFloat\" -= \"Integer\"... ");
2343 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 2),
2344 "Check element 3 of \"IntToFloat\" -= \"Integer\"... ");
2345 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 3),
2346 "Check element 4 of \"IntToFloat\" -= \"Integer\"... ");
2347 test_fvalue(0.0, 0.00001,
2348 cpl_table_get_float(table,
"IntToFloat", 4, NULL),
2349 "Check element 5 of \"IntToFloat\" -= \"Integer\"... ");
2350 test_fvalue(0.0, 0.00001,
2351 cpl_table_get_float(table,
"IntToFloat", 5, NULL),
2352 "Check element 6 of \"IntToFloat\" -= \"Integer\"... ");
2353 test_fvalue(1000.0, 0.00001,
2354 cpl_table_get_float(table,
"IntToFloat", 6, NULL),
2355 "Check element 7 of \"IntToFloat\" -= \"Integer\"... ");
2356 test_fvalue(-1000.0, 0.00001,
2357 cpl_table_get_float(table,
"IntToFloat", 7, NULL),
2358 "Check element 8 of \"IntToFloat\" -= \"Integer\"... ");
2359 test_fvalue(0.0, 0.00001,
2360 cpl_table_get_float(table,
"IntToFloat", 8, NULL),
2361 "Check element 9 of \"IntToFloat\" -= \"Integer\"... ");
2362 test_fvalue(0.0, 0.00001,
2363 cpl_table_get_float(table,
"IntToFloat", 9, NULL),
2364 "Check element 10 of \"IntToFloat\" -= \"Integer\"... ");
2365 test_fvalue(0.0, 0.00001,
2366 cpl_table_get_float(table,
"IntToFloat", 10, NULL),
2367 "Check element 11 of \"IntToFloat\" -= \"Integer\"... ");
2368 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 11),
2369 "Check element 12 of \"IntToFloat\" -= \"Integer\"... ");
2370 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 12),
2371 "Check element 13 of \"IntToFloat\" -= \"Integer\"... ");
2372 test_fvalue(-4.0, 0.00001,
2373 cpl_table_get_float(table,
"IntToFloat", 13, NULL),
2374 "Check element 14 of \"IntToFloat\" -= \"Integer\"... ");
2375 test_fvalue(6.0, 0.00001,
2376 cpl_table_get_float(table,
"IntToFloat", 14, NULL),
2377 "Check element 15 of \"IntToFloat\" -= \"Integer\"... ");
2378 test_fvalue(-3.0, 0.00001,
2379 cpl_table_get_float(table,
"IntToFloat", 15, NULL),
2380 "Check element 16 of \"IntToFloat\" -= \"Integer\"... ");
2381 test_fvalue(-2.0, 0.00001,
2382 cpl_table_get_float(table,
"IntToFloat", 16, NULL),
2383 "Check element 17 of \"IntToFloat\" -= \"Integer\"... ");
2384 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 17),
2385 "Check element 18 of \"IntToFloat\" -= \"Integer\"... ");
2386 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 18),
2387 "Check element 19 of \"IntToFloat\" -= \"Integer\"... ");
2388 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 19),
2389 "Check element 20 of \"IntToFloat\" -= \"Integer\"... ");
2390 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 20),
2391 "Check element 21 of \"IntToFloat\" -= \"Integer\"... ");
2392 test_fvalue(0.0, 0.00001,
2393 cpl_table_get_float(table,
"IntToFloat", 21, NULL),
2394 "Check element 22 of \"IntToFloat\" -= \"Integer\"... ");
2396 test(cpl_table_multiply_columns(table,
"IntToFloat",
"Double"),
2397 "Multiply double column with float column... ");
2399 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 0),
2400 "Check element 1 of \"IntToFloat\" *= \"Double\"... ");
2401 test_fvalue(0.0, 0.00001,
2402 cpl_table_get_float(table,
"IntToFloat", 1, NULL),
2403 "Check element 2 of \"IntToFloat\" *= \"Double\"... ");
2404 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 2),
2405 "Check element 3 of \"IntToFloat\" *= \"Double\"... ");
2406 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 3),
2407 "Check element 4 of \"IntToFloat\" *= \"Double\"... ");
2408 test_fvalue(0.0, 0.00001,
2409 cpl_table_get_float(table,
"IntToFloat", 4, NULL),
2410 "Check element 5 of \"IntToFloat\" *= \"Double\"... ");
2411 test_fvalue(0.0, 0.00001,
2412 cpl_table_get_float(table,
"IntToFloat", 5, NULL),
2413 "Check element 6 of \"IntToFloat\" *= \"Double\"... ");
2414 test_fvalue(-1110.0, 0.00001,
2415 cpl_table_get_float(table,
"IntToFloat", 6, NULL),
2416 "Check element 7 of \"IntToFloat\" *= \"Double\"... ");
2417 test_fvalue(-999880.0, 0.00001,
2418 cpl_table_get_float(table,
"IntToFloat", 7, NULL),
2419 "Check element 8 of \"IntToFloat\" *= \"Double\"... ");
2420 test_fvalue(0.0, 0.00001,
2421 cpl_table_get_float(table,
"IntToFloat", 8, NULL),
2422 "Check element 9 of \"IntToFloat\" *= \"Double\"... ");
2423 test_fvalue(0.0, 0.00001,
2424 cpl_table_get_float(table,
"IntToFloat", 9, NULL),
2425 "Check element 10 of \"IntToFloat\" *= \"Double\"... ");
2426 test_fvalue(0.0, 0.00001,
2427 cpl_table_get_float(table,
"IntToFloat", 10, NULL),
2428 "Check element 11 of \"IntToFloat\" *= \"Double\"... ");
2429 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 11),
2430 "Check element 12 of \"IntToFloat\" *= \"Double\"... ");
2431 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 12),
2432 "Check element 13 of \"IntToFloat\" *= \"Double\"... ");
2433 test_fvalue(-28.44, 0.00001,
2434 cpl_table_get_float(table,
"IntToFloat", 13, NULL),
2435 "Check element 14 of \"IntToFloat\" *= \"Double\"... ");
2436 test_fvalue(6.66, 0.00001,
2437 cpl_table_get_float(table,
"IntToFloat", 14, NULL),
2438 "Check element 15 of \"IntToFloat\" *= \"Double\"... ");
2439 test_fvalue(-12.33, 0.00001,
2440 cpl_table_get_float(table,
"IntToFloat", 15, NULL),
2441 "Check element 16 of \"IntToFloat\" *= \"Double\"... ");
2442 test_fvalue(-12.22, 0.00001,
2443 cpl_table_get_float(table,
"IntToFloat", 16, NULL),
2444 "Check element 17 of \"IntToFloat\" *= \"Double\"... ");
2445 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 17),
2446 "Check element 18 of \"IntToFloat\" *= \"Double\"... ");
2447 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 18),
2448 "Check element 19 of \"IntToFloat\" *= \"Double\"... ");
2449 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 19),
2450 "Check element 20 of \"IntToFloat\" *= \"Double\"... ");
2451 test_ivalue(0, cpl_table_is_valid(table,
"IntToFloat", 20),
2452 "Check element 21 of \"IntToFloat\" *= \"Double\"... ");
2453 test_fvalue(0.0, 0.00001,
2454 cpl_table_get_float(table,
"IntToFloat", 21, NULL),
2455 "Check element 22 of \"IntToFloat\" *= \"Double\"... ");
2457 test(cpl_table_divide_columns(table,
"Float",
"IntToFloat"),
2458 "Divide float column with float column... ");
2460 test_ivalue(0, cpl_table_is_valid(table,
"Float", 0),
2461 "Check element 1 of \"Float\" /= \"IntToFloat\"... ");
2462 test_ivalue(0, cpl_table_is_valid(table,
"Float", 1),
2463 "Check element 2 of \"Float\" /= \"IntToFloat\"... ");
2464 test_ivalue(0, cpl_table_is_valid(table,
"Float", 2),
2465 "Check element 3 of \"Float\" /= \"IntToFloat\"... ");
2466 test_ivalue(0, cpl_table_is_valid(table,
"Float", 3),
2467 "Check element 4 of \"Float\" /= \"IntToFloat\"... ");
2468 test_ivalue(0, cpl_table_is_valid(table,
"Float", 4),
2469 "Check element 5 of \"Float\" /= \"IntToFloat\"... ");
2470 test_ivalue(0, cpl_table_is_valid(table,
"Float", 5),
2471 "Check element 6 of \"Float\" /= \"IntToFloat\"... ");
2472 test_fvalue(0.000991, 0.0000001,
2473 cpl_table_get_float(table,
"Float", 6, NULL),
2474 "Check element 7 of \"Float\" /= \"IntToFloat\"... ");
2475 test_fvalue(-0.0010001, 0.0000001,
2476 cpl_table_get_float(table,
"Float", 7, NULL),
2477 "Check element 8 of \"Float\" /= \"IntToFloat\"... ");
2478 test_ivalue(0, cpl_table_is_valid(table,
"Float", 8),
2479 "Check element 9 of \"Float\" /= \"IntToFloat\"... ");
2480 test_ivalue(0, cpl_table_is_valid(table,
"Float", 9),
2481 "Check element 10 of \"Float\" /= \"IntToFloat\"... ");
2482 test_ivalue(0, cpl_table_is_valid(table,
"Float", 10),
2483 "Check element 11 of \"Float\" /= \"IntToFloat\"... ");
2484 test_ivalue(0, cpl_table_is_valid(table,
"Float", 11),
2485 "Check element 12 of \"Float\" /= \"IntToFloat\"... ");
2486 test_ivalue(0, cpl_table_is_valid(table,
"Float", 12),
2487 "Check element 13 of \"Float\" /= \"IntToFloat\"... ");
2488 test_fvalue(-0.2496484, 0.0000001,
2489 cpl_table_get_float(table,
"Float", 13, NULL),
2490 "Check element 14 of \"Float\" /= \"IntToFloat\"... ");
2491 test_fvalue(0.1651652, 0.0000001,
2492 cpl_table_get_float(table,
"Float", 14, NULL),
2493 "Check element 15 of \"Float\" /= \"IntToFloat\"... ");
2494 test_fvalue(-0.3325223, 0.0000001,
2495 cpl_table_get_float(table,
"Float", 15, NULL),
2496 "Check element 16 of \"Float\" /= \"IntToFloat\"... ");
2497 test_fvalue(-0.4991817, 0.0000001,
2498 cpl_table_get_float(table,
"Float", 16, NULL),
2499 "Check element 17 of \"Float\" /= \"IntToFloat\"... ");
2500 test_ivalue(0, cpl_table_is_valid(table,
"Float", 17),
2501 "Check element 18 of \"Float\" /= \"IntToFloat\"... ");
2502 test_ivalue(0, cpl_table_is_valid(table,
"Float", 18),
2503 "Check element 19 of \"Float\" /= \"IntToFloat\"... ");
2504 test_ivalue(0, cpl_table_is_valid(table,
"Float", 19),
2505 "Check element 20 of \"Float\" /= \"IntToFloat\"... ");
2506 test_ivalue(0, cpl_table_is_valid(table,
"Float", 20),
2507 "Check element 21 of \"Float\" /= \"IntToFloat\"... ");
2508 test_ivalue(0, cpl_table_is_valid(table,
"Float", 21),
2509 "Check element 22 of \"Float\" /= \"IntToFloat\"... ");
2511 test(cpl_table_add_scalar(table,
"Float", 1),
2512 "Add integer constant to \"Float\"... ");
2514 test_ivalue(0, cpl_table_is_valid(table,
"Float", 0),
2515 "Check element 1 of adding 1 to \"Float\"... ");
2516 test_ivalue(0, cpl_table_is_valid(table,
"Float", 1),
2517 "Check element 2 of adding 1 to \"Float\"... ");
2518 test_ivalue(0, cpl_table_is_valid(table,
"Float", 2),
2519 "Check element 3 of adding 1 to \"Float\"... ");
2520 test_ivalue(0, cpl_table_is_valid(table,
"Float", 3),
2521 "Check element 4 of adding 1 to \"Float\"... ");
2522 test_ivalue(0, cpl_table_is_valid(table,
"Float", 4),
2523 "Check element 5 of adding 1 to \"Float\"... ");
2524 test_ivalue(0, cpl_table_is_valid(table,
"Float", 5),
2525 "Check element 6 of adding 1 to \"Float\"... ");
2526 test_fvalue(1.000991, 0.0000001,
2527 cpl_table_get_float(table,
"Float", 6, NULL),
2528 "Check element 7 of adding 1 to \"Float\"... ");
2529 test_fvalue(1-0.0010001, 0.0000001,
2530 cpl_table_get_float(table,
"Float", 7, NULL),
2531 "Check element 8 of adding 1 to \"Float\"... ");
2532 test_ivalue(0, cpl_table_is_valid(table,
"Float", 8),
2533 "Check element 9 of adding 1 to \"Float\"... ");
2534 test_ivalue(0, cpl_table_is_valid(table,
"Float", 9),
2535 "Check element 10 of adding 1 to \"Float\"... ");
2536 test_ivalue(0, cpl_table_is_valid(table,
"Float", 10),
2537 "Check element 11 of adding 1 to \"Float\"... ");
2538 test_ivalue(0, cpl_table_is_valid(table,
"Float", 11),
2539 "Check element 12 of adding 1 to \"Float\"... ");
2540 test_ivalue(0, cpl_table_is_valid(table,
"Float", 12),
2541 "Check element 13 of adding 1 to \"Float\"... ");
2542 test_fvalue(1-0.2496484, 0.0000001,
2543 cpl_table_get_float(table,
"Float", 13, NULL),
2544 "Check element 14 of adding 1 to \"Float\"... ");
2545 test_fvalue(1.1651652, 0.0000001,
2546 cpl_table_get_float(table,
"Float", 14, NULL),
2547 "Check element 15 of adding 1 to \"Float\"... ");
2548 test_fvalue(1-0.3325223, 0.0000001,
2549 cpl_table_get_float(table,
"Float", 15, NULL),
2550 "Check element 16 of adding 1 to \"Float\"... ");
2551 test_fvalue(1-0.4991817, 0.0000001,
2552 cpl_table_get_float(table,
"Float", 16, NULL),
2553 "Check element 17 of adding 1 to \"Float\"... ");
2554 test_ivalue(0, cpl_table_is_valid(table,
"Float", 17),
2555 "Check element 18 of adding 1 to \"Float\"... ");
2556 test_ivalue(0, cpl_table_is_valid(table,
"Float", 18),
2557 "Check element 19 of adding 1 to \"Float\"... ");
2558 test_ivalue(0, cpl_table_is_valid(table,
"Float", 19),
2559 "Check element 20 of adding 1 to \"Float\"... ");
2560 test_ivalue(0, cpl_table_is_valid(table,
"Float", 20),
2561 "Check element 21 of adding 1 to \"Float\"... ");
2562 test_ivalue(0, cpl_table_is_valid(table,
"Float", 21),
2563 "Check element 22 of adding 1 to \"Float\"... ");
2565 test(cpl_table_set_column_invalid(table,
"Float", 0,
2566 cpl_table_get_nrow(table)),
2567 "Set \"Float\" column to NULL... ");
2569 test_data(copia, cpl_table_duplicate(table),
"Duplicate table... ");
2571 test(cpl_table_erase_invalid_rows(table),
"Pruning table... ");
2573 test_ivalue(18, cpl_table_get_nrow(table),
2574 "Checking table length after pruning... ");
2576 test_ivalue(10, cpl_table_get_ncol(table),
2577 "Checking table width after pruning... ");
2579 test(cpl_table_erase_invalid(copia),
"Cleaning table... ");
2581 test_ivalue(8, cpl_table_get_nrow(copia),
2582 "Checking table length after cleaning... ");
2584 test_ivalue(10, cpl_table_get_ncol(copia),
2585 "Checking table width after cleaning... ");
2587 cpl_table_delete(copia);
2589 test(cpl_table_name_column(table,
"IntToFloat",
"Float"),
2590 "Renaming \"IntToFloat\" to \"Float\"... ");
2592 test(cpl_table_set_column_invalid(table,
"Integer", 7, 2),
2593 "Set NULLs in \"Integer\" column... ");
2595 test(cpl_table_set_invalid(table,
"Float", 7),
2596 "Set NULL in \"Float\" column... ");
2598 test(cpl_table_set_invalid(table,
"Float", 9),
2599 "Set another NULL in \"Float\" column... ");
2601 test(cpl_table_set_invalid(table,
"Double", 7),
2602 "Set NULL in \"Double\" column... ");
2604 test(cpl_table_set_invalid(table,
"String", 7),
2605 "Set NULL in \"String\" column... ");
2607 test(cpl_table_new_column(table,
"Sequence", CPL_TYPE_INT),
2608 "Creating the \"Sequence\" column... ");
2610 for (i = 0; i < 18; i++) {
2611 sprintf(message,
"Writing to row %d of the \"Sequence\" column... ", i);
2612 test(cpl_table_set_int(table,
"Sequence", i, i), message);
2618 names[0] =
"Integer";
2621 uves_propertylist_append_bool(reflist, names[0], 0);
2628 test(uves_table_sort(table, reflist),
2629 "Sorting by increasing values of the \"Integer\" column... ");
2634 cpl_table_fill_invalid_int(table,
"Integer", 320);
2635 cpl_table_fill_invalid_int(table,
"AInt", 320);
2636 cpl_table_fill_invalid_int(table,
"New AInt", 320);
2637 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
2638 cpl_table_delete(table);
2639 table = cpl_table_load(
"test_table.tfits", 1, 1);
2642 test_ivalue(18, cpl_table_get_nrow(table),
2643 "Checking table length after sorting... ");
2645 test_ivalue(11, cpl_table_get_ncol(table),
2646 "Checking table width after sorting... ");
2648 test_ivalue(7, cpl_table_count_invalid(table,
"Integer"),
2649 "Count \"Integer\" NULLs after sorting... ");
2651 test_ivalue(7, cpl_table_count_invalid(table,
"Float"),
2652 "Count \"Float\" NULLs after sorting... ");
2654 test_ivalue(2, cpl_table_count_invalid(table,
"Double"),
2655 "Count \"Double\" NULLs after sorting... ");
2657 test_ivalue(2, cpl_table_count_invalid(table,
"String"),
2658 "Count \"String\" NULLs after sorting... ");
2660 for (i = 0; i < 7; i++) {
2661 sprintf(message,
"Check element %d of sorted \"Integer\"... ", i + 1);
2662 test_ivalue(0, cpl_table_is_valid(table,
"Integer", i), message);
2665 test_ivalue(-1, cpl_table_get_int(table,
"Integer", 7, NULL),
2666 "Check element 7 of sorted \"Integer\"... ");
2668 test_ivalue(1, cpl_table_get_int(table,
"Integer", 8, NULL),
2669 "Check element 8 of sorted \"Integer\"... ");
2671 test_ivalue(4, cpl_table_get_int(table,
"Integer", 9, NULL),
2672 "Check element 9 of sorted \"Integer\"... ");
2674 test_ivalue(6, cpl_table_get_int(table,
"Integer", 10, NULL),
2675 "Check element 10 of sorted \"Integer\"... ");
2677 test_ivalue(7, cpl_table_get_int(table,
"Integer", 11, NULL),
2678 "Check element 11 of sorted \"Integer\"... ");
2680 for (i = 12; i < 18; i++) {
2681 sprintf(message,
"Check element %d of sorted \"Integer\"... ", i + 1);
2682 test_ivalue(999, cpl_table_get_int(table,
"Integer", i, NULL),
2686 test_fvalue(999.88, 0.00001,
2687 cpl_table_get_double(table,
"Double", 0, NULL),
2688 "Check element 1 of sorted \"Double\"... ");
2690 test_fvalue(999.88, 0.00001,
2691 cpl_table_get_double(table,
"Double", 1, NULL),
2692 "Check element 2 of sorted \"Double\"... ");
2694 test_ivalue(0, cpl_table_is_valid(table,
"Double", 2),
2695 "Check element 3 of sorted \"Double\"... ");
2697 test_fvalue(999.88, 0.00001,
2698 cpl_table_get_double(table,
"Double", 3, NULL),
2699 "Check element 4 of sorted \"Double\"... ");
2701 test_fvalue(3.11, 0.00001,
2702 cpl_table_get_double(table,
"Double", 4, NULL),
2703 "Check element 5 of sorted \"Double\"... ");
2705 test_ivalue(0, cpl_table_is_valid(table,
"Double", 5),
2706 "Check element 6 of sorted \"Double\"... ");
2708 test_fvalue(999.88, 0.00001,
2709 cpl_table_get_double(table,
"Double", 6, NULL),
2710 "Check element 7 of sorted \"Double\"... ");
2712 test_fvalue(-1.11, 0.00001,
2713 cpl_table_get_double(table,
"Double", 7, NULL),
2714 "Check element 8 of sorted \"Double\"... ");
2716 test_fvalue(1.11, 0.00001,
2717 cpl_table_get_double(table,
"Double", 8, NULL),
2718 "Check element 9 of sorted \"Double\"... ");
2720 test_fvalue(4.11, 0.00001,
2721 cpl_table_get_double(table,
"Double", 9, NULL),
2722 "Check element 10 of sorted \"Double\"... ");
2724 test_fvalue(6.11, 0.00001,
2725 cpl_table_get_double(table,
"Double", 10, NULL),
2726 "Check element 11 of sorted \"Double\"... ");
2728 test_fvalue(7.11, 0.00001,
2729 cpl_table_get_double(table,
"Double", 11, NULL),
2730 "Check element 12 of sorted \"Double\"... ");
2732 for (i = 12; i < 18; i++) {
2733 sprintf(message,
"Check element %d of sorted \"Double\"... ", i + 1);
2734 test_fvalue(999.88, 0.00001,
2735 cpl_table_get_double(table,
"Double", i, NULL), message);
2738 test_svalue(
"999", cpl_table_get_string(table,
"String", 0),
2739 "Check element 1 of sorted \"String\"... ");
2741 test_svalue(
"999", cpl_table_get_string(table,
"String", 1),
2742 "Check element 2 of sorted \"String\"... ");
2744 test_ivalue(0, cpl_table_is_valid(table,
"String", 2),
2745 "Check element 3 of sorted \"String\"... ");
2747 test_svalue(
"999", cpl_table_get_string(table,
"String", 3),
2748 "Check element 4 of sorted \"String\"... ");
2750 test_svalue(
"baaa", cpl_table_get_string(table,
"String", 4),
2751 "Check element 5 of sorted \"String\"... ");
2753 test_ivalue(0, cpl_table_is_valid(table,
"String", 5),
2754 "Check element 6 of sorted \"String\"... ");
2756 test_svalue(
"999", cpl_table_get_string(table,
"String", 6),
2757 "Check element 7 of sorted \"String\"... ");
2759 test_svalue(
"extra", cpl_table_get_string(table,
"String", 7),
2760 "Check element 8 of sorted \"String\"... ");
2762 test_svalue(
"acde", cpl_table_get_string(table,
"String", 8),
2763 "Check element 9 of sorted \"String\"... ");
2765 test_svalue(
" sss", cpl_table_get_string(table,
"String", 9),
2766 "Check element 10 of sorted \"String\"... ");
2768 test_svalue(
"daaa", cpl_table_get_string(table,
"String", 10),
2769 "Check element 11 of sorted \"String\"... ");
2771 test_svalue(
"aaaa", cpl_table_get_string(table,
"String", 11),
2772 "Check element 11 of sorted \"String\"... ");
2774 for (i = 12; i < 18; i++) {
2775 sprintf(message,
"Check element %d of sorted \"String\"... ", i + 1);
2776 test_svalue(
"999", cpl_table_get_string(table,
"String", i), message);
2780 test_ivalue(0, cpl_table_is_valid(table,
"Float", 0),
2781 "Check element 1 of sorted \"Float\"... ");
2783 test_ivalue(0, cpl_table_is_valid(table,
"Float", 1),
2784 "Check element 2 of sorted \"Float\"... ");
2786 test_ivalue(0, cpl_table_is_valid(table,
"Float", 2),
2787 "Check element 3 of sorted \"Float\"... ");
2789 test_fvalue(0.0, 0.00001, cpl_table_get_float(table,
"Float", 3, NULL),
2790 "Check element 4 of sorted \"Float\"... ");
2792 test_ivalue(0, cpl_table_is_valid(table,
"Float", 4),
2793 "Check element 5 of sorted \"Float\"... ");
2795 test_ivalue(0, cpl_table_is_valid(table,
"Float", 5),
2796 "Check element 6 of sorted \"Float\"... ");
2798 test_ivalue(0, cpl_table_is_valid(table,
"Float", 6),
2799 "Check element 7 of sorted \"Float\"... ");
2801 test_fvalue(-1110.0, 0.00001,
2802 cpl_table_get_float(table,
"Float", 7, NULL),
2803 "Check element 8 of sorted \"Float\"... ");
2805 test_fvalue(6.66, 0.00001,
2806 cpl_table_get_float(table,
"Float", 8, NULL),
2807 "Check element 9 of sorted \"Float\"... ");
2809 test_fvalue(-12.33, 0.00001,
2810 cpl_table_get_float(table,
"Float", 9, NULL),
2811 "Check element 10 of sorted \"Float\"... ");
2813 test_fvalue(-12.22, 0.00001,
2814 cpl_table_get_float(table,
"Float", 10, NULL),
2815 "Check element 11 of sorted \"Float\"... ");
2817 test_fvalue(-28.44, 0.00001,
2818 cpl_table_get_float(table,
"Float", 11, NULL),
2819 "Check element 12 of sorted \"Float\"... ");
2821 test_fvalue(0.0, 0.00001,
2822 cpl_table_get_float(table,
"Float", 12, NULL),
2823 "Check element 13 of sorted \"Float\"... ");
2825 test_fvalue(0.0, 0.00001,
2826 cpl_table_get_float(table,
"Float", 13, NULL),
2827 "Check element 14 of sorted \"Float\"... ");
2829 test_fvalue(0.0, 0.00001,
2830 cpl_table_get_float(table,
"Float", 14, NULL),
2831 "Check element 15 of sorted \"Float\"... ");
2833 test_fvalue(-999880.0, 0.00001,
2834 cpl_table_get_float(table,
"Float", 15, NULL),
2835 "Check element 16 of sorted \"Float\"... ");
2837 test_ivalue(0, cpl_table_is_valid(table,
"Float", 16),
2838 "Check element 17 of sorted \"Float\"... ");
2840 test_fvalue(0.0, 0.00001,
2841 cpl_table_get_float(table,
"Float", 17, NULL),
2842 "Check element 18 of sorted \"Float\"... ");
2844 names[0] =
"Sequence";
2847 uves_propertylist_append_bool(reflist, names[0], 0);
2849 test(uves_table_sort(table, reflist),
"Undo table sorting... ");
2853 names[0] =
"Integer";
2857 uves_propertylist_append_bool(reflist, names[0], 1);
2859 test(uves_table_sort(table, reflist),
2860 "Sorting by decreasing values of the \"Integer\" column... ");
2887 test_fvalue(999.000000, 0.001, cpl_table_get_column_median(table,
"Integer"),
2888 "Median of Integer...");
2889 test_fvalue(0.000000, 0.001, cpl_table_get_column_median(table,
"Float"),
2890 "Median of Float...");
2891 test_fvalue(999.880000, 0.001, cpl_table_get_column_median(table,
"Double"),
2892 "Median of Double...");
2893 test_fvalue(8.000000, 0.001, cpl_table_get_column_median(table,
"Sequence"),
2894 "Median of Sequence...");
2895 test_fvalue(546.454545, 0.001, cpl_table_get_column_mean(table,
"Integer"),
2896 "Mean of Integer...");
2897 test_fvalue(-91003.302727, 0.001, cpl_table_get_column_mean(table,
"Float"),
2898 "Mean of Float...");
2899 test_fvalue(626.202500, 0.001, cpl_table_get_column_mean(table,
"Double"),
2900 "Mean of Double...");
2901 test_fvalue(8.500000, 0.001, cpl_table_get_column_mean(table,
"Sequence"),
2902 "Mean of Sequence...");
2903 test_fvalue(519.939489, 0.001, cpl_table_get_column_stdev(table,
"Integer"),
2904 "Stdev of Integer...");
2905 test_fvalue(301440.480937, 0.001, cpl_table_get_column_stdev(table,
"Float"),
2906 "Stdev of Float...");
2907 test_fvalue(498.239830, 0.001, cpl_table_get_column_stdev(table,
"Double"),
2908 "Stdev of Double...");
2909 test_fvalue(5.338539, 0.001, cpl_table_get_column_stdev(table,
"Sequence"),
2910 "Stdev of Sequence...");
2929 cpl_table_fill_invalid_int(table,
"Integer", 320);
2930 cpl_table_fill_invalid_int(table,
"AInt", 320);
2931 cpl_table_fill_invalid_int(table,
"New AInt", 320);
2932 check_nomsg(cpl_table_save(table, NULL, NULL,
"test_table.tfits", CPL_IO_DEFAULT));
2933 cpl_table_delete(table);
2934 table = cpl_table_load(
"test_table.tfits", 1, 1);
2937 test_ivalue(18, cpl_table_get_nrow(table),
2938 "Checking table length after decreasing sorting... ");
2940 test_ivalue(11, cpl_table_get_ncol(table),
2941 "Checking table width after decreasing sorting... ");
2943 test_ivalue(7, cpl_table_count_invalid(table,
"Integer"),
2944 "Count \"Integer\" NULLs after decreasing sorting... ");
2946 test_ivalue(7, cpl_table_count_invalid(table,
"Float"),
2947 "Count \"Float\" NULLs after decreasing sorting... ");
2949 test_ivalue(2, cpl_table_count_invalid(table,
"Double"),
2950 "Count \"Double\" NULLs after decreasing sorting... ");
2952 test_ivalue(2, cpl_table_count_invalid(table,
"String"),
2953 "Count \"String\" NULLs after decreasing sorting... ");
2955 for (i = 0; i < 7; i++) {
2956 sprintf(message,
"Check element %d of sorted \"Integer\"... ", i + 1);
2957 test_ivalue(0, cpl_table_is_valid(table,
"Integer", i), message);
2960 for (i = 7; i < 13; i++) {
2961 sprintf(message,
"Check element %d of sorted \"Integer\"... ", i + 1);
2962 test_ivalue(999, cpl_table_get_int(table,
"Integer", i, NULL),
2966 test_ivalue(7, cpl_table_get_int(table,
"Integer", 13, NULL),
2967 "Check element 13 of sorted \"Integer\"... ");
2969 test_ivalue(6, cpl_table_get_int(table,
"Integer", 14, NULL),
2970 "Check element 14 of sorted \"Integer\"... ");
2972 test_ivalue(4, cpl_table_get_int(table,
"Integer", 15, NULL),
2973 "Check element 15 of sorted \"Integer\"... ");
2975 test_ivalue(1, cpl_table_get_int(table,
"Integer", 16, NULL),
2976 "Check element 16 of sorted \"Integer\"... ");
2978 test_ivalue(-1, cpl_table_get_int(table,
"Integer", 17, NULL),
2979 "Check element 17 of sorted \"Integer\"... ");
2982 test_fvalue(999.88, 0.00001,
2983 cpl_table_get_double(table,
"Double", 0, NULL),
2984 "Check element 1 of sorted \"Double\"... ");
2986 test_fvalue(999.88, 0.00001,
2987 cpl_table_get_double(table,
"Double", 1, NULL),
2988 "Check element 2 of sorted \"Double\"... ");
2990 test_ivalue(0, cpl_table_is_valid(table,
"Double", 2),
2991 "Check element 3 of sorted \"Double\"... ");
2993 test_fvalue(999.88, 0.00001,
2994 cpl_table_get_double(table,
"Double", 3, NULL),
2995 "Check element 4 of sorted \"Double\"... ");
2997 test_fvalue(3.11, 0.00001,
2998 cpl_table_get_double(table,
"Double", 4, NULL),
2999 "Check element 5 of sorted \"Double\"... ");
3001 test_ivalue(0, cpl_table_is_valid(table,
"Double", 5),
3002 "Check element 6 of sorted \"Double\"... ");
3004 test_fvalue(999.88, 0.00001,
3005 cpl_table_get_double(table,
"Double", 6, NULL),
3006 "Check element 7 of sorted \"Double\"... ");
3008 for (i = 7; i < 13; i++) {
3009 sprintf(message,
"Check element %d of sorted \"Double\"... ", i + 1);
3010 test_fvalue(999.88, 0.00001,
3011 cpl_table_get_double(table,
"Double", i, NULL), message);
3014 test_fvalue(7.11, 0.00001,
3015 cpl_table_get_double(table,
"Double", 13, NULL),
3016 "Check element 14 of sorted \"Double\"... ");
3018 test_fvalue(6.11, 0.00001,
3019 cpl_table_get_double(table,
"Double", 14, NULL),
3020 "Check element 15 of sorted \"Double\"... ");
3022 test_fvalue(4.11, 0.00001,
3023 cpl_table_get_double(table,
"Double", 15, NULL),
3024 "Check element 16 of sorted \"Double\"... ");
3026 test_fvalue(1.11, 0.00001,
3027 cpl_table_get_double(table,
"Double", 16, NULL),
3028 "Check element 17 of sorted \"Double\"... ");
3030 test_fvalue(-1.11, 0.00001,
3031 cpl_table_get_double(table,
"Double", 17, NULL),
3032 "Check element 18 of sorted \"Double\"... ");
3035 test_svalue(
"999", cpl_table_get_string(table,
"String", 0),
3036 "Check element 1 of sorted \"String\"... ");
3038 test_svalue(
"999", cpl_table_get_string(table,
"String", 1),
3039 "Check element 2 of sorted \"String\"... ");
3041 test_ivalue(0, cpl_table_is_valid(table,
"String", 2),
3042 "Check element 3 of sorted \"String\"... ");
3044 test_svalue(
"999", cpl_table_get_string(table,
"String", 3),
3045 "Check element 4 of sorted \"String\"... ");
3047 test_svalue(
"baaa", cpl_table_get_string(table,
"String", 4),
3048 "Check element 5 of sorted \"String\"... ");
3050 test_ivalue(0, cpl_table_is_valid(table,
"String", 5),
3051 "Check element 6 of sorted \"String\"... ");
3053 test_svalue(
"999", cpl_table_get_string(table,
"String", 6),
3054 "Check element 7 of sorted \"String\"... ");
3056 for (i = 7; i < 13; i++) {
3057 sprintf(message,
"Check element %d of sorted \"String\"... ", i + 1);
3058 test_svalue(
"999", cpl_table_get_string(table,
"String", i), message);
3061 test_svalue(
"aaaa", cpl_table_get_string(table,
"String", 13),
3062 "Check element 14 of sorted \"String\"... ");
3064 test_svalue(
"daaa", cpl_table_get_string(table,
"String", 14),
3065 "Check element 15 of sorted \"String\"... ");
3067 test_svalue(
" sss", cpl_table_get_string(table,
"String", 15),
3068 "Check element 16 of sorted \"String\"... ");
3070 test_svalue(
"acde", cpl_table_get_string(table,
"String", 16),
3071 "Check element 17 of sorted \"String\"... ");
3073 test_svalue(
"extra", cpl_table_get_string(table,
"String", 17),
3074 "Check element 18 of sorted \"String\"... ");
3077 test_ivalue(0, cpl_table_is_valid(table,
"Float", 0),
3078 "Check element 1 of sorted \"Float\"... ");
3080 test_ivalue(0, cpl_table_is_valid(table,
"Float", 1),
3081 "Check element 2 of sorted \"Float\"... ");
3083 test_ivalue(0, cpl_table_is_valid(table,
"Float", 2),
3084 "Check element 3 of sorted \"Float\"... ");
3086 test_fvalue(0.0, 0.00001, cpl_table_get_float(table,
"Float", 3, NULL),
3087 "Check element 4 of sorted \"Float\"... ");
3089 test_ivalue(0, cpl_table_is_valid(table,
"Float", 4),
3090 "Check element 5 of sorted \"Float\"... ");
3092 test_ivalue(0, cpl_table_is_valid(table,
"Float", 5),
3093 "Check element 6 of sorted \"Float\"... ");
3095 test_ivalue(0, cpl_table_is_valid(table,
"Float", 6),
3096 "Check element 7 of sorted \"Float\"... ");
3098 test_fvalue(0.0, 0.00001,
3099 cpl_table_get_float(table,
"Float", 7, NULL),
3100 "Check element 8 of sorted \"Float\"... ");
3102 test_fvalue(0.0, 0.00001,
3103 cpl_table_get_float(table,
"Float", 8, NULL),
3104 "Check element 9 of sorted \"Float\"... ");
3106 test_fvalue(0.0, 0.00001,
3107 cpl_table_get_float(table,
"Float", 9, NULL),
3108 "Check element 10 of sorted \"Float\"... ");
3110 test_fvalue(-999880.0, 0.00001,
3111 cpl_table_get_float(table,
"Float", 10, NULL),
3112 "Check element 11 of sorted \"Float\"... ");
3114 test_ivalue(0, cpl_table_is_valid(table,
"Float", 11),
3115 "Check element 12 of sorted \"Float\"... ");
3117 test_fvalue(0.0, 0.00001,
3118 cpl_table_get_float(table,
"Float", 12, NULL),
3119 "Check element 13 of sorted \"Float\"... ");
3121 test_fvalue(-28.44, 0.00001,
3122 cpl_table_get_float(table,
"Float", 13, NULL),
3123 "Check element 14 of sorted \"Float\"... ");
3125 test_fvalue(-12.22, 0.00001,
3126 cpl_table_get_float(table,
"Float", 14, NULL),
3127 "Check element 15 of sorted \"Float\"... ");
3129 test_fvalue(-12.33, 0.00001,
3130 cpl_table_get_float(table,
"Float", 15, NULL),
3131 "Check element 16 of sorted \"Float\"... ");
3133 test_fvalue(6.66, 0.00001,
3134 cpl_table_get_float(table,
"Float", 16, NULL),
3135 "Check element 17 of sorted \"Float\"... ");
3137 test_fvalue(-1110.0, 0.00001,
3138 cpl_table_get_float(table,
"Float", 17, NULL),
3139 "Check element 18 of sorted \"Float\"... ");
3141 cpl_table_delete(table);
3150 table = cpl_table_new(nrows);
3151 cpl_table_new_column(table,
"Int", CPL_TYPE_INT);
3152 cpl_table_new_column(table,
"Float", CPL_TYPE_FLOAT);
3153 cpl_table_new_column(table,
"Double", CPL_TYPE_DOUBLE);
3155 for (i = 0; i < nrows; i++) {
3156 cpl_table_set_int(table,
"Int", i, i);
3157 cpl_table_set_float(table,
"Float", i, i);
3158 cpl_table_set_double(table,
"Double", i, i);
3161 cpl_table_exponential_column(table,
"Int", 2);
3162 cpl_table_exponential_column(table,
"Float", 2);
3163 cpl_table_exponential_column(table,
"Double", 2);
3166 for (i = 0; i < nrows; i++) {
3167 test_ivalue(pp, cpl_table_get_int(table,
3168 "Int", i, NULL),
"Check expo Int... ");
3169 test_fvalue((
float)pp, 0.00001, cpl_table_get_float(table,
3170 "Float", i, NULL),
"Check expo Float... ");
3171 test_fvalue((
float)pp, 0.00001, cpl_table_get_double(table,
3172 "Double", i, NULL),
"Check expo Double... ");
3176 cpl_table_logarithm_column(table,
"Int", 2);
3177 cpl_table_logarithm_column(table,
"Float", 2);
3178 cpl_table_logarithm_column(table,
"Double", 2);
3180 for (i = 0; i < nrows; i++) {
3181 test_ivalue(i, cpl_table_get_int(table,
3182 "Int", i, NULL),
"Check log Int... ");
3183 test_fvalue((
float)i, 0.00001, cpl_table_get_float(table,
3184 "Float", i, NULL),
"Check log Float... ");
3185 test_fvalue((
float)i, 0.00001, cpl_table_get_double(table,
3186 "Double", i, NULL),
"Check log Double... ");
3189 cpl_table_power_column(table,
"Int", 2);
3190 cpl_table_power_column(table,
"Float", 2);
3191 cpl_table_power_column(table,
"Double", 2);
3193 for (i = 0; i < nrows; i++) {
3194 test_ivalue(i*i, cpl_table_get_int(table,
3195 "Int", i, NULL),
"Check pow Int... ");
3196 test_fvalue((
float)i*i, 0.00001, cpl_table_get_float(table,
3197 "Float", i, NULL),
"Check pow Float... ");
3198 test_fvalue((
float)i*i, 0.00001, cpl_table_get_double(table,
3199 "Double", i, NULL),
"Check pow Double... ");
3202 cpl_table_power_column(table,
"Int", 0.5);
3203 cpl_table_power_column(table,
"Float", 0.5);
3204 cpl_table_power_column(table,
"Double", 0.5);
3206 for (i = 0; i < nrows; i++) {
3207 test_ivalue(i, cpl_table_get_int(table,
3208 "Int", i, NULL),
"Check sqrt Int... ");
3209 test_fvalue((
float)i, 0.00001, cpl_table_get_float(table,
3210 "Float", i, NULL),
"Check sqrt Float... ");
3211 test_fvalue((
float)i, 0.00001, cpl_table_get_double(table,
3212 "Double", i, NULL),
"Check sqrt Double... ");
3215 cpl_table_delete(table);
3224 table = cpl_table_new(nrows);
3225 cpl_table_new_column(table,
"Int", CPL_TYPE_INT);
3226 cpl_table_new_column(table,
"String", CPL_TYPE_STRING);
3228 unit =
"abcd\0efgh\0ijkl\0mnop\0qrst\0uvwx\0yz";
3230 for (i = 0; i < nrows; i++) {
3231 cpl_table_set_int(table,
"Int", i, i);
3232 cpl_table_set_string(table,
"String", i, unit + i*5);
3235 cpl_table_duplicate_column(table,
"Int2", table,
"Int");
3236 cpl_table_multiply_columns(table,
"Int2",
"Int2");
3237 cpl_table_cast_column(table,
"Int",
"Float", CPL_TYPE_FLOAT);
3241 printf(
"\nThis is the test table:\n\n");
3242 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3244 printf(
"\nNow erase all selected:\n\n");
3248 copia = cpl_table_duplicate(table);
3249 test_ivalue(7, cpl_table_count_selected(copia),
"Check all selected... ");
3250 cpl_table_erase_selected(copia);
3252 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3254 test_ivalue(0, cpl_table_get_nrow(copia),
3255 "Check length erase all selected... ");
3256 cpl_table_delete(copia);
3260 printf(
"\nThis is the test table:\n\n");
3261 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3263 printf(
"\nNow delete all Int >= Int2:\n\n");
3267 copia = cpl_table_duplicate(table);
3268 cpl_table_and_selected(copia,
"Int", CPL_NOT_LESS_THAN,
"Int2");
3269 test_ivalue(2, cpl_table_count_selected(copia),
3270 "Check Int >= Int2 selected... ");
3271 cpl_table_erase_selected(copia);
3273 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3275 test_ivalue(5, cpl_table_get_nrow(copia),
3276 "Check length erase all Int >= Int2... ");
3277 cpl_table_delete(copia);
3281 printf(
"\nThis is the test table:\n\n");
3282 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3284 printf(
"\nNow delete all Int > 3:\n\n");
3288 copia = cpl_table_duplicate(table);
3289 cpl_table_and_selected_int(copia,
"Int", CPL_GREATER_THAN, 3);
3290 test_ivalue(3, cpl_table_count_selected(copia),
3291 "Check Int > 3 selected... ");
3292 cpl_table_erase_selected(copia);
3294 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3296 test_ivalue(4, cpl_table_get_nrow(copia),
3297 "Check length erase all Int > 3... ");
3298 cpl_table_delete(copia);
3302 printf(
"\nThis is the test table:\n\n");
3303 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3305 printf(
"\nNow delete all Int2 > Float:\n\n");
3309 copia = cpl_table_duplicate(table);
3310 cpl_table_and_selected(copia,
"Int2", CPL_GREATER_THAN,
"Float");
3311 test_ivalue(5, cpl_table_count_selected(copia),
3312 "Check Int2 > Float selected... ");
3313 cpl_table_erase_selected(copia);
3315 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3317 test_ivalue(2, cpl_table_get_nrow(copia),
3318 "Check length erase all Int2 > Float... ");
3319 cpl_table_delete(copia);
3323 printf(
"\nThis is the test table:\n\n");
3324 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3326 printf(
"\nNow delete all String == \"^[a-l].*\":\n\n");
3330 copia = cpl_table_duplicate(table);
3331 cpl_table_and_selected_string(copia,
"String", CPL_EQUAL_TO,
"^[a-l].*");
3332 test_ivalue(3, cpl_table_count_selected(copia),
3333 "Check String == \"^[a-l].*\" selected... ");
3334 cpl_table_erase_selected(copia);
3336 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3338 test_ivalue(4, cpl_table_get_nrow(copia),
3339 "Check length erase all String == \"^[a-l].*\"... ");
3340 cpl_table_delete(copia);
3344 printf(
"\nThis is the test table:\n\n");
3345 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3347 printf(
"\nNow delete all String > \"carlo\":\n\n");
3351 copia = cpl_table_duplicate(table);
3352 cpl_table_and_selected_string(copia,
"String", CPL_GREATER_THAN,
"carlo");
3353 test_ivalue(6, cpl_table_count_selected(copia),
3354 "Check String > \"carlo\" selected... ");
3355 cpl_table_erase_selected(copia);
3357 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3359 test_ivalue(1, cpl_table_get_nrow(copia),
3360 "Check length erase all String > \"carlo\"... ");
3361 cpl_table_delete(copia);
3365 printf(
"\nThis is the test table:\n\n");
3366 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3368 printf(
"\nNow delete all String > \"tattoo\" and Int == 3:\n\n");
3372 copia = cpl_table_duplicate(table);
3373 cpl_table_and_selected_string(copia,
"String", CPL_GREATER_THAN,
"tattoo");
3374 cpl_table_or_selected_int(copia,
"Int", CPL_EQUAL_TO, 3);
3375 test_ivalue(3, cpl_table_count_selected(copia),
3376 "Check String > \"tattoo\" and Int == 3 selected... ");
3377 cpl_table_erase_selected(copia);
3379 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3381 test_ivalue(4, cpl_table_get_nrow(copia),
3382 "Check length erase all String > \"tattoo\" and Int == 3... ");
3383 cpl_table_delete(copia);
3387 printf(
"\nNow keep all String > \"tattoo\" and Int == 3:\n\n");
3391 copia = cpl_table_duplicate(table);
3392 cpl_table_and_selected_string(copia,
"String", CPL_GREATER_THAN,
"tattoo");
3393 cpl_table_or_selected_int(copia,
"Int", CPL_EQUAL_TO, 3);
3394 cpl_table_not_selected(copia);
3395 test_ivalue(4, cpl_table_count_selected(copia),
3396 "Check String > \"tattoo\" and Int == 3 rejected... ");
3397 cpl_table_erase_selected(copia);
3399 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3401 test_ivalue(3, cpl_table_get_nrow(copia),
3402 "Check length keep all String > \"tattoo\" and Int == 3... ");
3403 cpl_table_delete(copia);
3407 printf(
"\nThis is the test table:\n\n");
3408 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3410 printf(
"\nNow delete rows 0, 2, and 6:\n\n");
3414 copia = cpl_table_duplicate(table);
3415 cpl_table_unselect_all(copia);
3416 cpl_table_select_row(copia, 0);
3417 cpl_table_select_row(copia, 2);
3418 cpl_table_select_row(copia, 6);
3419 test_ivalue(3, cpl_table_count_selected(copia),
3420 "Check rows 0, 2, and 6 selected... ");
3421 cpl_table_erase_selected(copia);
3423 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3425 test_ivalue(4, cpl_table_get_nrow(copia),
3426 "Check length erase rows 0, 2, and 6... ");
3427 cpl_table_delete(copia);
3431 printf(
"\nNow keep rows 0, 2, and 6:\n\n");
3435 copia = cpl_table_duplicate(table);
3436 cpl_table_unselect_row(copia, 0);
3437 cpl_table_unselect_row(copia, 2);
3438 cpl_table_unselect_row(copia, 6);
3439 test_ivalue(4, cpl_table_count_selected(copia),
3440 "Check rows 0, 2, and 6 rejected... ");
3441 cpl_table_erase_selected(copia);
3443 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3445 test_ivalue(3, cpl_table_get_nrow(copia),
3446 "Check length erase rows 0, 2, and 6... ");
3447 cpl_table_delete(copia);
3451 printf(
"\nThis is the test table:\n\n");
3452 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3454 printf(
"\nNow delete first 3 rows:\n\n");
3458 copia = cpl_table_duplicate(table);
3459 cpl_table_and_selected_window(copia, 0, 3);
3460 test_ivalue(3, cpl_table_count_selected(copia),
3461 "Check first 3 rows selected... ");
3462 cpl_table_erase_selected(copia);
3464 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3466 test_ivalue(4, cpl_table_get_nrow(copia),
3467 "Check length erase first 3 rows... ");
3468 cpl_table_delete(copia);
3472 printf(
"\nNow delete last 2 rows:\n\n");
3476 copia = cpl_table_duplicate(table);
3477 cpl_table_and_selected_window(copia, 5, 2);
3478 test_ivalue(2, cpl_table_count_selected(copia),
3479 "Check last 2 rows selected... ");
3480 cpl_table_erase_selected(copia);
3482 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3484 test_ivalue(5, cpl_table_get_nrow(copia),
3485 "Check length erase last 2 rows... ");
3486 cpl_table_delete(copia);
3490 printf(
"\nNow delete rows from 2 to 3:\n\n");
3494 copia = cpl_table_duplicate(table);
3495 cpl_table_and_selected_window(copia, 2, 2);
3496 test_ivalue(2, cpl_table_count_selected(copia),
3497 "Check middle 2 rows selected... ");
3498 cpl_table_erase_selected(copia);
3500 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3502 test_ivalue(5, cpl_table_get_nrow(copia),
3503 "Check length erase rows from 2 to 3... ");
3504 cpl_table_delete(copia);
3508 printf(
"\nNow delete rows from 1 to 3 and row 6:\n\n");
3512 copia = cpl_table_duplicate(table);
3513 cpl_table_and_selected_window(copia, 1, 3);
3514 cpl_table_or_selected_window(copia, 6, 1);
3515 test_ivalue(4, cpl_table_count_selected(copia),
3516 "Check rows 1 to 3 and row 6 rejected... ");
3517 cpl_table_erase_selected(copia);
3519 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3521 test_ivalue(3, cpl_table_get_nrow(copia),
3522 "Check length erase rows from 1 to 3 and row 6... ");
3523 cpl_table_delete(copia);
3526 copia = cpl_table_duplicate(table);
3527 for (i = 0; i < nrows; i++) {
3528 cpl_table_set_invalid(copia,
"Int", i);
3531 cpl_table_unselect_row(copia, nrows-1);
3533 cpl_table_erase_selected(copia);
3535 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3537 test_ivalue(1, cpl_table_get_nrow(copia),
3538 "Check length erase last row, only invalid values... ");
3539 cpl_table_delete(copia);
3542 copia = cpl_table_duplicate(table);
3544 cpl_table_cast_column(copia,
"Int",
"Double", CPL_TYPE_DOUBLE);
3546 test(cpl_table_new_column_array(copia,
"ADouble",
3547 CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, 2),
3548 "Creating the ArrayDouble column... ");
3550 array = cpl_array_new(2, CPL_TYPE_DOUBLE);
3551 test(cpl_table_set_array(copia,
"ADouble", 1, array),
3552 "Set a valid array to ADouble 1... ");
3553 test(cpl_table_set_array(copia,
"ADouble", 2, array),
3554 "Set a valid array to ADouble 2... ");
3555 cpl_array_delete(array);
3557 cpl_table_unselect_row(copia, 0);
3558 cpl_table_unselect_row(copia, 2);
3559 cpl_table_set_invalid(copia,
"Int", 6);
3560 cpl_table_set_invalid(copia,
"Int2", 0);
3561 cpl_table_set_invalid(copia,
"Int2", 1);
3562 cpl_table_set_invalid(copia,
"Double", 0);
3563 cpl_table_set_invalid(copia,
"Double", 1);
3565 cpl_table_erase_selected(copia);
3567 cpl_table_dump(copia, 0, cpl_table_get_nrow(copia), NULL);
3569 test_ivalue(2, cpl_table_get_nrow(copia),
3570 "Check length erase valid/invalid values... ");
3571 test_ivalue(0, cpl_table_is_valid(copia,
"Int2", 0),
3572 "Check that first element of \"Int2\" is still NULL... ");
3573 test_ivalue(1, cpl_table_is_valid(copia,
"Int2", 1),
3574 "Check that first element of \"Int2\" is now valid... ");
3576 cpl_table_unselect_row(copia, 0);
3577 cpl_table_unselect_row(copia, 1);
3578 cpl_table_erase_selected(copia);
3579 test_ivalue(2, cpl_table_count_selected(copia),
3580 "Check that rows are selected... ");
3582 cpl_table_delete(copia);
3584 cpl_table_delete(table);
3588 table = cpl_table_new(4);
3589 cpl_table_new_column(table,
"S", CPL_TYPE_STRING);
3590 cpl_table_new_column(table,
"D", CPL_TYPE_DOUBLE);
3592 cpl_table_set_double(table,
"D", 0, 43.04);
3593 cpl_table_set_double(table,
"D", 1, 43.04);
3594 cpl_table_set_double(table,
"D", 2, 43.04);
3595 cpl_table_set_double(table,
"D", 3, 43.04);
3596 cpl_table_set_invalid(table,
"D", 3);
3598 cpl_table_set_string(table,
"S", 0,
"type");
3599 cpl_table_set_string(table,
"S", 1,
"type");
3600 cpl_table_set_string(table,
"S", 2,
"type");
3601 cpl_table_set_string(table,
"S", 3,
"type");
3602 cpl_table_set_invalid(table,
"S", 1);
3605 cpl_table_dump(table, 0, 4, stdout);
3608 cpl_table_select_all(table);
3609 test_ivalue(4, cpl_table_count_selected(table),
"A...");
3610 cpl_table_and_selected_invalid(table,
"D");
3611 test_ivalue(1, cpl_table_count_selected(table),
"B...");
3613 cpl_table_select_all(table);
3614 test_ivalue(4, cpl_table_count_selected(table),
"C...");
3617 uves_table_and_selected_invalid(table,
"S");
3619 test_ivalue(1, cpl_table_count_selected(table),
"D...");
3621 cpl_table_delete(table);
3630 table = cpl_table_new(nrows);
3631 cpl_table_new_column(table,
"Int", CPL_TYPE_INT);
3633 for (i = 0; i < nrows; i++)
3634 cpl_table_set_int(table,
"Int", i, i + 1);
3636 cpl_table_cast_column(table,
"Int",
"Double", CPL_TYPE_DOUBLE);
3638 test(cpl_table_divide_columns(table,
"Double",
"Int"),
3639 "Divide double column with integer column... ");
3641 for (i = 0; i < nrows; i++) {
3642 sprintf(message,
"Check element %d of result column... ", i);
3643 test_fvalue(1.0, 0.00001, cpl_table_get_double(table,
"Double", i, NULL),
3648 cpl_table_dump(table, 0, cpl_table_get_nrow(table), NULL);
3651 cpl_table_delete(table);
3667 return cpl_error_get_code();
3681 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
3684 uves_find_property_test();
3685 uves_average_reject_test();
3686 uves_polynomial_fit_2d_test();
3690 return cpl_test_end(0);