Fix JsonValueRef nil comparison

This commit is contained in:
jangko 2023-12-29 12:33:58 +07:00
parent ce214b000d
commit 547604004d
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 9 additions and 1 deletions

View File

@ -136,7 +136,7 @@ func `==`*(lhs, rhs: JsonValueRef): bool =
if lhs.isNil and rhs.isNil: if lhs.isNil and rhs.isNil:
return true return true
if lhs.isNil and rhs.isNil: if not lhs.isNil and rhs.isNil:
return false return false
if lhs.isNil and not rhs.isNil: if lhs.isNil and not rhs.isNil:

View File

@ -243,6 +243,14 @@ suite "Public parser":
if name notin allowedToFail: if name notin allowedToFail:
testParseAsString(fileName) testParseAsString(fileName)
test "JsonValueRef comparison":
var x = JsonValueRef[uint64](kind: JsonValueKind.Null)
var n = JsonValueRef[uint64](nil)
check x != n
check n != x
check x == x
check n == n
const const
jsonText = """ jsonText = """