Passing open and close test

This commit is contained in:
Michael Tryby
2019-04-18 16:16:02 -04:00
parent bf519fdd94
commit 901a802f21
4 changed files with 35 additions and 12 deletions

View File

@@ -132,7 +132,7 @@ int juncdata(Project *pr)
// apply the default demand pattern and append the data
if (p == 0) p = findpattern(net, parser->DefPatID);
demand_data = create_demand_data(y, p, NULL);
if (demand_data == NULL) return 101;
if (demand_data == NULL) return 101;
append_list(demand_list, &demand_data);
}

View File

@@ -339,14 +339,14 @@ typedef struct // Curve Object
double *Y; // y-values
} Scurve;
struct Sdemand // Demand List Item
{
double Base; // baseline demand
int Pat; // pattern index
char *Name; // demand category name
struct Sdemand *next; // next demand list item
};
typedef struct Sdemand *Pdemand; // Pointer to demand list
//struct Sdemand // Demand List Item
//{
// double Base; // baseline demand
// int Pat; // pattern index
// char *Name; // demand category name
// struct Sdemand *next; // next demand list item
//};
//typedef struct Sdemand *Pdemand; // Pointer to demand list
typedef struct // Energy Usage Object
{

View File

@@ -27,7 +27,7 @@ add_executable(test_demand_data test_demand_data.cpp
../src/demand.c
../src/util/list.c)
target_include_directories(test_demand_data PUBLIC ../src/ ../src/util/)
target_link_libraries(test_demand_data ${Boost_LIBRARIES})
target_link_libraries(test_demand_data ${Boost_LIBRARIES} epanet2)
add_test(NAME test_demand_data
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_demand_data
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)

View File

@@ -15,6 +15,13 @@
#include <boost/test/unit_test.hpp>
#include "demand.h"
#include "epanet2_2.h"
#define DATA_PATH_NET1 "./net1.inp"
#define DATA_PATH_TMP "./tmp.inp"
#define DATA_PATH_RPT "./test.rpt"
#define DATA_PATH_OUT "./test.out"
boost::test_tools::predicate_result check_string(std::string test, std::string ref)
@@ -62,12 +69,11 @@ struct Fixture {
_data = create_demand_data(100.0, 1, "CUB_SCOUT_BASE_CAMP");
append_list(dlist, &_data);
}
~Fixture() {
delete_list(dlist);
}
void *_data;
demand_data_t *_data;
list_t *dlist;
};
@@ -134,5 +140,22 @@ BOOST_FIXTURE_TEST_CASE(test_convert_demand, Fixture)
BOOST_TEST(demand == 6.31, boost::test_tools::tolerance(0.01));
}
BOOST_AUTO_TEST_CASE(test_openclose)
{
int error;
EN_Project ph = NULL;
EN_createproject(&ph);
error = EN_open(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
BOOST_REQUIRE(error == 0);
error = EN_close(ph);
BOOST_REQUIRE(error == 0);
EN_deleteproject(&ph);
}
BOOST_AUTO_TEST_SUITE_END()