mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Logical combination: add purely negative match at EOD unit test
MultiCombPurelyNegativeUniSubEOD6.
This commit is contained in:
parent
fdc3c290b6
commit
4b1927c038
@ -805,6 +805,59 @@ TEST(LogicalCombination, MultiCombPurelyNegativeUniSub6) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(LogicalCombination, MultiCombPurelyNegativeUniSubEOD6) {
|
||||
hs_database_t *db = nullptr;
|
||||
hs_compile_error_t *compile_err = nullptr;
|
||||
CallBackContext c;
|
||||
string data = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
"-----------------------------------------------"
|
||||
"xdefedxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
"-----------------------------------------------"
|
||||
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
"-------------------------------------defed";
|
||||
const char *expr[] = {"abc", "defed", "foobar.*gh", "teakettle{4,10}",
|
||||
"ijkl[mMn]", "cba", "fed", "google.*cn",
|
||||
"haystacks{4,8}", "ijkl[oOp]", "cab", "fee",
|
||||
"goobar.*jp", "shockwave{4,6}", "ijkl[rRs]",
|
||||
"(101 & 102 & 103) | (!104 & !105)",
|
||||
"(!201 | 202 & 203) & (!204 | 205)",
|
||||
"((301 | 302) & 303) & (304 | 305)"};
|
||||
unsigned flags[] = {0, 0, 0, 0, 0, 0, HS_FLAG_MULTILINE,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
HS_FLAG_COMBINATION, HS_FLAG_COMBINATION,
|
||||
HS_FLAG_COMBINATION};
|
||||
unsigned ids[] = {101, 102, 103, 104, 105, 201, 202, 203, 204, 205, 301,
|
||||
302, 303, 304, 305, 1001, 1002, 1003};
|
||||
hs_error_t err = hs_compile_multi(expr, flags, ids, 18, HS_MODE_NOSTREAM,
|
||||
nullptr, &db, &compile_err);
|
||||
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_TRUE(db != nullptr);
|
||||
|
||||
hs_scratch_t *scratch = nullptr;
|
||||
err = hs_alloc_scratch(db, &scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_TRUE(scratch != nullptr);
|
||||
|
||||
c.halt = 0;
|
||||
err = hs_scan(db, data.c_str(), data.size(), 0, scratch, record_cb,
|
||||
(void *)&c);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(8U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(106, 102), c.matches[0]);
|
||||
ASSERT_EQ(MatchRecord(106, 202), c.matches[1]);
|
||||
ASSERT_EQ(MatchRecord(106, 1001), c.matches[2]);
|
||||
ASSERT_EQ(MatchRecord(106, 1002), c.matches[3]);
|
||||
ASSERT_EQ(MatchRecord(300, 102), c.matches[4]);
|
||||
ASSERT_EQ(MatchRecord(300, 202), c.matches[5]);
|
||||
ASSERT_EQ(MatchRecord(300, 1001), c.matches[6]);
|
||||
ASSERT_EQ(MatchRecord(300, 1002), c.matches[7]);
|
||||
|
||||
hs_free_database(db);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(LogicalCombination, MultiCombStream1) {
|
||||
hs_database_t *db = nullptr;
|
||||
hs_compile_error_t *compile_err = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user