Skip to content

Commit

Permalink
Use strict decoders should be false; added long decoder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed Apr 29, 2024
1 parent 580386d commit 5b6cd8c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun interface Decoder<T> {

companion object {

var useStrictPrimitiveDecoders = true
var useStrictPrimitiveDecoders = false

fun decoderFor(type: KType): Decoder<*> {
val decoder: Decoder<*> = when (val classifier = type.classifier) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.sksamuel.centurion.avro.decoders

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import org.apache.avro.Schema

class LongDecoderTest : FunSpec({

test("bytes") {
val schema = Schema.create(Schema.Type.LONG)
LongDecoder.decode(schema).invoke(1.toByte()) shouldBe 1L
}

test("shorts") {
val schema = Schema.create(Schema.Type.LONG)
LongDecoder.decode(schema).invoke(1.toShort()) shouldBe 1L
}
test("ints") {
val schema = Schema.create(Schema.Type.LONG)
LongDecoder.decode(schema).invoke(1) shouldBe 1L
}

test("longs") {
val schema = Schema.create(Schema.Type.LONG)
LongDecoder.decode(schema).invoke(1L) shouldBe 1L
}

})

0 comments on commit 5b6cd8c

Please sign in to comment.