From 54c0510bbeb74941398e6f14152f1798957e5013 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 19 Jun 2020 18:48:39 +0200 Subject: [PATCH] Fix tests --- .../test/java/net/osmand/search/SearchUICoreTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java index 82bb2152bc..f3ed25ca0b 100644 --- a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java @@ -180,14 +180,14 @@ public class SearchUICoreTest { SearchResultCollection collection = new SearchResultCollection(phrase); collection.addSearchResults(matcher.getRequestResults(), true, true); List searchResults = collection.getCurrentSearchResults(); - int i = 0; - for (SearchResult res : searchResults) { - String expected = result.get(i++); + for(int i = 0; i < result.size(); i++) { + String expected = result.get(i); + SearchResult res = i >= searchResults.size() ? null : searchResults.get(i); if (simpleTest && expected.indexOf('[') != -1) { expected = expected.substring(0, expected.indexOf('[')).trim(); } // String present = result.toString(); - String present = formatResult(simpleTest, res, phrase); + String present = res == null ? ("#MISSING " + (i+1)) : formatResult(simpleTest, res, phrase); if (!Algorithms.stringsEqual(expected, present)) { System.out.println(String.format("Phrase: %s", phrase)); System.out.println(String.format("Mismatch for '%s' != '%s'. Result: ", expected, present)); @@ -196,9 +196,6 @@ public class SearchUICoreTest { } } Assert.assertEquals(expected, present); - if (i >= result.size()) { - break; - } } }