0.0.3 release: docs, foxed dump formatting

This commit is contained in:
sergeych committed 2023-09-28 18:03:47 +01:00
1 parent ee20bfdee7
commit b7784fec18
4 files changed
+33 -20

No files matched your search

@@ -118,7 +118,7 @@ fun ByteArray.toDumpLines(wide: Boolean = false): List<String> {
fun dumpChars(_from: Int): String {
var from = _from
val b = StringBuilder(22)
val b = StringBuilder()
b.append('|')
val max: Int = kotlin.math.min(size, from + lineSize)
@@ -162,7 +162,7 @@ fun ByteArray.toDumpLines(wide: Boolean = false): List<String> {
if (line != null) {
val l = size
var fill = lineSize - l % lineSize
if( fill > lineSize/2 ) line.append(" ")
if( fill > lineSize/2 && fill < lineSize ) line.append(" ")
if (fill < lineSize) while (fill-- > 0) line.append(" ")
val index = l - l % lineSize
line.append(dumpChars(if (index < l) index else l - lineSize))
@@ -0,0 +1,19 @@
package bintools
import net.sergeych.bintools.toDump
import kotlin.test.Test
class TestTools {
@Test
fun testDump() {
// val src =
// "MfsmHUExZpb3xd0X8FVj2MSOxc1dRd-93i3zkmJVhgWH0r8p0Agtg6lc9_TB6srlXJF4MOWT3a_Cfy87W3FTKRzdCdsAEDOBkSL-JANDey4"
// .decodeBase64Url()
// println(src.toDump())
var res = byteArrayOf(0)
for( i in 1..100) {
res += byteArrayOf(i.toByte())
println(res.toDump())
}
}
}