implement numeric encodings, optimize
This commit is contained in:
@@ -1,31 +1,33 @@
|
||||
package com.infendro.encoding
|
||||
|
||||
import com.infendro.encoding.stream.Base16
|
||||
import com.infendro.encoding.stream.StreamEncoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base16 Test` {
|
||||
val encoding: Encoding
|
||||
val encoding: StreamEncoding
|
||||
get() = Base16
|
||||
|
||||
val `Hello World!` = ubyteArrayOf(
|
||||
0x48U, 0x65U, 0x6cU, 0x6cU,
|
||||
0x6fU, 0x20U, 0x57U, 0x6fU,
|
||||
0x72U, 0x6cU, 0x64U, 0x21U,
|
||||
val `Hello World!` = byteArrayOf(
|
||||
0x48, 0x65, 0x6c, 0x6c,
|
||||
0x6f, 0x20, 0x57, 0x6f,
|
||||
0x72, 0x6c, 0x64, 0x21,
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `encode empty ByteArray`() {
|
||||
val expected = ubyteArrayOf()
|
||||
val actual = encoding.encode(ubyteArrayOf())
|
||||
val expected = byteArrayOf()
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `encode "Hello World!"`() {
|
||||
val expected = ubyteArrayOf(
|
||||
0x34U, 0x38U, 0x36U, 0x35U, 0x36U, 0x63U, 0x36U, 0x63U,
|
||||
0x36U, 0x66U, 0x32U, 0x30U, 0x35U, 0x37U, 0x36U, 0x66U,
|
||||
0x37U, 0x32U, 0x36U, 0x63U, 0x36U, 0x34U, 0x32U, 0x31U,
|
||||
val expected = byteArrayOf(
|
||||
0x34, 0x38, 0x36, 0x35, 0x36, 0x63, 0x36, 0x63,
|
||||
0x36, 0x66, 0x32, 0x30, 0x35, 0x37, 0x36, 0x66,
|
||||
0x37, 0x32, 0x36, 0x63, 0x36, 0x34, 0x32, 0x31,
|
||||
)
|
||||
val actual = encoding.encode(`Hello World!`)
|
||||
assertContentEquals(expected, actual)
|
||||
|
||||
Reference in New Issue
Block a user