Florian Sundermann 12 лет назад
Родитель
Сommit
3ddff87dab
2 измененных файлов с 18 добавлено и 0 удалено
  1. 0 0
      qr/unicode.go
  2. 18 0
      qr/unicode_test.go

+ 0 - 0
qr/utf8.go → qr/unicode.go


+ 18 - 0
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")
+	}
+}