5 #include "../qrinput.h"
12 char num[9]="01234567";
15 testStart("Estimation of Numeric stream (8 digits)");
16 stream = QRinput_new();
17 QRinput_append(stream, QR_MODE_NUM, 8, (unsigned char *)num);
18 bits = QRinput_estimateBitStreamSize(stream, 0);
19 testEndExp(bits == 41);
21 QRinput_append(gstream, QR_MODE_NUM, 8, (unsigned char *)num);
25 void test_numbit2(void)
28 char num[17]="0123456789012345";
31 testStart("Estimation of Numeric stream (16 digits)");
32 stream = QRinput_new();
33 QRinput_append(stream, QR_MODE_NUM, 16, (unsigned char *)num);
34 bits = QRinput_estimateBitStreamSize(stream, 0);
35 testEndExp(bits == 68);
37 QRinput_append(gstream, QR_MODE_NUM, 16, (unsigned char *)num);
41 void test_numbit3(void)
47 testStart("Estimation of Numeric stream (400 digits)");
48 stream = QRinput_new();
49 num = (char *)malloc(401);
50 memset(num, '1', 400);
52 QRinput_append(stream, QR_MODE_NUM, 400, (unsigned char *)num);
53 bits = QRinput_estimateBitStreamSize(stream, 0);
54 /* 4 + 10 + 133*10 + 4 = 1348 */
55 testEndExp(bits == 1348);
57 QRinput_append(gstream, QR_MODE_NUM, 400, (unsigned char *)num);
68 testStart("Estimation of Alphabet-Numeric stream (5 chars)");
69 stream = QRinput_new();
70 QRinput_append(stream, QR_MODE_AN, 5, (unsigned char *)str);
71 bits = QRinput_estimateBitStreamSize(stream, 0);
72 testEndExp(bits == 41);
74 QRinput_append(gstream, QR_MODE_AN, 5, (unsigned char *)str);
81 char str[9]="12345678";
84 testStart("Estimation of 8 bit data stream (8 bytes)");
85 stream = QRinput_new();
86 QRinput_append(stream, QR_MODE_8, 8, (unsigned char *)str);
87 bits = QRinput_estimateBitStreamSize(stream, 0);
88 testEndExp(bits == 76);
90 QRinput_append(gstream, QR_MODE_8, 8, (unsigned char *)str);
94 void test_structure(void)
99 testStart("Estimation of a structure-append header");
100 stream = QRinput_new();
101 QRinput_insertStructuredAppendHeader(stream, 10, 1, 0);
102 bits = QRinput_estimateBitStreamSize(stream, 1);
103 testEndExp(bits == 20);
105 QRinput_insertStructuredAppendHeader(gstream, 10, 1, 0);
106 QRinput_free(stream);
109 void test_kanji(void)
114 unsigned char str[4]= {0x93, 0x5f,0xe4, 0xaa};
117 testStart("Estimation of Kanji stream (2 chars)");
118 stream = QRinput_new();
119 res = QRinput_append(stream, QR_MODE_KANJI, 4, (unsigned char *)str);
121 printf("Failed to add.\n");
124 bits = QRinput_estimateBitStreamSize(stream, 0);
125 testEndExp(bits == 38);
126 QRinput_append(gstream, QR_MODE_KANJI, 4, (unsigned char *)str);
129 QRinput_free(stream);
136 testStart("Estimation of Mixed stream");
137 bits = QRinput_estimateBitStreamSize(gstream, 0);
138 testEndExp(bits == (41 + 68 + 1348 + 41 + 76 + 38 + 20));
139 QRinput_free(gstream);
142 int main(int argc, char **argv)
144 gstream = QRinput_new();