summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/testequivalence.nim15
-rw-r--r--tests/stdlib/tsets.nim17
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/stdlib/testequivalence.nim b/tests/stdlib/testequivalence.nim
new file mode 100644
index 000000000..7c5d9e3e9
--- /dev/null
+++ b/tests/stdlib/testequivalence.nim
@@ -0,0 +1,15 @@
+discard """
+  output: ''''''
+"""
+import unittest
+import sets
+
+doAssert(toSet(@[1,2,3]) <= toSet(@[1,2,3,4]), "equivalent or subset")
+doAssert(toSet(@[1,2,3]) <= toSet(@[1,2,3]), "equivalent or subset")
+doAssert((not(toSet(@[1,2,3]) <= toSet(@[1,2]))), "equivalent or subset")
+doAssert(toSet(@[1,2,3]) <= toSet(@[1,2,3,4]), "strict subset")
+doAssert((not(toSet(@[1,2,3]) < toSet(@[1,2,3]))), "strict subset")
+doAssert((not(toSet(@[1,2,3]) < toSet(@[1,2]))), "strict subset")
+doAssert((not(toSet(@[1,2,3]) == toSet(@[1,2,3,4]))), "==")
+doAssert(toSet(@[1,2,3]) == toSet(@[1,2,3]), "==")
+doAssert((not(toSet(@[1,2,3]) == toSet(@[1,2]))), "==")
diff --git a/tests/stdlib/tsets.nim b/tests/stdlib/tsets.nim
new file mode 100644
index 000000000..656c5b3f2
--- /dev/null
+++ b/tests/stdlib/tsets.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''true
+true'''
+"""
+
+import sets
+var
+  a = initSet[int]()
+  b = initSet[int]()
+  c = initSet[string]()
+
+for i in 0..5: a.incl(i)
+for i in 1..6: b.incl(i)
+for i in 0..5: c.incl($i)
+
+echo map(a, proc(x: int): int = x + 1) == b
+echo map(a, proc(x: int): string = $x) == c