diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e5d3f8..2e82365 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + # Sets the position independent code property for all targets SET(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -69,8 +70,6 @@ ENDIF (MSVC) # configure file groups file(GLOB EPANET_SOURCES src/*.c) - - file(GLOB EPANET_LIB_ALL src/*) source_group("Library" FILES ${EPANET_LIB_ALL}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 609d0b4..be6dc5a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,8 +37,7 @@ foreach(testSrc ${TEST_SRCS}) #link to Boost libraries AND your targets and dependencies 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 add_test(NAME ${testName} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${testName} diff --git a/tests/test_output.cpp b/tests/test_output.cpp index cd55f4f..3a0607e 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -22,7 +22,6 @@ #include "epanet_output.h" - #define DATA_PATH "./net1.out" using namespace std; @@ -117,7 +116,6 @@ struct Fixture{ float* array; int array_dim; - }; BOOST_AUTO_TEST_SUITE(test_output_fixture) @@ -179,7 +177,6 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeAttribute, Fixture) { std::vector ref_vec; ref_vec.assign(ref_array, ref_array + ref_dim); - std::vector test_vec; test_vec.assign(array, array + array_dim); diff --git a/tests/test_toolkit.cpp b/tests/test_toolkit.cpp new file mode 100644 index 0000000..abe33a3 --- /dev/null +++ b/tests/test_toolkit.cpp @@ -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 + +#include +#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; +// }