Unit testing a text index

Posted by jplot on Programmers See other posts from Programmers or by jplot
Published on 2012-10-05T01:39:43Z Indexed on 2012/10/05 3:50 UTC
Read the original article Hit count: 178

Filed under:
|
|

Consider a text index such as a suffix tree or a suffix array supporting Count queries (number of occurrences of a pattern) and Locate queries (the positions of all the occurrences of a pattern) over a given text. How would you go about unit testing such a class ?

What I have in mind is to generate a big random string then extract a random substring from this big string and compare the results of both queries with naive implementations (such as string::find). Another idea I have is to find the most frequent substring of length l appearing in the original string (using perhaps a naive method) and use these substrings for testing the index.

This isn't the best way, so what would be a good design of the unit tests for a text index ?

In case it matters, this is in C++ using google test.

© Programmers or respective owner

Related posts about c++

Related posts about unit-testing