Python package epanet-python builds and runs

This commit is contained in:
Michael Tryby
2018-07-03 18:47:30 -04:00
4 changed files with 70 additions and 7 deletions

View File

@@ -52,6 +52,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Sets the position independent code property for all targets # Sets the position independent code property for all targets
SET(CMAKE_POSITION_INDEPENDENT_CODE ON) SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -69,8 +70,6 @@ ENDIF (MSVC)
# configure file groups # configure file groups
file(GLOB EPANET_SOURCES src/*.c) file(GLOB EPANET_SOURCES src/*.c)
file(GLOB EPANET_LIB_ALL src/*) file(GLOB EPANET_LIB_ALL src/*)
source_group("Library" FILES ${EPANET_LIB_ALL}) source_group("Library" FILES ${EPANET_LIB_ALL})

View File

@@ -37,8 +37,7 @@ foreach(testSrc ${TEST_SRCS})
#link to Boost libraries AND your targets and dependencies #link to Boost libraries AND your targets and dependencies
target_link_libraries(${testName} ${Boost_LIBRARIES} epanet epanet-output) target_link_libraries(${testName} ${Boost_LIBRARIES} epanet epanet-output)
#Finally add it to test execution
#Finally add it to test execution -
#Notice the WORKING_DIRECTORY and COMMAND #Notice the WORKING_DIRECTORY and COMMAND
add_test(NAME ${testName} add_test(NAME ${testName}
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${testName} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${testName}

View File

@@ -22,7 +22,6 @@
#include "epanet_output.h" #include "epanet_output.h"
#define DATA_PATH "./net1.out" #define DATA_PATH "./net1.out"
using namespace std; using namespace std;
@@ -117,7 +116,6 @@ struct Fixture{
float* array; float* array;
int array_dim; int array_dim;
}; };
BOOST_AUTO_TEST_SUITE(test_output_fixture) BOOST_AUTO_TEST_SUITE(test_output_fixture)
@@ -179,7 +177,6 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeAttribute, Fixture) {
std::vector<float> ref_vec; std::vector<float> ref_vec;
ref_vec.assign(ref_array, ref_array + ref_dim); ref_vec.assign(ref_array, ref_array + ref_dim);
std::vector<float> test_vec; std::vector<float> test_vec;
test_vec.assign(array, array + array_dim); test_vec.assign(array, array + array_dim);

68
tests/test_toolkit.cpp Normal file
View File

@@ -0,0 +1,68 @@
//
// test_epanet_toolkit.cpp
//
// Date Created: January 24, 2018
//
// Author: Michael E. Tryby
// US EPA - ORD/NRMRL
//
//#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "toolkit"
#include <boost/test/included/unit_test.hpp>
#include <string>
#include "epanet2.h"
// NOTE: Project Home needs to be updated to run unit test
#define PROJECT_HOME "C:/Users/mtryby/Workspace/GitRepo/michaeltryby/epanet"
#define DATA_PATH "/tests/network_tests/net1"
using namespace std;
BOOST_AUTO_TEST_SUITE (test_toolkit)
BOOST_AUTO_TEST_CASE (test_alloc_free)
{
int error = 0;
EN_ProjectHandle ph = NULL;
error = EN_alloc(&ph);
BOOST_REQUIRE(error == 0);
BOOST_CHECK(ph != NULL);
error = EN_free(&ph);
BOOST_REQUIRE(error == 0);
BOOST_CHECK(ph == NULL);
}
BOOST_AUTO_TEST_SUITE_END( )
// int main(int argc, char *argv[])
// {
// int error = 0;
// EN_ProjectHandle project = NULL;
// std::string data_path = std::string(PROJECT_HOME) + std::string(DATA_PATH);
// std::string inputFile(data_path);
// inputFile.append(std::string("/net1.inp"));
// std::string reportFile(data_path);
// reportFile.append(std::string("/net1.rpt"));
// std::string outputFile(data_path);
// outputFile.append(std::string("/net1.out"));
// error = EN_alloc(&project);
// error = EN_open(project, inputFile.c_str(), reportFile.c_str(), outputFile.c_str());
// error = EN_solveH(project);
// error = EN_solveQ(project);
// error = EN_report(project);
// error = EN_close(project);
// error = EN_free(&project);
// return error;
// }