2024-03-17 11:05:30 +01:00
|
|
|
package jp.juggler
|
2023-02-01 17:11:39 +01:00
|
|
|
|
|
|
|
import jp.juggler.util.data.Base128.decodeBase128
|
|
|
|
import jp.juggler.util.data.Base128.encodeBase128
|
|
|
|
import java.io.ByteArrayOutputStream
|
2024-03-17 11:05:30 +01:00
|
|
|
import kotlin.test.Test
|
|
|
|
import kotlin.test.assertContentEquals
|
2023-02-01 17:11:39 +01:00
|
|
|
|
|
|
|
class Base128Test {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun useBase128() {
|
|
|
|
for (len in 0..20) {
|
|
|
|
for (i in 0 until 256) {
|
|
|
|
val orig = ByteArrayOutputStream(32)
|
|
|
|
.apply {
|
|
|
|
repeat(len) {
|
|
|
|
write(i)
|
|
|
|
}
|
|
|
|
}.toByteArray()
|
|
|
|
val encoded = orig.encodeBase128()
|
|
|
|
val decoded = encoded.decodeBase128()
|
2024-03-17 11:05:30 +01:00
|
|
|
assertContentEquals(
|
2023-02-01 17:11:39 +01:00
|
|
|
orig,
|
2024-03-17 11:05:30 +01:00
|
|
|
decoded,
|
|
|
|
"len=$len,i=$i",
|
2023-02-01 17:11:39 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|