forked from unicode-org/conformance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:unicode-org/conformance
- Loading branch information
Showing
15 changed files
with
285 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...or-icu4j/src/main/java/org/unicode/conformance/testtype/langnames/LangNamesInputJson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.unicode.conformance.testtype.langnames; | ||
|
||
import org.unicode.conformance.testtype.ITestTypeInputJson; | ||
|
||
public class LangNamesInputJson implements ITestTypeInputJson { | ||
|
||
public String test_type; | ||
|
||
public String label; | ||
|
||
public String language_label; | ||
|
||
public String locale_label; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...r-icu4j/src/main/java/org/unicode/conformance/testtype/langnames/LangNamesOutputJson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.unicode.conformance.testtype.langnames; | ||
|
||
import org.unicode.conformance.testtype.ITestTypeOutputJson; | ||
|
||
public class LangNamesOutputJson implements ITestTypeOutputJson { | ||
|
||
public String test_type; | ||
|
||
public String label; | ||
|
||
public String language_label; | ||
|
||
public String locale_label; | ||
|
||
public String result; | ||
|
||
public String error; | ||
|
||
public String error_message; | ||
} |
60 changes: 60 additions & 0 deletions
60
...cutor-icu4j/src/main/java/org/unicode/conformance/testtype/langnames/LangNamesTester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.unicode.conformance.testtype.langnames; | ||
|
||
import com.ibm.icu.util.ULocale; | ||
import io.lacuna.bifurcan.Map; | ||
import org.unicode.conformance.ExecutorUtils; | ||
import org.unicode.conformance.testtype.ITestType; | ||
import org.unicode.conformance.testtype.ITestTypeInputJson; | ||
import org.unicode.conformance.testtype.ITestTypeOutputJson; | ||
import org.unicode.conformance.testtype.collator.CollatorInputJson; | ||
import org.unicode.conformance.testtype.collator.CollatorOutputJson; | ||
|
||
public class LangNamesTester implements ITestType { | ||
|
||
public static LangNamesTester INSTANCE = new LangNamesTester(); | ||
|
||
@Override | ||
public ITestTypeInputJson inputMapToJson(Map<String, String> inputMapData) { | ||
LangNamesInputJson result = new LangNamesInputJson(); | ||
|
||
result.test_type = inputMapData.get("test_type", null); | ||
result.label = inputMapData.get("label", null); | ||
|
||
result.language_label = inputMapData.get("language_label", null); | ||
result.locale_label = inputMapData.get("locale_label", null); | ||
|
||
return result; | ||
} | ||
|
||
@Override | ||
public ITestTypeOutputJson execute(ITestTypeInputJson inputJson) { | ||
LangNamesInputJson input = (LangNamesInputJson) inputJson; | ||
|
||
// partially construct output | ||
LangNamesOutputJson output = new LangNamesOutputJson(); | ||
output.label = input.label; | ||
|
||
try { | ||
String displayNameResult = getDisplayLanguageString(input); | ||
output.result = displayNameResult; | ||
} catch (Exception e) { | ||
output.error = "error running test"; | ||
output.error = e.getMessage(); | ||
return output; | ||
} | ||
|
||
// If we get here, it's a pass/fail result (supported options and no runtime errors/exceptions) | ||
return output; | ||
} | ||
|
||
@Override | ||
public String formatOutputJson(ITestTypeOutputJson outputJson) { | ||
return ExecutorUtils.GSON.toJson((LangNamesOutputJson) outputJson); | ||
} | ||
|
||
public String getDisplayLanguageString(LangNamesInputJson input) { | ||
String localeID = input.language_label; | ||
String displayLocaleID = input.locale_label; | ||
return ULocale.getDisplayNameWithDialect(localeID, displayLocaleID); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...cu4j/73/executor-icu4j/src/test/java/org/unicode/conformance/langnames/LangNamesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.unicode.conformance.langnames; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.unicode.conformance.testtype.langnames.LangNamesOutputJson; | ||
import org.unicode.conformance.testtype.langnames.LangNamesTester; | ||
|
||
public class LangNamesTest { | ||
|
||
@Test | ||
public void testLocaleAndDisplayLocale() { | ||
String testInput = | ||
"{\"test_type\": \"lang_names\", \"label\": \"01\", \"language_label\": \"fr\", \"locale_label\": \"de\"}"; | ||
|
||
LangNamesOutputJson output = | ||
(LangNamesOutputJson) LangNamesTester.INSTANCE.getStructuredOutputFromInputStr(testInput); | ||
|
||
assertEquals("Französisch", output.result); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.