@@ -28,6 +28,14 @@ class PgJsonSupportSuite extends FunSuite {
28
28
val testRec2 = JsonBean (35L , JsonString (""" [ {"a":"v1","b":2}, {"a":"v5","b":3} ] """ ))
29
29
val testRec3 = JsonBean (37L , JsonString (""" ["a", "b"] """ ))
30
30
31
+ // Unicode testing
32
+ // This byte string is equal to {"d":"123\u000045\u00006"}
33
+ val unicodeJsonBytes : List [Byte ] = List (123 , 34 , 100 , 34 , 58 , 34 , 49 , 50 , 51 , 92 , 117 , 48 , 48 , 48 , 48 , 52 , 53 , 92 , 117 , 48 , 48 , 48 , 48 , 54 , 34 , 125 )
34
+ val unicodeJsonString = new String (unicodeJsonBytes.map(_.toChar).toArray)
35
+ val unicodedJson = JsonString (unicodeJsonString)
36
+ val unicodelessJson = JsonString (""" {"d": "123456"}""" )
37
+ val testRec4 = JsonBean (39L , unicodedJson)
38
+
31
39
test(" Json Lifted support" ) {
32
40
val json1 = """ {"a":"v1","b":2}"""
33
41
val json2 = """ {"a":"v5","b":3}"""
@@ -36,7 +44,7 @@ class PgJsonSupportSuite extends FunSuite {
36
44
DBIO .seq(
37
45
JsonTests .schema create,
38
46
// /
39
- JsonTests forceInsertAll List (testRec1, testRec2, testRec3)
47
+ JsonTests forceInsertAll List (testRec1, testRec2, testRec3, testRec4 )
40
48
).andThen(
41
49
DBIO .seq(
42
50
JsonTests .filter(_.id === testRec2.id.bind).map(_.json).result.head.map(
@@ -123,7 +131,11 @@ class PgJsonSupportSuite extends FunSuite {
123
131
// #-
124
132
JsonTests .filter(_.id === 33L ).map(_.json.set(List (" c" ), JsonString (""" [1] """ ))).result.head.map(
125
133
r => assert(""" {"a": 101, "b": "aaa", "c": [1]} """ .replace(" " , " " ) === r.value.replace(" " , " " ))
126
- )
134
+ ),
135
+ // \u0000 test
136
+ JsonTests .filter(_.id === testRec4.id).map(_.json).result.head.map { r =>
137
+ assert(unicodelessJson === r)
138
+ }
127
139
)
128
140
).andFinally(
129
141
JsonTests .schema drop
@@ -156,4 +168,4 @@ class PgJsonSupportSuite extends FunSuite {
156
168
).transactionally
157
169
), Duration .Inf )
158
170
}
159
- }
171
+ }
0 commit comments