Adding tests for save and use hydraulics file

This commit is contained in:
Michael Tryby
2019-02-28 11:14:15 -05:00
parent 91120b8e71
commit a4b2e53768
3 changed files with 37 additions and 10 deletions

View File

@@ -220,7 +220,7 @@ typedef struct Project *EN_Project;
Do not call this function while the hydraulics solver is open. Do not call this function while the hydraulics solver is open.
*/ */
int DLLEXPORT EN_usehydfile(EN_Project ph, char *filename); int DLLEXPORT EN_usehydfile(EN_Project ph, const char *filename);
/** /**
@brief Opens a project's hydraulic solver. @brief Opens a project's hydraulic solver.
@@ -343,7 +343,7 @@ typedef struct Project *EN_Project;
called ::EN_solveH or the ::EN_initH - ::EN_runH - ::EN_nextH sequence with the initflag called ::EN_solveH or the ::EN_initH - ::EN_runH - ::EN_nextH sequence with the initflag
argument of ::EN_initH set to `EN_SAVE` or `EN_SAVE_AND_INIT`. argument of ::EN_initH set to `EN_SAVE` or `EN_SAVE_AND_INIT`.
*/ */
int DLLEXPORT EN_savehydfile(EN_Project ph, char *filename); int DLLEXPORT EN_savehydfile(EN_Project ph, const char *filename);
/** /**
@brief Closes the hydraulic solver freeing all of its allocated memory. @brief Closes the hydraulic solver freeing all of its allocated memory.

View File

@@ -583,7 +583,7 @@ int DLLEXPORT EN_closeH(EN_Project p)
return 0; return 0;
} }
int DLLEXPORT EN_savehydfile(EN_Project p, char *filename) int DLLEXPORT EN_savehydfile(EN_Project p, const char *filename)
/*---------------------------------------------------------------- /*----------------------------------------------------------------
** Input: filename = name of file to which hydraulic results are saved ** Input: filename = name of file to which hydraulic results are saved
** Output: none ** Output: none
@@ -611,7 +611,7 @@ int DLLEXPORT EN_savehydfile(EN_Project p, char *filename)
return 0; return 0;
} }
int DLLEXPORT EN_usehydfile(EN_Project p, char *filename) int DLLEXPORT EN_usehydfile(EN_Project p, const char *filename)
/*---------------------------------------------------------------- /*----------------------------------------------------------------
** Input: filename = name of previously saved hydraulics file ** Input: filename = name of previously saved hydraulics file
** Output: none ** Output: none

View File

@@ -19,6 +19,7 @@
#define BOOST_TEST_MODULE "hydqual" #define BOOST_TEST_MODULE "hydqual"
#include <boost/test/included/unit_test.hpp> #include <boost/test/included/unit_test.hpp>
#include <boost/filesystem.hpp>
#include "test_fixtures.hpp" #include "test_fixtures.hpp"
@@ -26,7 +27,7 @@ using namespace std;
using namespace boost; using namespace boost;
BOOST_AUTO_TEST_SUITE (test_hydraulics_quality) BOOST_AUTO_TEST_SUITE (test_hyd_qual)
BOOST_FIXTURE_TEST_CASE(test_solveH_solveQ, FixtureOpenClose) BOOST_FIXTURE_TEST_CASE(test_solveH_solveQ, FixtureOpenClose)
{ {
@@ -131,4 +132,30 @@ BOOST_FIXTURE_TEST_CASE(test_progressive_step, FixtureOpenClose)
} }
// saveH
BOOST_FIXTURE_TEST_CASE(test_hydr_savefile, FixtureOpenClose)
{
string hyd_file("test_savefile.hyd");
error = EN_solveH(ph);
BOOST_REQUIRE(error == 0);
error = EN_savehydfile(ph, hyd_file.c_str());
BOOST_REQUIRE(error == 0);
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"))
{
string hyd_file("test_savefile.hyd");
error = EN_usehydfile(ph, hyd_file.c_str());
BOOST_REQUIRE(error == 0);
error = EN_solveQ(ph);
BOOST_REQUIRE(error == 0);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()