diff options
author | Araq <rumpf_a@web.de> | 2011-06-07 03:37:36 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-06-07 03:37:36 +0200 |
commit | 3bc821aa5c676869d65f1448a005dfd47f197f61 (patch) | |
tree | 16b757f5f8bcab86e46b677b8b8becd63ff04bed /tests/accept/run/tlists.nim | |
parent | 42eb21be7b422b47732a56a1b8420b6f1b63f2c6 (diff) | |
download | Nim-3bc821aa5c676869d65f1448a005dfd47f197f61.tar.gz |
basic generic collections implemented and tested
Diffstat (limited to 'tests/accept/run/tlists.nim')
-rw-r--r-- | tests/accept/run/tlists.nim | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/accept/run/tlists.nim b/tests/accept/run/tlists.nim index e69de29bb..7d5379945 100644 --- a/tests/accept/run/tlists.nim +++ b/tests/accept/run/tlists.nim @@ -0,0 +1,66 @@ +discard """ + output: '''true''' +""" + +import lists + +const + data = [1, 2, 3, 4, 5, 6] + +block SinglyLinkedListTest1: + var L: TSinglyLinkedList[int] + for d in items(data): L.prepend(d) + assert($L == "[6, 5, 4, 3, 2, 1]") + + assert(4 in L) + +block SinglyLinkedListTest2: + var L: TSinglyLinkedList[string] + for d in items(data): L.prepend($d) + assert($L == "[6, 5, 4, 3, 2, 1]") + + assert("4" in L) + + +block DoublyLinkedListTest1: + var L: TDoublyLinkedList[int] + for d in items(data): L.prepend(d) + for d in items(data): L.append(d) + L.remove(L.find(1)) + assert($L == "[6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]") + + assert(4 in L) + +block SinglyLinkedRingTest1: + var L: TSinglyLinkedRing[int] + L.prepend(4) + assert($L == "[4]") + L.prepend(4) + + assert($L == "[4, 4]") + assert(4 in L) + + +block DoublyLinkedRingTest1: + var L: TDoublyLinkedRing[int] + L.prepend(4) + assert($L == "[4]") + L.prepend(4) + + assert($L == "[4, 4]") + assert(4 in L) + + L.append(3) + L.append(5) + assert($L == "[4, 4, 3, 5]") + + L.remove(L.find(3)) + L.remove(L.find(5)) + L.remove(L.find(4)) + L.remove(L.find(4)) + assert($L == "[]") + assert(4 notin L) + + +echo "true" + |