Commit 4485b0359539b4dbfe9f236f719e36c822d9a24b
1 parent
f6d1944f
Add GTestSuite::test_value() method with automatic precision computation
Showing
6 changed files
with
45 additions
and
6 deletions
ChangeLog
| 1 | -2016-08-10 | |
| 1 | +2016-08-12 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.2.0 released |
| 4 | 4 | ========================= |
| 5 | 5 | |
| 6 | + Add GTestSuite::test_value() method with automatic precision computation | |
| 6 | 7 | Add GSkyMap::is_empty() method (#1828) |
| 7 | 8 | Add GApplication access by index operator (#1838) |
| 8 | 9 | Add GApplication::pars() and GApplicationPar::current_value() methods (#1838) | ... | ... |
NEWS
| 1 | 1 | New Features and Important Changes in GammaLib 1.2.0 |
| 2 | 2 | |
| 3 | -10 August 2016 | |
| 3 | +12 August 2016 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | 1. Introduction |
| ... | ... | @@ -173,7 +173,10 @@ None |
| 173 | 173 | |
| 174 | 174 | 17. Test module |
| 175 | 175 | --------------- |
| 176 | -None | |
| 176 | +A GTestSuite::test_value() method for double precision values has been added | |
| 177 | +that automatically requires a relative precision of 1.0e-7. The default value | |
| 178 | +for "eps" has been removed from the former double precision test_value() | |
| 179 | +method. This should allow writing of more compact unit tests. | |
| 177 | 180 | |
| 178 | 181 | |
| 179 | 182 | 18. Multi-wavelength interface | ... | ... |
README.md
| 1 | 1 | GammaLib information |
| 2 | 2 | ==================== |
| 3 | -* Version: 1.2.0.dev1 (10 August 2016) | |
| 3 | +* Version: 1.2.0.dev1 (12 August 2016) | |
| 4 | 4 | * Author: Juergen Knoedlseder (jurgen.knodlseder@irap.omp.eu) |
| 5 | 5 | |
| 6 | 6 | [](https://cta-jenkins.irap.omp.eu/job/gammalib-integrate-os/) | ... | ... |
include/GTestSuite.hpp
| ... | ... | @@ -85,7 +85,11 @@ public: |
| 85 | 85 | const std::string& message = ""); |
| 86 | 86 | void test_value(const double& value, |
| 87 | 87 | const double& expected, |
| 88 | - const double& eps = 1.0e-7, | |
| 88 | + const std::string& name = "", | |
| 89 | + const std::string& message = ""); | |
| 90 | + void test_value(const double& value, | |
| 91 | + const double& expected, | |
| 92 | + const double& eps, | |
| 89 | 93 | const std::string& name = "", |
| 90 | 94 | const std::string& message = ""); |
| 91 | 95 | void test_value(const std::string& value, | ... | ... |
pyext/GTestSuite.i
| ... | ... | @@ -250,7 +250,11 @@ public: |
| 250 | 250 | const std::string& message = ""); |
| 251 | 251 | void test_value(const double& value, |
| 252 | 252 | const double& expected, |
| 253 | - const double& eps = 1.0e-7, | |
| 253 | + const std::string& name = "", | |
| 254 | + const std::string& message = ""); | |
| 255 | + void test_value(const double& value, | |
| 256 | + const double& expected, | |
| 257 | + const double& eps, | |
| 254 | 258 | const std::string& name = "", |
| 255 | 259 | const std::string& message = ""); |
| 256 | 260 | void test_value(const std::string& value, | ... | ... |
src/test/GTestSuite.cpp
| ... | ... | @@ -458,6 +458,33 @@ void GTestSuite::test_value(const int& value, |
| 458 | 458 | * |
| 459 | 459 | * @param[in] value Double precision value to test. |
| 460 | 460 | * @param[in] expected Expected double precision value. |
| 461 | + * @param[in] name Test case name. | |
| 462 | + * @param[in] message Test case message. | |
| 463 | + * | |
| 464 | + * Test if the @p value is equal to the @p expected value within a relative | |
| 465 | + * precision of 1.0e-7. | |
| 466 | + ***************************************************************************/ | |
| 467 | +void GTestSuite::test_value(const double& value, | |
| 468 | + const double& expected, | |
| 469 | + const std::string& name, | |
| 470 | + const std::string& message) | |
| 471 | +{ | |
| 472 | + // Compute precision | |
| 473 | + double eps = (expected != 0.0) ? 1.0e-7 * expected : 1.0e-7; | |
| 474 | + | |
| 475 | + // Test double precision value | |
| 476 | + test_value(value, expected, eps, name, message); | |
| 477 | + | |
| 478 | + // Return | |
| 479 | + return; | |
| 480 | +} | |
| 481 | + | |
| 482 | + | |
| 483 | +/***********************************************************************//** | |
| 484 | + * @brief Test a double precision value | |
| 485 | + * | |
| 486 | + * @param[in] value Double precision value to test. | |
| 487 | + * @param[in] expected Expected double precision value. | |
| 461 | 488 | * @param[in] eps Precision of the test. |
| 462 | 489 | * @param[in] name Test case name. |
| 463 | 490 | * @param[in] message Test case message. | ... | ... |