static void verifyDocFreq(const DirectoryPtr& dir) {
    IndexReaderPtr reader = IndexReader::open(dir, true);

    // create enumeration of all terms
    TermEnumPtr termEnum = reader->terms();
    // go to the first term (aaa)
    termEnum->next();
    // assert that term is 'aaa'
    EXPECT_EQ(L"aaa", termEnum->term()->text());
    EXPECT_EQ(200, termEnum->docFreq());
    // go to the second term (bbb)
    termEnum->next();
    // assert that term is 'bbb'
    EXPECT_EQ(L"bbb", termEnum->term()->text());
    EXPECT_EQ(100, termEnum->docFreq());

    termEnum->close();

    // create enumeration of terms after term 'aaa', including 'aaa'
    termEnum = reader->terms(newLucene<Term>(L"content", L"aaa"));
    // assert that term is 'aaa'
    EXPECT_EQ(L"aaa", termEnum->term()->text());
    EXPECT_EQ(200, termEnum->docFreq());
    // go to term 'bbb'
    termEnum->next();
    // assert that term is 'bbb'
    EXPECT_EQ(L"bbb", termEnum->term()->text());
    EXPECT_EQ(100, termEnum->docFreq());

    termEnum->close();
}
TEST_F(ParallelTermEnumTest, testParallelTermEnum) {
    ParallelReaderPtr pr = newLucene<ParallelReader>();
    pr->add(ir1);
    pr->add(ir2);

    TermDocsPtr td = pr->termDocs();
    TermEnumPtr te = pr->terms();

    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field1:brown", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field1:fox", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field1:jumps", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field1:quick", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field1:the", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field2:brown", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field2:fox", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field2:jumps", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field2:quick", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field2:the", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field3:dog", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field3:fox", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field3:jumps", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field3:lazy", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field3:over", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(te->next());
    EXPECT_EQ(L"field3:the", te->term()->toString());
    td->seek(te->term());
    EXPECT_TRUE(td->next());
    EXPECT_EQ(0, td->doc());
    EXPECT_TRUE(!td->next());
    EXPECT_TRUE(!te->next());
}