test: add thorough test coverage for engine, UI model, and version
- Expanded calc_test.go with additional cases for decimal point, backspace, sign change, mod, div0, multi-step ops, negatives, format, is-integer with entry, etc. (calc coverage to ~86%)
- New ui_test.go: unit tests for App (New, Update key sequences for digits/ops/MOD/HEX entry/base cycle/CERR/clears/flashes/pressed state, View contains checks). ui coverage ~82%
- New version_test.go: 100% for String()
- All tests pass (go test ./...); total project coverage ~81%
- Complements the HEX entry and UI polish work.
- Uses table-friendly and direct model testing suitable for the Bubble Tea spike.
2026-06-06 15:02:56 +00:00
|
|
|
package version
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestString(t *testing.T) {
|
|
|
|
|
// default dev
|
|
|
|
|
if got := String(); got != "dev" {
|
|
|
|
|
t.Errorf("default: want dev, got %s", got)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// with commit
|
|
|
|
|
Version = "1.0.0"
|
|
|
|
|
Commit = "abc123"
|
|
|
|
|
if got := String(); !strings.Contains(got, "1.0.0") || !strings.Contains(got, "abc123") {
|
|
|
|
|
t.Errorf("with commit: want version-commit, got %s", got)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// reset
|
|
|
|
|
Version = "dev"
|
|
|
|
|
Commit = ""
|
2026-06-06 16:04:11 +00:00
|
|
|
}
|