improve test coverage
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
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: StreamEncoding
|
||||
get() = Base16
|
||||
|
||||
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(
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.infendro.encoding
|
||||
|
||||
import com.infendro.encoding.stream.Base32
|
||||
import com.infendro.encoding.stream.StreamEncoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base32 Test` {
|
||||
val encoding: StreamEncoding
|
||||
get() = Base32
|
||||
|
||||
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(
|
||||
0x4a, 0x42, 0x53, 0x57, 0x59, 0x33, 0x44, 0x50,
|
||||
0x45, 0x42, 0x4c, 0x57, 0x36, 0x34, 0x54, 0x4d,
|
||||
0x4d, 0x51, 0x51, 0x51, 0x3d, 0x3d, 0x3d, 0x3d,
|
||||
)
|
||||
val actual = encoding.encode(`Hello World!`)
|
||||
assertContentEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.infendro.encoding
|
||||
|
||||
import com.infendro.encoding.stream.Base64
|
||||
import com.infendro.encoding.stream.StreamEncoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base64 Test` {
|
||||
val encoding: StreamEncoding
|
||||
get() = Base64
|
||||
|
||||
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(
|
||||
0x53, 0x47, 0x56, 0x73, 0x62, 0x47, 0x38, 0x67,
|
||||
0x56, 0x32, 0x39, 0x79, 0x62, 0x47, 0x51, 0x68,
|
||||
)
|
||||
val actual = encoding.encode(`Hello World!`)
|
||||
assertContentEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.infendro.encoding
|
||||
|
||||
import com.infendro.encoding.stream.Base8
|
||||
import com.infendro.encoding.stream.StreamEncoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base8 Test` {
|
||||
val encoding: StreamEncoding
|
||||
get() = Base8
|
||||
|
||||
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(
|
||||
0x32, 0x32, 0x30, 0x36, 0x32, 0x35, 0x35, 0x34,
|
||||
0x33, 0x33, 0x30, 0x36, 0x37, 0x34, 0x34, 0x30,
|
||||
0x32, 0x35, 0x36, 0x36, 0x37, 0x35, 0x36, 0x32,
|
||||
0x33, 0x33, 0x30, 0x36, 0x32, 0x30, 0x34, 0x31,
|
||||
)
|
||||
val actual = encoding.encode(`Hello World!`)
|
||||
assertContentEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.numeric
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base36 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base36
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "2678LX5GVMSV1DRO9B5".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.numeric
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base62 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base62
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "T8dgcjRGkZ3aysdN".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base16.kt
Normal file
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base16.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.stream
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base16 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base16
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "48656C6C6F20576F726C6421".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base2.kt
Normal file
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base2.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.stream
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base2 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base2
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base32.kt
Normal file
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base32.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.stream
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base32 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base32
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "JBSWY3DPEBLW64TMMQQQ====".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base64.kt
Normal file
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base64.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.stream
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base64 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base64
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "SGVsbG8gV29ybGQh".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base8.kt
Normal file
37
src/commonTest/kotlin/com/infendro/encoding/stream/Base8.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.infendro.encoding.stream
|
||||
|
||||
import com.infendro.encoding.Encoding
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertContentEquals
|
||||
|
||||
class `Base8 Test` {
|
||||
val encoding: Encoding
|
||||
get() = Base8
|
||||
|
||||
val original = "Hello World!".encodeToByteArray()
|
||||
val encoded = "22062554330674402566756233062041".encodeToByteArray()
|
||||
|
||||
@Test
|
||||
fun `encode empty`() {
|
||||
val actual = encoding.encode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `decode empty`() {
|
||||
val actual = encoding.decode(byteArrayOf())
|
||||
assertContentEquals(byteArrayOf(), actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
val actual = encoding.encode(original)
|
||||
assertContentEquals(encoded, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun decode() {
|
||||
val actual = encoding.decode(encoded)
|
||||
assertContentEquals(original, actual)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user