Skip to content

Commit

Permalink
update test to use long instead of int - try to replicate bug for par…
Browse files Browse the repository at this point in the history
…sing long types from int
  • Loading branch information
daviddenton committed Apr 29, 2024
1 parent 9d3bc3f commit 73e10cc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import dev.forkhandles.values.IntValue
import dev.forkhandles.values.IntValueFactory
import dev.forkhandles.values.LocalDateValue
import dev.forkhandles.values.LocalDateValueFactory
import dev.forkhandles.values.LongValue
import dev.forkhandles.values.LongValueFactory
import dev.forkhandles.values.StringValue
import dev.forkhandles.values.StringValueFactory
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -68,14 +70,14 @@ interface MainClassFields<C : ChildFields<G>, G : GrandchildFields, CONTENT> {
var optionalData: CONTENT?
var requiredData: CONTENT

var intValue: IntType?
var longValue: LongType?
var booleanValue: BooleanType
var stringValue: StringType
var localDateValue: LocalDateType
}

class IntType private constructor(value: Int) : IntValue(value) {
companion object : IntValueFactory<IntType>(::IntType)
class LongType private constructor(value: Long) : LongValue(value) {
companion object : LongValueFactory<LongType>(::LongType)
}

class BooleanType private constructor(value: Boolean) : BooleanValue(value) {
Expand Down Expand Up @@ -134,7 +136,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
"stringValue" to "stringValue",
"booleanValue" to true,
"localDateValue" to "1999-12-31",
"intValue" to 1,
"longValue" to 1,
)
)

Expand All @@ -153,7 +155,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
expectThrows<ClassCastException> { container(mapOf("mapped" to 123)).mapped }
expectThat(input.value).isEqualTo(MyType.of(123))
expectThat(input.stringValue).isEqualTo(StringType.of("stringValue"))
expectThat(input.intValue).isEqualTo(IntType.of(1))
expectThat(input.longValue).isEqualTo(LongType.of(1))
expectThat(input.localDateValue).isEqualTo(LocalDateType.of(of(1999, 12, 31)))
expectThat(input.booleanValue).isEqualTo(BooleanType.of(true))

Expand Down Expand Up @@ -181,7 +183,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
"localDateValue" to "1999-12-31",
"stringValue" to "stringValue",
"booleanValue" to true,
"intValue" to 1
"longValue" to 1
)
)

Expand All @@ -192,7 +194,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
expectSetWorks(input::long, 0)
expectSetWorks(input::double, 5.4536)
expectSetWorks(input::stringValue, StringType.of("123"))
expectSetWorks(input::intValue, IntType.of(123))
expectSetWorks(input::longValue, LongType.of(123))
expectSetWorks(input::localDateValue, LocalDateType.of(of(1999, 12, 12)))
expectSetWorks(input::booleanValue, BooleanType.of(false))

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"string":"123","boolean":false,"int":999,"long":0,"double":5.4536,"value":123,"mapped":"123","optionalValue":123,"optional":null,"localDateValue":"1999-12-12","stringValue":"123","booleanValue":false,"intValue":123}
{"string":"123","boolean":false,"int":999,"long":0,"double":5.4536,"value":123,"mapped":"123","optionalValue":123,"optional":null,"localDateValue":"1999-12-12","stringValue":"123","booleanValue":false,"longValue":123}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TopNode(node: JsonNode) : JsonNodeDataContainer(node), MainClassFields<Chi
override var mapped by required(String::toInt, Int::toString, foo, bar)
override var requiredData by requiredData(foo, bar)

override var intValue by optional(IntType)
override var longValue by optional(LongType)
override var stringValue by required(StringType)
override var localDateValue by required(LocalDateType)
override var booleanValue by required(BooleanType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{string=123, boolean=false, int=999, long=0, double=5.4536, value=123, mapped=123, optionalValue=123, optional=null, localDateValue=1999-12-12, stringValue=123, booleanValue=false, intValue=123}
{string=123, boolean=false, int=999, long=0, double=5.4536, value=123, mapped=123, optionalValue=123, optional=null, localDateValue=1999-12-12, stringValue=123, booleanValue=false, longValue=123}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MapBacked(map: MutableMap<String, Any?>) : MapDataContainer(map),
override var value by required(MyType, foo, bar)
override var requiredData by requiredData(foo, bar)

override var intValue by optional(IntType)
override var longValue by optional(LongType)
override var stringValue by required(StringType)
override var localDateValue by required(LocalDateType)
override var booleanValue by required(BooleanType)
Expand Down

0 comments on commit 73e10cc

Please sign in to comment.