From b3a97018635ae75ba92d2432212eac67300a5aae Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Fri, 1 Mar 2019 12:12:10 -0500 Subject: [PATCH] Adding test for getoption --- src/epanet.c | 2 +- tests/test_rprtanlys.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/epanet.c b/src/epanet.c index d00499a..a89d648 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -1042,7 +1042,7 @@ int DLLEXPORT EN_getstatistic(EN_Project p, int type, double *value) break; default: *value = 0.0; - break; + return 251; } return 0; } diff --git a/tests/test_rprtanlys.cpp b/tests/test_rprtanlys.cpp index bbdbece..4af6604 100644 --- a/tests/test_rprtanlys.cpp +++ b/tests/test_rprtanlys.cpp @@ -52,8 +52,36 @@ BOOST_FIXTURE_TEST_CASE(test_rprt_anlysstats, FixtureOpenClose) test.assign(array, array + 5); BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); + + error = EN_getstatistic(ph, 8, &array[0]); + BOOST_CHECK(error == 251); } +BOOST_FIXTURE_TEST_CASE(test_anlys_getoption, FixtureOpenClose) +{ + int i; + double array[13]; + std::vector test; + vector ref = {40.0, 0.001, 0.01, 0.5, 1.0, 0.0, 0.0, 1.0, 0.0, 75.0, 0.0, 0.0, 0.0}; + + error = EN_solveH(ph); + BOOST_REQUIRE(error == 0); + + error = EN_solveQ(ph); + BOOST_REQUIRE(error == 0); + + + for (i=EN_TRIALS; i<=EN_DEMANDCHARGE; i++) { + error = EN_getoption(ph, i, &array[i]); + BOOST_REQUIRE(error == 0); + } + + test.assign(array, array + 13); + BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); + + error = EN_getoption(ph, 18, &array[0]); + BOOST_CHECK(error == 251); +} BOOST_AUTO_TEST_SUITE_END()