postings: Fix bad test and revert changed logic

A bad test was introduced a couple of commits ago which also made
changes to pass the bad test. Fixed the test and revert the changes.
Signed-off-by: NGoutham Veeramachaneni <cs14btech11014@iith.ac.in>
上级 86929ed0
......@@ -201,30 +201,7 @@ func (it *mergedPostings) Seek(id uint32) bool {
it.aok = it.a.Seek(id)
it.bok = it.b.Seek(id)
if !it.aok && !it.bok {
return false
}
if !it.aok {
it.cur = it.b.At()
return true
}
if !it.bok {
it.cur = it.a.At()
return true
}
acur, bcur := it.a.At(), it.b.At()
if acur < bcur {
it.cur = acur
} else {
it.cur = bcur
}
return true
return it.Next()
}
func (it *mergedPostings) Err() error {
......
......@@ -219,9 +219,18 @@ func TestMerge(t *testing.T) {
require.Equal(t, c.success, p.Seek(c.seek))
res, err := expandPostings(p)
require.NoError(t, err)
require.Equal(t, c.res, res)
if c.success {
// check the current element and then proceed to check the rest.
i := 0
require.Equal(t, c.res[i], p.At())
for p.Next() {
i++
require.Equal(t, int(c.res[i]), int(p.At()))
}
require.Equal(t, len(c.res)-1, i)
}
}
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册