This commit is contained in:
Michael Tryby
2019-04-02 15:27:05 -04:00
parent 44fc73cf41
commit ecf0e5173c
28 changed files with 163 additions and 158 deletions

View File

@@ -12,7 +12,6 @@
*/
#include <stdio.h>
#include "epanet2.h"
void writeConsole(char *s)

View File

@@ -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,24 +216,26 @@ 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));
// Read input data
ERRCODE(getdata(p));
// Close input file
if (p->parser.InFile != NULL) {
// Close input file
if (p->parser.InFile != NULL)
{
fclose(p->parser.InFile);
p->parser.InFile = NULL;
}
}
// Free temporary linked lists used for Patterns & Curves
freeTmplist(p->parser.Patlist);
freeTmplist(p->parser.Curvelist);
// Free temporary linked lists used for Patterns & Curves
freeTmplist(p->parser.Patlist);
freeTmplist(p->parser.Curvelist);
// If using previously saved hydraulics file then open it
if (p->outfile.Hydflag == USE) ERRCODE(openhydfile(p));
// If using previously saved hydraulics file then open it
if (p->outfile.Hydflag == USE) ERRCODE(openhydfile(p));
// Write input summary to report file
// Write input summary to report file
if (!errcode)
{
if (p->report.Summaryflag) writesummary(p);
writetime(p, FMT104);
p->Openflag = TRUE;

View File

@@ -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>
#include <stdlib.h>
#endif
#include <string.h>
#include "types.h"

View File

@@ -26,7 +26,6 @@ typedef struct {
Project *project;
error_handle_t *error;
}handle_t;
// Extern functions
extern char *geterrmsg(int, char *);
// Local functions

View File

@@ -11,9 +11,12 @@
******************************************************************************
*/
#ifndef __APPLE__
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include <string.h>
#include "hash.h"
#define HASHTABLEMAXSIZE 128000

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -12,7 +12,6 @@ Last Updated: 11/27/2018
*/
#include <stdio.h>
#include "types.h"
#include "funcs.h"

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -15,7 +15,9 @@
*/
#include <stdlib.h>
#ifndef __APPLE__
#include <malloc.h>
#endif
#include "mempool.h"
/*

View File

@@ -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"

View File

@@ -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>

View File

@@ -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"

View File

@@ -13,7 +13,6 @@ Last Updated: 11/27/2018
#include <stdio.h>
#include <math.h>
#include "types.h"
// Exported functions

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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"

View File

@@ -14,10 +14,8 @@
#ifndef TYPES_H
#define TYPES_H
#include <stdio.h>
#include "hash.h"
#include <stdio.h>
/*
-------------------------------------------

View File

@@ -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"

View File

@@ -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})

View File

@@ -11,6 +11,7 @@
******************************************************************************
*/
//#define BOOST_ALL_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "test_toolkit.hpp"

View File

@@ -56,47 +56,35 @@ BOOST_AUTO_TEST_CASE(test_save)
{
int error;
EN_Project ph = NULL;
EN_Project ph_save;
error = EN_createproject(&ph);
BOOST_REQUIRE(error == 0);
error = EN_open(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
EN_createproject(&ph_save);
error = EN_open(ph_save, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
BOOST_REQUIRE(error == 0);
error = EN_saveinpfile(ph, DATA_PATH_TMP);
error = EN_saveinpfile(ph_save, "test_reopen.inp");
BOOST_REQUIRE(error == 0);
BOOST_CHECK(boost::filesystem::exists(DATA_PATH_TMP) == true);
BOOST_CHECK(boost::filesystem::exists("test_reopen.inp") == true);
error = EN_close(ph);
error = EN_close(ph_save);
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);
BOOST_REQUIRE(error == 0);
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);
BOOST_REQUIRE(error == 0);
error = EN_close(ph);
BOOST_REQUIRE(error == 0);
EN_deleteproject(&ph);
BOOST_REQUIRE(error == 0);
BOOST_CHECK(ph == NULL);
error = EN_close(ph_reopen);
BOOST_REQUIRE(error == 0);
EN_deleteproject(&ph_reopen);
}
BOOST_AUTO_TEST_CASE(test_run)

View File

@@ -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"