aboutsummaryrefslogtreecommitdiff
path: root/pkg/pointer/storage-offset_test.go
blob: 62e8a6e0bcc91deb7debbcf9c6d4d1eb8970a75e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package pointer

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestGetStorageOffset(t *testing.T) {
	p := NewPointer()
	x, y := p.GetStorageOffset()
	require.Equal(t, 0, x)
	require.Equal(t, 0, y)
	p.SetStorageOffset(3, 8)
	x, y = p.GetStorageOffset()
	require.Equal(t, 3, x)
	require.Equal(t, 8, y)
}

func TestCalculateNewStorageOffset(t *testing.T) {
	p := NewPointer()
	p.CalculateNewStorageOffset()
	x, y := p.GetStorageOffset()
	require.Equal(t, 1, x)
	require.Equal(t, 0, y)
	p.sox, p.soy = 3, 2
	x, y = p.GetStorageOffset()
	require.Equal(t, 3, x)
	require.Equal(t, 2, y)
	p.x, p.y = 8, 12
	p.CalculateNewStorageOffset()
	x, y = p.GetStorageOffset()
	require.Equal(t, 9, x)
	require.Equal(t, 12, y)
}