diff options
author | Julien Dessaux | 2021-10-04 18:22:59 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-10-04 18:22:59 +0200 |
commit | 1d11df68fc011a023e19b4ec7db4df73bef331d7 (patch) | |
tree | 0a86ae37833929ad9972dbc5779fca0e59f91531 /tests | |
parent | Cosmetics (diff) | |
download | nimfunge98-1d11df68fc011a023e19b4ec7db4df73bef331d7.tar.gz nimfunge98-1d11df68fc011a023e19b4ec7db4df73bef331d7.tar.bz2 nimfunge98-1d11df68fc011a023e19b4ec7db4df73bef331d7.zip |
Implemented the stackstack
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stack.nim | 7 | ||||
-rw-r--r-- | tests/stackStack.nim | 104 |
2 files changed, 111 insertions, 0 deletions
diff --git a/tests/stack.nim b/tests/stack.nim index 0f7e4c8..cb49daf 100644 --- a/tests/stack.nim +++ b/tests/stack.nim @@ -130,6 +130,13 @@ suite "Stack": check full.data[0] == 1 check empty.data[0] == 2 check empty.data[1] == 3 + test "Discard": + var empty = NewStack() + empty[].Discard(1) + check empty.height == 0 + empty[].Push(2) + empty[].Discard(3) + check empty.height == 0 test "Next": var empty = NewStack() check empty[].Next() == nil diff --git a/tests/stackStack.nim b/tests/stackStack.nim new file mode 100644 index 0000000..03650f8 --- /dev/null +++ b/tests/stackStack.nim @@ -0,0 +1,104 @@ +import unittest + +include ../src/stackStack + +suite "StackStack": + test "Pop": + var empty = NewStackStack() + check empty[].Pop() == 0 + test "Push": + var empty = NewStackStack() + empty[].Push(5) + check empty[].Pop() == 5 + test "PopVector": + var empty = NewStackStack() + check empty[].PopVector() == (0, 0) + test "PushVector": + var empty = NewStackStack() + empty[].PushVector((3, 2)) + check empty[].PopVector() == (3, 2) + test "Clear": + var empty = NewStackStack() + empty[].Push(3) + empty[].Clear() + check empty[].Pop() == 0 + test "Begin": + var empty = NewStackStack() + empty[].Begin((1, 2)) + check empty.height == 2 + check empty[].Pop() == 0 + empty[].Push(5) + empty[].Push(6) + empty[].Push(4) + empty[].Begin((3, 4)) + check empty.height == 3 + check empty[].Pop() == 6 + check empty[].Pop() == 5 + check empty[].Pop() == 0 + check empty[].Pop() == 0 + empty[].Push(7) + empty[].Push(8) + empty[].Push(9) + empty[].Push(2) + empty[].Begin((10, 11)) + check empty.height == 4 + check empty[].Pop() == 9 + check empty[].Pop() == 8 + check empty[].Pop() == 0 + empty[].Push(13) + empty[].Push(14) + empty[].Push(-2) + empty[].Begin((15, 16)) + check empty[].Pop() == 0 + test "End": + var empty = NewStackStack() + var v: tuple[x,y: int] = (0, 0) + empty[].Push(1) + check empty[].End(v) == true + check empty.height == 1 + check empty[].Pop() == 1 + empty[].Push(1) + empty[].Push(2) + empty[].Push(3) + empty[].Push(4) + empty[].Push(2) + v = (5, 6) + empty[].Begin(v) + v = (0, 0) + empty[].Push(2) + check empty[].End(v) == false + check v == (5, 6) + check empty.height == 1 + check empty[].End(v) == true + check empty[].Pop() == 4 + check empty[].Pop() == 3 + check empty[].Pop() == 2 + check empty[].Pop() == 1 + empty[].Push(1) + empty[].Push(2) + empty[].Push(3) + empty[].Push(4) + empty[].Push(2) + empty[].Begin(v) + empty[].Push(4) + check empty[].End(v) == false + check v == (5, 6) + check empty.height == 1 + check empty[].Pop() == 4 + check empty[].Pop() == 3 + check empty[].Pop() == 0 + check empty[].Pop() == 0 + check empty[].Pop() == 2 + check empty[].Pop() == 1 + empty[].Push(1) + empty[].Push(2) + empty[].Push(3) + empty[].Push(4) + empty[].Push(1) + empty[].Begin(v) + empty[].Push(-2) + check empty[].End(v) == false + check v == (5, 6) + check empty.height == 1 + check empty[].Pop() == 1 + check empty[].Pop() == 0 |