Cleaning up tests

Fixing memory leak associated with using string objects to pass filepath arguments to toolkit
This commit is contained in:
Michael Tryby
2019-03-19 13:27:07 -04:00
parent ed9a89763b
commit 29cfe43e5a
8 changed files with 75 additions and 148 deletions

View File

@@ -7,7 +7,6 @@
// US EPA - ORD/NRMRL
//
#define BOOST_TEST_MODULE "node"
#include "shared_test.hpp"
@@ -137,17 +136,12 @@ BOOST_AUTO_TEST_SUITE(setid_save_reopen)
BOOST_AUTO_TEST_CASE(test_setid_save)
{
std::string path_inp(DATA_PATH_NET1);
std::string path_out(DATA_PATH_OUT);
std::string path_rpt(DATA_PATH_RPT);
std::string inp_save("net1_setid.inp");
int error = 0;
EN_Project ph = NULL;
EN_createproject(&ph);
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), "");
error = EN_open(ph, DATA_PATH_NET1, DATA_PATH_RPT, "");
BOOST_REQUIRE(error == 0);
// Test of illegal node name change
@@ -161,7 +155,7 @@ BOOST_AUTO_TEST_CASE(test_setid_save)
BOOST_REQUIRE(error == 0);
// Save the project
error = EN_saveinpfile(ph, inp_save.c_str());
error = EN_saveinpfile(ph, "net1_setid.inp");
BOOST_REQUIRE(error == 0);
error = EN_close(ph);
@@ -172,24 +166,18 @@ BOOST_AUTO_TEST_CASE(test_setid_save)
BOOST_AUTO_TEST_CASE(test_setid_reopen, * boost::unit_test::depends_on("setid_save_reopen/test_setid_save"))
{
std::string inp_save("net1_setid.inp");
std::string path_out(DATA_PATH_OUT);
std::string path_rpt(DATA_PATH_RPT);
int error = 0;
int index;
EN_Project ph = NULL;
char newid_2[] = "Node3";
// Re-open the saved project
EN_createproject(&ph);
error = EN_open(ph, inp_save.c_str(), path_rpt.c_str(), "");
error = EN_open(ph, "net1_setid.inp", DATA_PATH_RPT, "");
BOOST_REQUIRE(error == 0);
// Check that 3rd node has its new name
error = EN_getnodeindex(ph, newid_2, &index);
error = EN_getnodeindex(ph, "Node3", &index);
BOOST_REQUIRE(error == 0);
BOOST_REQUIRE(index == 3);