git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/barcode/qr/unicode_test.go (about)

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