Adding test for stepQ and proj save/reopen

This commit is contained in:
Michael Tryby
2019-03-01 10:45:50 -05:00
parent 41f810395a
commit 07dfac6198
2 changed files with 20 additions and 18 deletions

View File

@@ -83,7 +83,7 @@ BOOST_FIXTURE_TEST_CASE(test_qual_step, FixtureOpenClose)
error = EN_runQ(ph, &t); error = EN_runQ(ph, &t);
BOOST_REQUIRE(error == 0); BOOST_REQUIRE(error == 0);
error = EN_nextQ(ph, &tstep); error = EN_stepQ(ph, &tstep);
BOOST_REQUIRE(error == 0); BOOST_REQUIRE(error == 0);
} while (tstep > 0); } while (tstep > 0);

View File

@@ -72,8 +72,7 @@ BOOST_AUTO_TEST_CASE (test_proj_open_close)
EN_deleteproject(&ph); EN_deleteproject(&ph);
} }
// Note: This test causes a segfault when built using debug configuration BOOST_AUTO_TEST_CASE(test_proj_savefile)
BOOST_AUTO_TEST_CASE(test_save_reopen, * unit_test::disabled())
{ {
int error; int error;
@@ -83,7 +82,7 @@ BOOST_AUTO_TEST_CASE(test_save_reopen, * unit_test::disabled())
string path_out(DATA_PATH_OUT); string path_out(DATA_PATH_OUT);
EN_Project ph_save; EN_Project ph_save;
EN_Project ph_reopen;
EN_createproject(&ph_save); EN_createproject(&ph_save);
error = EN_open(ph_save, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); error = EN_open(ph_save, path_inp.c_str(), path_rpt.c_str(), path_out.c_str());
@@ -92,10 +91,23 @@ BOOST_AUTO_TEST_CASE(test_save_reopen, * unit_test::disabled())
error = EN_saveinpfile(ph_save, inp_save.c_str()); error = EN_saveinpfile(ph_save, inp_save.c_str());
BOOST_REQUIRE(error == 0); BOOST_REQUIRE(error == 0);
BOOST_CHECK(filesystem::exists(inp_save) == true);
error = EN_close(ph_save); error = EN_close(ph_save);
BOOST_REQUIRE(error == 0); BOOST_REQUIRE(error == 0);
EN_deleteproject(&ph_save); EN_deleteproject(&ph_save);
BOOST_TEST_CHECKPOINT("Saved input file"); }
BOOST_AUTO_TEST_CASE(test_proj_reopen, * unit_test::depends_on("test_project/test_proj_savefile"))
{
int error;
string inp_save("test_reopen.inp");
string path_rpt(DATA_PATH_RPT);
string path_out(DATA_PATH_OUT);
EN_Project ph_reopen;
EN_createproject(&ph_reopen); EN_createproject(&ph_reopen);
error = EN_open(ph_reopen, inp_save.c_str(), path_rpt.c_str(), path_out.c_str()); error = EN_open(ph_reopen, inp_save.c_str(), path_rpt.c_str(), path_out.c_str());
@@ -129,19 +141,9 @@ BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(test_project_fixture) BOOST_AUTO_TEST_SUITE(test_project_fixture)
BOOST_FIXTURE_TEST_CASE(test_proj_save, FixtureOpenClose)
{
string inp_save("test_projsave.inp");
error = EN_saveinpfile(ph, inp_save.c_str());
BOOST_REQUIRE(error == 0);
BOOST_CHECK(filesystem::exists(inp_save) == true);
}
BOOST_FIXTURE_TEST_CASE(test_proj_title, FixtureOpenClose) BOOST_FIXTURE_TEST_CASE(test_proj_title, FixtureOpenClose)
{ {
// How is the API user supposed to know array size?
char c_test[3][80], c_ref[3][80]; char c_test[3][80], c_ref[3][80];
strncpy(c_ref[0], " EPANET Example Network 1", 26); strncpy(c_ref[0], " EPANET Example Network 1", 26);