Add icon: Lucide 1.58.0 SVG set, lazy parse, Must, Names
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e53a8d0b50
commit
2431e2fcde
2164 files changed
+37063
No files matched your search
@@ -0,0 +1,64 @@
|
||||
package icon
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
func TestEveryIconParses(t *testing.T) {
|
||||
n := Names()
|
||||
if len(n) != 2159 {
|
||||
t.Fatalf("icons = %d, want 2159", len(n))
|
||||
}
|
||||
if !slices.IsSorted(n) {
|
||||
t.Error("Names not sorted")
|
||||
}
|
||||
for _, name := range n {
|
||||
if Must(name) == nil {
|
||||
t.Errorf("%s parsed to nil", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMustCaches(t *testing.T) {
|
||||
if Must("check") != Must("check") {
|
||||
t.Error("Must parsed check twice")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMustPanicsOnUnknown(t *testing.T) {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
t.Error("Must(nope) did not panic")
|
||||
}
|
||||
}()
|
||||
Must("nope")
|
||||
}
|
||||
|
||||
func TestNamesIsACopy(t *testing.T) {
|
||||
n := Names()
|
||||
n[0] = "changed"
|
||||
if Names()[0] == "changed" {
|
||||
t.Error("Names exposed its slice")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIconDraws(t *testing.T) {
|
||||
img := ui.Render(func(c *ui.Context) {
|
||||
ui.Icon(c, Must("check")).Size(24, 24)
|
||||
}, 32, 32, 1)
|
||||
bg := img.RGBAAt(0, 0)
|
||||
inked := 0
|
||||
for y := range 32 {
|
||||
for x := range 32 {
|
||||
if img.RGBAAt(x, y) != bg {
|
||||
inked++
|
||||
}
|
||||
}
|
||||
}
|
||||
if inked < 20 {
|
||||
t.Errorf("check drew %d pixels", inked)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user