[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master dcfcc94 3/8: Rename and document a unit-test
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master dcfcc94 3/8: Rename and document a unit-test function template |
Date: |
Mon, 28 Jun 2021 10:29:52 -0400 (EDT) |
branch: master
commit dcfcc945f2302d436335d8941db85242b1fe2c35
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Rename and document a unit-test function template
---
zero_test.cpp | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/zero_test.cpp b/zero_test.cpp
index 131eb80..ae94688 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -66,8 +66,10 @@ int max_n_iter_brent(double a, double b, double tol, double
zeta)
}
} // Unnamed namespace.
+/// Test with all biases, asserting obvious invariants.
+
template<typename F>
-void test_zero(double bound0, double bound1, int dec, F f, double exact_root)
+void test_bias(double bound0, double bound1, int dec, F f, double exact_root)
{
double maximum_error = max_err(exact_root, 0.5 * std::pow(10.0, -dec));
@@ -245,17 +247,17 @@ int test_main(int, char*[])
// Various tests--see function-template definition.
- test_zero(-1.0e100, 4.0e100, -100, e, std::exp(1.0));
- test_zero(-1.0 , 4.0 , 0, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 1, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 2, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 3, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 4, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 5, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 6, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 7, e, std::exp(1.0));
- test_zero( 0.5 , 5.0 , 8, e, std::exp(1.0));
- test_zero(-1.0 , 4.0 , 100, e, std::exp(1.0));
+ test_bias(-1.0e100, 4.0e100, -100, e, std::exp(1.0));
+ test_bias(-1.0 , 4.0 , 0, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 1, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 2, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 3, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 4, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 5, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 6, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 7, e, std::exp(1.0));
+ test_bias( 0.5 , 5.0 , 8, e, std::exp(1.0));
+ test_bias(-1.0 , 4.0 , 100, e, std::exp(1.0));
// Brent's book uses the nineteenth-power function in examples.
// His example using a tolerance of 1e-20 is subject to underflow
- [lmi-commits] [lmi] master updated (ef6c706 -> 016bf00), Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master cb924a4 1/8: Translate from Brent's ALGOL more directly, Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master dcfcc94 3/8: Rename and document a unit-test function template,
Greg Chicares <=
- [lmi-commits] [lmi] master e995bb8 7/8: Document an important qualification for Brent's error term, Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master ed9d62d 2/8: Explain some commented-out unit tests, Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master 94d6b7b 4/8: Restructure a unit test, Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master 5848d68 6/8: Improve an error term, and rewrite a misleading comment, Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master 623ddbd 5/8: Assert a precondition, Greg Chicares, 2021/06/28
- [lmi-commits] [lmi] master 016bf00 8/8: Add a function template to facilitate testing, Greg Chicares, 2021/06/28