From d1979e7ed09384131dc5784d632ac32d418a1a93 Mon Sep 17 00:00:00 2001 From: Michael Tryby Date: Wed, 17 Apr 2019 09:39:24 -0400 Subject: [PATCH] Update errror code from 250 to 252 --- .gitignore | 2 ++ src/epanet.c | 18 +++++++++--------- src/errors.dat | 1 + tests/test_curve.cpp | 8 ++++---- tests/test_link.cpp | 8 ++++---- tests/test_node.cpp | 8 ++++---- tests/test_pattern.cpp | 8 ++++---- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 8566bb4..6e469d5 100755 --- a/.gitignore +++ b/.gitignore @@ -223,6 +223,8 @@ temp/ # Testing Stuff nrtestsuite/ tests/data/ +tests/outfile/data/en* + #Cmake stuff __cmake_systeminformation/ diff --git a/src/epanet.c b/src/epanet.c index d1bb49c..6a9c546 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -1734,7 +1734,7 @@ int DLLEXPORT EN_addnode(EN_Project p, char *id, int nodeType) if (hyd->OpenHflag || qual->OpenQflag) return 262; // Check if id contains invalid characters - if (!cstr_isvalid(id)) return 250; + if (!cstr_isvalid(id)) return 252; // Check if a node with same id already exists if (EN_getnodeindex(p, id, &i) == 0) return 215; @@ -2021,7 +2021,7 @@ int DLLEXPORT EN_setnodeid(EN_Project p, int index, char *newid) if (index <= 0 || index > net->Nnodes) return 203; n = strlen(newid); if (n < 1 || n > MAXID) return 209; - if (!cstr_isvalid(newid)) return 250; + if (!cstr_isvalid(newid)) return 252; // Check if another node with same name exists if (hashtable_find(net->NodeHashTable, newid) > 0) return 215; @@ -2945,7 +2945,7 @@ int DLLEXPORT EN_addlink(EN_Project p, char *id, int linkType, if (p->hydraul.OpenHflag || p->quality.OpenQflag) return 262; // Check if id contains invalid characters - if (!cstr_isvalid(id)) return 250; + if (!cstr_isvalid(id)) return 252; // Check if a link with same id already exists if (EN_getlinkindex(p, id, &i) == 0) return 215; @@ -3208,7 +3208,7 @@ int DLLEXPORT EN_setlinkid(EN_Project p, int index, char *newid) if (index <= 0 || index > net->Nlinks) return 204; n = strlen(newid); if (n < 1 || n > MAXID) return 211; - if (!cstr_isvalid(newid)) return 250; + if (!cstr_isvalid(newid)) return 252; // Check if another link with same name exists if (hashtable_find(net->LinkHashTable, newid) > 0) return 215; @@ -3960,7 +3960,7 @@ int DLLEXPORT EN_addpattern(EN_Project p, char *id) if (EN_getpatternindex(p, id, &i) == 0) return 215; // Check is id name contains invalid characters - if (!cstr_isvalid(id)) return 250; + if (!cstr_isvalid(id)) return 252; // Check that id name is not too long if (strlen(id) > MAXID) return 250; @@ -4087,7 +4087,7 @@ int DLLEXPORT EN_setpatternid(EN_Project p, int index, char *id) if (index < 1 || index > p->network.Npats) return 205; // Check is id name contains invalid characters - if (!cstr_isvalid(id)) return 250; + if (!cstr_isvalid(id)) return 252; if (strlen(id) > MAXID) return 250; @@ -4236,7 +4236,7 @@ int DLLEXPORT EN_addcurve(EN_Project p, char *id) if (EN_getcurveindex(p, id, &i) == 0) return 215; // Check is id name contains invalid characters - if (!cstr_isvalid(id)) return 250; + if (!cstr_isvalid(id)) return 252; // Check that id name is not too long if (strlen(id) > MAXID) return 250; @@ -4359,8 +4359,8 @@ int DLLEXPORT EN_setcurveid(EN_Project p, int index, char *id) if (index < 1 || index > p->network.Ncurves) return 205; // Check is id name contains invalid characters - if (!cstr_isvalid(id)) return 250; - + if (!cstr_isvalid(id)) return 252; + if (strlen(id) > MAXID) return 250; for (i = 1; i <= p->network.Ncurves; i++) { diff --git a/src/errors.dat b/src/errors.dat index 52922c7..52baec3 100644 --- a/src/errors.dat +++ b/src/errors.dat @@ -49,6 +49,7 @@ DAT(240,"nonexistent source") DAT(241,"nonexistent control") DAT(250,"invalid format") DAT(251,"invalid parameter code") +DAT(252,"invalid ID name") DAT(253,"nonexistent demand category") DAT(254,"node with no coordinates") DAT(257,"nonexistent rule") diff --git a/tests/test_curve.cpp b/tests/test_curve.cpp index 8cb9705..6e80cd5 100644 --- a/tests/test_curve.cpp +++ b/tests/test_curve.cpp @@ -75,17 +75,17 @@ BOOST_FIXTURE_TEST_CASE(test_curve_id_isvalid, FixtureInitClose) BOOST_REQUIRE(error == 0); error = EN_addcurve(ph, (char *)"C 2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addcurve(ph, (char *)"C\"2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addcurve(ph, (char *)"C;2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); EN_getcurveindex(ph, (char *)"C1", &index); error = EN_setcurveid(ph, index, (char *)"C;2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); } diff --git a/tests/test_link.cpp b/tests/test_link.cpp index 0863d96..2a24512 100644 --- a/tests/test_link.cpp +++ b/tests/test_link.cpp @@ -68,17 +68,17 @@ BOOST_FIXTURE_TEST_CASE(test_link_id_isvalid, FixtureInitClose) BOOST_REQUIRE(error == 0); error = EN_addlink(ph, (char *)"L 2", EN_PIPE, (char *)"N1", (char *)"N2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addlink(ph, (char *)"L\"2", EN_PIPE, (char *)"N1", (char *)"N2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addlink(ph, (char *)"L;2", EN_PIPE, (char *)"N1", (char *)"N2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); EN_getlinkindex(ph, (char *)"L1", &index); error = EN_setlinkid(ph, index, (char *)"L;1"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); } BOOST_AUTO_TEST_CASE(test_setlinktype) diff --git a/tests/test_node.cpp b/tests/test_node.cpp index 907ae4e..e7139ae 100644 --- a/tests/test_node.cpp +++ b/tests/test_node.cpp @@ -55,17 +55,17 @@ BOOST_FIXTURE_TEST_CASE(test_node_validate_id, FixtureInitClose) BOOST_REQUIRE(error == 0); error = EN_addnode(ph, (char *)"N 3", EN_JUNCTION); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addnode(ph, (char *)"N\"3", EN_JUNCTION); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addnode(ph, (char *)"N;3", EN_JUNCTION); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); EN_getnodeindex(ph, (char *)"N2", &index); error = EN_setnodeid(ph, index, (char *)"N;2"); - BOOST_REQUIRE(error = 250); + BOOST_REQUIRE(error = 252); } diff --git a/tests/test_pattern.cpp b/tests/test_pattern.cpp index e370134..ef2eb71 100644 --- a/tests/test_pattern.cpp +++ b/tests/test_pattern.cpp @@ -155,17 +155,17 @@ BOOST_FIXTURE_TEST_CASE(test_pat_id_isvalid, FixtureInitClose) BOOST_REQUIRE(error == 0); error = EN_addpattern(ph, (char *)"P 2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addpattern(ph, (char *)"P\"2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); error = EN_addpattern(ph, (char *)"P;2"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); EN_getpatternindex(ph, (char *)"P1", &index); error = EN_setpatternid(ph, index, (char *)"P;1"); - BOOST_REQUIRE(error == 250); + BOOST_REQUIRE(error == 252); }