diff options
author | GrundleTrundle <gtrundle@sdf.org> | 2017-03-16 03:06:24 -0400 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-16 08:06:24 +0100 |
commit | 13ba0b557e7009a397fa550747fbc92e6fb15400 (patch) | |
tree | 836028ff471f3e2ad599c516178216d4802a4f9d /tests | |
parent | e99721a593cfceb43b8b0c3869d82565c03f3fae (diff) | |
download | Nim-13ba0b557e7009a397fa550747fbc92e6fb15400.tar.gz |
Added clear() function for OrderedSet and HashSet. (#5545)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/collections/tsets.nim | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/collections/tsets.nim b/tests/collections/tsets.nim index a5bbe8dbd..6139560bd 100644 --- a/tests/collections/tsets.nim +++ b/tests/collections/tsets.nim @@ -34,4 +34,46 @@ block setWithSequences: doAssert s.contains(@[1, 2, 3]) doAssert( not s.contains(@[4, 5, 6]) ) +block setClearWorked: + var s = initSet[char]() + + for c in "this is a test": + s.incl(c) + + doAssert len(s) == 7 + clear(s) + doAssert len(s) == 0 + + s.incl('z') + for c in "this is a test": + s.incl(c) + + doAssert len(s) == 8 + +block orderedSetClearWorked: + var s = initOrderedSet[char]() + + for c in "eat at joes": + s.incl(c) + + var r = "" + + for c in items(s): + add(r, c) + + doAssert r == "eat jos" + clear(s) + + s.incl('z') + for c in "eat at joes": + s.incl(c) + + r = "" + for c in items(s): + add(r, c) + + doAssert r == "zeat jos" + + + |