From 97f2b4d3f4a9c45061162da04003c45c16aff36b Mon Sep 17 00:00:00 2001 From: MohitMali Date: Tue, 14 Mar 2023 17:53:27 +0530 Subject: [PATCH] Added searcher test cases --- lib/src/test/test.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/src/test/test.java b/lib/src/test/test.java index c4e73ce..f27aeb9 100644 --- a/lib/src/test/test.java +++ b/lib/src/test/test.java @@ -69,6 +69,8 @@ public class test { assertNotEquals("", dai.filename); c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length)); assertEquals(new String(faviconData), c); + + archive.dispose(); } @Test @@ -98,6 +100,8 @@ public class test { assertNotEquals("", dai.filename); c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length)); assertEquals(new String(faviconData), c); + + archive.dispose(); } @Test @@ -128,6 +132,8 @@ public class test { assertNotEquals("", dai.filename); c = new String(getFileContentPartial(dai.filename, (int) dai.offset, faviconData.length)); assertEquals(new String(faviconData), c); + + archive.dispose(); } @Test @@ -149,7 +155,7 @@ public class test { } @Test - public void testServer() throws IOException, ZimFileFormatException, JNIKiwixException { + public void testServer() throws ZimFileFormatException, JNIKiwixException { Archive archive = new Archive("small.zim"); Library lib = new Library(); Book book = new Book(); @@ -162,7 +168,7 @@ public class test { } @Test - public void testBookMark() throws IOException, ZimFileFormatException, JNIKiwixException { + public void testBookMark() throws ZimFileFormatException, JNIKiwixException { Archive archive = new Archive("small.zim"); Library lib = new Library(); Book book = new Book(); @@ -183,6 +189,18 @@ public class test { //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 public void main(String[] args) { Library lib = new Library();