From 3ddff87dab98ca07d8f51660801a030023cc17c6 Mon Sep 17 00:00:00 2001 From: Florian Sundermann Date: Thu, 12 Dec 2013 14:04:10 +0100 Subject: [PATCH] more tests renamed utf8.go --- qr/{utf8.go => unicode.go} | 0 qr/unicode_test.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) rename qr/{utf8.go => unicode.go} (100%) create mode 100644 qr/unicode_test.go diff --git a/qr/utf8.go b/qr/unicode.go similarity index 100% rename from qr/utf8.go rename to qr/unicode.go diff --git a/qr/unicode_test.go b/qr/unicode_test.go new file mode 100644 index 0000000..1a3da7b --- /dev/null +++ b/qr/unicode_test.go @@ -0,0 +1,18 @@ +package qr + +import ( + "bytes" + "testing" +) + +func Test_UnicodeEncoding(t *testing.T) { + encode := Unicode.getEncoder() + x, vi, err := encode("A", H) // 65 + if x == nil || vi == nil || vi.Version != 1 || bytes.Compare(x.GetBytes(), []byte{64, 20, 16, 236, 17, 236, 17, 236, 17}) != 0 { + t.Errorf("\"A\" failed to encode: %s", err) + } + _, _, err = encode(makeString(3000), H) + if err == nil { + t.Error("Unicode encoding should not be able to encode a 3kb string") + } +}