summary refs log tree commit diff stats
path: root/tests/stdlib/tmimetypes.nim
blob: fd66ebd97ff5e20bc37c5134b6a84f68c6a9ff2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
discard """
  matrix: "--mm:refc; --mm:orc"
  targets: "c js"
"""

import std/mimetypes
import std/assertions


template main() =
  var m = newMimetypes()
  doAssert m.getMimetype("mp4") == "video/mp4"
  doAssert m.getExt("application/json") == "json"
  doAssert m.getMimetype("json") == "application/json"
  m.register("foo", "baa")
  doAssert m.getMimetype("foo") == "baa"
  doAssert m.getMimetype("txt") == "text/plain"
  doAssert m.getExt("text/plain") == "txt"
  # see also `runnableExamples`.
  # xxx we should have a way to avoid duplicating code between runnableExamples and tests

  doAssert m.getMimetype("nim") == "text/nim"
  doAssert m.getMimetype("nimble") == "text/nimble"
  doAssert m.getMimetype("nimf") == "text/nim"
  doAssert m.getMimetype("nims") == "text/nim"

static: main()
main()