mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-07-03 04:12:54 +00:00
Add methods to initialize icon generators
This commit is contained in:
@ -7,13 +7,13 @@ import (
|
||||
)
|
||||
|
||||
func TestIgnoreCase(t *testing.T) {
|
||||
iconGenerator := IdIconGenerator{}
|
||||
|
||||
w1 := bytes.NewBuffer([]byte{})
|
||||
png.Encode(w1, iconGenerator.GenIcon("example", 80, ColorV1))
|
||||
ig1 := NewIdIconGenerator().WithColorGenerator(ColorV1)
|
||||
png.Encode(w1, ig1.GenIcon("example", 80))
|
||||
|
||||
w2 := bytes.NewBuffer([]byte{})
|
||||
png.Encode(w2, iconGenerator.GenIcon("Example", 80, ColorV1))
|
||||
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")
|
||||
@ -21,14 +21,14 @@ func TestIgnoreCase(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStringMatchesHash(t *testing.T) {
|
||||
iconGenerator := IdIconGenerator{}
|
||||
|
||||
w1 := bytes.NewBuffer([]byte{})
|
||||
ig1 := NewIdIconGenerator().WithColorGenerator(ColorV2)
|
||||
// MD5 of lowercase 'example'
|
||||
png.Encode(w1, iconGenerator.GenIcon("1a79a4d60de6718e8e5b326e338ae533", 80, ColorV2))
|
||||
png.Encode(w1, ig1.GenIcon("1a79a4d60de6718e8e5b326e338ae533", 80))
|
||||
|
||||
w2 := bytes.NewBuffer([]byte{})
|
||||
png.Encode(w2, iconGenerator.GenIcon("Example", 80, ColorV2))
|
||||
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")
|
||||
|
Reference in New Issue
Block a user