diff options
author | Ruslan Mustakov <endragor@users.noreply.github.com> | 2017-05-05 03:33:52 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-05-04 22:33:52 +0200 |
commit | 78315792d33a26e519278aec650f76022f53082b (patch) | |
tree | 54b6aace028e3428f8bf613b033465091d5e1347 /tests/collections | |
parent | 6c7d2ce8fb104af8f880e6a2973c012174604a5c (diff) | |
download | Nim-78315792d33a26e519278aec650f76022f53082b.tar.gz |
Implement 'take' for Table and TableRef (#5773)
Diffstat (limited to 'tests/collections')
-rw-r--r-- | tests/collections/ttables.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim index a2988e841..01dab44fc 100644 --- a/tests/collections/ttables.nim +++ b/tests/collections/ttables.nim @@ -235,6 +235,21 @@ block withKeyTest: except KeyError: discard +block takeTest: + var t = initTable[string, int]() + t["key"] = 123 + + var val = 0 + assert(t.take("key", val)) + assert(val == 123) + + val = -1 + assert(not t.take("key", val)) + assert(val == -1) + + assert(not t.take("otherkey", val)) + assert(val == -1) + proc orderedTableSortTest() = var t = initOrderedTable[string, int](2) for key, val in items(data): t[key] = val |