]> git.sur5r.net Git - glabels/blob - glabels2/qrencode-3.1.0/tests/test_rs.c
2009-09-22 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / qrencode-3.1.0 / tests / test_rs.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "common.h"
4 #include "../qrencode_inner.h"
5 #include "../qrinput.h"
6 #include "../rscode.h"
7
8 /* See pp. 73 of JIS X0510:2004 */
9 void test_rscode1(void)
10 {
11         QRinput *stream;
12         QRRawCode *code;
13         static const char str[9] = "01234567";
14         static unsigned char correct[26] = {
15                 0x10, 0x20, 0x0c, 0x56, 0x61, 0x80, 0xec, 0x11, 0xec, 0x11, 0xec, 0x11,
16                 0xec, 0x11, 0xec, 0x11, 0xa5, 0x24, 0xd4, 0xc1, 0xed, 0x36, 0xc7, 0x87,
17                 0x2c, 0x55};
18
19         testStart("RS ecc test");
20         stream = QRinput_new();
21         QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)str);
22         QRinput_setErrorCorrectionLevel(stream, QR_ECLEVEL_M);
23         code = QRraw_new(stream);
24
25         testEnd(memcmp(correct + 16, code->rsblock[0].ecc, 10));
26         QRinput_free(stream);
27         QRraw_free(code);
28 }
29
30 int main(int argc, char **argv)
31 {
32         test_rscode1();
33
34         free_rs_cache();
35         report();
36
37         return 0;
38 }