From b63e15f7fff0c8c66fcbb784a5c6555936b570d6 Mon Sep 17 00:00:00 2001 From: boombuler Date: Fri, 20 Dec 2013 09:24:20 +0100 Subject: [PATCH] added testscase for ean encoding --- ean/encoder_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ean/encoder_test.go diff --git a/ean/encoder_test.go b/ean/encoder_test.go new file mode 100644 index 0000000..e2d1e2c --- /dev/null +++ b/ean/encoder_test.go @@ -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() + } + } +}