Hi there,
I'm learning nim from dom's book Nim in Action and I'm stuck on testing.
Here is the code:
import json
type
Message* = object
username*: string
message*: string
proc parseMessage*(data: string): Message =
let dataJson = parseJson(data)
result.username = dataJson["username"].getStr()
result.message = dataJson["message"].getStr()
when isMainModule:
block:
let data = """{"username" : "John", "message" : "Hi!"}"""
let parsed = parseMessage(data)
doAssert parsed.username == "John"
doAssert parsed.message == "Hello!"
According the book the last line of the code should fail because of different values, but when I compile it it says that it's successfull. Any ideas what's going on?