From 186c17bb153f56681f88e9447330b0de64818d75 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Mon, 10 Dec 2018 17:30:47 -0500 Subject: [PATCH] Adding file headers --- include/epanet_py.h | 14 ++++++++-- src/epanet_py.c | 12 ++++++++ tests/test_epanet_py.cpp | 59 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 tests/test_epanet_py.cpp diff --git a/include/epanet_py.h b/include/epanet_py.h index fd81651..ffadb7b 100644 --- a/include/epanet_py.h +++ b/include/epanet_py.h @@ -1,5 +1,15 @@ - - +/* + ****************************************************************************** + Project: OWA EPANET + Version: 2.2 + Module: epanet_py.h + Description: EPANET API functions for Python SWIG wrap + Authors: see AUTHORS + Copyright: see AUTHORS + License: see LICENSE + Last Updated: 12/10/2018 + ****************************************************************************** +*/ #ifndef EPANET_PY_H diff --git a/src/epanet_py.c b/src/epanet_py.c index 56d0878..f1e8dc9 100644 --- a/src/epanet_py.c +++ b/src/epanet_py.c @@ -1,3 +1,15 @@ +/* + ****************************************************************************** + Project: OWA EPANET + Version: 2.2 + Module: epanet_py.c + Description: EPANET API functions for Python SWIG wrap + Authors: see AUTHORS + Copyright: see AUTHORS + License: see LICENSE + Last Updated: 12/10/2018 + ****************************************************************************** +*/ #include diff --git a/tests/test_epanet_py.cpp b/tests/test_epanet_py.cpp new file mode 100644 index 0000000..f7d0a2b --- /dev/null +++ b/tests/test_epanet_py.cpp @@ -0,0 +1,59 @@ + + + + +#define BOOST_TEST_MODULE "toolkit" +#include + +#include +#include "epanet_py.h" + +// NOTE: Project Home needs to be updated to run unit test +#define DATA_PATH_INP "./net1.inp" +#define DATA_PATH_RPT "./test.rpt" +#define DATA_PATH_OUT "./test.out" + +using namespace std; + + +BOOST_AUTO_TEST_SUITE (test_toolkit) + +BOOST_AUTO_TEST_CASE (test_alloc_free) +{ + int error = 0; + Handle ph = NULL; + + error = create_project(&ph); + + BOOST_REQUIRE(error == 0); + BOOST_CHECK(ph != NULL); + + error = delete_project(&ph); + + BOOST_REQUIRE(error == 0); + BOOST_CHECK(ph == NULL); +} + +BOOST_AUTO_TEST_CASE(test_epanet) +{ + string path_inp(DATA_PATH_INP); + string path_rpt(DATA_PATH_RPT); + string path_out(DATA_PATH_OUT); + + char *msg = nullptr; + + Handle ph = NULL; + + create_project(&ph); + clear_error(ph); + + int error = run_project(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); + BOOST_CHECK(error == 0); + + check_error(ph, &msg); + toolkit_free((void **)&msg); + + delete_project(&ph); +} + +BOOST_AUTO_TEST_SUITE_END()