package main

import (
	"testing"
)

func TestPosToGrid(t *testing.T) {
	if id := posToGrid(Pos{5, 3}, 3); id != 29 {
		t.Errorf("expected 21; got %d", id)
	}

	pos := gridToPos(29, 8, 3)
	if pos.x != 5 || pos.y != 3 {
		t.Errorf("expected (5, 3); got (%d, %d)", pos.x, pos.y)
	}

	pos = gridToPos(0, 8, 3)
	if pos.x != 0 || pos.y != 0 {
		t.Errorf("expected (0, 0); got (%d, %d)", pos.x, pos.y)
	}

	pos = gridToPos(524288, 1024, 10)
	if pos.x != 0 || pos.y != 512 {
		t.Errorf("expected (0, 512); got (%d, %d)", pos.x, pos.y)
	}
}
