aboutsummaryrefslogtreecommitdiff
path: root/internal/tools/tools_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-29 04:03:38 -0400
committerhistoria <[not public]>2026-06-29 04:03:38 -0400
commitba34490aaed5f7c242c2b0453130fefc07d0d5d0 (patch)
treedb5818757d5080221494cead1c7e61a576d1cb65 /internal/tools/tools_test.go
parentb1e252c996a6332d391f96624a7d6f149eb097c4 (diff)
downloadtui-ascii-mapper-main.tar.gz
restructured projectHEADmain
Diffstat (limited to 'internal/tools/tools_test.go')
-rw-r--r--internal/tools/tools_test.go36
1 files changed, 36 insertions, 0 deletions
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")
+}