nim-lang-utils/tlangutils.nim
2017-05-05 19:17:43 -05:00

45 lines
1023 B
Nim

import langutils, unittest
type
SimpleObj = object
strVal*: string
TestObj = object
strVal*: string
intVal*: int
objVal*: SimpleObj
suite "testutil":
test "sameContents":
let a1 = [1, 2, 3, 4]
let a2 = [3, 2, 4, 1]
let a3 = [1, 2, 3, 5]
let b1 = ["this", "is", "a", "test"]
let b2 = ["a", "test", "this", "is"]
let b3 = ["a", "negative", "test", "this", "is"]
let c1 = [TestObj(strVal: "a", intVal: 1, objVal: SimpleObj(strVal: "innerA")),
TestObj(strVal: "b", intVal: 2, objVal: SimpleObj(strVal: "innerB"))]
let c2 = [c1[1], c1[0]]
check:
sameContents(a1, a2)
sameContents(b2, b1)
sameContents(c1, c2)
sameContents(a1, a3) == false
sameContents(b1, b3) == false
test "sameContents (seq)":
let a1 = @[1, 2, 3, 4]
let a2 = @[3, 2, 4, 1]
check:
sameContents(a1, a2)
test "sameContents (cross-type)":
let a1 = @[1, 2, 3, 4]
let a2 = [3, 2, 4, 1]
check:
sameContents(a1, a2)