Fix import stew/results to pkg/results (#101)

This commit is contained in:
andri lim 2024-10-15 18:24:47 +07:00 committed by GitHub
parent 5127b26ee5
commit 96fcb658b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 13 deletions

View File

@ -18,7 +18,8 @@ skipDirs = @["tests", "fuzzer"]
requires "nim >= 1.6.0",
"serialization",
"stew"
"stew",
"results"
let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)

View File

@ -8,7 +8,7 @@
# those terms.
import
stew/results, ../../json_serialization/[reader, writer, lexer]
pkg/results, ../../json_serialization/[reader, writer, lexer]
export
results

View File

@ -23,7 +23,7 @@ type
a: Opt[int]
b: Option[string]
c: int
createJsonFlavor YourJson,
omitOptionalFields = false
@ -149,16 +149,16 @@ suite "Test writer":
)
let u = YourJson.encode(x)
check u.string == """{"a":123,"b":"nano","c":456}"""
check u == """{"a":123,"b":"nano","c":456}"""
let v = YourJson.encode(y)
check v.string == """{"a":null,"b":null,"c":999}"""
check v == """{"a":null,"b":null,"c":999}"""
let xx = MyJson.encode(x)
check xx.string == """{"a":123,"b":"nano","c":456}"""
check xx == """{"a":123,"b":"nano","c":456}"""
let yy = MyJson.encode(y)
check yy.string == """{"c":999}"""
check yy == """{"c":999}"""
test "writeField with object with optional fields":
let x = OWOF(
@ -174,14 +174,14 @@ suite "Test writer":
)
let xx = MyJson.encode(x)
check xx.string == """{"a":123,"b":"nano","c":456}"""
check xx == """{"a":123,"b":"nano","c":456}"""
let yy = MyJson.encode(y)
check yy.string == """{"c":999}"""
check yy == """{"c":999}"""
let uu = YourJson.encode(x)
check uu.string == """{"a":123,"b":"nano","c":456}"""
check uu == """{"a":123,"b":"nano","c":456}"""
let vv = YourJson.encode(y)
check vv.string == """{"a":null,"b":null,"c":999}"""
check vv == """{"a":null,"b":null,"c":999}"""
test "Enum value representation primitives":
when DefaultFlavor.flavorEnumRep() == EnumAsString:
@ -268,8 +268,7 @@ suite "Test writer":
# configuration: Json.configureJsonSerialization(Drawer, EnumAsNumber)
let u = Json.encode(Two)
check u == "1"
# configuration: MyJson.configureJsonSerialization(Drawer, EnumAsString)
let v = MyJson.encode(One)
check v == "\"One\""