updated tests

This commit is contained in:
Robin Müller 2021-01-05 22:46:17 +01:00
parent 85764ba94c
commit a05cf8d4ab

View File

@ -11,27 +11,39 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation()
== retval::CATCH_OK); == retval::CATCH_OK);
// very basic test. SECTION("Basic Tests") {
lp_var_t<uint8_t> testVariable = lp_var_t<uint8_t>( // very basic test.
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t<uint8_t> testVariable = lp_var_t<uint8_t>(
REQUIRE(testVariable.read() == retval::CATCH_OK); objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
CHECK(testVariable.value == 0); REQUIRE(testVariable.read() == retval::CATCH_OK);
testVariable.value = 5; CHECK(testVariable.value == 0);
REQUIRE(testVariable.commit() == retval::CATCH_OK); testVariable.value = 5;
REQUIRE(testVariable.read() == retval::CATCH_OK); REQUIRE(testVariable.commit() == retval::CATCH_OK);
REQUIRE(testVariable.value == 5); REQUIRE(testVariable.read() == retval::CATCH_OK);
REQUIRE(testVariable.value == 5);
// not try to use a local pool variable which does not exist CHECK(not testVariable.isValid());
lp_var_t<uint8_t> invalidVariable = lp_var_t<uint8_t>(
objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); // not try to use a local pool variable which does not exist
REQUIRE(invalidVariable.read() == lp_var_t<uint8_t> invalidVariable = lp_var_t<uint8_t>(
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND)); objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff);
REQUIRE(invalidVariable.read() ==
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND));
// now try to access with wrong type
lp_var_t<int8_t> invalidVariable2 = lp_var_t<int8_t>(
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
REQUIRE(invalidVariable2.read() ==
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT));
// now try to access with wrong type
lp_var_t<int8_t> readOnlyVar = lp_var_t<int8_t>(
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId,
nullptr, pool_rwm_t::VAR_READ);
REQUIRE(readOnlyVar.commit() ==
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
}
// now try to access with wrong type
lp_var_t<int8_t> invalidVariable2 = lp_var_t<int8_t>(
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId);
REQUIRE(invalidVariable2.read() ==
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT));
} }