@@ -12,7 +12,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "epanet2.h"
|
||||
|
||||
void writeConsole(char *s)
|
||||
|
||||
19
src/epanet.c
19
src/epanet.c
@@ -11,17 +11,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -221,12 +216,12 @@ int DLLEXPORT EN_open(EN_Project p, const char *inpFile, const char *rptFile,
|
||||
ERRCODE(netsize(p));
|
||||
ERRCODE(allocdata(p));
|
||||
|
||||
if (!errcode) {
|
||||
// Read input data
|
||||
ERRCODE(getdata(p));
|
||||
|
||||
// Close input file
|
||||
if (p->parser.InFile != NULL) {
|
||||
if (p->parser.InFile != NULL)
|
||||
{
|
||||
fclose(p->parser.InFile);
|
||||
p->parser.InFile = NULL;
|
||||
}
|
||||
@@ -239,6 +234,8 @@ int DLLEXPORT EN_open(EN_Project p, const char *inpFile, const char *rptFile,
|
||||
if (p->outfile.Hydflag == USE) ERRCODE(openhydfile(p));
|
||||
|
||||
// Write input summary to report file
|
||||
if (!errcode)
|
||||
{
|
||||
if (p->report.Summaryflag) writesummary(p);
|
||||
writetime(p, FMT104);
|
||||
p->Openflag = TRUE;
|
||||
|
||||
@@ -10,15 +10,11 @@
|
||||
Last Updated: 03/17/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -26,7 +26,6 @@ typedef struct {
|
||||
Project *project;
|
||||
error_handle_t *error;
|
||||
}handle_t;
|
||||
|
||||
// Extern functions
|
||||
extern char *geterrmsg(int, char *);
|
||||
// Local functions
|
||||
|
||||
@@ -11,9 +11,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
#define HASHTABLEMAXSIZE 128000
|
||||
|
||||
@@ -11,9 +11,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -11,9 +11,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -12,9 +12,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -12,7 +12,6 @@ Last Updated: 11/27/2018
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "funcs.h"
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@ Last Updated: 03/17/2019
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
14
src/input1.c
14
src/input1.c
@@ -10,23 +10,19 @@ License: see LICENSE
|
||||
Last Updated: 03/17/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "funcs.h"
|
||||
#include "hash.h"
|
||||
#include "text.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// Default values
|
||||
#define MAXITER 200 // Default max. # hydraulic iterations
|
||||
|
||||
15
src/input2.c
15
src/input2.c
@@ -10,16 +10,13 @@ License: see LICENSE
|
||||
Last Updated: 03/17/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
@@ -150,7 +147,7 @@ int readdata(Project *pr)
|
||||
inperr, errsum; // Error code & total error count
|
||||
|
||||
// Allocate input buffer
|
||||
parser->X = (double *)calloc(MAXTOKS + 1, sizeof(double));
|
||||
parser->X = (double *)calloc(MAXTOKS, sizeof(double));
|
||||
ERRCODE(MEMCHECK(parser->X));
|
||||
if (errcode) return errcode;
|
||||
|
||||
@@ -178,7 +175,7 @@ int readdata(Project *pr)
|
||||
while (fgets(line, MAXLINE, parser->InFile) != NULL)
|
||||
{
|
||||
// Make copy of line and scan for tokens
|
||||
strncpy(wline, line, MAXLINE);
|
||||
strcpy(wline, line);
|
||||
parser->Ntokens = gettokens(wline, parser->Tok, MAXTOKS, parser->Comment);
|
||||
|
||||
// Skip blank lines and those filled with a comment
|
||||
|
||||
11
src/input3.c
11
src/input3.c
@@ -10,16 +10,13 @@ License: see LICENSE
|
||||
Last Updated: 03/17/2019
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include "mempool.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,9 +11,13 @@ Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -11,18 +11,14 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
//*** For the Windows SDK _tempnam function ***//
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
@@ -11,9 +11,13 @@ Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "mempool.h"
|
||||
|
||||
@@ -13,7 +13,6 @@ Last Updated: 11/27/2018
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// Exported functions
|
||||
|
||||
@@ -11,10 +11,13 @@ Last Updated: 11/27/2018
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "mempool.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf
|
||||
|
||||
@@ -11,9 +11,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "funcs.h"
|
||||
|
||||
@@ -18,11 +18,16 @@
|
||||
linsolve() -- called from netsolve() in HYDRAUL.C
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <time.h> //For optional timer macros
|
||||
|
||||
#include "text.h"
|
||||
|
||||
@@ -14,10 +14,8 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "hash.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
-------------------------------------------
|
||||
|
||||
@@ -10,7 +10,13 @@
|
||||
// US EPA - ORD/NRMRL
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//#ifdef _WIN32
|
||||
//#define _CRTDBG_MAP_ALLOC
|
||||
//#include <stdlib.h>
|
||||
//#include <crtdbg.h>
|
||||
//#else
|
||||
#include <stdlib.h>
|
||||
//#endif
|
||||
#include <string.h>
|
||||
|
||||
#include "errormanager.h"
|
||||
|
||||
@@ -19,19 +19,18 @@ endif(UNIX)
|
||||
set(toolkit_test_srcs
|
||||
test_toolkit.cpp
|
||||
test_project.cpp
|
||||
# test_hydraulics.cpp
|
||||
# test_quality.cpp
|
||||
# test_report.cpp
|
||||
# test_analysis.cpp
|
||||
# test_node.cpp
|
||||
# test_demand.cpp
|
||||
# test_link.cpp
|
||||
test_hydraulics.cpp
|
||||
test_quality.cpp
|
||||
test_report.cpp
|
||||
test_analysis.cpp
|
||||
test_node.cpp
|
||||
test_demand.cpp
|
||||
test_link.cpp
|
||||
# test_pump.cpp
|
||||
# test_pattern.cpp
|
||||
# test_curve.cpp
|
||||
# test_control.cpp
|
||||
# test_net_builder.cpp
|
||||
)
|
||||
test_pattern.cpp
|
||||
test_curve.cpp
|
||||
test_control.cpp
|
||||
test_net_builder.cpp)
|
||||
|
||||
add_executable(test_toolkit ${toolkit_test_srcs})
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
//#define BOOST_ALL_DYN_LINK
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "test_toolkit.hpp"
|
||||
|
||||
@@ -56,47 +56,35 @@ BOOST_AUTO_TEST_CASE(test_save)
|
||||
{
|
||||
int error;
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_Project ph_save;
|
||||
|
||||
error = EN_createproject(&ph);
|
||||
EN_createproject(&ph_save);
|
||||
error = EN_open(ph_save, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_open(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
|
||||
error = EN_saveinpfile(ph_save, "test_reopen.inp");
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_saveinpfile(ph, DATA_PATH_TMP);
|
||||
BOOST_CHECK(boost::filesystem::exists("test_reopen.inp") == true);
|
||||
|
||||
error = EN_close(ph_save);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
BOOST_CHECK(boost::filesystem::exists(DATA_PATH_TMP) == true);
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_deleteproject(&ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
BOOST_CHECK(ph == NULL);
|
||||
EN_deleteproject(&ph_save);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_reopen, * boost::unit_test::depends_on("test_project/test_save"))
|
||||
{
|
||||
int error;
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_Project ph_reopen;
|
||||
|
||||
error = EN_createproject(&ph);
|
||||
EN_createproject(&ph_reopen);
|
||||
error = EN_open(ph_reopen, "test_reopen.inp", DATA_PATH_RPT, DATA_PATH_OUT);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_open(ph, DATA_PATH_TMP, DATA_PATH_RPT, DATA_PATH_OUT);
|
||||
error = EN_close(ph_reopen);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_close(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
EN_deleteproject(&ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
BOOST_CHECK(ph == NULL);
|
||||
EN_deleteproject(&ph_reopen);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_run)
|
||||
|
||||
@@ -14,12 +14,6 @@
|
||||
#ifndef TEST_TOOLKIT_HPP
|
||||
#define TEST_TOOLKIT_HPP
|
||||
|
||||
// MSVC ONLY
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#include "epanet2_2.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user