From 612c898bd20ee3da59535d07f37d4375ca63fd94 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 1 Mar 2019 11:45:39 -0500 Subject: [PATCH] Renaming files, adding test for getstatistics --- tests/{test_hydqual.cpp => test_hydrqual.cpp} | 8 +-- tests/{test_project.cpp => test_proj.cpp} | 8 +-- tests/test_rprtanlys.cpp | 59 +++++++++++++++++++ 3 files changed, 67 insertions(+), 8 deletions(-) rename tests/{test_hydqual.cpp => test_hydrqual.cpp} (95%) rename tests/{test_project.cpp => test_proj.cpp} (98%) create mode 100644 tests/test_rprtanlys.cpp diff --git a/tests/test_hydqual.cpp b/tests/test_hydrqual.cpp similarity index 95% rename from tests/test_hydqual.cpp rename to tests/test_hydrqual.cpp index 58c6637..24e2100 100644 --- a/tests/test_hydqual.cpp +++ b/tests/test_hydrqual.cpp @@ -1,7 +1,7 @@ // -// test_project.cpp +// test_hydrqual.cpp // -// Date Created: January 24, 2018 +// Date Created: February 28, 2019 // // Author: Michael E. Tryby // US EPA - ORD/NRMRL @@ -27,7 +27,7 @@ using namespace std; using namespace boost; -BOOST_AUTO_TEST_SUITE (test_hyd_qual) +BOOST_AUTO_TEST_SUITE (test_hydrqual) BOOST_FIXTURE_TEST_CASE(test_solveH_solveQ, FixtureOpenClose) { @@ -157,7 +157,7 @@ BOOST_FIXTURE_TEST_CASE(test_hydr_savefile, FixtureOpenClose) BOOST_CHECK(filesystem::exists(hyd_file) == true); } -BOOST_FIXTURE_TEST_CASE(test_hydr_usefile, FixtureOpenClose, * unit_test::depends_on("test_hyd_qual/test_hydr_savefile")) +BOOST_FIXTURE_TEST_CASE(test_hydr_usefile, FixtureOpenClose, * unit_test::depends_on("test_hydrqual/test_hydr_savefile")) { string hyd_file("test_savefile.hyd"); diff --git a/tests/test_project.cpp b/tests/test_proj.cpp similarity index 98% rename from tests/test_project.cpp rename to tests/test_proj.cpp index 511f30a..295d1e1 100644 --- a/tests/test_project.cpp +++ b/tests/test_proj.cpp @@ -36,7 +36,7 @@ boost::test_tools::predicate_result check_string(std::string test, std::string r } -BOOST_AUTO_TEST_SUITE (test_project) +BOOST_AUTO_TEST_SUITE (test_proj) BOOST_AUTO_TEST_CASE (test_proj_create_delete) { @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(test_proj_savefile) EN_deleteproject(&ph_save); } -BOOST_AUTO_TEST_CASE(test_proj_reopen, * unit_test::depends_on("test_project/test_proj_savefile")) +BOOST_AUTO_TEST_CASE(test_proj_reopen, * unit_test::depends_on("test_proj/test_proj_savefile")) { int error; @@ -138,8 +138,7 @@ BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE(test_project_fixture) - +BOOST_AUTO_TEST_SUITE(test_proj_fixture) BOOST_FIXTURE_TEST_CASE(test_proj_title, FixtureOpenClose) { @@ -214,6 +213,7 @@ BOOST_FIXTURE_TEST_CASE(test_setdemandpattern, FixtureOpenClose) } } } + BOOST_FIXTURE_TEST_CASE(test_addpattern, FixtureOpenClose) { int pat_index, n_patterns_1, n_patterns_2; diff --git a/tests/test_rprtanlys.cpp b/tests/test_rprtanlys.cpp new file mode 100644 index 0000000..bbdbece --- /dev/null +++ b/tests/test_rprtanlys.cpp @@ -0,0 +1,59 @@ +// +// test_rprtanlys.cpp +// +// Date Created: February 28, 2019 +// +// Author: Michael E. Tryby +// US EPA - ORD/NRMRL +// + +//#define BOOST_TEST_DYN_LINK + +#ifdef _WIN32 +#define _CRTDBG_MAP_ALLOC +#include +#include +#else +#include +#endif + +#define BOOST_TEST_MODULE hydqual +#include +#include + +#include "test_fixtures.hpp" + +using namespace std; +using namespace boost; + + +BOOST_AUTO_TEST_SUITE (test_rprtanlys) + +BOOST_FIXTURE_TEST_CASE(test_rprt_anlysstats, FixtureOpenClose) +{ + int i; + double array[5]; + + std::vector test; + vector ref = {3.0, 7.0799498320679432e-06, 1.6680242187483429e-08, + 0.0089173150106518495, 0.99999998187144024}; + + error = EN_solveH(ph); + BOOST_REQUIRE(error == 0); + + error = EN_solveQ(ph); + BOOST_REQUIRE(error == 0); + + + for (i=EN_ITERATIONS; i<=EN_MASSBALANCE; i++) { + error = EN_getstatistic(ph, i, &array[i]); + BOOST_REQUIRE(error == 0); + } + + test.assign(array, array + 5); + BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); +} + + + +BOOST_AUTO_TEST_SUITE_END()