Merge pull request #265 from eladsal/dev-control

Add EN_addcontrol function
This commit is contained in:
Elad Salomons
2018-09-05 07:42:02 +03:00
committed by GitHub
5 changed files with 230 additions and 15 deletions

View File

@@ -260,4 +260,62 @@ BOOST_FIXTURE_TEST_CASE(test_addpattern, Fixture)
BOOST_REQUIRE(pat_index == n_patterns_2);
}
BOOST_FIXTURE_TEST_CASE(test_add_control, Fixture)
{
int flag = 00;
long t, tstep;
float h1, h2;
int Cindex;
// run with original controls
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);
error = EN_getnodevalue(ph, 11, EN_HEAD, &h1); // get the tank head
BOOST_REQUIRE(error == 0);
error = EN_nextH(ph, &tstep);
BOOST_REQUIRE(error == 0);
} while (tstep > 0);
error = EN_closeH(ph);
BOOST_REQUIRE(error == 0);
// disable current controls
error = EN_setcontrol(ph, 1, 0, 0, 0, 0, 0);
BOOST_REQUIRE(error == 0);
error = EN_setcontrol(ph, 2, 1, 0, 0, 0, 0);
BOOST_REQUIRE(error == 0);
// add new controls
error = EN_addcontrol(ph, &Cindex, 0, 13, 1, 11, 110);
BOOST_REQUIRE(error == 0);
BOOST_REQUIRE(Cindex == 3);
error = EN_addcontrol(ph, &Cindex, 1, 13, 0, 11, 140);
BOOST_REQUIRE(error == 0);
BOOST_REQUIRE(Cindex == 4);
// run with new controls
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);
error = EN_getnodevalue(ph, 11, EN_HEAD, &h2); // get the tank head
BOOST_REQUIRE(error == 0);
error = EN_nextH(ph, &tstep);
BOOST_REQUIRE(error == 0);
} while (tstep > 0);
error = EN_closeH(ph);
BOOST_REQUIRE(error == 0);
BOOST_REQUIRE(h1 == h2); // end head should be the same with new controls
}
BOOST_AUTO_TEST_SUITE_END()