Add tests for SIZE_BYTES and SIZE_BITS constants
#KT-8247 Fixed
This commit is contained in:
@@ -173,5 +173,23 @@ class NumbersTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun sizeInBitsAndBytes() {
|
||||||
|
fun testSizes(companion: Any, sizeBytes: Int, sizeBits: Int, expectedSizeBytes: Int) {
|
||||||
|
assertEquals(expectedSizeBytes, sizeBytes, companion.toString())
|
||||||
|
assertEquals(expectedSizeBytes * 8, sizeBits, companion.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
testSizes(Char, Char.SIZE_BYTES, Char.SIZE_BITS, 2)
|
||||||
|
|
||||||
|
testSizes(Byte, Byte.SIZE_BYTES, Byte.SIZE_BITS, 1)
|
||||||
|
testSizes(Short, Short.SIZE_BYTES, Short.SIZE_BITS, 2)
|
||||||
|
testSizes(Int, Int.SIZE_BYTES, Int.SIZE_BITS, 4)
|
||||||
|
testSizes(Long, Long.SIZE_BYTES, Long.SIZE_BITS, 8)
|
||||||
|
|
||||||
|
testSizes(UByte, UByte.SIZE_BYTES, UByte.SIZE_BITS, 1)
|
||||||
|
testSizes(UShort, UShort.SIZE_BYTES, UShort.SIZE_BITS, 2)
|
||||||
|
testSizes(UInt, UInt.SIZE_BYTES, UInt.SIZE_BITS, 4)
|
||||||
|
testSizes(ULong, ULong.SIZE_BYTES, ULong.SIZE_BITS, 8)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user