Fix bug and test remove demand

This commit is contained in:
Michael Tryby
2019-04-24 18:40:47 -04:00
parent dc3c2ffe1a
commit 35cf9bd422
2 changed files with 17 additions and 2 deletions

View File

@@ -2560,7 +2560,7 @@ int DLLEXPORT EN_removedemand(EN_Project p, int node_index, int demand_key)
list_t *dlist = Node[node_index].D;
remove_node(dlist, search_list(dlist, demand_key));
remove_node(dlist, demand_key);
return 0;
}

View File

@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(test_categories_reopen, * boost::unit_test::depends_on("tes
BOOST_FIXTURE_TEST_CASE(test_adddemand, FixtureSingleNode)
{
int demand_key;
int key, demand_key;
error = EN_adddemand(ph, node_qhut, 100.0, "PrimaryPattern", "PrimaryDemand", &demand_key);
BOOST_CHECK(error != 0);
@@ -94,6 +94,21 @@ BOOST_FIXTURE_TEST_CASE(test_adddemand, FixtureSingleNode)
error = EN_adddemand(ph, node_qhut, 100.0, "PrimaryPattern", "PrimaryDemand", &demand_key);
BOOST_CHECK(error == 0);
error = EN_addpattern(ph, (char *)"SecondaryPattern");
BOOST_REQUIRE(error == 0);
error = EN_adddemand(ph, node_qhut, 10.0, "SecondaryPattern", "SecondaryDemand", &key);
BOOST_CHECK(error == 0);
error = EN_addpattern(ph, (char *)"TertiaryPattern");
BOOST_REQUIRE(error == 0);
error = EN_adddemand(ph, node_qhut, 1.0, "TertiaryPattern", "TertiaryDemand", &demand_key);
BOOST_CHECK(error == 0);
error = EN_removedemand(ph, node_qhut, key);
BOOST_CHECK(error == 0);
}