2020-02-01 12:38:38 +01:00
|
|
|
package jp.juggler.subwaytooter
|
|
|
|
|
2020-02-04 03:04:07 +01:00
|
|
|
import org.junit.Assert.assertEquals
|
2020-02-01 12:38:38 +01:00
|
|
|
import org.junit.Test
|
|
|
|
import java.net.IDN
|
|
|
|
|
|
|
|
class TestIDN {
|
2021-06-20 05:02:30 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
@Throws(Exception::class)
|
|
|
|
fun testIDN() {
|
|
|
|
// normal conversion
|
|
|
|
assertEquals("xn--3-pfuzbe6htf.juggler.jp", IDN.toASCII("マストドン3.juggler.jp", IDN.ALLOW_UNASSIGNED))
|
|
|
|
assertEquals("マストドン3.juggler.jp", IDN.toUnicode("xn--3-pfuzbe6htf.juggler.jp", IDN.ALLOW_UNASSIGNED))
|
|
|
|
|
|
|
|
// not IDN domain
|
|
|
|
assertEquals("mastodon.juggler.jp", IDN.toASCII("mastodon.juggler.jp", IDN.ALLOW_UNASSIGNED))
|
|
|
|
assertEquals("mastodon.juggler.jp", IDN.toUnicode("mastodon.juggler.jp", IDN.ALLOW_UNASSIGNED))
|
|
|
|
|
|
|
|
// 既に変換済みの引数
|
|
|
|
assertEquals("xn--3-pfuzbe6htf.juggler.jp", IDN.toASCII("xn--3-pfuzbe6htf.juggler.jp", IDN.ALLOW_UNASSIGNED))
|
|
|
|
assertEquals("マストドン3.juggler.jp", IDN.toUnicode("マストドン3.juggler.jp", IDN.ALLOW_UNASSIGNED))
|
|
|
|
|
|
|
|
// 複数のpunycode
|
|
|
|
assertEquals("թութ.հայ", IDN.toUnicode("xn--69aa8bzb.xn--y9a3aq", IDN.ALLOW_UNASSIGNED))
|
|
|
|
|
|
|
|
// ?
|
|
|
|
assertEquals("?", IDN.toASCII("?", IDN.ALLOW_UNASSIGNED))
|
|
|
|
assertEquals("?", IDN.toUnicode("?", IDN.ALLOW_UNASSIGNED))
|
|
|
|
}
|
|
|
|
}
|