unicode_test.go 473 B

123456789101112131415161718
  1. package qr
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. func Test_UnicodeEncoding(t *testing.T) {
  7. encode := Unicode.getEncoder()
  8. x, vi, err := encode("A", H) // 65
  9. if x == nil || vi == nil || vi.Version != 1 || bytes.Compare(x.GetBytes(), []byte{64, 20, 16, 236, 17, 236, 17, 236, 17}) != 0 {
  10. t.Errorf("\"A\" failed to encode: %s", err)
  11. }
  12. _, _, err = encode(makeString(3000, "A"), H)
  13. if err == nil {
  14. t.Error("Unicode encoding should not be able to encode a 3kb string")
  15. }
  16. }