#lang racket/base
(require rackunit
"data.rkt"
"qrcode.rkt"
"private/bits.rkt"
"private/bmp.rkt"
"private/encode.rkt"
"private/layout.rkt")
(check-equal? "01110000 10010100 00000101 10100001 10100010 10100011 10100100 10100101"
(bits->string
(qr-data->bits
(list (eci 9) (8bit (bytes #xA1 #xA2 #xA3 #xA4 #xA5)))
1)))
(check-equal? "00010000 00100000 00001100 01010110 01100001 1"
(bits->string
(qr-data->bits
(numeric "01234567")
1)))
(check-equal? "00010000 01000000 00001100 01010110 01101010 01101110 00010100 11101010 0101"
(bits->string
(qr-data->bits
(numeric "0123456789012345")
1)))
(check-equal? "00100000 00101001 11001110 11100111 00100001 0"
(bits->string
(qr-data->bits
(alpha "AC-42")
1)))
(check-equal? (bytes #b00010000 #b00100000 #b00001100 #b01010110 #b01100001
#b10000000 #b11101100 #b00010001 #b11101100
#b00010001 #b11101100 #b00010001 #b11101100 #b00010001
#b11101100 #b00010001 #b10100101 #b00100100
#b11010100 #b11000001 #b11101101 #b00110110 #b11000111
#b10000111 #b00101100 #b01010101)
(qr-encode-data (qr-spec 1 'M (numeric "01234567"))))
(check-equal? (bytes #b01111111 #b11001000 #b00011111
#b01000001 #b01001100 #b00010000
#b01011101 #b01010010 #b00010111
#b01011101 #b01010000 #b00010111
#b01011101 #b01001110 #b00010111
#b01000001 #b01000010 #b00010000
#b01111111 #b11010101 #b00011111
#b00000000 #b00001010 #b00000000
#b01000000 #b00000000 #b00000000
#b10100001 #b00000111 #b00000010
#b11001101 #b10111000 #b00011011
#b00011001 #b00010000 #b00000011
#b11110001 #b10111011 #b00000101
#b00000000 #b11101111 #b00000010
#b01111111 #b01000100 #b00000100
#b01000001 #b11101110 #b00010000
#b01011101 #b00000010 #b00000010
#b01011101 #b00000000 #b00000100
#b01011101 #b10111110 #b00000001
#b01000001 #b00010010 #b00001001
#b01111111 #b10111100 #b00000001)
(let ([spec (qr-spec 1 'M (numeric "01234567"))])
(let* ([version (qr-spec-version spec)]
[bits (qr-encode-data spec)]
[sym (qr-template version)]
[mask (qr-data-mask version)])
(qr-layout-data! sym mask bits)
(bmp-bits sym))))
(check-equal? (bytes ...)
(let ([spec (qr-spec 1 'M (numeric "01234567"))])
(qr-encode/bmp spec)))