[🤖] Add Unit-Tests
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m34s

This commit is contained in:
2026-04-27 10:46:08 +02:00
parent dad0e3240d
commit 02d6894ec6
116 changed files with 18795 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
package wpdf
import (
"testing"
)
func TestHexToColor(t *testing.T) {
cases := []struct {
in uint32
want PDFColor
}{
{0x000000, PDFColor{R: 0, G: 0, B: 0}},
{0xFFFFFF, PDFColor{R: 255, G: 255, B: 255}},
{0xFF0000, PDFColor{R: 255, G: 0, B: 0}},
{0x00FF00, PDFColor{R: 0, G: 255, B: 0}},
{0x0000FF, PDFColor{R: 0, G: 0, B: 255}},
{0x123456, PDFColor{R: 0x12, G: 0x34, B: 0x56}},
{0xC0C0C0, PDFColor{R: 192, G: 192, B: 192}},
}
for _, c := range cases {
got := hexToColor(c.in)
if got != c.want {
t.Errorf("hexToColor(%#x) = %+v, want %+v", c.in, got, c.want)
}
}
}
func TestHexToColorIgnoresHigherBits(t *testing.T) {
got := hexToColor(0xFF123456)
want := PDFColor{R: 0x12, G: 0x34, B: 0x56}
if got != want {
t.Errorf("hexToColor(0xFF123456) = %+v, want %+v", got, want)
}
}
func TestRgbToColor(t *testing.T) {
got := rgbToColor(10, 20, 30)
want := PDFColor{R: 10, G: 20, B: 30}
if got != want {
t.Errorf("rgbToColor(10,20,30) = %+v, want %+v", got, want)
}
}