From 8687af337fd2afb109794179d066400ec1dfcebc Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Wed, 5 Sep 2018 09:33:21 +0300 Subject: [PATCH 01/10] Initial net builder test --- tests/test_net_builder.cpp | 244 +++++++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 tests/test_net_builder.cpp diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp new file mode 100644 index 0000000..30c45ce --- /dev/null +++ b/tests/test_net_builder.cpp @@ -0,0 +1,244 @@ +// +// test_net_builder.cpp +// + +#define BOOST_TEST_MODULE "toolkit" +#include + +#include +#include "epanet2.h" + +// NOTE: Project Home needs to be updated to run unit test +#define DATA_PATH_INP "./net1.inp" +#define DATA_PATH_RPT "./test.rpt" +#define DATA_PATH_OUT "./test.out" + +using namespace std; + +BOOST_AUTO_TEST_SUITE (test_toolkit) + +BOOST_AUTO_TEST_CASE(test_net_builder) +{ + int error = 0; + int flag = 00; + long t, tstep; + int i, ind, Lindex, Nindex, Cindex; + float h_orig, h_build, h_build_loaded; + + // first we load Net1.inp, run it and record the head in Tank 2 at the end of the simulation (h_orig) + EN_ProjectHandle ph = NULL; + EN_createproject(&ph); + + std::string path_inp = std::string(DATA_PATH_INP); + std::string path_rpt = std::string(DATA_PATH_RPT); + std::string path_out = std::string(DATA_PATH_OUT); + + error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); + BOOST_REQUIRE(error == 0); + + error = EN_getnodeindex(ph, "2", &Nindex); + BOOST_REQUIRE(error == 0); + + error = EN_openH(ph); + BOOST_REQUIRE(error == 0); + + error = EN_initH(ph, flag); + BOOST_REQUIRE(error == 0); + + do { + error = EN_runH(ph, &t); + BOOST_REQUIRE(error == 0); + + // this is the head at the end of the simulation after loading the original Net1.inp + error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_orig); + BOOST_REQUIRE(error == 0); + + error = EN_nextH(ph, &tstep); + BOOST_REQUIRE(error == 0); + + } while (tstep > 0); + + error = EN_closeH(ph); + BOOST_REQUIRE(error == 0); + + error = EN_close(ph); + BOOST_REQUIRE(error == 0); + + EN_deleteproject(&ph); + + // ------------------------------------------------------------------------ + // now we build Net1 from scratch... + char juncs[9][10] = { "10", "11", "12", "13", "21", "22", "23", "31", "32" }; + float e[9] = {710, 710, 700, 695, 700, 695, 690, 700, 710}; + float d[9] = {0, 150, 150, 100, 150, 200, 150, 100, 100 }; + float X[9] = {20, 30, 50, 70, 30, 50, 70, 30, 50}; + float Y[9] = {70, 70, 70, 70, 40, 40, 40, 10, 10 }; + float L[12] = {10530, 5280, 5280, 5280, 5280, 5280, 200, 5280, 5280, 5280, 5280, 5280}; + float dia[12] = { 18, 14, 10, 10, 12, 6, 18, 10, 12, 8, 8, 6 }; + float P[12] = { 1, 1.2, 1.4, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.6, 0.8 }; + + error = EN_createproject(&ph); + error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW); + for (i = 0; i < 9; i++) + { + error = EN_addnode(ph, juncs[i], EN_JUNCTION); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, i + 1,EN_ELEVATION, e[i]); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, i + 1, EN_BASEDEMAND, d[i]); + BOOST_REQUIRE(error == 0); + error = EN_setcoord(ph, i + 1, X[i], Y[i]); + BOOST_REQUIRE(error == 0); + } + error = EN_addnode(ph, "9", EN_RESERVOIR); + BOOST_REQUIRE(error == 0); + error = EN_setcoord(ph, 10, 10, 70); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 10, EN_ELEVATION, 800); + BOOST_REQUIRE(error == 0); + + error = EN_addnode(ph, "2", EN_TANK); + BOOST_REQUIRE(error == 0); + error = EN_setcoord(ph, 11, 50, 90); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 11, EN_TANKDIAM, 50.5); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 11, EN_ELEVATION, 850); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 11, EN_MAXLEVEL, 150); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 11, EN_TANKLEVEL, 120); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 11, EN_MINLEVEL, 100); + BOOST_REQUIRE(error == 0); + error = EN_setnodevalue(ph, 11, EN_MIXFRACTION, 1); + BOOST_REQUIRE(error == 0); + + error = EN_addlink(ph, "10", EN_PIPE, "10", "11"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "11", EN_PIPE, "11", "12"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "12", EN_PIPE, "12", "13"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "21", EN_PIPE, "21", "22"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "22", EN_PIPE, "22", "23"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "31", EN_PIPE, "31", "32"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "110", EN_PIPE, "2", "12"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "111", EN_PIPE, "11", "21"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "112", EN_PIPE, "12", "22"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "113", EN_PIPE, "13", "23"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "121", EN_PIPE, "21", "31"); + BOOST_REQUIRE(error == 0); + error = EN_addlink(ph, "122", EN_PIPE, "22", "32"); + BOOST_REQUIRE(error == 0); + for (i = 0; i < 12; i++) + { + error = EN_setlinkvalue(ph, i + 1, EN_LENGTH, L[i]); + BOOST_REQUIRE(error == 0); + error = EN_setlinkvalue(ph, i + 1, EN_DIAMETER, dia[i]); + BOOST_REQUIRE(error == 0); + } + + error = EN_addlink(ph, "9", EN_PUMP, "9", "10"); + BOOST_REQUIRE(error == 0); + error = EN_addcurve(ph, "1"); + BOOST_REQUIRE(error == 0); + error = EN_setcurvevalue(ph, 1, 1, 1500, 250); + BOOST_REQUIRE(error == 0); + error = EN_getlinkindex(ph, "9", &ind); + BOOST_REQUIRE(error == 0); + error = EN_setheadcurveindex(ph, ind, 1); + BOOST_REQUIRE(error == 0); + + error = EN_addpattern(ph, "1"); + BOOST_REQUIRE(error == 0); + error = EN_setpattern(ph, 1, P, 12); + BOOST_REQUIRE(error == 0); + error = EN_settimeparam(ph, EN_DURATION, 24*3600); + BOOST_REQUIRE(error == 0); + error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600); + BOOST_REQUIRE(error == 0); + + error = EN_getlinkindex(ph, "9", &Lindex); + BOOST_REQUIRE(error == 0); + error = EN_getnodeindex(ph, "2", &Nindex); + BOOST_REQUIRE(error == 0); + + // Add controls + error = EN_addcontrol(ph, &Cindex, EN_LOWLEVEL, Lindex, 1, Nindex, 110); + BOOST_REQUIRE(error == 0); + error = EN_addcontrol(ph, &Cindex, EN_HILEVEL, Lindex, 0, Nindex, 140); + BOOST_REQUIRE(error == 0); + + error = EN_saveinpfile(ph, "net_builder.inp"); + BOOST_REQUIRE(error == 0); + + error = EN_openH(ph); + BOOST_REQUIRE(error == 0); + error = EN_initH(ph, 0); + BOOST_REQUIRE(error == 0); + do { + error = EN_runH(ph, &t); + BOOST_REQUIRE(error == 0); + // this is the head at the end of the simulation after building the network *without* saving it to file + error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_build); + BOOST_REQUIRE(error == 0); + error = EN_nextH(ph, &tstep); + BOOST_REQUIRE(error == 0); + } while (tstep > 0); + error = EN_closeH(ph); + BOOST_REQUIRE(error == 0); + error = EN_close(ph); + BOOST_REQUIRE(error == 0); + error = EN_deleteproject(&ph); + BOOST_REQUIRE(error == 0); + + // ------------------------------------------------------------------------ + // now we load the netwok we just built and saved + EN_createproject(&ph); + error = EN_open(ph, "net_builder.inp", path_rpt.c_str(), path_out.c_str()); + BOOST_REQUIRE(error == 0); + + error = EN_openH(ph); + BOOST_REQUIRE(error == 0); + + error = EN_initH(ph, flag); + BOOST_REQUIRE(error == 0); + + do { + error = EN_runH(ph, &t); + BOOST_REQUIRE(error == 0); + // this is the head at the end of the simulation after building the network and saving it to file + error = EN_getnodevalue(ph, Nindex, EN_HEAD, &h_build_loaded); + BOOST_REQUIRE(error == 0); + error = EN_nextH(ph, &tstep); + BOOST_REQUIRE(error == 0); + + } while (tstep > 0); + + error = EN_closeH(ph); + BOOST_REQUIRE(error == 0); + + error = EN_close(ph); + BOOST_REQUIRE(error == 0); + + EN_deleteproject(&ph); + //--------------------------------------------------------------------- + // if we got this far we can compare results + + // compare the original to the build & saved network + BOOST_REQUIRE(h_orig == h_build_loaded); + + // compare the original to the build without saving +// BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( + +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file From ad3b26d72767d6cc65fe61bbf1fc9f7203a62c23 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Wed, 5 Sep 2018 09:37:21 +0300 Subject: [PATCH 02/10] Fail the test... --- tests/test_net_builder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index 30c45ce..b2803bf 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -237,7 +237,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(h_orig == h_build_loaded); // compare the original to the build without saving -// BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( + BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( } From d46dd1a1823ec79971fc690d22c6953d631b6aa8 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Wed, 5 Sep 2018 13:56:18 +0300 Subject: [PATCH 03/10] Added documentation --- tests/test_net_builder.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index b2803bf..c3f0559 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -2,6 +2,17 @@ // test_net_builder.cpp // +/* +This is a test for the network builder functions. It has three parts: +First Net1.inp is loaded, run and the head for Tank 2 at the end of the simulation is recorded (h_orig). +Then, Net1 is built from scratch using the net builder functions (EN_init, EN_addnode, EN_addlink....). +The built network is then run and the the final head of Tank 2 is recorded again (h_build). +In the last stage, the built network is saved to an INP file which is reloaded and runs. Again the final +head is recoded (h_build_loaded). + +The test ends with a check that the three head values are equal. +*/ + #define BOOST_TEST_MODULE "toolkit" #include @@ -177,9 +188,6 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_addcontrol(ph, &Cindex, EN_HILEVEL, Lindex, 0, Nindex, 140); BOOST_REQUIRE(error == 0); - error = EN_saveinpfile(ph, "net_builder.inp"); - BOOST_REQUIRE(error == 0); - error = EN_openH(ph); BOOST_REQUIRE(error == 0); error = EN_initH(ph, 0); @@ -195,6 +203,10 @@ BOOST_AUTO_TEST_CASE(test_net_builder) } while (tstep > 0); error = EN_closeH(ph); BOOST_REQUIRE(error == 0); + + error = EN_saveinpfile(ph, "net_builder.inp"); + BOOST_REQUIRE(error == 0); + error = EN_close(ph); BOOST_REQUIRE(error == 0); error = EN_deleteproject(&ph); @@ -237,7 +249,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(h_orig == h_build_loaded); // compare the original to the build without saving - BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( + //BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( } From 102ac90a9863b0a184267fa7e2c25eb83c97e93e Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Wed, 5 Sep 2018 13:56:59 +0300 Subject: [PATCH 04/10] Adding last test --- tests/test_net_builder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index c3f0559..079eabf 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(h_orig == h_build_loaded); // compare the original to the build without saving - //BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( + BOOST_REQUIRE(h_orig == h_build); // this seems to fail :( } From 40a53718cc0d4b94aeabbfe0c17e3e9559c00c6d Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 6 Sep 2018 12:01:09 +0300 Subject: [PATCH 05/10] Fix EN_setnodevalue for EN_MINLEVEL Vmin was not updated correctly --- src/epanet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/epanet.c b/src/epanet.c index f1da41b..72bc727 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -3044,7 +3044,7 @@ int DLLEXPORT EN_setnodevalue(EN_ProjectHandle ph, int index, int code, EN_API_F if (Tank[j].Vcurve > 0) return set_error(p->error_handle, 202); Tank[j].Hmin = Htmp; - Tank[j].Vmin = tankvolume(p, j, Tank[j].Hmin); + Tank[j].Vmin = (Tank[j].Hmin - Node[index].El) * Tank[j].A; } else { return set_error(p->error_handle, 251); } From 7cf8d53356235b2163f6d0a2a01a53e1f63f5cdc Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 6 Sep 2018 12:07:14 +0300 Subject: [PATCH 06/10] Explicitly set demant patterns for junctions This is since there is currently no way to set the default demand pattern. Should be fixed in #280 and then the test can be changed. --- tests/test_net_builder.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index 079eabf..d279664 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -90,6 +90,10 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_createproject(&ph); error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW); + error = EN_addpattern(ph, "1"); + BOOST_REQUIRE(error == 0); + error = EN_setpattern(ph, 1, P, 12); + BOOST_REQUIRE(error == 0); for (i = 0; i < 9; i++) { error = EN_addnode(ph, juncs[i], EN_JUNCTION); @@ -100,6 +104,8 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, i + 1, X[i], Y[i]); BOOST_REQUIRE(error == 0); + error = EN_setdemandpattern(ph, i + 1, 1, 1); + BOOST_REQUIRE(error == 0); } error = EN_addnode(ph, "9", EN_RESERVOIR); BOOST_REQUIRE(error == 0); @@ -168,10 +174,6 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setheadcurveindex(ph, ind, 1); BOOST_REQUIRE(error == 0); - error = EN_addpattern(ph, "1"); - BOOST_REQUIRE(error == 0); - error = EN_setpattern(ph, 1, P, 12); - BOOST_REQUIRE(error == 0); error = EN_settimeparam(ph, EN_DURATION, 24*3600); BOOST_REQUIRE(error == 0); error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600); From 8d5d20f5427b72bddaea6d9cfc193a71170c5076 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 13 Sep 2018 15:33:12 +0300 Subject: [PATCH 07/10] Fixing char casting in test file --- tests/test_net_builder.cpp | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index d279664..a9d896e 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, "2", &Nindex); + error = EN_getnodeindex(ph, (const char *)"2", &Nindex); BOOST_REQUIRE(error == 0); error = EN_openH(ph); @@ -89,8 +89,8 @@ BOOST_AUTO_TEST_CASE(test_net_builder) float P[12] = { 1, 1.2, 1.4, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.6, 0.8 }; error = EN_createproject(&ph); - error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW); - error = EN_addpattern(ph, "1"); + error = EN_init(ph, (const char *)"net.rpt", (const char *)"net.out", EN_GPM, EN_HW); + error = EN_addpattern(ph, (const char *)"1"); BOOST_REQUIRE(error == 0); error = EN_setpattern(ph, 1, P, 12); BOOST_REQUIRE(error == 0); @@ -107,14 +107,14 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setdemandpattern(ph, i + 1, 1, 1); BOOST_REQUIRE(error == 0); } - error = EN_addnode(ph, "9", EN_RESERVOIR); + error = EN_addnode(ph, (const char *)"9", EN_RESERVOIR); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 10, 10, 70); BOOST_REQUIRE(error == 0); error = EN_setnodevalue(ph, 10, EN_ELEVATION, 800); BOOST_REQUIRE(error == 0); - error = EN_addnode(ph, "2", EN_TANK); + error = EN_addnode(ph, (const char *)"2", EN_TANK); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 11, 50, 90); BOOST_REQUIRE(error == 0); @@ -131,29 +131,29 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setnodevalue(ph, 11, EN_MIXFRACTION, 1); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "10", EN_PIPE, "10", "11"); + error = EN_addlink(ph, (const char *)"10", EN_PIPE, (const char *)"10", (const char *)"11"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "11", EN_PIPE, "11", "12"); + error = EN_addlink(ph, (const char *)"11", EN_PIPE, (const char *)"11", (const char *)"12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "12", EN_PIPE, "12", "13"); + error = EN_addlink(ph, (const char *)"12", EN_PIPE, (const char *)"12", (const char *)"13"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "21", EN_PIPE, "21", "22"); + error = EN_addlink(ph, (const char *)"21", EN_PIPE, (const char *)"21", (const char *)"22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "22", EN_PIPE, "22", "23"); + error = EN_addlink(ph, (const char *)"22", EN_PIPE, (const char *)"22", (const char *)"23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "31", EN_PIPE, "31", "32"); + error = EN_addlink(ph, (const char *)"31", EN_PIPE, (const char *)"31", (const char *)"32"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "110", EN_PIPE, "2", "12"); + error = EN_addlink(ph, (const char *)"110", EN_PIPE, (const char *)"2", (const char *)"12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "111", EN_PIPE, "11", "21"); + error = EN_addlink(ph, (const char *)"111", EN_PIPE, (const char *)"11", (const char *)"21"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "112", EN_PIPE, "12", "22"); + error = EN_addlink(ph, (const char *)"112", EN_PIPE, (const char *)"12", (const char *)"22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "113", EN_PIPE, "13", "23"); + error = EN_addlink(ph, (const char *)"113", EN_PIPE, (const char *)"13", (const char *)"23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "121", EN_PIPE, "21", "31"); + error = EN_addlink(ph, (const char *)"121", EN_PIPE, (const char *)"21", (const char *)"31"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "122", EN_PIPE, "22", "32"); + error = EN_addlink(ph, (const char *)"122", EN_PIPE, (const char *)"22", (const char *)"32"); BOOST_REQUIRE(error == 0); for (i = 0; i < 12; i++) { @@ -163,13 +163,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(error == 0); } - error = EN_addlink(ph, "9", EN_PUMP, "9", "10"); + error = EN_addlink(ph, (const char *)"9", EN_PUMP, (const char *)"9", (const char *)"10"); BOOST_REQUIRE(error == 0); - error = EN_addcurve(ph, "1"); + error = EN_addcurve(ph, (const char *)"1"); BOOST_REQUIRE(error == 0); error = EN_setcurvevalue(ph, 1, 1, 1500, 250); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, "9", &ind); + error = EN_getlinkindex(ph, (const char *)"9", &ind); BOOST_REQUIRE(error == 0); error = EN_setheadcurveindex(ph, ind, 1); BOOST_REQUIRE(error == 0); @@ -179,9 +179,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, "9", &Lindex); + error = EN_getlinkindex(ph, (const char *)"9", &Lindex); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, "2", &Nindex); + error = EN_getnodeindex(ph, (const char *)"2", &Nindex); BOOST_REQUIRE(error == 0); // Add controls @@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_closeH(ph); BOOST_REQUIRE(error == 0); - error = EN_saveinpfile(ph, "net_builder.inp"); + error = EN_saveinpfile(ph, (const char *)"net_builder.inp"); BOOST_REQUIRE(error == 0); error = EN_close(ph); @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) // ------------------------------------------------------------------------ // now we load the netwok we just built and saved EN_createproject(&ph); - error = EN_open(ph, "net_builder.inp", path_rpt.c_str(), path_out.c_str()); + error = EN_open(ph, (const char *)"net_builder.inp", path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); error = EN_openH(ph); From 735811dd60b00f920998904dc19fbcd94c8cfef5 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 13 Sep 2018 16:17:06 +0300 Subject: [PATCH 08/10] Revert "Fixing char casting in test file" This reverts commit 8d5d20f5427b72bddaea6d9cfc193a71170c5076. --- tests/test_net_builder.cpp | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index a9d896e..d279664 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, (const char *)"2", &Nindex); + error = EN_getnodeindex(ph, "2", &Nindex); BOOST_REQUIRE(error == 0); error = EN_openH(ph); @@ -89,8 +89,8 @@ BOOST_AUTO_TEST_CASE(test_net_builder) float P[12] = { 1, 1.2, 1.4, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.6, 0.8 }; error = EN_createproject(&ph); - error = EN_init(ph, (const char *)"net.rpt", (const char *)"net.out", EN_GPM, EN_HW); - error = EN_addpattern(ph, (const char *)"1"); + error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW); + error = EN_addpattern(ph, "1"); BOOST_REQUIRE(error == 0); error = EN_setpattern(ph, 1, P, 12); BOOST_REQUIRE(error == 0); @@ -107,14 +107,14 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setdemandpattern(ph, i + 1, 1, 1); BOOST_REQUIRE(error == 0); } - error = EN_addnode(ph, (const char *)"9", EN_RESERVOIR); + error = EN_addnode(ph, "9", EN_RESERVOIR); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 10, 10, 70); BOOST_REQUIRE(error == 0); error = EN_setnodevalue(ph, 10, EN_ELEVATION, 800); BOOST_REQUIRE(error == 0); - error = EN_addnode(ph, (const char *)"2", EN_TANK); + error = EN_addnode(ph, "2", EN_TANK); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 11, 50, 90); BOOST_REQUIRE(error == 0); @@ -131,29 +131,29 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setnodevalue(ph, 11, EN_MIXFRACTION, 1); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"10", EN_PIPE, (const char *)"10", (const char *)"11"); + error = EN_addlink(ph, "10", EN_PIPE, "10", "11"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"11", EN_PIPE, (const char *)"11", (const char *)"12"); + error = EN_addlink(ph, "11", EN_PIPE, "11", "12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"12", EN_PIPE, (const char *)"12", (const char *)"13"); + error = EN_addlink(ph, "12", EN_PIPE, "12", "13"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"21", EN_PIPE, (const char *)"21", (const char *)"22"); + error = EN_addlink(ph, "21", EN_PIPE, "21", "22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"22", EN_PIPE, (const char *)"22", (const char *)"23"); + error = EN_addlink(ph, "22", EN_PIPE, "22", "23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"31", EN_PIPE, (const char *)"31", (const char *)"32"); + error = EN_addlink(ph, "31", EN_PIPE, "31", "32"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"110", EN_PIPE, (const char *)"2", (const char *)"12"); + error = EN_addlink(ph, "110", EN_PIPE, "2", "12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"111", EN_PIPE, (const char *)"11", (const char *)"21"); + error = EN_addlink(ph, "111", EN_PIPE, "11", "21"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"112", EN_PIPE, (const char *)"12", (const char *)"22"); + error = EN_addlink(ph, "112", EN_PIPE, "12", "22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"113", EN_PIPE, (const char *)"13", (const char *)"23"); + error = EN_addlink(ph, "113", EN_PIPE, "13", "23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"121", EN_PIPE, (const char *)"21", (const char *)"31"); + error = EN_addlink(ph, "121", EN_PIPE, "21", "31"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, (const char *)"122", EN_PIPE, (const char *)"22", (const char *)"32"); + error = EN_addlink(ph, "122", EN_PIPE, "22", "32"); BOOST_REQUIRE(error == 0); for (i = 0; i < 12; i++) { @@ -163,13 +163,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(error == 0); } - error = EN_addlink(ph, (const char *)"9", EN_PUMP, (const char *)"9", (const char *)"10"); + error = EN_addlink(ph, "9", EN_PUMP, "9", "10"); BOOST_REQUIRE(error == 0); - error = EN_addcurve(ph, (const char *)"1"); + error = EN_addcurve(ph, "1"); BOOST_REQUIRE(error == 0); error = EN_setcurvevalue(ph, 1, 1, 1500, 250); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, (const char *)"9", &ind); + error = EN_getlinkindex(ph, "9", &ind); BOOST_REQUIRE(error == 0); error = EN_setheadcurveindex(ph, ind, 1); BOOST_REQUIRE(error == 0); @@ -179,9 +179,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, (const char *)"9", &Lindex); + error = EN_getlinkindex(ph, "9", &Lindex); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, (const char *)"2", &Nindex); + error = EN_getnodeindex(ph, "2", &Nindex); BOOST_REQUIRE(error == 0); // Add controls @@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_closeH(ph); BOOST_REQUIRE(error == 0); - error = EN_saveinpfile(ph, (const char *)"net_builder.inp"); + error = EN_saveinpfile(ph, "net_builder.inp"); BOOST_REQUIRE(error == 0); error = EN_close(ph); @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) // ------------------------------------------------------------------------ // now we load the netwok we just built and saved EN_createproject(&ph); - error = EN_open(ph, (const char *)"net_builder.inp", path_rpt.c_str(), path_out.c_str()); + error = EN_open(ph, "net_builder.inp", path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); error = EN_openH(ph); From 8e96d1e7a351072c4f91a549580ee4ac0b16dd79 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Thu, 13 Sep 2018 17:21:33 +0300 Subject: [PATCH 09/10] Fixing casting of chars (take 2) --- tests/test_net_builder.cpp | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index d279664..0183594 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, "2", &Nindex); + error = EN_getnodeindex(ph, (char *)"2", &Nindex); BOOST_REQUIRE(error == 0); error = EN_openH(ph); @@ -89,8 +89,8 @@ BOOST_AUTO_TEST_CASE(test_net_builder) float P[12] = { 1, 1.2, 1.4, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.6, 0.8 }; error = EN_createproject(&ph); - error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW); - error = EN_addpattern(ph, "1"); + error = EN_init(ph, (char *)"net.rpt", (char *)"net.out", EN_GPM, EN_HW); + error = EN_addpattern(ph, (char *)"1"); BOOST_REQUIRE(error == 0); error = EN_setpattern(ph, 1, P, 12); BOOST_REQUIRE(error == 0); @@ -107,14 +107,14 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setdemandpattern(ph, i + 1, 1, 1); BOOST_REQUIRE(error == 0); } - error = EN_addnode(ph, "9", EN_RESERVOIR); + error = EN_addnode(ph, (char *)"9", EN_RESERVOIR); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 10, 10, 70); BOOST_REQUIRE(error == 0); error = EN_setnodevalue(ph, 10, EN_ELEVATION, 800); BOOST_REQUIRE(error == 0); - error = EN_addnode(ph, "2", EN_TANK); + error = EN_addnode(ph, (char *)"2", EN_TANK); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 11, 50, 90); BOOST_REQUIRE(error == 0); @@ -131,29 +131,29 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setnodevalue(ph, 11, EN_MIXFRACTION, 1); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "10", EN_PIPE, "10", "11"); + error = EN_addlink(ph, (char *)"10", EN_PIPE, (char *)"10", (char *)"11"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "11", EN_PIPE, "11", "12"); + error = EN_addlink(ph, (char *)"11", EN_PIPE, (char *)"11", (char *)"12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "12", EN_PIPE, "12", "13"); + error = EN_addlink(ph, (char *)"12", EN_PIPE, (char *)"12", (char *)"13"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "21", EN_PIPE, "21", "22"); + error = EN_addlink(ph, (char *)"21", EN_PIPE, (char *)"21", (char *)"22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "22", EN_PIPE, "22", "23"); + error = EN_addlink(ph, (char *)"22", EN_PIPE, (char *)"22", (char *)"23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "31", EN_PIPE, "31", "32"); + error = EN_addlink(ph, (char *)"31", EN_PIPE, (char *)"31", (char *)"32"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "110", EN_PIPE, "2", "12"); + error = EN_addlink(ph, (char *)"110", EN_PIPE, (char *)"2", (char *)"12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "111", EN_PIPE, "11", "21"); + error = EN_addlink(ph, (char *)"111", EN_PIPE, (char *)"11", (char *)"21"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "112", EN_PIPE, "12", "22"); + error = EN_addlink(ph, (char *)"112", EN_PIPE, (char *)"12", (char *)"22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "113", EN_PIPE, "13", "23"); + error = EN_addlink(ph, (char *)"113", EN_PIPE, (char *)"13", (char *)"23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "121", EN_PIPE, "21", "31"); + error = EN_addlink(ph, (char *)"121", EN_PIPE, (char *)"21", (char *)"31"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "122", EN_PIPE, "22", "32"); + error = EN_addlink(ph, (char *)"122", EN_PIPE, (char *)"22", (char *)"32"); BOOST_REQUIRE(error == 0); for (i = 0; i < 12; i++) { @@ -163,13 +163,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(error == 0); } - error = EN_addlink(ph, "9", EN_PUMP, "9", "10"); + error = EN_addlink(ph, (char *)"9", EN_PUMP, (char *)"9", (char *)"10"); BOOST_REQUIRE(error == 0); - error = EN_addcurve(ph, "1"); + error = EN_addcurve(ph, (char *)"1"); BOOST_REQUIRE(error == 0); error = EN_setcurvevalue(ph, 1, 1, 1500, 250); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, "9", &ind); + error = EN_getlinkindex(ph, (char *)"9", &ind); BOOST_REQUIRE(error == 0); error = EN_setheadcurveindex(ph, ind, 1); BOOST_REQUIRE(error == 0); @@ -179,9 +179,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, "9", &Lindex); + error = EN_getlinkindex(ph, (char *)"9", &Lindex); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, "2", &Nindex); + error = EN_getnodeindex(ph, (char *)"2", &Nindex); BOOST_REQUIRE(error == 0); // Add controls @@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_closeH(ph); BOOST_REQUIRE(error == 0); - error = EN_saveinpfile(ph, "net_builder.inp"); + error = EN_saveinpfile(ph, (char *)"net_builder.inp"); BOOST_REQUIRE(error == 0); error = EN_close(ph); @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) // ------------------------------------------------------------------------ // now we load the netwok we just built and saved EN_createproject(&ph); - error = EN_open(ph, "net_builder.inp", path_rpt.c_str(), path_out.c_str()); + error = EN_open(ph, (char *)"net_builder.inp", path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); error = EN_openH(ph); From bec729a669f83d44b3b63475e0fd09f228788b7c Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Thu, 13 Sep 2018 10:48:55 -0400 Subject: [PATCH 10/10] Fixing compiler warnings --- include/epanet2.h | 11 +++++----- src/epanet.c | 10 ++++----- src/funcs.h | 2 +- src/inpfile.c | 2 +- tests/test_net_builder.cpp | 44 +++++++++++++++++++------------------- 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/include/epanet2.h b/include/epanet2.h index dd99410..dc3d362 100644 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -308,7 +308,8 @@ extern "C" { @param HeadlossFormula headloss formula flag @return error code */ - int DLLEXPORT ENinit(char *rptFile, char *binOutFile, int UnitsType, int HeadlossFormula); + int DLLEXPORT ENinit(const char *rptFile, const char *binOutFile, + int UnitsType, int HeadlossFormula); /** @brief Opens EPANET input file & reads in network data @@ -317,14 +318,14 @@ extern "C" { @param binOutFile pointer to name of binary output file (to be created) @return error code */ - int DLLEXPORT ENopen(char *inpFile, char *rptFile, char *binOutFile); + int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *binOutFile); /** @brief Saves current data to "INP" formatted text file. @param filename The file path to create @return Error code */ - int DLLEXPORT ENsaveinpfile(char *filename); + int DLLEXPORT ENsaveinpfile(const char *filename); /** @brief Frees all memory and files used by EPANET @@ -1200,13 +1201,13 @@ extern "C" { //int DLLEXPORT EN_epanet(EN_ProjectHandle ph, const char *f1, const char *f2, // const char *f3, void(*pviewprog)(char *)); - int DLLEXPORT EN_init(EN_ProjectHandle ph, char *rptFile, char *binOutFile, + int DLLEXPORT EN_init(EN_ProjectHandle ph, const char *rptFile, const char *binOutFile, EN_FlowUnits UnitsType, EN_FormType HeadlossFormula); int DLLEXPORT EN_open(EN_ProjectHandle ph, const char *inpFile, const char *rptFile, const char *binOutFile); - int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, char *filename); + int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, const char *filename); int DLLEXPORT EN_close(EN_ProjectHandle ph); int DLLEXPORT EN_solveH(EN_ProjectHandle ph); diff --git a/src/epanet.c b/src/epanet.c index 72bc727..d8e3cc4 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -185,7 +185,7 @@ int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3, void (*pv return (errcode); } -int DLLEXPORT ENinit(char *f2, char *f3, int UnitsType, +int DLLEXPORT ENinit(const char *f2, const char *f3, int UnitsType, int HeadlossFormula) { int errcode = 0; ERRCODE(EN_createproject(&_defaultModel)); @@ -193,14 +193,14 @@ int DLLEXPORT ENinit(char *f2, char *f3, int UnitsType, return (errcode); } -int DLLEXPORT ENopen(char *f1, char *f2, char *f3) { +int DLLEXPORT ENopen(const char *f1, const char *f2, const char *f3) { int errcode = 0; ERRCODE(EN_createproject(&_defaultModel)); EN_open(_defaultModel, f1, f2, f3); return (errcode); } -int DLLEXPORT ENsaveinpfile(char *filename) { +int DLLEXPORT ENsaveinpfile(const char *filename) { return EN_saveinpfile(_defaultModel, filename); } @@ -642,7 +642,7 @@ int DLLEXPORT EN_runproject(EN_ProjectHandle ph, const char *f1, const char *f2, return errcode; } -int DLLEXPORT EN_init(EN_ProjectHandle ph, char *f2, char *f3, +int DLLEXPORT EN_init(EN_ProjectHandle ph, const char *f2, const char *f3, EN_FlowUnits UnitsType, EN_FormType HeadlossFormula) /*---------------------------------------------------------------- ** Input: @@ -777,7 +777,7 @@ int DLLEXPORT EN_open(EN_ProjectHandle ph, const char *f1, const char *f2, const return set_error(p->error_handle, errcode); } -int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, char *filename) +int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, const char *filename) /*---------------------------------------------------------------- ** Input: filename = name of INP file ** Output: none diff --git a/src/funcs.h b/src/funcs.h index b961a82..07d9303 100755 --- a/src/funcs.h +++ b/src/funcs.h @@ -248,6 +248,6 @@ int saveepilog(EN_Project *pr); /* Saves output file epilog /* ------------ INPFILE.C --------------*/ -int saveinpfile(EN_Project *pr, char *); /* Saves network to text file */ +int saveinpfile(EN_Project *pr, const char *); /* Saves network to text file */ #endif diff --git a/src/inpfile.c b/src/inpfile.c index 9e4b130..1d7c11e 100644 --- a/src/inpfile.c +++ b/src/inpfile.c @@ -114,7 +114,7 @@ void saveauxdata(parser_data_t *parser, FILE *f) //// This function was heavily modified. //// -int saveinpfile(EN_Project *pr, char *fname) +int saveinpfile(EN_Project *pr, const char *fname) /* ------------------------------------------------- Writes network data to text file. diff --git a/tests/test_net_builder.cpp b/tests/test_net_builder.cpp index d279664..7721fe8 100644 --- a/tests/test_net_builder.cpp +++ b/tests/test_net_builder.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str()); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, "2", &Nindex); + error = EN_getnodeindex(ph, (char *)"2", &Nindex); BOOST_REQUIRE(error == 0); error = EN_openH(ph); @@ -86,11 +86,11 @@ BOOST_AUTO_TEST_CASE(test_net_builder) float Y[9] = {70, 70, 70, 70, 40, 40, 40, 10, 10 }; float L[12] = {10530, 5280, 5280, 5280, 5280, 5280, 200, 5280, 5280, 5280, 5280, 5280}; float dia[12] = { 18, 14, 10, 10, 12, 6, 18, 10, 12, 8, 8, 6 }; - float P[12] = { 1, 1.2, 1.4, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.6, 0.8 }; + float P[12] = { 1.0f, 1.2f, 1.4f, 1.6f, 1.4f, 1.2f, 1.0f, 0.8f, 0.6f, 0.4f, 0.6f, 0.8f }; error = EN_createproject(&ph); error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW); - error = EN_addpattern(ph, "1"); + error = EN_addpattern(ph, (char *)"1"); BOOST_REQUIRE(error == 0); error = EN_setpattern(ph, 1, P, 12); BOOST_REQUIRE(error == 0); @@ -107,14 +107,14 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setdemandpattern(ph, i + 1, 1, 1); BOOST_REQUIRE(error == 0); } - error = EN_addnode(ph, "9", EN_RESERVOIR); + error = EN_addnode(ph, (char *)"9", EN_RESERVOIR); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 10, 10, 70); BOOST_REQUIRE(error == 0); error = EN_setnodevalue(ph, 10, EN_ELEVATION, 800); BOOST_REQUIRE(error == 0); - error = EN_addnode(ph, "2", EN_TANK); + error = EN_addnode(ph, (char *)"2", EN_TANK); BOOST_REQUIRE(error == 0); error = EN_setcoord(ph, 11, 50, 90); BOOST_REQUIRE(error == 0); @@ -131,29 +131,29 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_setnodevalue(ph, 11, EN_MIXFRACTION, 1); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "10", EN_PIPE, "10", "11"); + error = EN_addlink(ph, (char *)"10", EN_PIPE, (char *)"10", (char *)"11"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "11", EN_PIPE, "11", "12"); + error = EN_addlink(ph, (char *)"11", EN_PIPE, (char *)"11", (char *)"12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "12", EN_PIPE, "12", "13"); + error = EN_addlink(ph, (char *)"12", EN_PIPE, (char *)"12", (char *)"13"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "21", EN_PIPE, "21", "22"); + error = EN_addlink(ph, (char *)"21", EN_PIPE, (char *)"21", (char *)"22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "22", EN_PIPE, "22", "23"); + error = EN_addlink(ph, (char *)"22", EN_PIPE, (char *)"22", (char *)"23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "31", EN_PIPE, "31", "32"); + error = EN_addlink(ph, (char *)"31", EN_PIPE, (char *)"31", (char *)"32"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "110", EN_PIPE, "2", "12"); + error = EN_addlink(ph, (char *)"110", EN_PIPE, (char *)"2", (char *)"12"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "111", EN_PIPE, "11", "21"); + error = EN_addlink(ph, (char *)"111", EN_PIPE, (char *)"11", (char *)"21"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "112", EN_PIPE, "12", "22"); + error = EN_addlink(ph, (char *)"112", EN_PIPE, (char *)"12", (char *)"22"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "113", EN_PIPE, "13", "23"); + error = EN_addlink(ph, (char *)"113", EN_PIPE, (char *)"13", (char *)"23"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "121", EN_PIPE, "21", "31"); + error = EN_addlink(ph, (char *)"121", EN_PIPE, (char *)"21", (char *)"31"); BOOST_REQUIRE(error == 0); - error = EN_addlink(ph, "122", EN_PIPE, "22", "32"); + error = EN_addlink(ph, (char *)"122", EN_PIPE, (char *)"22", (char *)"32"); BOOST_REQUIRE(error == 0); for (i = 0; i < 12; i++) { @@ -163,13 +163,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder) BOOST_REQUIRE(error == 0); } - error = EN_addlink(ph, "9", EN_PUMP, "9", "10"); + error = EN_addlink(ph, (char *)"9", EN_PUMP, (char *)"9", (char *)"10"); BOOST_REQUIRE(error == 0); - error = EN_addcurve(ph, "1"); + error = EN_addcurve(ph, (char *)"1"); BOOST_REQUIRE(error == 0); error = EN_setcurvevalue(ph, 1, 1, 1500, 250); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, "9", &ind); + error = EN_getlinkindex(ph, (char *)"9", &ind); BOOST_REQUIRE(error == 0); error = EN_setheadcurveindex(ph, ind, 1); BOOST_REQUIRE(error == 0); @@ -179,9 +179,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder) error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600); BOOST_REQUIRE(error == 0); - error = EN_getlinkindex(ph, "9", &Lindex); + error = EN_getlinkindex(ph, (char *)"9", &Lindex); BOOST_REQUIRE(error == 0); - error = EN_getnodeindex(ph, "2", &Nindex); + error = EN_getnodeindex(ph, (char *)"2", &Nindex); BOOST_REQUIRE(error == 0); // Add controls