Skip to content

Commit

Permalink
test (toJsonString): add test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
aarcex3 committed Oct 29, 2024
1 parent f66b05f commit 02a4ce1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/test_json.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest

include yahttp

suite "toJsonString Test Suite":
test "Simple Case":
let sample = %*{"name": "Alice", "age": 30}
let expected = """{"name":"Alice","age":30}"""
check toJsonString(sample) == expected

test "Empty JSON":
let empty = %*{}
let expected = """{}"""
check toJsonString(empty) == expected

test "Nested JSON":
let nested = %*{
"user": {
"name": "Bob",
"location": {"city": "Paris", "country": "France"}
}
}
let expected = """{"user":{"name":"Bob","location":{"city":"Paris","country":"France"}}}"""
check toJsonString(nested) == expected

0 comments on commit 02a4ce1

Please sign in to comment.