diff options
-rw-r--r-- | lib/pure/collections/sets.nim | 4 | ||||
-rw-r--r-- | tests/sets/testequivalence.nim | 22 |
2 files changed, 11 insertions, 15 deletions
diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim index e478a2ce1..e6ab617e5 100644 --- a/lib/pure/collections/sets.nim +++ b/lib/pure/collections/sets.nim @@ -226,11 +226,11 @@ proc `$`*[A](s: TOrderedSet[A]): string = dollarImpl() proc `<`*[A](s, t: TSet[A]): bool = - ## Is a a strict subset of b? + ## Is s a strict subset of t? s.counter != t.counter and s <= t proc `<=`*[A](s, t: TSet[A]): bool = - ## Is a a subset of b? + ## Is s a subset of t? result = false if s.counter > t.counter: return result = true diff --git a/tests/sets/testequivalence.nim b/tests/sets/testequivalence.nim index a1e02fee7..8a83e2a21 100644 --- a/tests/sets/testequivalence.nim +++ b/tests/sets/testequivalence.nim @@ -1,16 +1,12 @@ import unittest import sets -suite "sets": - test "equivalent or subset": - check toSet(@[1,2,3]) <= toSet(@[1,2,3,4]) - check toSet(@[1,2,3]) <= toSet(@[1,2,3]) - check(not(toSet(@[1,2,3]) <= toSet(@[1,2]))) - test "strict subset": - check toSet(@[1,2,3]) <= toSet(@[1,2,3,4]) - check(not(toSet(@[1,2,3]) < toSet(@[1,2,3]))) - check(not(toSet(@[1,2,3]) < toSet(@[1,2]))) - test "==": - check(not(toSet(@[1,2,3]) == toSet(@[1,2,3,4]))) - check toSet(@[1,2,3]) == toSet(@[1,2,3]) - check(not(toSet(@[1,2,3]) == toSet(@[1,2]))) +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]))), "==") |