Skip to content

Commit 71ff19f

Browse files
committed
test: added more tests
1 parent cffb0b1 commit 71ff19f

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

module-ped-bson/src/jvmTest/kotlin/example.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ data class Document1f2(val document: BsonDocument) {
9393

9494
val Document1f2.birthday1 get() = document[Document1.Birthday1]
9595

96-
val Document1f1Codec = Codec {
96+
val Document1f1Codec = BsonCodec {
9797
encodeCatching { it: Document1f1 ->
9898
BsonDocument {
9999
Document1.Id by it.id
@@ -109,3 +109,19 @@ val Document1f1Codec = Codec {
109109
)
110110
}
111111
}
112+
113+
@JvmInline
114+
value class CustomScalar(val value: String)
115+
116+
val ChSq: BsonCodec<CharSequence> = TODO()
117+
118+
val CustomScalarCodec = BsonCodec<CustomScalar> {
119+
encodeCatching(Bson.String) { it.value }
120+
decodeCatching(Bson.String) { CustomScalar(it) }
121+
encodeCatching(ChSq) { it.value }
122+
decodeCatching(ChSq) { xyz: String -> CustomScalar(xyz) }
123+
decodeCatching { it: BsonString -> CustomScalar(it.value) }
124+
encodeCatching { it: CustomScalar -> it.value.bson }
125+
decodeCatching { CustomScalar(it decode Bson.String) }
126+
encodeCatching { it.value.bson }
127+
}

0 commit comments

Comments
 (0)