Skip to content

Commit 73e10cc

Browse files
committed
update test to use long instead of int - try to replicate bug for parsing long types from int
1 parent 9d3bc3f commit 73e10cc

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

data4k/src/test/kotlin/dev/forkhandles/lens/DataContainerContract.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import dev.forkhandles.values.IntValue
1313
import dev.forkhandles.values.IntValueFactory
1414
import dev.forkhandles.values.LocalDateValue
1515
import dev.forkhandles.values.LocalDateValueFactory
16+
import dev.forkhandles.values.LongValue
17+
import dev.forkhandles.values.LongValueFactory
1618
import dev.forkhandles.values.StringValue
1719
import dev.forkhandles.values.StringValueFactory
1820
import org.junit.jupiter.api.Test
@@ -68,14 +70,14 @@ interface MainClassFields<C : ChildFields<G>, G : GrandchildFields, CONTENT> {
6870
var optionalData: CONTENT?
6971
var requiredData: CONTENT
7072

71-
var intValue: IntType?
73+
var longValue: LongType?
7274
var booleanValue: BooleanType
7375
var stringValue: StringType
7476
var localDateValue: LocalDateType
7577
}
7678

77-
class IntType private constructor(value: Int) : IntValue(value) {
78-
companion object : IntValueFactory<IntType>(::IntType)
79+
class LongType private constructor(value: Long) : LongValue(value) {
80+
companion object : LongValueFactory<LongType>(::LongType)
7981
}
8082

8183
class BooleanType private constructor(value: Boolean) : BooleanValue(value) {
@@ -134,7 +136,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
134136
"stringValue" to "stringValue",
135137
"booleanValue" to true,
136138
"localDateValue" to "1999-12-31",
137-
"intValue" to 1,
139+
"longValue" to 1,
138140
)
139141
)
140142

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

@@ -181,7 +183,7 @@ abstract class DataContainerContract<C : ChildFields<G>, G : GrandchildFields, C
181183
"localDateValue" to "1999-12-31",
182184
"stringValue" to "stringValue",
183185
"booleanValue" to true,
184-
"intValue" to 1
186+
"longValue" to 1
185187
)
186188
)
187189

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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}
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,"longValue":123}

data4k/src/test/kotlin/dev/forkhandles/lens/JsonNodeDataContainerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TopNode(node: JsonNode) : JsonNodeDataContainer(node), MainClassFields<Chi
4040
override var mapped by required(String::toInt, Int::toString, foo, bar)
4141
override var requiredData by requiredData(foo, bar)
4242

43-
override var intValue by optional(IntType)
43+
override var longValue by optional(LongType)
4444
override var stringValue by required(StringType)
4545
override var localDateValue by required(LocalDateType)
4646
override var booleanValue by required(BooleanType)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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}
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, longValue=123}

data4k/src/test/kotlin/dev/forkhandles/lens/MapDataContainerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class MapBacked(map: MutableMap<String, Any?>) : MapDataContainer(map),
4343
override var value by required(MyType, foo, bar)
4444
override var requiredData by requiredData(foo, bar)
4545

46-
override var intValue by optional(IntType)
46+
override var longValue by optional(LongType)
4747
override var stringValue by required(StringType)
4848
override var localDateValue by required(LocalDateType)
4949
override var booleanValue by required(BooleanType)

0 commit comments

Comments
 (0)