Floating pt. args in thread-safe API changed to doubles (Issue #365)
This commit is contained in:
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
|
||||
int error = 0;
|
||||
int ruleCount, nP, nTA, nEA;
|
||||
int link113, node23, link22, pump9_before, pump9_after;
|
||||
float priority;
|
||||
double priority;
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
int flag = 00;
|
||||
long t, tstep;
|
||||
int i, ind, Lindex, Nindex, Cindex;
|
||||
float h_orig, h_build, h_build_loaded;
|
||||
double 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_Project ph = NULL;
|
||||
@@ -80,13 +80,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
// ------------------------------------------------------------------------
|
||||
// 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.0f, 1.2f, 1.4f, 1.6f, 1.4f, 1.2f, 1.0f, 0.8f, 0.6f, 0.4f, 0.6f, 0.8f };
|
||||
double e[9] = {710, 710, 700, 695, 700, 695, 690, 700, 710};
|
||||
double d[9] = {0, 150, 150, 100, 150, 200, 150, 100, 100 };
|
||||
double X[9] = {20, 30, 50, 70, 30, 50, 70, 30, 50};
|
||||
double Y[9] = {70, 70, 70, 70, 40, 40, 40, 10, 10 };
|
||||
double L[12] = {10530, 5280, 5280, 5280, 5280, 5280, 200, 5280, 5280, 5280, 5280, 5280};
|
||||
double dia[12] = { 18, 14, 10, 10, 12, 6, 18, 10, 12, 8, 8, 6 };
|
||||
double 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);
|
||||
@@ -187,9 +187,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Add controls
|
||||
error = EN_addcontrol(ph, &Cindex, EN_LOWLEVEL, Lindex, 1, Nindex, 110);
|
||||
error = EN_addcontrol(ph, EN_LOWLEVEL, Lindex, 1, Nindex, 110, &Cindex);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_addcontrol(ph, &Cindex, EN_HILEVEL, Lindex, 0, Nindex, 140);
|
||||
error = EN_addcontrol(ph, EN_HILEVEL, Lindex, 0, Nindex, 140, &Cindex);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
error = EN_openH(ph);
|
||||
@@ -250,10 +250,10 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
||||
// if we got this far we can compare results
|
||||
|
||||
// compare the original to the build & saved network
|
||||
BOOST_REQUIRE(h_orig == h_build_loaded);
|
||||
BOOST_REQUIRE(abs(h_orig - h_build_loaded) < 0.0001);
|
||||
|
||||
// compare the original to the build without saving
|
||||
BOOST_REQUIRE(h_orig == h_build); // this seems to fail :(
|
||||
BOOST_REQUIRE(abs(h_orig - h_build) < 0.0001);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
int index;
|
||||
char id[EN_MAXID+1];
|
||||
float p1_1, p2_1, p1_2, p2_2;
|
||||
float q1_1, q2_1, q1_2, q2_2;
|
||||
double p1_1, p2_1, p1_2, p2_2;
|
||||
double q1_1, q2_1, q1_2, q2_2;
|
||||
|
||||
// Create & initialize a project
|
||||
EN_Project ph = NULL;
|
||||
@@ -100,10 +100,10 @@ int main(int argc, char *argv[])
|
||||
cout << "\n Link L2 Flow: " << q2_1 << " " << q2_2;
|
||||
|
||||
// Compare old & new results
|
||||
BOOST_REQUIRE(p1_1 == p1_2);
|
||||
BOOST_REQUIRE(p2_1 == p2_2);
|
||||
BOOST_REQUIRE(q1_1 == q1_2);
|
||||
BOOST_REQUIRE(q2_1 == q2_2);
|
||||
BOOST_REQUIRE(abs(p1_1 - p1_2) < 1.e-5);
|
||||
BOOST_REQUIRE(abs(p2_1 - p2_2) < 1.e-5);
|
||||
BOOST_REQUIRE(abs(q1_1 - q1_2) < 1.e-5);
|
||||
BOOST_REQUIRE(abs(q2_1 - q2_2) < 1.e-5);
|
||||
|
||||
// Close project
|
||||
EN_close(ph);
|
||||
|
||||
@@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(test_setlinktype)
|
||||
{
|
||||
int error = 0;
|
||||
int p113, n31, p121, n113_1, n113_2;
|
||||
float q113 = 0.0f, p31 = 0.0f, diam;
|
||||
double q113 = 0.0, p31 = 0.0, diam;
|
||||
|
||||
EN_Project ph = NULL;
|
||||
EN_createproject(&ph);
|
||||
|
||||
@@ -301,7 +301,7 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
|
||||
{
|
||||
int flag = 00;
|
||||
long t, tstep;
|
||||
float h1, h2;
|
||||
double h1, h2;
|
||||
int Cindex;
|
||||
|
||||
// run with original controls
|
||||
@@ -328,10 +328,10 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// add new controls
|
||||
error = EN_addcontrol(ph, &Cindex, 0, 13, 1, 11, 110);
|
||||
error = EN_addcontrol(ph, 0, 13, 1, 11, 110, &Cindex);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(Cindex == 3);
|
||||
error = EN_addcontrol(ph, &Cindex, 1, 13, 0, 11, 140);
|
||||
error = EN_addcontrol(ph, 1, 13, 0, 11, 140, &Cindex);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(Cindex == 4);
|
||||
|
||||
@@ -352,7 +352,7 @@ BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
|
||||
error = EN_closeH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
BOOST_CHECK(h1 == h2); // end head should be the same with new controls
|
||||
BOOST_CHECK(abs(h1 - h2) < 1.e-5); // end head should be the same with new controls
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user