aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/field/error_test.go2
-rw-r--r--pkg/field/utils_test.go8
-rw-r--r--pkg/pointer/pointer_test.go4
-rw-r--r--pkg/pointer/storage-offset_test.go20
-rw-r--r--pkg/stack/stack_test.go35
5 files changed, 30 insertions, 39 deletions
diff --git a/pkg/field/error_test.go b/pkg/field/error_test.go
index 45e8f83..e87083e 100644
--- a/pkg/field/error_test.go
+++ b/pkg/field/error_test.go
@@ -8,7 +8,7 @@ import (
)
func requireErrorTypeMatch(t *testing.T, err error, expected error) {
- require.Equalf(t, reflect.TypeOf(err), reflect.TypeOf(expected), "Invalid error type. Got %s but expected %s", reflect.TypeOf(err), reflect.TypeOf(expected))
+ require.Equalf(t, reflect.TypeOf(expected), reflect.TypeOf(err), "Invalid error type. Got %s but expected %s", reflect.TypeOf(err), reflect.TypeOf(expected))
}
func TestErrorsCoverage(t *testing.T) {
diff --git a/pkg/field/utils_test.go b/pkg/field/utils_test.go
index 59a7cee..9c1f7c7 100644
--- a/pkg/field/utils_test.go
+++ b/pkg/field/utils_test.go
@@ -319,13 +319,13 @@ func TestGetAndSetOnEmptyLines(t *testing.T) {
field, err := Load(file)
field.Set(0, 3, '#')
v := field.Get(0, 3)
- require.Equal(t, v, int('#'))
+ require.Equal(t, int('#'), v)
v = field.Get(0, 2)
- require.Equal(t, v, int(' '))
+ require.Equal(t, int(' '), v)
field.Set(0, 2, 'a')
field.Set(0, -4, 'b')
v = field.Get(0, -1)
- require.Equal(t, v, int(' '))
+ require.Equal(t, int(' '), v)
field.Set(0, -1, 'c')
- require.Equal(t, field, &f)
+ require.Equal(t, &f, field)
}
diff --git a/pkg/pointer/pointer_test.go b/pkg/pointer/pointer_test.go
index 4d3b6bf..658528d 100644
--- a/pkg/pointer/pointer_test.go
+++ b/pkg/pointer/pointer_test.go
@@ -23,8 +23,8 @@ func TestSplit(t *testing.T) {
// We check that p2 is a real copy
p.Step(*f)
p2.Step(*f)
- require.Equal(t, p, &Pointer{x: 1, y: 0, dx: 1})
- require.Equal(t, p2, &Pointer{x: 1, y: 0, dx: 1})
+ require.Equal(t, &Pointer{x: 1, y: 0, dx: 1}, p)
+ require.Equal(t, &Pointer{x: 1, y: 0, dx: 1}, p2)
}
func TestStep(t *testing.T) { // Step is thoroughly tested in the field package
diff --git a/pkg/pointer/storage-offset_test.go b/pkg/pointer/storage-offset_test.go
index 26a5f38..62e8a6e 100644
--- a/pkg/pointer/storage-offset_test.go
+++ b/pkg/pointer/storage-offset_test.go
@@ -9,27 +9,27 @@ import (
func TestGetStorageOffset(t *testing.T) {
p := NewPointer()
x, y := p.GetStorageOffset()
- require.Equal(t, x, 0)
- require.Equal(t, y, 0)
+ require.Equal(t, 0, x)
+ require.Equal(t, 0, y)
p.SetStorageOffset(3, 8)
x, y = p.GetStorageOffset()
- require.Equal(t, x, 3)
- require.Equal(t, y, 8)
+ 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, x, 1)
- require.Equal(t, y, 0)
+ require.Equal(t, 1, x)
+ require.Equal(t, 0, y)
p.sox, p.soy = 3, 2
x, y = p.GetStorageOffset()
- require.Equal(t, x, 3)
- require.Equal(t, y, 2)
+ 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, x, 9)
- require.Equal(t, y, 12)
+ require.Equal(t, 9, x)
+ require.Equal(t, 12, y)
}
diff --git a/pkg/stack/stack_test.go b/pkg/stack/stack_test.go
index d9e0cca..e48c615 100644
--- a/pkg/stack/stack_test.go
+++ b/pkg/stack/stack_test.go
@@ -6,46 +6,37 @@ import (
"github.com/stretchr/testify/require"
)
-func TestNewStack(t *testing.T) {
- require.Equal(t, NewStack(), &Stack{
- size: 32,
- height: 0,
- data: make([]int, 32),
- next: nil,
- })
-}
-
func TestClear(t *testing.T) {
s := NewStack()
s.Clear()
- require.Equal(t, s.height, 0)
+ require.Equal(t, 0, s.height)
}
func TestDupicate(t *testing.T) {
s := NewStack()
s2 := NewStack()
s.Duplicate()
- require.Equal(t, s.height, s2.height)
+ require.Equal(t, s2.height, s.height)
s.Push(12)
s.Duplicate()
s2.Push(12)
s2.Push(12)
- require.Equal(t, s.height, s2.height)
- require.Equal(t, s.data, s2.data)
+ 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, v, 0)
+ require.Equal(t, 0, v)
s.Push(12)
s.Push(14)
v = s.Pop()
- require.Equal(t, v, 14)
+ require.Equal(t, 14, v)
v = s.Pop()
- require.Equal(t, v, 12)
+ require.Equal(t, 12, v)
v = s.Pop()
- require.Equal(t, v, 0)
+ require.Equal(t, 0, v)
}
func TestPush(t *testing.T) {
@@ -53,9 +44,9 @@ func TestPush(t *testing.T) {
for i := 0; i < 32; i++ {
s.Push(i)
}
- require.Equal(t, s.size, 32)
+ require.Equal(t, 32, s.size)
s.Push(-1)
- require.Equal(t, s.size, 64)
+ require.Equal(t, 64, s.size)
}
func TestSwap(t *testing.T) {
@@ -64,14 +55,14 @@ func TestSwap(t *testing.T) {
s.Swap()
s2.Push(0)
s2.Push(0)
- require.Equal(t, s, s2)
+ require.Equal(t, s2, s)
s.Clear()
s.Push(1)
s.Swap()
s2.Clear()
s2.Push(1)
s2.Push(0)
- require.Equal(t, s, s2)
+ require.Equal(t, s2, s)
s.Clear()
s.Push(1)
s.Push(2)
@@ -79,5 +70,5 @@ func TestSwap(t *testing.T) {
s2.Push(2)
s2.Push(1)
s.Swap()
- require.Equal(t, s, s2)
+ require.Equal(t, s2, s)
}