aboutsummaryrefslogtreecommitdiff
path: root/pkg/pointer/storage-offset_test.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-21 00:27:57 +0200
committerJulien Dessaux2021-09-21 00:27:57 +0200
commit309dcb5a029d9b40c72fa8bc01a3009389b66e8e (patch)
tree21d3456847ec32c8219c3b7d935f6c3cec5d5058 /pkg/pointer/storage-offset_test.go
parentBegan implementing the Instruction Pointer (diff)
downloadgofunge98-309dcb5a029d9b40c72fa8bc01a3009389b66e8e.tar.gz
gofunge98-309dcb5a029d9b40c72fa8bc01a3009389b66e8e.tar.bz2
gofunge98-309dcb5a029d9b40c72fa8bc01a3009389b66e8e.zip
Continued implementing the Instruction Pointer
Diffstat (limited to '')
-rw-r--r--pkg/pointer/storage-offset_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/pkg/pointer/storage-offset_test.go b/pkg/pointer/storage-offset_test.go
new file mode 100644
index 0000000..26a5f38
--- /dev/null
+++ b/pkg/pointer/storage-offset_test.go
@@ -0,0 +1,35 @@
+package pointer
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestGetStorageOffset(t *testing.T) {
+ p := NewPointer()
+ x, y := p.GetStorageOffset()
+ require.Equal(t, x, 0)
+ require.Equal(t, y, 0)
+ p.SetStorageOffset(3, 8)
+ x, y = p.GetStorageOffset()
+ require.Equal(t, x, 3)
+ require.Equal(t, y, 8)
+}
+
+func TestCalculateNewStorageOffset(t *testing.T) {
+ p := NewPointer()
+ p.CalculateNewStorageOffset()
+ x, y := p.GetStorageOffset()
+ require.Equal(t, x, 1)
+ require.Equal(t, y, 0)
+ p.sox, p.soy = 3, 2
+ x, y = p.GetStorageOffset()
+ require.Equal(t, x, 3)
+ require.Equal(t, y, 2)
+ p.x, p.y = 8, 12
+ p.CalculateNewStorageOffset()
+ x, y = p.GetStorageOffset()
+ require.Equal(t, x, 9)
+ require.Equal(t, y, 12)
+}