added testscase for ean encoding

This commit is contained in:
boombuler 2013-12-20 09:24:20 +01:00
parent 6a44551dc4
commit b63e15f7ff
1 changed files with 23 additions and 0 deletions

23
ean/encoder_test.go Normal file
View File

@ -0,0 +1,23 @@
package ean
import (
"image/color"
"testing"
)
func Test_EncodeEAN13(t *testing.T) {
testResult := "10100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101"
testCode := "5901234123457"
code, err := Encode(testCode)
if err != nil {
t.Error(err)
}
if code.Metadata().Dimensions != 1 || code.Content() != testCode || code.Metadata().CodeKind != "EAN 13" {
t.Error("Metadata missmatch")
}
for i, r := range testResult {
if (code.At(i, 0) == color.Black) != (r == '1') {
t.Fail()
}
}
}