aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-20 01:22:18 +0200
committerJulien Dessaux2021-09-20 01:22:18 +0200
commitae7f4d5acfe2ab97bd51523aed24b6f6aa74523e (patch)
tree7f8cded5121abcf0ea61ce2ffbae9019f730b041 /pkg
parentImplemented function to set a field value (diff)
downloadgofunge98-ae7f4d5acfe2ab97bd51523aed24b6f6aa74523e.tar.gz
gofunge98-ae7f4d5acfe2ab97bd51523aed24b6f6aa74523e.tar.bz2
gofunge98-ae7f4d5acfe2ab97bd51523aed24b6f6aa74523e.zip
Refactoring
Diffstat (limited to '')
-rw-r--r--pkg/field/field.go2
-rw-r--r--pkg/field/field_test.go4
-rw-r--r--pkg/field/step_test.go2
-rw-r--r--pkg/field/utils_test.go12
4 files changed, 10 insertions, 10 deletions
diff --git a/pkg/field/field.go b/pkg/field/field.go
index 0495635..42ade84 100644
--- a/pkg/field/field.go
+++ b/pkg/field/field.go
@@ -28,7 +28,7 @@ type Line struct {
columns []int
}
-func LoadFile(fd io.Reader) (*Field, error) {
+func Load(fd io.Reader) (*Field, error) {
f := new(Field)
l := new(Line)
trailingSpaces := 0
diff --git a/pkg/field/field_test.go b/pkg/field/field_test.go
index 767a0dd..66b0291 100644
--- a/pkg/field/field_test.go
+++ b/pkg/field/field_test.go
@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)
-func TestLoadFile(t *testing.T) {
+func TestLoad(t *testing.T) {
// minimal b98 file
minimalField := Field{
x: 0,
@@ -149,7 +149,7 @@ func TestLoadFile(t *testing.T) {
} else {
fd = file
}
- valid, err := LoadFile(fd)
+ valid, err := Load(fd)
if tc.expectedError != nil {
require.Error(t, err)
requireErrorTypeMatch(t, err, tc.expectedError)
diff --git a/pkg/field/step_test.go b/pkg/field/step_test.go
index e21540c..aecf89d 100644
--- a/pkg/field/step_test.go
+++ b/pkg/field/step_test.go
@@ -32,7 +32,7 @@ func TestStep(t *testing.T) {
file, err := os.Open(tc.input)
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
x, y := field.Step(tc.x, tc.y, tc.dx, tc.dy)
require.NoError(t, err)
require.Equal(t, tc.ex, x, "Invalid x value")
diff --git a/pkg/field/utils_test.go b/pkg/field/utils_test.go
index 52916e3..59a7cee 100644
--- a/pkg/field/utils_test.go
+++ b/pkg/field/utils_test.go
@@ -32,7 +32,7 @@ func TestGet(t *testing.T) {
file, err := os.Open(tc.input)
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
valid := field.Get(tc.inputX, tc.inputY)
require.NoError(t, err)
require.Equal(t, tc.expected, valid, "Invalid value")
@@ -65,7 +65,7 @@ func TestIsIn(t *testing.T) {
file, err := os.Open(tc.input)
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
valid := field.isIn(tc.inputX, tc.inputY)
require.NoError(t, err)
require.Equal(t, tc.expected, valid, "Invalid value")
@@ -141,7 +141,7 @@ func TestSetMinimalAppendOne(t *testing.T) {
file, err := os.Open(tc.input)
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
field.Set(tc.inputX, tc.inputY, tc.inputV)
require.NoError(t, err)
require.Equal(t, tc.expected, field, "Invalid value")
@@ -217,7 +217,7 @@ func TestSetMinimalAppendTwo(t *testing.T) {
file, err := os.Open(tc.input)
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
field.Set(tc.inputX, tc.inputY, tc.inputV)
require.NoError(t, err)
require.Equal(t, tc.expected, field, "Invalid value")
@@ -287,7 +287,7 @@ func TestSetMinimalAppendThree(t *testing.T) {
file, err := os.Open(tc.input)
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
field.Set(tc.inputX, tc.inputY, tc.inputV)
require.NoError(t, err)
require.Equal(t, tc.expected, field, "Invalid value")
@@ -316,7 +316,7 @@ func TestGetAndSetOnEmptyLines(t *testing.T) {
file, err := os.Open("test_data/minimal.b98")
require.NoError(t, err, "Failed to open file")
defer file.Close()
- field, err := LoadFile(file)
+ field, err := Load(file)
field.Set(0, 3, '#')
v := field.Get(0, 3)
require.Equal(t, v, int('#'))