Added searcher test cases

This commit is contained in:
MohitMali 2023-03-14 17:53:27 +05:30
parent 9a2573e7ca
commit 97f2b4d3f4

View File

@ -69,6 +69,8 @@ public class test {
assertNotEquals("", dai.filename); assertNotEquals("", dai.filename);
c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length)); c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length));
assertEquals(new String(faviconData), c); assertEquals(new String(faviconData), c);
archive.dispose();
} }
@Test @Test
@ -98,6 +100,8 @@ public class test {
assertNotEquals("", dai.filename); assertNotEquals("", dai.filename);
c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length)); c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length));
assertEquals(new String(faviconData), c); assertEquals(new String(faviconData), c);
archive.dispose();
} }
@Test @Test
@ -128,6 +132,8 @@ public class test {
assertNotEquals("", dai.filename); assertNotEquals("", dai.filename);
c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length)); c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length));
assertEquals(new String(faviconData), c); assertEquals(new String(faviconData), c);
archive.dispose();
} }
@Test @Test
@ -149,7 +155,7 @@ public class test {
} }
@Test @Test
public void testServer() throws IOException, ZimFileFormatException, JNIKiwixException { public void testServer() throws ZimFileFormatException, JNIKiwixException {
Archive archive = new Archive("small.zim"); Archive archive = new Archive("small.zim");
Library lib = new Library(); Library lib = new Library();
Book book = new Book(); Book book = new Book();
@ -162,7 +168,7 @@ public class test {
} }
@Test @Test
public void testBookMark() throws IOException, ZimFileFormatException, JNIKiwixException { public void testBookMark() throws ZimFileFormatException, JNIKiwixException {
Archive archive = new Archive("small.zim"); Archive archive = new Archive("small.zim");
Library lib = new Library(); Library lib = new Library();
Book book = new Book(); Book book = new Book();
@ -183,6 +189,18 @@ public class test {
//assertEquals(true, lib.removeBookmark(bookmark.getBookId(), bookmark.getUrl())); //assertEquals(true, lib.removeBookmark(bookmark.getBookId(), bookmark.getUrl()));
} }
@Test
public void testSearcher() throws Exception, ZimFileFormatException, JNIKiwixException {
Archive archive = new Archive("small.zim");
Searcher searcher = new Searcher(archive);
Query query = new Query("test");
Search search = searcher.search(query);
int matches = (int) search.getEstimatedMatches();
assertEquals(1, matches);
SearchIterator iterator = search.getResults(0, matches);
searcher.dispose();
}
static static
public void main(String[] args) { public void main(String[] args) {
Library lib = new Library(); Library lib = new Library();