void test_rank(Ranker& r, Index& idx, const std::string& encoding)
{
    for (size_t i = 0; i < idx.num_docs(); ++i)
    {
        auto d_id = idx.docs()[i];
        corpus::document query{idx.doc_path(d_id), doc_id{i}};
        query.encoding(encoding);

        auto ranking = r.score(idx, query);
        ASSERT_EQUAL(ranking.size(), 10); // default is 10 docs

        // since we're searching for a document already in the index, the same
        // document should be ranked first, but there are a few duplicate
        // documents......
        if (ranking[0].first != i)
        {
            ASSERT_EQUAL(ranking[1].first, i);
            ASSERT_APPROX_EQUAL(ranking[0].second, ranking[1].second);
        }
    }
}