DitchOoM / buffer

Kotlin Multiplatform bytebuffer/byte[] wrapper
Apache License 2.0
63 stars 5 forks source link

Inconsistent behaviour ios/jvm, write() doesn't update position on iOS #49

Closed jbruchanov closed 10 months ago

jbruchanov commented 10 months ago

Using version 1.3.9

Having following test

@Test
fun test() {
    val text = "Hello world!"
    val input = PlatformBuffer.wrap(text.encodeToByteArray())
    val output = PlatformBuffer.allocate(text.length)
    output.write(input)
    assertThat(input.position()).isEqualTo(text.length) //<- ios fails
    assertThat(output.position()).isEqualTo(text.length)
    output.position(0)
    assertThat(output.readString(text.length)).isEqualTo(text)
}

JVM: OK iOS: fails

com.willowtreeapps.opentest4k.AssertionFailedError: expected:<[12]> but was:<[0]>
Expected :[12]
Actual   :[0]
thebehera commented 10 months ago

Interesting, that is definitely a bug. I should be able to get a fix up within a day or two. Thanks for filling this issue!

thebehera commented 10 months ago

should be fixed in 1.3.10