From bc3a37b65f9073afd423fa8ed89f59d3c7dc1949 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 21 Apr 2021 17:23:08 +0200 Subject: [PATCH] Add current vs expected --- .../java/net/osmand/search/core/SearchResult.java | 2 +- .../java/net/osmand/search/SearchUICoreTest.java | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java index be50174bff..8d1df0a41a 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchResult.java @@ -62,7 +62,7 @@ public class SearchResult { double res = 1; if (match) { res = ObjectType.getTypeWeight(match ? objectType : null); - fullCompleteMatch = getSelfPhrase().equals(name); + fullCompleteMatch = getSelfPhrase().equalsIgnoreCase(name); if (fullCompleteMatch) { res = res * 10; } 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 07e7339401..328b16543a 100644 --- a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java @@ -180,21 +180,28 @@ public class SearchUICoreTest { SearchResultCollection collection = new SearchResultCollection(phrase); collection.addSearchResults(matcher.getRequestResults(), true, true); List searchResults = collection.getCurrentSearchResults(); - for(int i = 0; i < result.size(); 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 = res == null ? ("#MISSING " + (i+1)) : formatResult(simpleTest, res, phrase); + // String present = result.toString(); + 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)); - } + System.out.println("CURRENT RESULTS: "); for (SearchResult r : searchResults) { System.out.println(String.format("\t\"%s\",", formatResult(false, r, phrase))); + } + System.out.println("EXPECTED : "); + for (String r : result) { + System.out.println(String.format("\t\"%s\",", r)); + + } + } Assert.assertEquals(expected, present); } }