git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/barcode/aztec/aztec_test.go (about) 1 package aztec 2 3 import ( 4 "testing" 5 ) 6 7 func encodeTest(t *testing.T, data, wanted string) { 8 result, err := Encode([]byte(data), DEFAULT_EC_PERCENT, DEFAULT_LAYERS) 9 if err != nil { 10 t.Error(err) 11 } else { 12 ac, ok := result.(*aztecCode) 13 if !ok { 14 t.Error("returned barcode is no aztec code...") 15 } else if draw := ac.string(); draw != wanted { 16 t.Errorf("Invalid Barcode returned:\n%s", draw) 17 } 18 19 } 20 } 21 22 func Test_Encode1(t *testing.T) { 23 encodeTest(t, "This is an example Aztec symbol for Wikipedia.", 24 "X X X X X X X X \n"+ 25 "X X X X X X X X X X \n"+ 26 "X X X X X X X X X X X \n"+ 27 "X X X X X X X X X X X \n"+ 28 " X X X X X X X X X X X \n"+ 29 " X X X X X X X X X X X X X \n"+ 30 " X X X X X X X X X X X X \n"+ 31 "X X X X X X X X X X X X X X X X \n"+ 32 "X X X X X X X X X X X \n"+ 33 "X X X X X X X X X X X X X X X X \n"+ 34 "X X X X X X X X X X \n"+ 35 "X X X X X X X X X X \n"+ 36 " X X X X X X X X X X \n"+ 37 " X X X X X X X X X X X X X X X X X X \n"+ 38 " X X X X X X X X X X X X \n"+ 39 " X X X X X X X X X X X X X X X X \n"+ 40 " X X X X X X X X X X X \n"+ 41 " X X X X X X X X \n"+ 42 " X X X X X X X X X X X X X X X X \n"+ 43 " X X X X X X X X X X X X \n"+ 44 " X X X \n"+ 45 " X X X X X X X X X X \n"+ 46 " X X X X X X X X X X \n") 47 } 48 49 func Test_Encode2(t *testing.T) { 50 encodeTest(t, "Aztec Code is a public domain 2D matrix barcode symbology"+ 51 " of nominally square symbols built on a square grid with a "+ 52 "distinctive square bullseye pattern at their center.", 53 " X X X X X X X X X X X X X X X \n"+ 54 " X X X X X X X X X X X X X X X \n"+ 55 " X X X X X X X X X X X X X X X X X X X \n"+ 56 "X X X X X X X X X X X X X X \n"+ 57 "X X X X X X X X X X X X X X X X X X X X X \n"+ 58 " X X X X X X X X X X X X X X X X \n"+ 59 "X X X X X X X X X X X X X X X X X X X X \n"+ 60 " X X X X X X X X X X X X X X X X X X X X X X \n"+ 61 "X X X X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 62 " X X X X X X X X X X X X X X X X X X X X \n"+ 63 " X X X X X X X X X X X X X X X X X X X X \n"+ 64 " X X X X X X X X X X X X X X X X X X X X X X X \n"+ 65 "X X X X X X X X X X X X X X X X X X X X X \n"+ 66 " X X X X X X X X X X X X X X X \n"+ 67 " X X X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 68 " X X X X X X X X X X X \n"+ 69 " X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 70 " X X X X X X X X X X X X X X X \n"+ 71 "X X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 72 "X X X X X X X X X X X X X X X X X X X X \n"+ 73 "X X X X X X X X X X X X X X X X X X X X X \n"+ 74 " X X X X X X X X X X X X \n"+ 75 " X X X X X X X X X X X X X X X X X X X X X X X \n"+ 76 "X X X X X X X X X X X X X X X X X \n"+ 77 " X X X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 78 " X X X X X X X X X X X X X X X X \n"+ 79 " X X X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 80 " X X X X X X X X X X X X X X X X X \n"+ 81 "X X X X X X X X X X X X X X X X X \n"+ 82 "X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 83 " X X X X X X X X X X X X X X X X X X X X \n"+ 84 "X X X X X X X X X X X X X X X \n"+ 85 " X X X X X X X X X X X X X X X X X X X X X X X X X \n"+ 86 " X X X X X X X X X X X X X X X X X \n"+ 87 "X X X X X X X X X X X X X X X X X X \n"+ 88 "X X X X X X X X X X X X X X X X X X X X X X X \n"+ 89 "X X X X X X X X X X X X X X X X X X X X X \n"+ 90 "X X X X X X X X X X X X X X X X \n"+ 91 "X X X X X X X X X X X X X X X X X X X X X \n"+ 92 " X X X X X X X X X X X X X X X X \n"+ 93 "X X X X X X X X X X X X X \n") 94 }