package main

import (
	"testing"

	"github.com/perlw/advent_of_code/toolkit/grid"
)

func TestTask1ShouldFindResult(t *testing.T) {
	var input grid.Grid
	input.FromRunes([]rune{
		'.', '.', '#', '#', '.', '.', '.', '.', '.', '.', '.',
		'#', '.', '.', '.', '#', '.', '.', '.', '#', '.', '.',
		'.', '#', '.', '.', '.', '.', '#', '.', '.', '#', '.',
		'.', '.', '#', '.', '#', '.', '.', '.', '#', '.', '#',
		'.', '#', '.', '.', '.', '#', '#', '.', '.', '#', '.',
		'.', '.', '#', '.', '#', '#', '.', '.', '.', '.', '.',
		'.', '#', '.', '#', '.', '#', '.', '.', '.', '.', '#',
		'.', '#', '.', '.', '.', '.', '.', '.', '.', '.', '#',
		'#', '.', '#', '#', '.', '.', '.', '#', '.', '.', '.',
		'#', '.', '.', '.', '#', '#', '.', '.', '.', '.', '#',
		'.', '#', '.', '.', '#', '.', '.', '.', '#', '.', '#',
	})
	input.Width = 11
	input.Height = 11
	input.Label = "Test1"
	expect := 7

	result := Task1(&input)
	if result != expect {
		t.Errorf("got %d, expected %d", result, expect)
	}
}

func TestTask2ShouldFindResult(t *testing.T) {
	var input grid.Grid
	input.FromRunes([]rune{
		'.', '.', '#', '#', '.', '.', '.', '.', '.', '.', '.',
		'#', '.', '.', '.', '#', '.', '.', '.', '#', '.', '.',
		'.', '#', '.', '.', '.', '.', '#', '.', '.', '#', '.',
		'.', '.', '#', '.', '#', '.', '.', '.', '#', '.', '#',
		'.', '#', '.', '.', '.', '#', '#', '.', '.', '#', '.',
		'.', '.', '#', '.', '#', '#', '.', '.', '.', '.', '.',
		'.', '#', '.', '#', '.', '#', '.', '.', '.', '.', '#',
		'.', '#', '.', '.', '.', '.', '.', '.', '.', '.', '#',
		'#', '.', '#', '#', '.', '.', '.', '#', '.', '.', '.',
		'#', '.', '.', '.', '#', '#', '.', '.', '.', '.', '#',
		'.', '#', '.', '.', '#', '.', '.', '.', '#', '.', '#',
	})
	input.Width = 11
	input.Height = 11
	input.Label = "Test2"
	expect := 336

	result := Task2(&input)
	if result != expect {
		t.Errorf("got %d, expected %d", result, expect)
	}
}