aboutsummaryrefslogtreecommitdiff
path: root/pkg/stack/stack_test.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-23 11:45:49 +0200
committerJulien Dessaux2021-09-23 11:45:49 +0200
commit759ee2aa10323d1960405c93f7cd4cf6d383ae7a (patch)
tree87648b4811b0264f1b54c454ed2569abe1abee94 /pkg/stack/stack_test.go
parentBegan coding the interpreter (only manages the minimal example for now!) (diff)
downloadgofunge98-759ee2aa10323d1960405c93f7cd4cf6d383ae7a.tar.gz
gofunge98-759ee2aa10323d1960405c93f7cd4cf6d383ae7a.tar.bz2
gofunge98-759ee2aa10323d1960405c93f7cd4cf6d383ae7a.zip
Each pointer needs its own stack, merging the two packages to avoid a circular dependency
Diffstat (limited to 'pkg/stack/stack_test.go')
-rw-r--r--pkg/stack/stack_test.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/pkg/stack/stack_test.go b/pkg/stack/stack_test.go
deleted file mode 100644
index e48c615..0000000
--- a/pkg/stack/stack_test.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package stack
-
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
-func TestClear(t *testing.T) {
- s := NewStack()
- s.Clear()
- require.Equal(t, 0, s.height)
-}
-
-func TestDupicate(t *testing.T) {
- s := NewStack()
- s2 := NewStack()
- s.Duplicate()
- require.Equal(t, s2.height, s.height)
- s.Push(12)
- s.Duplicate()
- s2.Push(12)
- s2.Push(12)
- require.Equal(t, s2.height, s.height)
- require.Equal(t, s2.data, s.data)
-}
-
-func TestPop(t *testing.T) {
- s := NewStack()
- v := s.Pop()
- require.Equal(t, 0, v)
- s.Push(12)
- s.Push(14)
- v = s.Pop()
- require.Equal(t, 14, v)
- v = s.Pop()
- require.Equal(t, 12, v)
- v = s.Pop()
- require.Equal(t, 0, v)
-}
-
-func TestPush(t *testing.T) {
- s := NewStack()
- for i := 0; i < 32; i++ {
- s.Push(i)
- }
- require.Equal(t, 32, s.size)
- s.Push(-1)
- require.Equal(t, 64, s.size)
-}
-
-func TestSwap(t *testing.T) {
- s := NewStack()
- s2 := NewStack()
- s.Swap()
- s2.Push(0)
- s2.Push(0)
- require.Equal(t, s2, s)
- s.Clear()
- s.Push(1)
- s.Swap()
- s2.Clear()
- s2.Push(1)
- s2.Push(0)
- require.Equal(t, s2, s)
- s.Clear()
- s.Push(1)
- s.Push(2)
- s2.Clear()
- s2.Push(2)
- s2.Push(1)
- s.Swap()
- require.Equal(t, s2, s)
-}