Updating unit tests

This commit is contained in:
Michael Tryby
2019-04-12 15:22:38 -04:00
parent 2404493f81
commit ce12b2297e
3 changed files with 287 additions and 222 deletions

View File

@@ -20,6 +20,41 @@
BOOST_AUTO_TEST_SUITE (test_link) BOOST_AUTO_TEST_SUITE (test_link)
BOOST_FIXTURE_TEST_CASE(test_adddelete_link, FixtureInitClose)
{
int index;
// Build a network
EN_addnode(ph, (char *)"N1", EN_JUNCTION);
EN_addnode(ph, (char *)"N2", EN_JUNCTION);
EN_addnode(ph, (char *)"N3", EN_RESERVOIR);
error = EN_addlink(ph, (char *)"L1", EN_PUMP, (char *)"N3", (char *)"N1");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, (char *)"L2", EN_PIPE, (char *)"N1", (char *)"N3");
BOOST_REQUIRE(error == 0);
error = EN_getlinkindex(ph, "L2", &index);
BOOST_REQUIRE(error == 0);
error = EN_deletelink(ph, index, EN_UNCONDITIONAL);
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, (char *)"L3", EN_PIPE, (char *)"N1", (char *)"N2");
BOOST_REQUIRE(error == 0);
error = EN_getlinkindex(ph, "L1", &index);
BOOST_REQUIRE(error == 0);
error = EN_deletelink(ph, index, EN_UNCONDITIONAL);
BOOST_REQUIRE(error == 0);
error = EN_getlinkindex(ph, "L3", &index);
BOOST_REQUIRE(error == 0);
error = EN_deletelink(ph, index, EN_UNCONDITIONAL);
BOOST_REQUIRE(error == 0);
}
BOOST_AUTO_TEST_CASE(test_setlinktype) BOOST_AUTO_TEST_CASE(test_setlinktype)
{ {
int error = 0; int error = 0;

View File

@@ -1,25 +1,25 @@
/* /*
****************************************************************************** ******************************************************************************
Project: OWA EPANET Project: OWA EPANET
Version: 2.2 Version: 2.2
Module: test_net_builder.cpp Module: test_net_builder.cpp
Description: Tests EPANET toolkit api functions Description: Tests EPANET toolkit api functions
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 03/21/2019 Last Updated: 04/12/2019
****************************************************************************** ******************************************************************************
*/ */
#define BOOST_TEST_MODULE net_builder #define BOOST_TEST_MODULE net_builder
#ifdef _DEBUG #ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC #define _CRTDBG_MAP_ALLOC
#include <stdlib.h> #include <stdlib.h>
#include <crtdbg.h> #include <crtdbg.h>
#else #else
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#include <boost/test/included/unit_test.hpp> #include <boost/test/included/unit_test.hpp>
@@ -400,10 +400,10 @@ BOOST_AUTO_TEST_CASE(test_reopen_net2, *boost::unit_test::depends_on("test_net_b
//cout << "\n Link L2 Flow: " << q2_1 << " " << q2_2; //cout << "\n Link L2 Flow: " << q2_1 << " " << q2_2;
// Compare old & new results // Compare old & new results
// BOOST_CHECK(abs(p1_1 - p1_2) < 1.e-5); // BOOST_CHECK(abs(p1_1 - p1_2) < 1.e-5);
// BOOST_CHECK(abs(q1_1 - q1_2) < 1.e-5); // BOOST_CHECK(abs(q1_1 - q1_2) < 1.e-5);
// BOOST_CHECK(abs(p2_1 - p2_2) < 1.e-5); // BOOST_CHECK(abs(p2_1 - p2_2) < 1.e-5);
// BOOST_CHECK(abs(q2_1 - q2_2) < 1.e-5); // BOOST_CHECK(abs(q2_1 - q2_2) < 1.e-5);
// Close project // Close project
EN_close(ph); EN_close(ph);

View File

@@ -18,6 +18,35 @@
BOOST_AUTO_TEST_SUITE (test_node) BOOST_AUTO_TEST_SUITE (test_node)
BOOST_FIXTURE_TEST_CASE(test_adddelete_node, FixtureInitClose)
{
int index;
error = EN_addnode(ph, (char *)"N2", EN_JUNCTION);
BOOST_REQUIRE(error == 0);
error = EN_addnode(ph, (char *)"N3", EN_RESERVOIR);
BOOST_REQUIRE(error == 0);
error = EN_getnodeindex(ph, "N2", &index);
BOOST_REQUIRE(error == 0);
error = EN_deletenode(ph, index, EN_UNCONDITIONAL);
BOOST_REQUIRE(error == 0);
error = EN_addnode(ph, (char *)"N4", EN_TANK);
BOOST_REQUIRE(error == 0);
error = EN_getnodeindex(ph, "N4", &index);
BOOST_REQUIRE(error == 0);
error = EN_deletenode(ph, index, EN_UNCONDITIONAL);
BOOST_REQUIRE(error == 0);
error = EN_getnodeindex(ph, "N3", &index);
BOOST_REQUIRE(error == 0);
error = EN_deletenode(ph, index, EN_UNCONDITIONAL);
BOOST_REQUIRE(error == 0);
}
BOOST_FIXTURE_TEST_CASE(test_junc_props, FixtureOpenClose) BOOST_FIXTURE_TEST_CASE(test_junc_props, FixtureOpenClose)
{ {
int index; int index;
@@ -297,4 +326,5 @@ BOOST_AUTO_TEST_CASE(test_reopen_comment, * boost::unit_test::depends_on("node_c
EN_deleteproject(&ph); EN_deleteproject(&ph);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()