[KT-10456] Move tests from StringNumberConversionJVMTest to StringNumberConversionTest
This commit is contained in:
committed by
Ilya Gorbunov
parent
d7bada0c29
commit
8453ed1803
@@ -43,44 +43,6 @@ class StringNumberConversionJVMTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test fun byteToStringWithRadix() {
|
||||
assertEquals("7a", 0x7a.toByte().toString(16))
|
||||
assertEquals("-80", Byte.MIN_VALUE.toString(radix = 16))
|
||||
assertEquals("3v", Byte.MAX_VALUE.toString(radix = 32))
|
||||
assertEquals("-40", Byte.MIN_VALUE.toString(radix = 32))
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 37") { 37.toByte().toString(radix = 37) }
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 1") { 1.toByte().toString(radix = 1) }
|
||||
}
|
||||
|
||||
@Test fun shortToStringWithRadix() {
|
||||
assertEquals("7FFF", 0x7FFF.toShort().toString(radix = 16).toUpperCase())
|
||||
assertEquals("-8000", (-0x8000).toShort().toString(radix = 16))
|
||||
assertEquals("-sfs", (-29180).toShort().toString(radix = 32))
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 37") { 37.toShort().toString(radix = 37) }
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 1") { 1.toShort().toString(radix = 1) }
|
||||
}
|
||||
|
||||
@Test fun intToStringWithRadix() {
|
||||
assertEquals("-ff", (-255).toString(radix = 16))
|
||||
assertEquals("1100110", 102.toString(radix = 2))
|
||||
assertEquals("kona", 411787.toString(radix = 27))
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 37") { 37.toString(radix = 37) }
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 1") { 1.toString(radix = 1) }
|
||||
|
||||
}
|
||||
|
||||
@Test fun longToStringWithRadix() {
|
||||
assertEquals("7f11223344556677", 0x7F11223344556677.toString(radix = 16))
|
||||
assertEquals("hazelnut", 1356099454469L.toString(radix = 36))
|
||||
assertEquals("-8000000000000000", Long.MIN_VALUE.toString(radix = 16))
|
||||
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 37") { 37L.toString(radix = 37) }
|
||||
assertFailsWith<IllegalArgumentException>("Expected to fail with radix 1") { 1L.toString(radix = 1) }
|
||||
}
|
||||
|
||||
@Test fun toBigInteger() {
|
||||
compareConversion(String::toBigInteger, String::toBigIntegerOrNull) {
|
||||
assertProduces("0", java.math.BigInteger.ZERO)
|
||||
|
||||
Reference in New Issue
Block a user