mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 13:37:55 +00:00
[4094] Addressed comments (comments, complex test)
This commit is contained in:
parent
4ba6b71ae8
commit
e15edffe3e
@ -23,8 +23,8 @@ namespace dhcp {
|
||||
/// @brief Evaluate a RPN expression for a v4 or v6 packet and return
|
||||
/// a true or false decision
|
||||
///
|
||||
/// @param expr the RPN expression, i.e., a vector (stack) of parsed tokens
|
||||
/// @param pkt The v4 or v6 packet (can be ignored)
|
||||
/// @param expr the RPN expression, i.e., a vector of parsed tokens
|
||||
/// @param pkt The v4 or v6 packet
|
||||
/// @return the boolean decision
|
||||
/// @throw EvalStackError if there is not exactly one element on the value
|
||||
/// stack at the end of the evaluation
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
/// @brief Initializes Pkt4,Pkt6 and options that can be useful for
|
||||
/// evaluation tests.
|
||||
EvaluateTest() {
|
||||
e_.clear();
|
||||
e_.clear();
|
||||
|
||||
pkt4_.reset(new Pkt4(DHCPDISCOVER, 12345));
|
||||
pkt6_.reset(new Pkt6(DHCPV6_SOLICIT, 12345));
|
||||
@ -209,4 +209,38 @@ TEST_F(EvaluateTest, packet) {
|
||||
EXPECT_FALSE(result_);
|
||||
}
|
||||
|
||||
// A test using substring on an option.
|
||||
TEST_F(EvaluateTest, complex) {
|
||||
TokenPtr toption;
|
||||
TokenPtr tstart;
|
||||
TokenPtr tlength;
|
||||
TokenPtr tsubstring;
|
||||
TokenPtr tstring;
|
||||
TokenPtr tequal;
|
||||
|
||||
// Get the option, i.e., "hundred[46]"
|
||||
ASSERT_NO_THROW(toption.reset(new TokenOption(100)));
|
||||
e_.push_back(toption);
|
||||
|
||||
// Get substring("hundred[46]", 0, 7), i.e., "hundred"
|
||||
ASSERT_NO_THROW(tstart.reset(new TokenString("0")));
|
||||
e_.push_back(tstart);
|
||||
ASSERT_NO_THROW(tlength.reset(new TokenString("7")));
|
||||
e_.push_back(tlength);
|
||||
ASSERT_NO_THROW(tsubstring.reset(new TokenSubstring()));
|
||||
e_.push_back(tsubstring);
|
||||
|
||||
// Compare with "hundred"
|
||||
ASSERT_NO_THROW(tstring.reset(new TokenString("hundred")));
|
||||
e_.push_back(tstring);
|
||||
ASSERT_NO_THROW(tequal.reset(new TokenEqual()));
|
||||
e_.push_back(tequal);
|
||||
|
||||
// Should return true for v4 and v6 packets
|
||||
ASSERT_NO_THROW(result_ = evaluate(e_, *pkt4_));
|
||||
EXPECT_TRUE(result_);
|
||||
ASSERT_NO_THROW(result_ = evaluate(e_, *pkt6_));
|
||||
EXPECT_TRUE(result_);
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user