<commit_before>package engine

import (
	"fmt"
	"testing"

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

func Test_NewArea_InvalidSize(t *testing.T) {
	var area Area
	var err error

	area, err = NewArea(0, 0)
	require.NotNil(t, err)
	require.Equal(t, Area{}, area)

	area, err = NewArea(1, 0)
	require.NotNil(t, err)
	require.Equal(t, Area{}, area)

	area, err = NewArea(0, 1)
	require.NotNil(t, err)
	require.Equal(t, Area{}, area)
}

func Test_NewArea_ValidSize(t *testing.T) {
	var err error

	_, err = NewArea(1, 1)
	require.Nil(t, err)

	_, err = NewArea(100, 100)
	require.Nil(t, err)
}

func Test_Area_Navigate_SquareArea100x100(t *testing.T) {
	tests := []struct {
		inputDot    Dot
		inputDir    Direction
		inputDis    uint8
		expectedDot Dot
		expectedErr error
	}{
		{Dot{0, 0}, DirectionWest, 0, Dot{0, 0}, nil},
		{Dot{0, 0}, DirectionEast, 0, Dot{0, 0}, nil},
		{Dot{0, 0}, DirectionNorth, 0, Dot{0, 0}, nil},
		{Dot{0, 0}, DirectionSouth, 0, Dot{0, 0}, nil},

		{Dot{0, 0}, DirectionWest, 1, Dot{99, 0}, nil},
		{Dot{0, 0}, DirectionEast, 1, Dot{1, 0}, nil},
		{Dot{0, 0}, DirectionNorth, 1, Dot{0, 99}, nil},
		{Dot{0, 0}, DirectionSouth, 1, Dot{0, 1}, nil},

		{Dot{99, 0}, DirectionEast, 1, Dot{0, 0}, nil},
		{Dot{0, 99}, DirectionSouth, 1, Dot{0, 0}, nil},
	}
<commit_msg>Create test cases to engine.Area.Navigate method<commit_after>package engine

import (
	"fmt"
	"testing"

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

func Test_NewArea_InvalidSize(t *testing.T) {
	var area Area
	var err error

	area, err = NewArea(0, 0)
	require.NotNil(t, err)
	require.Equal(t, Area{}, area)

	area, err = NewArea(1, 0)
	require.NotNil(t, err)
	require.Equal(t, Area{}, area)

	area, err = NewArea(0, 1)
	require.NotNil(t, err)
	require.Equal(t, Area{}, area)
}

func Test_NewArea_ValidSize(t *testing.T) {
	var err error

	_, err = NewArea(1, 1)
	require.Nil(t, err)

	_, err = NewArea(100, 100)
	require.Nil(t, err)
}

func Test_Area_Navigate_SquareArea100x100(t *testing.T) {
	tests := []struct {
		inputDot    Dot
		inputDir    Direction
		inputDis    uint8
		expectedDot Dot
		expectedErr error
	}{
		{Dot{0, 0}, DirectionWest, 0, Dot{0, 0}, nil},
		{Dot{0, 0}, DirectionEast, 0, Dot{0, 0}, nil},
		{Dot{0, 0}, DirectionNorth, 0, Dot{0, 0}, nil},
		{Dot{0, 0}, DirectionSouth, 0, Dot{0, 0}, nil},

		{Dot{0, 0}, DirectionWest, 1, Dot{99, 0}, nil},
		{Dot{0, 0}, DirectionEast, 1, Dot{1, 0}, nil},
		{Dot{0, 0}, DirectionNorth, 1, Dot{0, 99}, nil},
		{Dot{0, 0}, DirectionSouth, 1, Dot{0, 1}, nil},

		{Dot{99, 0}, DirectionEast, 1, Dot{0, 0}, nil},
		{Dot{0, 99}, DirectionSouth, 1, Dot{0, 0}, nil},

		{Dot{0, 99}, DirectionSouth, 150, Dot{0, 49}, nil},
		{Dot{0, 99}, DirectionNorth, 150, Dot{0, 49}, nil},
		{Dot{0, 0}, DirectionEast, 150, Dot{50, 0}, nil},
		{Dot{0, 0}, DirectionWest, 150, Dot{50, 0}, nil},

		{Dot{30, 30}, DirectionWest, 5, Dot{25, 30}, nil},

		// Error case: invalid direction
		{Dot{0, 0}, 21, 150, Dot{}, &ErrNavigation{
			Err: &ErrInvalidDirection{
				Direction: 21,
			},
		}},
		// Error case: area doesn't contains dot
		{Dot{250, 25}, DirectionWest, 150, Dot{}, &ErrNavigation{
			Err: &ErrAreaNotContainsDot{
				Dot: Dot{250, 25},
			},
		}},
	}

{'fraction_non_alphanumeric': 0.18571875978703414, 'fraction_numerical': 0.06733479486376448, 'mean_word_length': 4.094098883572568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3055559', 'n_tokens_mistral': 1590, 'n_tokens_neox': 1324, 'n_words': 357}