Last active
March 7, 2019 02:48
-
-
Save ishideo/19c7fe7d9464618340d201e166a25671 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 was generated by the Gradle 'init' task. | |
* | |
* This generated file contains a sample Java project to get you started. | |
* For more details take a look at the Java Quickstart chapter in the Gradle | |
* user guide available at https://docs.gradle.org/5.0/userguide/tutorial_java_projects.html | |
*/ | |
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | |
plugins { | |
// Apply the java plugin to add support for Java | |
id("java") | |
// Apply the application plugin to add support for building an application | |
id("application") | |
id("com.github.johnrengelman.shadow") version "5.0.0" | |
} | |
repositories { | |
// Use jcenter for resolving your dependencies. | |
// You can declare any Maven/Ivy/file repository here. | |
jcenter() | |
} | |
dependencies { | |
implementation(fileTree(mapOf("dir" to "libs", "include" to arrayOf("*.jar")))) | |
// This dependency is found on compile classpath of this component and consumers. | |
implementation("com.google.guava:guava:26.0-jre") | |
implementation("com.ibm.icu:icu4j:63.1") | |
// Use JUnit test framework | |
testImplementation("junit:junit:4.12") | |
} | |
application { | |
// Define the main class for the application | |
mainClassName = "App.KatakanaRomajiConvert" | |
} | |
tasks.withType<Jar> { | |
manifest { | |
attributes(mapOf( | |
"Main-Class" to "App.KatakanaRomajiConvert" | |
)) | |
} | |
} | |
tasks.withType<ShadowJar> { | |
baseName = "kana2romaji" | |
classifier = "" | |
version = "" | |
} |
This file contains hidden or 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
org.gradle.jvmargs='-Dfile.encoding=UTF-8' | |
org.gradle.daemon=true | |
// org.gradle.java.home=C:\\JDKPortable | |
// systemProp.http.proxyHost= | |
// systemProp.http.proxyPort= | |
// systemProp.https.proxyHost= | |
// systemProp.https.proxyPort= |
This file contains hidden or 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
package App; | |
import java.util.Optional; | |
import com.ibm.icu.text.Transliterator; | |
public class KatakanaRomajiConvert { | |
public static void main(String[] args) { | |
try { | |
System.out.println(convertRomaji(args[0])); | |
} catch (ArrayIndexOutOfBoundsException e) { | |
System.out.println(""); | |
} | |
} | |
public static String convertRomaji() { | |
return ""; | |
} | |
public static String convertRomaji(String word) { | |
Transliterator transliterator = Transliterator.getInstance("Katakana-Latin"); | |
Optional<String> wordOpt = Optional.ofNullable(word); | |
String kana = wordOpt.orElse(""); | |
String result = transliterator.transliterate(kana); | |
return result; | |
} | |
} |
This file contains hidden or 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
package App; | |
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class KatakanaRomajiConvertTest { | |
@Test | |
public void testKatakanaRomajiConvertNullArg() { | |
KatakanaRomajiConvert AppTest = new KatakanaRomajiConvert(); | |
assertEquals("", AppTest.convertRomaji(null)); | |
} | |
public void testKatakanaRomajiConvertNoArg() { | |
KatakanaRomajiConvert AppTest = new KatakanaRomajiConvert(); | |
assertEquals("", AppTest.convertRomaji()); | |
} | |
public void testKatakanaRomajiConvertEmptyArg() { | |
KatakanaRomajiConvert AppTest = new KatakanaRomajiConvert(); | |
assertEquals("", AppTest.convertRomaji("")); | |
} | |
public void testKatakanaRomajiConvertAnArg() { | |
KatakanaRomajiConvert AppTest = new KatakanaRomajiConvert(); | |
assertEquals("kyouto", AppTest.convertRomaji("キョウト")); | |
} | |
public void testKatakanaRomajiConvertMixCharsStringArg() { | |
KatakanaRomajiConvert AppTest = new KatakanaRomajiConvert(); | |
assertEquals("あいうアイウabcABC", AppTest.convertRomaji("あいうaiuabcABC")); | |
} | |
public void testKatakanaRomajiConvertMixCharsAndSpcStringArg() { | |
KatakanaRomajiConvert AppTest = new KatakanaRomajiConvert(); | |
assertEquals("あいう アイウ abc ABC", AppTest.convertRomaji("あいうアイウabcABC")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment