Skip to content

Commit

Permalink
Functional test: Improve BitParameter in case of boolean
Browse files Browse the repository at this point in the history
Add BitParamter tests cases for boolean type format.

Signed-off-by: Sebastien Guiriec <[email protected]>
  • Loading branch information
Sebastien Guiriec committed Feb 13, 2017
1 parent 1990be1 commit 36497d5
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion test/functional-tests/BitParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace parameterFramework
const auto validBitParameterInstances = Config{
&Config::instances,
// Default for integers is unsigned/32bits
R"(<BitParameterBlock Name="nominal" Size="16"><BitParameter Pos="1" Size="2" Name="twobits"/><BitParameter Pos="3" Size="3" Max="6" Name="treebits"/></BitParameterBlock>)"};
R"(<BitParameterBlock Name="nominal" Size="16"><BitParameter Pos="0" Size="1" Name="bool"/><BitParameter Pos="1" Size="2" Name="twobits"/><BitParameter Pos="3" Size="3" Max="6" Name="treebits"/></BitParameterBlock>)"};

const auto &invalidBitParameterParameters =
Tests<string>{{"Too much bits", "<BitParameterBlock Name='toomuchbits' Size='8'><BitParameter "
Expand Down Expand Up @@ -124,6 +124,40 @@ SCENARIO_METHOD(BitParameterPF, "BitParameter types", "[BitParameter types]")
}
}
}

AND_THEN ("Set/Get a BitParameter type parameter in boolean") {
ElementHandle handle{*this, path};
/** @FIXME: 'set' operations on a ParameterHandle are silently
* ignored in tuning mode. Does it make sense ? */
REQUIRE_NOTHROW(setTuningMode(false));

for (auto &vec : Tests<bool>{
{"(upper limit)", true}, {"(lower limit)", false},
}) {
GIVEN ("Invalid value " + vec.title) {
CHECK_THROWS_AS(handle.setAsBoolean(vec.payload), Exception);
}
}
}

AND_THEN ("Set/Get a BitParameter type parameter in boolean") {
path = "/test/test/nominal/bool";
ElementHandle handle{*this, path};
/** @FIXME: 'set' operations on a ParameterHandle are silently
* ignored in tuning mode. Does it make sense ? */
REQUIRE_NOTHROW(setTuningMode(false));

for (auto &vec : Tests<bool>{
{"(upper limit)", true}, {"(lower limit)", false},
}) {
GIVEN ("A valid value " + vec.title) {
CHECK_NOTHROW(handle.setAsBoolean(vec.payload));
bool getValueBack;
REQUIRE_NOTHROW(handle.getAsBoolean(getValueBack));
CHECK(getValueBack == vec.payload);
}
}
}
}
}
}
Expand Down

0 comments on commit 36497d5

Please sign in to comment.