test: improve coverage to 98.2%, add staticcheck to CI (#7)

* test: improve coverage to 98.2%, add staticcheck to CI

- Fix comment typos (Intensty → Intensity)
- Add tests for createStringerPalette modes (background fill, smart mode)
- Add tests for ColorString variants, BytesToColor determinism
- Add tests for GetBackgroundColor mid-tone edge case
- Add tests for GenerateOKLCHPalette negative/large inputs
- Add Go 1.25 to CI matrix for compatibility testing
- Add staticcheck lint step to CI
- Fix goimports formatting in hash_test.go

* fix(ci): remove Go 1.25 from matrix (go.mod requires 1.26)
This commit is contained in:
2026-03-26 12:18:53 -04:00
committed by GitHub
parent e46914dabb
commit b653c3a59b
4 changed files with 131 additions and 5 deletions

View File

@@ -55,6 +55,27 @@ func TestGenerateOKLCHPaletteSingle(t *testing.T) {
}
}
func TestGenerateOKLCHPaletteNegative(t *testing.T) {
palette := GenerateOKLCHPalette(-5, 0.7, 0.15)
if len(palette) != 0 {
t.Errorf("expected empty palette for negative n, got %d colors", len(palette))
}
}
func TestGenerateOKLCHPaletteLarge(t *testing.T) {
palette := GenerateOKLCHPalette(360, 0.7, 0.15)
if len(palette) != 360 {
t.Fatalf("expected 360 colors, got %d", len(palette))
}
// Hue step should be ~1° for 360 colors
c0 := palette[0].ToOKLCH()
c1 := palette[1].ToOKLCH()
step := c1.H - c0.H
if math.Abs(step-1.0) > 1.0 {
t.Errorf("expected ~1° hue step, got %f°", step)
}
}
func TestGenerateOKLCHPaletteDistinct(t *testing.T) {
palette := GenerateOKLCHPalette(6, 0.7, 0.15)
// All colors should be distinct