Commit 1bbf2f8cd044afda325fd36a6cfdbd1d46ff9f78
1 parent
36f27ad0
use absolute values in unsigned tests
Showing
1 changed file
with
11 additions
and
11 deletions
test/test_GFits.cpp
| @@ -1352,7 +1352,7 @@ void test_bintable_ushort(void) | @@ -1352,7 +1352,7 @@ void test_bintable_ushort(void) | ||
| 1352 | 1352 | ||
| 1353 | // Dump header | 1353 | // Dump header |
| 1354 | std::cout << "Test GFitsTableUShortCol: "; | 1354 | std::cout << "Test GFitsTableUShortCol: "; |
| 1355 | - | 1355 | + |
| 1356 | // Remove FITS file | 1356 | // Remove FITS file |
| 1357 | std::string cmd = "rm -rf "+ filename; | 1357 | std::string cmd = "rm -rf "+ filename; |
| 1358 | system(cmd.c_str()); | 1358 | system(cmd.c_str()); |
| @@ -1390,7 +1390,7 @@ void test_bintable_ushort(void) | @@ -1390,7 +1390,7 @@ void test_bintable_ushort(void) | ||
| 1390 | // Set table | 1390 | // Set table |
| 1391 | GFitsTableUShortCol col_sht = GFitsTableUShortCol("USHORT", nrows); | 1391 | GFitsTableUShortCol col_sht = GFitsTableUShortCol("USHORT", nrows); |
| 1392 | for (int i = 0; i < nrows; ++i) { | 1392 | for (int i = 0; i < nrows; ++i) { |
| 1393 | - unsigned short val_sht = (unsigned short)(1000.0 * cos(0.1*float(i))); | 1393 | + unsigned short val_sht = (unsigned short)abs(1000.0 * cos(0.1*float(i))); |
| 1394 | col_sht(i) = val_sht; | 1394 | col_sht(i) = val_sht; |
| 1395 | sum_sht += val_sht; | 1395 | sum_sht += val_sht; |
| 1396 | sum_sht_int += int(val_sht); | 1396 | sum_sht_int += int(val_sht); |
| @@ -1454,7 +1454,7 @@ void test_bintable_ushort(void) | @@ -1454,7 +1454,7 @@ void test_bintable_ushort(void) | ||
| 1454 | GFitsTableUShortCol col_sht10 = GFitsTableUShortCol("USHORT10", nrows, nvec); | 1454 | GFitsTableUShortCol col_sht10 = GFitsTableUShortCol("USHORT10", nrows, nvec); |
| 1455 | for (int i = 0; i < nrows; ++i) { | 1455 | for (int i = 0; i < nrows; ++i) { |
| 1456 | for (int j = 0; j < nvec; ++j) { | 1456 | for (int j = 0; j < nvec; ++j) { |
| 1457 | - unsigned short val_sht = | 1457 | + unsigned short val_sht = |
| 1458 | (unsigned short)(abs(100.0*cos(0.1*float(i))*cos(0.33*float(j)))); | 1458 | (unsigned short)(abs(100.0*cos(0.1*float(i))*cos(0.33*float(j)))); |
| 1459 | col_sht10(i,j) = val_sht; | 1459 | col_sht10(i,j) = val_sht; |
| 1460 | sum_sht10 += val_sht; | 1460 | sum_sht10 += val_sht; |
| @@ -2433,7 +2433,7 @@ void test_bintable_ulong(void) | @@ -2433,7 +2433,7 @@ void test_bintable_ulong(void) | ||
| 2433 | 2433 | ||
| 2434 | // Dump header | 2434 | // Dump header |
| 2435 | std::cout << "Test GFitsTableULongCol: "; | 2435 | std::cout << "Test GFitsTableULongCol: "; |
| 2436 | - | 2436 | + |
| 2437 | // Remove FITS file | 2437 | // Remove FITS file |
| 2438 | std::string cmd = "rm -rf "+ filename; | 2438 | std::string cmd = "rm -rf "+ filename; |
| 2439 | system(cmd.c_str()); | 2439 | system(cmd.c_str()); |
| @@ -2471,7 +2471,7 @@ void test_bintable_ulong(void) | @@ -2471,7 +2471,7 @@ void test_bintable_ulong(void) | ||
| 2471 | // Set table | 2471 | // Set table |
| 2472 | GFitsTableULongCol col_lng = GFitsTableULongCol("ULONG", nrows); | 2472 | GFitsTableULongCol col_lng = GFitsTableULongCol("ULONG", nrows); |
| 2473 | for (int i = 0; i < nrows; ++i) { | 2473 | for (int i = 0; i < nrows; ++i) { |
| 2474 | - unsigned long val_lng = (unsigned long)(100000.0 * cos(0.1*float(i))); | 2474 | + unsigned long val_lng = (unsigned long)abs(100000.0 * cos(0.1*float(i))); |
| 2475 | col_lng(i) = val_lng; | 2475 | col_lng(i) = val_lng; |
| 2476 | sum_lng += val_lng; | 2476 | sum_lng += val_lng; |
| 2477 | sum_lng_int += int(val_lng); | 2477 | sum_lng_int += int(val_lng); |
| @@ -2535,8 +2535,8 @@ void test_bintable_ulong(void) | @@ -2535,8 +2535,8 @@ void test_bintable_ulong(void) | ||
| 2535 | GFitsTableULongCol col_lng10 = GFitsTableULongCol("ULONG10", nrows, nvec); | 2535 | GFitsTableULongCol col_lng10 = GFitsTableULongCol("ULONG10", nrows, nvec); |
| 2536 | for (int i = 0; i < nrows; ++i) { | 2536 | for (int i = 0; i < nrows; ++i) { |
| 2537 | for (int j = 0; j < nvec; ++j) { | 2537 | for (int j = 0; j < nvec; ++j) { |
| 2538 | - unsigned long val_lng = (unsigned long)(1000.0*cos(0.1*float(i))* | ||
| 2539 | - cos(0.33*float(j))); | 2538 | + unsigned long val_lng = (unsigned long)abs(1000.0*cos(0.1*float(i))* |
| 2539 | + cos(0.33*float(j))); | ||
| 2540 | col_lng10(i,j) = val_lng; | 2540 | col_lng10(i,j) = val_lng; |
| 2541 | sum_lng10 += val_lng; | 2541 | sum_lng10 += val_lng; |
| 2542 | sum_lng10_int += int(val_lng); | 2542 | sum_lng10_int += int(val_lng); |
| @@ -2793,7 +2793,7 @@ void test_bintable_string(void) | @@ -2793,7 +2793,7 @@ void test_bintable_string(void) | ||
| 2793 | 2793 | ||
| 2794 | // Dump header | 2794 | // Dump header |
| 2795 | std::cout << "Test GFitsTableStringCol: "; | 2795 | std::cout << "Test GFitsTableStringCol: "; |
| 2796 | - | 2796 | + |
| 2797 | // Remove FITS file | 2797 | // Remove FITS file |
| 2798 | std::string cmd = "rm -rf "+ filename; | 2798 | std::string cmd = "rm -rf "+ filename; |
| 2799 | system(cmd.c_str()); | 2799 | system(cmd.c_str()); |
| @@ -2805,7 +2805,7 @@ void test_bintable_string(void) | @@ -2805,7 +2805,7 @@ void test_bintable_string(void) | ||
| 2805 | double sum_str10_dbl = 0; | 2805 | double sum_str10_dbl = 0; |
| 2806 | double sum_str_int = 0; | 2806 | double sum_str_int = 0; |
| 2807 | double sum_str10_int = 0; | 2807 | double sum_str10_int = 0; |
| 2808 | - | 2808 | + |
| 2809 | // Build tables | 2809 | // Build tables |
| 2810 | try { | 2810 | try { |
| 2811 | // Open FITS file | 2811 | // Open FITS file |
| @@ -3152,7 +3152,7 @@ void test_bintable_logical(void) | @@ -3152,7 +3152,7 @@ void test_bintable_logical(void) | ||
| 3152 | 3152 | ||
| 3153 | // Dump header | 3153 | // Dump header |
| 3154 | std::cout << "Test GFitsTableBoolCol: "; | 3154 | std::cout << "Test GFitsTableBoolCol: "; |
| 3155 | - | 3155 | + |
| 3156 | // Remove FITS file | 3156 | // Remove FITS file |
| 3157 | std::string cmd = "rm -rf "+ filename; | 3157 | std::string cmd = "rm -rf "+ filename; |
| 3158 | system(cmd.c_str()); | 3158 | system(cmd.c_str()); |
| @@ -3517,7 +3517,7 @@ void test_bintable_bit(void) | @@ -3517,7 +3517,7 @@ void test_bintable_bit(void) | ||
| 3517 | 3517 | ||
| 3518 | // Dump header | 3518 | // Dump header |
| 3519 | std::cout << "Test GFitsTableBitCol: "; | 3519 | std::cout << "Test GFitsTableBitCol: "; |
| 3520 | - | 3520 | + |
| 3521 | // Remove FITS file | 3521 | // Remove FITS file |
| 3522 | std::string cmd = "rm -rf "+ filename; | 3522 | std::string cmd = "rm -rf "+ filename; |
| 3523 | system(cmd.c_str()); | 3523 | system(cmd.c_str()); |