From ba34490aaed5f7c242c2b0453130fefc07d0d5d0 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 29 Jun 2026 04:03:38 -0400 Subject: restructured project --- internal/tools/tools_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/tools/tools_test.go (limited to 'internal/tools/tools_test.go') diff --git a/internal/tools/tools_test.go b/internal/tools/tools_test.go new file mode 100644 index 0000000..22ac3d2 --- /dev/null +++ b/internal/tools/tools_test.go @@ -0,0 +1,36 @@ +package tools + +import ( + "fmt" + "testing" + + "tui-ascii-mapper/internal/model" +) + +func TestDemotools(t *testing.T) { + m := model.NewMap("test", 10, 10, nil) + Brush(m, model.Point{X: 5, Y: 5}, 0, 3, nil) + if m.Grid[5][5].Terrain != 0 { + t.Fatal("Brush failed") + } + pts := BresenhamLine(model.Point{X: 0, Y: 0}, model.Point{X: 3, Y: 0}) + if len(pts) != 4 || pts[0] != (model.Point{X: 0, Y: 0}) || pts[3] != (model.Point{X: 3, Y: 0}) { + t.Fatalf("Line failed: %v", pts) + } + if IntSqrt(25) != 5 || IntSqrt(26) != 5 || IntSqrt(0) != 0 { + t.Fatal("IntSqrt failed") + } + t2 := model.Terrain{Colors: []model.TerrainColor{{Color: "22", Weight: 100}}} + if t2.PickColor() != "22" { + t.Fatal("PickColor failed") + } + PlaceTextLabel(m, model.Point{X: 2, Y: 2}, "ABC", "") + if m.Grid[2][2].Text != "A" || m.Grid[2][3].Text != "B" { + t.Fatalf("TextLabel: %s,%s", m.Grid[2][2].Text, m.Grid[2][3].Text) + } + RemoveTextLabel(m, model.Point{X: 2, Y: 2}) + if m.Grid[2][2].Text != "" { + t.Fatal("TextLabel remove failed") + } + fmt.Println("tools: ok") +} -- cgit v1.2.3