#[
autogenerated by docgen
loc: /build/nim/src/nim/lib/std/jsheaders.nim(51, 17)
rdoccmd: -r:off
]#
import std/assertions
import "/build/nim/src/nim/lib/std/jsheaders.nim"
{.line: ("/build/nim/src/nim/lib/std/jsheaders.nim", 51, 17).}:

  block:
    let header: Headers = newHeaders()
    header.add("key", "value")
    assert header.hasKey("key")
    assert header.keys() == @["key".cstring]
    assert header.values() == @["value".cstring]
    assert header["key"] == "value".cstring
    header["other"] = "another".cstring
    assert header["other"] == "another".cstring
    assert header.entries() == @[("key".cstring, "value".cstring), ("other".cstring, "another".cstring)]
    assert header.toCstring() == """[["key","value"],["other","another"]]""".cstring
    header.delete("other")
    assert header.entries() == @[("key".cstring, "value".cstring)]
    header.clear()
    assert header.entries() == @[]
    assert header.len == 0

  block:
    let header: Headers = newHeaders()
    header.add("key", "a")
    header.add("key", "b")  ## Duplicated.
    header.add("key", "c")  ## Duplicated.
    assert header["key"] == "a, b, c".cstring
    header["key"] = "value".cstring
    assert header["key"] == "value".cstring

  block:
    let header: Headers = newHeaders()
    header["key"] = "a"
    header["key"] = "b"  ## Overwrites.
    assert header["key"] == "b".cstring

