diff --git a/tests/test_toolkit.cpp b/tests/test_toolkit.cpp index 618fc1c..114f34d 100644 --- a/tests/test_toolkit.cpp +++ b/tests/test_toolkit.cpp @@ -81,16 +81,16 @@ BOOST_AUTO_TEST_CASE(test_save_reopen) EN_open(ph_save, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); EN_saveinpfile(ph_save, inp_save.c_str()); - EN_close(ph_save); - + EN_close(ph_save); + EN_deleteproject(&ph_save); BOOST_TEST_CHECKPOINT("Saved input file"); EN_createproject(&ph_reopen); - + EN_open(ph_reopen, inp_save.c_str(), path_rpt.c_str(), path_out.c_str()); EN_close(ph_reopen); - + EN_deleteproject(&ph_reopen); } @@ -100,8 +100,14 @@ BOOST_AUTO_TEST_CASE(test_epanet) string path_rpt(DATA_PATH_RPT); string path_out(DATA_PATH_OUT); - int error = ENepanet(path_inp.c_str(), path_rpt.c_str(), path_out.c_str(), NULL); + EN_Project ph; + + EN_createproject(&ph); + + int error = EN_runproject(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str(), NULL); BOOST_REQUIRE(error == 0); + + EN_deleteproject(&ph); } BOOST_AUTO_TEST_SUITE_END() @@ -163,7 +169,7 @@ BOOST_FIXTURE_TEST_CASE(test_hyd_step, Fixture) BOOST_REQUIRE(error == 0); } while (tstep > 0); - + error = EN_closeH(ph); BOOST_REQUIRE(error == 0); } @@ -190,7 +196,7 @@ BOOST_FIXTURE_TEST_CASE(test_qual_step, Fixture) BOOST_REQUIRE(error == 0); } while (tstep > 0); - + error = EN_closeQ(ph); BOOST_REQUIRE(error == 0); } @@ -243,7 +249,7 @@ BOOST_FIXTURE_TEST_CASE(test_setdemandpattern, Fixture) // get the number of nodes error = EN_getcount(ph, EN_NODECOUNT, &nnodes); BOOST_REQUIRE(error == 0); - + // add a new pattern error = EN_addpattern(ph, newpat); BOOST_REQUIRE(error == 0); @@ -251,18 +257,18 @@ BOOST_FIXTURE_TEST_CASE(test_setdemandpattern, Fixture) // get the new patterns index, should be as the number of patterns error = EN_getpatternindex(ph, newpat, &pat_index); BOOST_REQUIRE(error == 0); - + for (i = 1; i <= nnodes; i++) { // get the number of demand categories error = EN_getnumdemands(ph, i, &numDemands); BOOST_REQUIRE(error == 0); - + for (j = 1; j <= numDemands; j++) { // set demand patterns - error = EN_setdemandpattern(ph, i, j, pat_index); + error = EN_setdemandpattern(ph, i, j, pat_index); BOOST_REQUIRE(error == 0); // get demand patterns should be the same with set - error = EN_getdemandpattern(ph, i, j, &pat_index_2); + error = EN_getdemandpattern(ph, i, j, &pat_index_2); BOOST_REQUIRE(error == 0); BOOST_CHECK(pat_index == pat_index_2); } @@ -272,11 +278,11 @@ BOOST_FIXTURE_TEST_CASE(test_addpattern, Fixture) { int pat_index, n_patterns_1, n_patterns_2; char newpat[] = "new_pattern"; - + // get the number of current patterns error = EN_getcount(ph, EN_PATCOUNT, &n_patterns_1); BOOST_REQUIRE(error == 0); - + // add a new pattern error = EN_addpattern(ph, newpat); BOOST_REQUIRE(error == 0); @@ -285,7 +291,7 @@ BOOST_FIXTURE_TEST_CASE(test_addpattern, Fixture) error = EN_getcount(ph, EN_PATCOUNT, &n_patterns_2); BOOST_REQUIRE(error == 0); BOOST_CHECK(n_patterns_1 + 1 == n_patterns_2); - + // gwt the new patterns index, should be as the number of patterns error = EN_getpatternindex(ph, newpat, &pat_index); BOOST_CHECK(pat_index == n_patterns_2); @@ -311,16 +317,16 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture) error = EN_nextH(ph, &tstep); BOOST_REQUIRE(error == 0); } while (tstep > 0); - + error = EN_closeH(ph); BOOST_REQUIRE(error == 0); - - // disable current controls + + // disable current controls error = EN_setcontrol(ph, 1, 0, 0, 0, 0, 0); BOOST_REQUIRE(error == 0); error = EN_setcontrol(ph, 2, 1, 0, 0, 0, 0); BOOST_REQUIRE(error == 0); - + // add new controls error = EN_addcontrol(ph, &Cindex, 0, 13, 1, 11, 110); BOOST_REQUIRE(error == 0); @@ -342,10 +348,10 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture) error = EN_nextH(ph, &tstep); BOOST_REQUIRE(error == 0); } while (tstep > 0); - + error = EN_closeH(ph); BOOST_REQUIRE(error == 0); - + BOOST_CHECK(h1 == h2); // end head should be the same with new controls }