[beast: 15/43] TESTS: only use Bse::assert_return{_unreached} and apply small fixes



commit 29fb1f2d2162d9d173fef29038d950e0a8a3bec6
Author: Tim Janik <timj gnu org>
Date:   Sun Jun 25 16:02:42 2017 +0200

    TESTS: only use Bse::assert_return{_unreached} and apply small fixes
    
    Signed-off-by: Tim Janik <timj gnu org>

 tests/testresampler.cc  |    2 +-
 tests/testresamplerq.cc |   12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/tests/testresampler.cc b/tests/testresampler.cc
index 71bbb91..bba9587 100644
--- a/tests/testresampler.cc
+++ b/tests/testresampler.cc
@@ -520,7 +520,7 @@ perform_test()
          printf ("#   max difference between correct and computed output: %f = %f dB\n", max_diff, 
max_diff_db);
          if (options.max_threshold_db < 0)
            printf ("#                             (threshold given by user: %f dB)\n", 
options.max_threshold_db);
-         assert (max_diff_db < options.max_threshold_db);
+         assert_return (max_diff_db < options.max_threshold_db, -1);
        }
       else if (TEST == TEST_ERROR_SPECTRUM)
        {
diff --git a/tests/testresamplerq.cc b/tests/testresamplerq.cc
index 47e786e..811c437 100644
--- a/tests/testresamplerq.cc
+++ b/tests/testresamplerq.cc
@@ -87,7 +87,7 @@ ResamplerTest::check_resampler_up (BseResampler2Precision precision)
         {
           if (j >= i * 2)
             {
-              assert (output[j] == results[0][j - i * 2]);
+              assert_return (output[j] == results[0][j - i * 2]);
             }
           // printf ("%d %.17g #p%d,%d\n", j, output[j], precision, i);
         }
@@ -126,7 +126,7 @@ ResamplerTest::check_resampler_down (BseResampler2Precision precision)
       for (size_t j = 0; j < output.size(); j++)
         {
           if (j >= i/2)
-            assert (output[j] == results[i % 2][j - i/2]);
+            assert_return (output[j] == results[i % 2][j - i/2]);
           //printf ("%zd %.17g #%d,%zd\n", j, output[j], precision, i);
         }
     }
@@ -174,7 +174,7 @@ band_err (BseResampler2Precision p)
       case BSE_RESAMPLER2_PREC_96DB:    return -95;
       case BSE_RESAMPLER2_PREC_120DB:   return -120;
       case BSE_RESAMPLER2_PREC_144DB:   return -144;
-      default:                          assert_unreached();
+      default:                          assert_return_unreached (NAN);
     }
 }
 
@@ -234,16 +234,18 @@ main (int argc, char **argv)
     {
       options.rand_samples = atoi (argv[2]);
     }
-  assert (options.rand_samples <= options.test_size / 2);
-  assert (options.test_size >= 128);
+  assert_return (options.rand_samples <= options.test_size / 2, -1);
+  assert_return (options.test_size >= 128, -1);
   printout ("Resampler test parameters: test_size=%zd rand_samples=%zd\n",
            options.test_size, options.rand_samples);
   run_tests ("FPU");
 
   /* load plugins */
+  Bse::assertion_failed_hook (NULL); // hack to allow test reinitialization
   bse_init_test (&argc, argv, Bse::cstrings_to_vector ("load-core-plugins=1", NULL));
   /* check for possible specialization */
   if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
     return 0;   /* nothing changed */
   run_tests ("SSE");
+  return 0;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]