Skip to content

Commit

Permalink
SearchQueryParser: Test boundary requirement of OR operator
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Oct 6, 2023
1 parent 1a618f0 commit c753ebe
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/searchqueryparsertest.cpp
Expand Up @@ -1054,6 +1054,36 @@ TEST_F(SearchQueryParserTest, EmptySpelledOutOrOperator) {
EXPECT_FALSE(pQuery->match(pTrack));
}

TEST_F(SearchQueryParserTest, PrefixedSpelledOutOrOperator) {
m_parser.setSearchColumns({"title"});

// 'OR' needs to have a boundary on the left to be parsed as an operator
auto pQuery = m_parser.parseQuery("aOR", QString());

TrackPointer pTrackA = newTestTrack();
pTrackA->setTitle("aOR");
EXPECT_TRUE(pQuery->match(pTrackA));

TrackPointer pTrackB = newTestTrack();
pTrackB->setTitle("a");
EXPECT_FALSE(pQuery->match(pTrackB));
}

TEST_F(SearchQueryParserTest, SuffixedSpelledOutOrOperator) {
m_parser.setSearchColumns({"title"});

// 'OR' needs to have a boundary on the right to be parsed as an operator
auto pQuery = m_parser.parseQuery("ORa", QString());

TrackPointer pTrackA = newTestTrack();
pTrackA->setTitle("ORa");
EXPECT_TRUE(pQuery->match(pTrackA));

TrackPointer pTrackB = newTestTrack();
pTrackB->setTitle("a");
EXPECT_FALSE(pQuery->match(pTrackB));
}

TEST_F(SearchQueryParserTest, LowercaseOr) {
m_parser.setSearchColumns({"title"});

Expand Down

0 comments on commit c753ebe

Please sign in to comment.