From 3b56cb449d8b00c4469c7301d3f7100257dbe0e0 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 8 Jun 2020 18:55:44 +0200 Subject: [PATCH] Add some comments --- .../src/main/java/net/osmand/Reshaper.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/Reshaper.java b/OsmAnd-java/src/main/java/net/osmand/Reshaper.java index 6efd414062..baba66d549 100644 --- a/OsmAnd-java/src/main/java/net/osmand/Reshaper.java +++ b/OsmAnd-java/src/main/java/net/osmand/Reshaper.java @@ -24,7 +24,8 @@ public class Reshaper { // return s; // } try { - ArabicShaping as = new ArabicShaping(ArabicShaping.LETTERS_SHAPE | ArabicShaping.LENGTH_GROW_SHRINK); + ArabicShaping as = new ArabicShaping(ArabicShaping.LETTERS_SHAPE | ArabicShaping.LENGTH_GROW_SHRINK + ); try { s = as.shape(s); } catch (ArabicShapingException e) { @@ -86,20 +87,30 @@ public class Reshaper { public static void main(String[] args) { // char[] c = new char[] {'א', 'ד','ם', ' ', '1', '2'} ; // String reshape = "אדם"; - char[] c = new char[] {'א', 'ד','ם'} ; - String reshape = reshape(new String(c)); - for(int i=0; i < reshape.length(); i++) { - System.out.println(reshape.charAt(i)); - } +// char[] c = new char[] {'א', 'ד','ם'} ; +// String reshape = reshape(new String(c)); +// for (int i = 0; i < reshape.length(); i++) { +// System.out.println(reshape.charAt(i)); +// } test2(); +// test3(); + } + + private static void test3() { + String s = "מרכז מסחרי/השלום (40050)"; + String reshape = reshape(s); + String expected = "(40050) םולשה/ירחסמ זכרמ"; + if (!reshape.equals(expected)) { + throw new IllegalArgumentException(String.format("Bug: expected '%s', reshaped '%s'", expected, reshape)); + } } private static void test2() { String s = "گچ پژ نمکی باللغة العربي"; String reshape = reshape(s); - - if (!reshape.equals("ﻲﺑﺮﻌﻟﺍ ﺔﻐﻠﻟﺎﺑ ﯽﮑﻤﻧ ﮋﭘ ﭻﮔ")) { - throw new IllegalArgumentException("BUG!!!"); + String expected = "ﻲﺑﺮﻌﻟﺍ ﺔﻐﻠﻟﺎﺑ ﯽﮑﻤﻧ ﮋﭘ ﭻﮔ"; + if (!reshape.equals(expected)) { + throw new IllegalArgumentException(String.format("Bug: expected '%s', reshaped '%s'", expected, reshape)); } }