[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 55873f1 13/13: Test an uncommon code path
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 55873f1 13/13: Test an uncommon code path |
Date: |
Sun, 4 Jul 2021 19:04:46 -0400 (EDT) |
branch: master
commit 55873f116bbca1c52c8b0f732b36e44a4632a2e0
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Test an uncommon code path
---
zero_test.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/zero_test.cpp b/zero_test.cpp
index c26a16c..be1ad58 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -535,6 +535,21 @@ void test_various_functions()
auto root_05 = 1.4142135623730951;
test_a_decimal_function(f05, root_05, 0.0 , 2.0, 17 , __LINE__, 10);
test_a_function (f05, root_05, 0.0 , 2.0, 1.0e-15, __LINE__);
+
+ // Despite its apparent insipidity, this is actually a very
+ // interesting test: after the first iterate has been calculated
+ // as -0.05 by linear interpolation, the values are:
+ // a, fa 1.9 -0.39
+ // b, fb -0.05 -3.9975
+ // c, fc -2.1 0.41
+ // so fb and fc have the same sign while |fc| < |fb|, which is
+ // an uncommon conjunction of circumstances that this unit test
+ // contrives to engender. Usually the second test is met only if
+ // the first is, too.
+ auto f06 = [](double x) {return x * x - 4.0;};
+ auto root_06 = -2.0;
+ test_a_function (f06, root_06 , 1.9, -2.1, 1.0e-15, __LINE__);
+ test_a_function (f06, root_06, -2.1 , 1.9, 1.0e-15, __LINE__);
}
void test_hodgepodge()
- [lmi-commits] [lmi] master e68be69 07/13: Test lmi_root() against reference implementation, (continued)
- [lmi-commits] [lmi] master e68be69 07/13: Test lmi_root() against reference implementation, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master 41d1896 08/13: Move some tests out of a hodgepodge, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master 0e29fb4 10/13: Augment a block of unit tests, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master bf65f24 12/13: Remove duplicative tests, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master 28955d1 01/13: Refactor for flexibility, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master 8a1404f 02/13: Describe the preceding commit, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master e6b40ee 04/13: Write root-finder arguments in a more natural order, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master d5bd712 06/13: Add an instrumented reference implementation, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master 9be9b1d 09/13: Refactor, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master a1a1901 11/13: Refactor, Greg Chicares, 2021/07/04
- [lmi-commits] [lmi] master 55873f1 13/13: Test an uncommon code path,
Greg Chicares <=