Cleaning up tests
Fixing memory leak associated with using string objects to pass filepath arguments to toolkit
This commit is contained in:
@@ -16,13 +16,11 @@ BOOST_AUTO_TEST_SUITE (test_demands)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_categories_save)
|
||||
{
|
||||
std::string path_inp(DATA_PATH_NET1);
|
||||
std::string inp_save("net1_dem_cat.inp");
|
||||
std::string path_rpt(DATA_PATH_RPT);
|
||||
std::string path_out(DATA_PATH_OUT);
|
||||
//std::string path_inp(DATA_PATH_NET1);
|
||||
//std::string inp_save = "net1_dem_cat.inp";
|
||||
//std::string path_rpt(DATA_PATH_RPT);
|
||||
//std::string path_out(DATA_PATH_OUT);
|
||||
|
||||
char node_id[] = "12";
|
||||
char demand_category[] = "Demand category name";
|
||||
|
||||
int error = 0;
|
||||
int Nindex, ndem;
|
||||
@@ -30,17 +28,17 @@ BOOST_AUTO_TEST_CASE(test_categories_save)
|
||||
EN_Project ph = NULL;
|
||||
|
||||
error = EN_createproject(&ph);
|
||||
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str());
|
||||
error = EN_open(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
|
||||
|
||||
error = EN_getnodeindex(ph, node_id, &Nindex);
|
||||
error = EN_getnodeindex(ph, "12", &Nindex);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getnumdemands(ph, Nindex, &ndem);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(ndem == 1);
|
||||
|
||||
error = EN_setdemandname(ph, Nindex, ndem, demand_category);
|
||||
error = EN_setdemandname(ph, Nindex, ndem, "Demand category name");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_saveinpfile(ph, inp_save.c_str());
|
||||
error = EN_saveinpfile(ph, "net1_dem_cat.inp");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_close(ph);
|
||||
@@ -51,12 +49,10 @@ BOOST_AUTO_TEST_CASE(test_categories_save)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_categories_reopen, * boost::unit_test::depends_on("test_demands/test_categories_save"))
|
||||
{
|
||||
std::string inp_save("net1_dem_cat.inp");
|
||||
std::string path_rpt(DATA_PATH_RPT);
|
||||
std::string path_out(DATA_PATH_OUT);
|
||||
|
||||
char node_id[] = "12";
|
||||
char demand_category[] = "Demand category name";
|
||||
//std::string inp_save = "net1_dem_cat.inp";
|
||||
//std::string path_rpt(DATA_PATH_RPT);
|
||||
//std::string path_out(DATA_PATH_OUT);
|
||||
|
||||
char demname[80];
|
||||
|
||||
int error = 0;
|
||||
@@ -67,10 +63,10 @@ BOOST_AUTO_TEST_CASE(test_categories_reopen, * boost::unit_test::depends_on("tes
|
||||
BOOST_TEST_CHECKPOINT("Reopening saved input file");
|
||||
error = EN_createproject(&ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), path_out.c_str());
|
||||
error = EN_open(ph, "net1_dem_cat.inp", DATA_PATH_RPT, DATA_PATH_OUT);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_getnodeindex(ph, node_id, &Nindex);
|
||||
error = EN_getnodeindex(ph, "12", &Nindex);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getnumdemands(ph, Nindex, &ndem);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
@@ -78,7 +74,8 @@ BOOST_AUTO_TEST_CASE(test_categories_reopen, * boost::unit_test::depends_on("tes
|
||||
|
||||
error = EN_getdemandname(ph, Nindex, ndem, demname);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(check_string(demname, demand_category));
|
||||
|
||||
BOOST_CHECK(check_string(demname, "Demand category name"));
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
Reference in New Issue
Block a user