TEST( FTSQuery, Phrase1 ) { FTSQuery q; ASSERT( q.parse( "doing a \"phrase test\" for fun", "english" ).isOK() ); ASSERT_EQUALS( 3U, q.getTerms().size() ); ASSERT_EQUALS( 0U, q.getNegatedTerms().size() ); ASSERT_EQUALS( 1U, q.getPhr().size() ); ASSERT_EQUALS( 0U, q.getNegatedPhr().size() ); ASSERT_EQUALS( "phrase test", q.getPhr()[0] ); ASSERT_EQUALS( "fun|phrase|test||||phrase test||", q.debugString() ); }
// Test textIndexVersion:1 query with language "english". This invokes the standard English // stemmer and stopword list. TEST(FTSQuery, TextIndexVersion1LanguageEnglish) { FTSQuery q; ASSERT(q.parse("the running", "english", TEXT_INDEX_VERSION_1).isOK()); ASSERT_EQUALS(1U, q.getTerms().size()); ASSERT_EQUALS("run", q.getTerms()[0]); ASSERT_EQUALS(0U, q.getNegatedTerms().size()); ASSERT_EQUALS(0U, q.getPhr().size()); ASSERT_EQUALS(0U, q.getNegatedPhr().size()); }
TEST( FTSQuery, Basic1 ) { FTSQuery q; ASSERT( q.parse( "this is fun", "english" ).isOK() ); ASSERT_EQUALS( 1U, q.getTerms().size() ); ASSERT_EQUALS( "fun", q.getTerms()[0] ); ASSERT_EQUALS( 0U, q.getNegatedTerms().size() ); ASSERT_EQUALS( 0U, q.getPhr().size() ); ASSERT_EQUALS( 0U, q.getNegatedPhr().size() ); }
// Test textIndexVersion:1 query with language "invalid". No stemming will be performed, // and no stopword list will be used. TEST(FTSQuery, TextIndexVersion1LanguageInvalid) { FTSQuery q; ASSERT(q.parse("the running", "invalid", TEXT_INDEX_VERSION_1).isOK()); ASSERT_EQUALS(2U, q.getTerms().size()); ASSERT_EQUALS(1, std::count(q.getTerms().begin(), q.getTerms().end(), "the")); ASSERT_EQUALS(1, std::count(q.getTerms().begin(), q.getTerms().end(), "running")); ASSERT_EQUALS(0U, q.getNegatedTerms().size()); ASSERT_EQUALS(0U, q.getPhr().size()); ASSERT_EQUALS(0U, q.getNegatedPhr().size()); }
TEST( FTSQuery, Phrase2 ) { FTSQuery q; ASSERT( q.parse( "doing a \"phrase-test\" for fun", "english" ).isOK() ); ASSERT_EQUALS( 1U, q.getPhr().size() ); ASSERT_EQUALS( "phrase-test", q.getPhr()[0] ); }