Files
encoding.kt/src/commonTest/kotlin/com/infendro/encoding/Base2.kt

45 lines
1.5 KiB
Kotlin

package com.infendro.encoding
import com.infendro.encoding.stream.Base2
import com.infendro.encoding.stream.StreamEncoding
import kotlin.test.Test
import kotlin.test.assertContentEquals
class `Base2 Test` {
val encoding: StreamEncoding
get() = Base2
val `Hello World!` = byteArrayOf(
0x48, 0x65, 0x6c, 0x6c,
0x6f, 0x20, 0x57, 0x6f,
0x72, 0x6c, 0x64, 0x21,
)
@Test
fun `encode empty ByteArray`() {
val expected = byteArrayOf()
val actual = encoding.encode(byteArrayOf())
assertContentEquals(expected, actual)
}
@Test
fun `encode "Hello World!"`() {
val expected = byteArrayOf(
0x30, 0x31, 0x30, 0x30, 0x31, 0x30, 0x30, 0x30,
0x30, 0x31, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31,
0x30, 0x31, 0x31, 0x30, 0x31, 0x31, 0x30, 0x30,
0x30, 0x31, 0x31, 0x30, 0x31, 0x31, 0x30, 0x30,
0x30, 0x31, 0x31, 0x30, 0x31, 0x31, 0x31, 0x31,
0x30, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x31,
0x30, 0x31, 0x31, 0x30, 0x31, 0x31, 0x31, 0x31,
0x30, 0x31, 0x31, 0x31, 0x30, 0x30, 0x31, 0x30,
0x30, 0x31, 0x31, 0x30, 0x31, 0x31, 0x30, 0x30,
0x30, 0x31, 0x31, 0x30, 0x30, 0x31, 0x30, 0x30,
0x30, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x31,
)
val actual = encoding.encode(`Hello World!`)
assertContentEquals(expected, actual)
}
}