mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-04-19 08:36:50 +00:00
37 lines
948 B
Go
37 lines
948 B
Go
package icons
|
|
|
|
import (
|
|
"bytes"
|
|
"image/png"
|
|
"testing"
|
|
)
|
|
|
|
func TestIgnoreCase(t *testing.T) {
|
|
w1 := bytes.NewBuffer([]byte{})
|
|
ig1 := NewIdIconGenerator().WithColorGenerator(ColorV1)
|
|
_ = png.Encode(w1, ig1.GenIcon("example", 80))
|
|
|
|
w2 := bytes.NewBuffer([]byte{})
|
|
ig2 := NewIdIconGenerator().WithColorGenerator(ColorV1)
|
|
_ = png.Encode(w2, ig2.GenIcon("Example", 80))
|
|
|
|
if bytes.Compare(w1.Bytes(), w2.Bytes()) != 0 {
|
|
t.Errorf("resulting images do not match")
|
|
}
|
|
}
|
|
|
|
func TestStringMatchesHash(t *testing.T) {
|
|
w1 := bytes.NewBuffer([]byte{})
|
|
ig1 := NewIdIconGenerator().WithColorGenerator(ColorV2)
|
|
// MD5 of lowercase 'example'
|
|
_ = png.Encode(w1, ig1.GenIcon("1a79a4d60de6718e8e5b326e338ae533", 80))
|
|
|
|
w2 := bytes.NewBuffer([]byte{})
|
|
ig2 := NewIdIconGenerator().WithColorGenerator(ColorV2)
|
|
_ = png.Encode(w2, ig2.GenIcon("Example", 80))
|
|
|
|
if bytes.Compare(w1.Bytes(), w2.Bytes()) != 0 {
|
|
t.Errorf("resulting images do not match")
|
|
}
|
|
}
|