Debian Codegraph @

src/tests/version.rs

raw symbols SCIP
1 use crate::{Mask, QRCode};
2
3 #[test]
4 fn version_format_l_mask0() {
5 const CONTENT: &str = "4";
6 const MASK: Option<Mask> = Some(Mask::Checkerboard);
7 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V05);
8 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
9
10 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
11 if q.is_err() {
12 assert_eq!(true, false, "Couldn't create QR");
13 };
14 let mat = q.unwrap();
15
16 const EXPECTED: [bool; 15] = [
17 true, true, true, false, true, true, true, true, true, false, false, false, true, false,
18 false,
19 ];
20
21 {
22 let l = mat.size;
23 #[rustfmt::skip]
24 let tmp = [
25 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
26 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
27 ];
28 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
29
30 #[rustfmt::skip]
31 let tmp = [
32 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
33 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
34 ];
35 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
36 }
37 }
38
39 #[test]
40 fn version_format_l_mask1() {
41 const CONTENT: &str = "4";
42 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
43 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V03);
44 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
45
46 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
47 if q.is_err() {
48 assert_eq!(true, false, "Couldn't create QR");
49 };
50 let mat = q.unwrap();
51
52 const EXPECTED: [bool; 15] = [
53 true, true, true, false, false, true, false, true, true, true, true, false, false, true,
54 true,
55 ];
56
57 {
58 let l = mat.size;
59 #[rustfmt::skip]
60 let tmp = [
61 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
62 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
63 ];
64 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
65
66 #[rustfmt::skip]
67 let tmp = [
68 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
69 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
70 ];
71 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
72 }
73 }
74
75 #[test]
76 fn version_format_l_mask2() {
77 const CONTENT: &str = "4";
78 const MASK: Option<Mask> = Some(Mask::VerticalLines);
79 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V06);
80 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
81
82 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
83 if q.is_err() {
84 assert_eq!(true, false, "Couldn't create QR");
85 };
86 let mat = q.unwrap();
87
88 const EXPECTED: [bool; 15] = [
89 true, true, true, true, true, false, true, true, false, true, false, true, false, true,
90 false,
91 ];
92
93 {
94 let l = mat.size;
95 #[rustfmt::skip]
96 let tmp = [
97 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
98 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
99 ];
100 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
101
102 #[rustfmt::skip]
103 let tmp = [
104 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
105 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
106 ];
107 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
108 }
109 }
110
111 #[test]
112 fn version_format_l_mask3() {
113 const CONTENT: &str = "4";
114 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
115 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V03);
116 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
117
118 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
119 if q.is_err() {
120 assert_eq!(true, false, "Couldn't create QR");
121 };
122 let mat = q.unwrap();
123
124 const EXPECTED: [bool; 15] = [
125 true, true, true, true, false, false, false, true, false, false, true, true, true, false,
126 true,
127 ];
128
129 {
130 let l = mat.size;
131 #[rustfmt::skip]
132 let tmp = [
133 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
134 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
135 ];
136 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
137
138 #[rustfmt::skip]
139 let tmp = [
140 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
141 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
142 ];
143 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
144 }
145 }
146
147 #[test]
148 fn version_format_l_mask4() {
149 const CONTENT: &str = "4";
150 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
151 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V06);
152 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
153
154 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
155 if q.is_err() {
156 assert_eq!(true, false, "Couldn't create QR");
157 };
158 let mat = q.unwrap();
159
160 const EXPECTED: [bool; 15] = [
161 true, true, false, false, true, true, false, false, false, true, false, true, true, true,
162 true,
163 ];
164
165 {
166 let l = mat.size;
167 #[rustfmt::skip]
168 let tmp = [
169 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
170 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
171 ];
172 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
173
174 #[rustfmt::skip]
175 let tmp = [
176 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
177 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
178 ];
179 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
180 }
181 }
182
183 #[test]
184 fn version_format_l_mask5() {
185 const CONTENT: &str = "4";
186 const MASK: Option<Mask> = Some(Mask::Fields);
187 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V06);
188 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
189
190 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
191 if q.is_err() {
192 assert_eq!(true, false, "Couldn't create QR");
193 };
194 let mat = q.unwrap();
195
196 const EXPECTED: [bool; 15] = [
197 true, true, false, false, false, true, true, false, false, false, true, true, false, false,
198 false,
199 ];
200
201 {
202 let l = mat.size;
203 #[rustfmt::skip]
204
205 #[rustfmt::skip]
206 let tmp = [
207 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
208 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
209 ];
210 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
211
212 #[rustfmt::skip]
213 let tmp = [
214 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
215 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
216 ];
217 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
218 }
219 }
220
221 #[test]
222 fn version_format_l_mask6() {
223 const CONTENT: &str = "4";
224 const MASK: Option<Mask> = Some(Mask::Diamonds);
225 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V06);
226 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
227
228 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
229 if q.is_err() {
230 assert_eq!(true, false, "Couldn't create QR");
231 };
232 let mat = q.unwrap();
233
234 const EXPECTED: [bool; 15] = [
235 true, true, false, true, true, false, false, false, true, false, false, false, false,
236 false, true,
237 ];
238
239 {
240 let l = mat.size;
241
242 #[rustfmt::skip]
243 let tmp = [
244 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
245 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
246 ];
247 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
248
249 #[rustfmt::skip]
250 let tmp = [
251 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
252 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
253 ];
254 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
255 }
256 }
257
258 #[test]
259 fn version_format_l_mask7() {
260 const CONTENT: &str = "4";
261 const MASK: Option<Mask> = Some(Mask::Meadow);
262 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V05);
263 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
264
265 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
266 if q.is_err() {
267 assert_eq!(true, false, "Couldn't create QR");
268 };
269 let mat = q.unwrap();
270
271 const EXPECTED: [bool; 15] = [
272 true, true, false, true, false, false, true, false, true, true, true, false, true, true,
273 false,
274 ];
275
276 {
277 let l = mat.size;
278 #[rustfmt::skip]
279 let tmp = [
280 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
281 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
282 ];
283 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
284
285 #[rustfmt::skip]
286 let tmp = [
287 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
288 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
289 ];
290 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
291 }
292 }
293
294 #[test]
295 fn version_format_m_mask0() {
296 const CONTENT: &str = "4";
297 const MASK: Option<Mask> = Some(Mask::Checkerboard);
298 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V01);
299 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
300
301 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
302 if q.is_err() {
303 assert_eq!(true, false, "Couldn't create QR");
304 };
305 let mat = q.unwrap();
306
307 const EXPECTED: [bool; 15] = [
308 true, false, true, false, true, false, false, false, false, false, true, false, false,
309 true, false,
310 ];
311
312 {
313 let l = mat.size;
314 #[rustfmt::skip]
315 let tmp = [
316 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
317 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
318 ];
319 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
320
321 #[rustfmt::skip]
322 let tmp = [
323 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
324 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
325 ];
326 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
327 }
328 }
329
330 #[test]
331 fn version_format_m_mask1() {
332 const CONTENT: &str = "4";
333 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
334 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V04);
335 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
336
337 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
338 if q.is_err() {
339 assert_eq!(true, false, "Couldn't create QR");
340 };
341 let mat = q.unwrap();
342
343 const EXPECTED: [bool; 15] = [
344 true, false, true, false, false, false, true, false, false, true, false, false, true,
345 false, true,
346 ];
347
348 {
349 let l = mat.size;
350 #[rustfmt::skip]
351 let tmp = [
352 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
353 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
354 ];
355 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
356
357 #[rustfmt::skip]
358 let tmp = [
359 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
360 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
361 ];
362 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
363 }
364 }
365
366 #[test]
367 fn version_format_m_mask2() {
368 const CONTENT: &str = "4";
369 const MASK: Option<Mask> = Some(Mask::VerticalLines);
370 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
371 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
372
373 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
374 if q.is_err() {
375 assert_eq!(true, false, "Couldn't create QR");
376 };
377 let mat = q.unwrap();
378
379 const EXPECTED: [bool; 15] = [
380 true, false, true, true, true, true, false, false, true, true, true, true, true, false,
381 false,
382 ];
383
384 {
385 let l = mat.size;
386 #[rustfmt::skip]
387 let tmp = [
388 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
389 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
390 ];
391 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
392
393 #[rustfmt::skip]
394 let tmp = [
395 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
396 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
397 ];
398 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
399 }
400 }
401
402 #[test]
403 fn version_format_m_mask3() {
404 const CONTENT: &str = "4";
405 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
406 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V06);
407 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
408
409 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
410 if q.is_err() {
411 assert_eq!(true, false, "Couldn't create QR");
412 };
413 let mat = q.unwrap();
414
415 const EXPECTED: [bool; 15] = [
416 true, false, true, true, false, true, true, false, true, false, false, true, false, true,
417 true,
418 ];
419
420 {
421 let l = mat.size;
422 #[rustfmt::skip]
423 let tmp = [
424 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
425 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
426 ];
427 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
428
429 #[rustfmt::skip]
430 let tmp = [
431 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
432 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
433 ];
434 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
435 }
436 }
437
438 #[test]
439 fn version_format_m_mask4() {
440 const CONTENT: &str = "4";
441 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
442 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V01);
443 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
444
445 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
446 if q.is_err() {
447 assert_eq!(true, false, "Couldn't create QR");
448 };
449 let mat = q.unwrap();
450
451 const EXPECTED: [bool; 15] = [
452 true, false, false, false, true, false, true, true, true, true, true, true, false, false,
453 true,
454 ];
455
456 {
457 let l = mat.size;
458 #[rustfmt::skip]
459 let tmp = [
460 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
461 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
462 ];
463 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
464
465 #[rustfmt::skip]
466 let tmp = [
467 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
468 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
469 ];
470 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
471 }
472 }
473
474 #[test]
475 fn version_format_m_mask5() {
476 const CONTENT: &str = "4";
477 const MASK: Option<Mask> = Some(Mask::Fields);
478 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
479 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
480
481 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
482 if q.is_err() {
483 assert_eq!(true, false, "Couldn't create QR");
484 };
485 let mat = q.unwrap();
486
487 const EXPECTED: [bool; 15] = [
488 true, false, false, false, false, false, false, true, true, false, false, true, true, true,
489 false,
490 ];
491
492 {
493 let l = mat.size;
494 #[rustfmt::skip]
495 let tmp = [
496 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
497 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
498 ];
499 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
500
501 #[rustfmt::skip]
502 let tmp = [
503 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
504 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
505 ];
506 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
507 }
508 }
509
510 #[test]
511 fn version_format_m_mask6() {
512 const CONTENT: &str = "4";
513 const MASK: Option<Mask> = Some(Mask::Diamonds);
514 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V01);
515 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
516
517 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
518 if q.is_err() {
519 assert_eq!(true, false, "Couldn't create QR");
520 };
521 let mat = q.unwrap();
522
523 const EXPECTED: [bool; 15] = [
524 true, false, false, true, true, true, true, true, false, false, true, false, true, true,
525 true,
526 ];
527
528 {
529 let l = mat.size;
530 #[rustfmt::skip]
531 let tmp = [
532 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
533 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
534 ];
535 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
536
537 #[rustfmt::skip]
538 let tmp = [
539 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
540 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
541 ];
542 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
543 }
544 }
545
546 #[test]
547 fn version_format_m_mask7() {
548 const CONTENT: &str = "4";
549 const MASK: Option<Mask> = Some(Mask::Meadow);
550 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V03);
551 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
552
553 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
554 if q.is_err() {
555 assert_eq!(true, false, "Couldn't create QR");
556 };
557 let mat = q.unwrap();
558
559 const EXPECTED: [bool; 15] = [
560 true, false, false, true, false, true, false, true, false, true, false, false, false,
561 false, false,
562 ];
563
564 {
565 let l = mat.size;
566 #[rustfmt::skip]
567 let tmp = [
568 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
569 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
570 ];
571 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
572
573 #[rustfmt::skip]
574 let tmp = [
575 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
576 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
577 ];
578 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
579 }
580 }
581
582 #[test]
583 fn version_format_q_mask0() {
584 const CONTENT: &str = "4";
585 const MASK: Option<Mask> = Some(Mask::Checkerboard);
586 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V04);
587 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
588
589 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
590 if q.is_err() {
591 assert_eq!(true, false, "Couldn't create QR");
592 };
593 let mat = q.unwrap();
594
595 const EXPECTED: [bool; 15] = [
596 false, true, true, false, true, false, true, false, true, false, true, true, true, true,
597 true,
598 ];
599
600 {
601 let l = mat.size;
602 #[rustfmt::skip]
603 let tmp = [
604 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
605 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
606 ];
607 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
608
609 #[rustfmt::skip]
610 let tmp = [
611 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
612 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
613 ];
614 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
615 }
616 }
617
618 #[test]
619 fn version_format_q_mask1() {
620 const CONTENT: &str = "4";
621 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
622 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
623 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
624
625 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
626 if q.is_err() {
627 assert_eq!(true, false, "Couldn't create QR");
628 };
629 let mat = q.unwrap();
630
631 const EXPECTED: [bool; 15] = [
632 false, true, true, false, false, false, false, false, true, true, false, true, false,
633 false, false,
634 ];
635
636 {
637 let l = mat.size;
638 #[rustfmt::skip]
639 let tmp = [
640 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
641 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
642 ];
643 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
644
645 #[rustfmt::skip]
646 let tmp = [
647 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
648 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
649 ];
650 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
651 }
652 }
653
654 #[test]
655 fn version_format_q_mask2() {
656 const CONTENT: &str = "4";
657 const MASK: Option<Mask> = Some(Mask::VerticalLines);
658 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V04);
659 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
660
661 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
662 if q.is_err() {
663 assert_eq!(true, false, "Couldn't create QR");
664 };
665 let mat = q.unwrap();
666
667 const EXPECTED: [bool; 15] = [
668 false, true, true, true, true, true, true, false, false, true, true, false, false, false,
669 true,
670 ];
671
672 {
673 let l = mat.size;
674 #[rustfmt::skip]
675 let tmp = [
676 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
677 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
678 ];
679 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
680
681 #[rustfmt::skip]
682 let tmp = [
683 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
684 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
685 ];
686 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
687 }
688 }
689
690 #[test]
691 fn version_format_q_mask3() {
692 const CONTENT: &str = "4";
693 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
694 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V05);
695 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
696
697 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
698 if q.is_err() {
699 assert_eq!(true, false, "Couldn't create QR");
700 };
701 let mat = q.unwrap();
702
703 const EXPECTED: [bool; 15] = [
704 false, true, true, true, false, true, false, false, false, false, false, false, true, true,
705 false,
706 ];
707
708 {
709 let l = mat.size;
710 #[rustfmt::skip]
711 let tmp = [
712 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
713 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
714 ];
715 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
716
717 #[rustfmt::skip]
718 let tmp = [
719 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
720 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
721 ];
722 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
723 }
724 }
725
726 #[test]
727 fn version_format_q_mask4() {
728 const CONTENT: &str = "4";
729 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
730 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V01);
731 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
732
733 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
734 if q.is_err() {
735 assert_eq!(true, false, "Couldn't create QR");
736 };
737 let mat = q.unwrap();
738
739 const EXPECTED: [bool; 15] = [
740 false, true, false, false, true, false, false, true, false, true, true, false, true, false,
741 false,
742 ];
743
744 {
745 let l = mat.size;
746 #[rustfmt::skip]
747 let tmp = [
748 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
749 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
750 ];
751 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
752
753 #[rustfmt::skip]
754 let tmp = [
755 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
756 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
757 ];
758 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
759 }
760 }
761
762 #[test]
763 fn version_format_q_mask5() {
764 const CONTENT: &str = "4";
765 const MASK: Option<Mask> = Some(Mask::Fields);
766 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V05);
767 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
768
769 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
770 if q.is_err() {
771 assert_eq!(true, false, "Couldn't create QR");
772 };
773 let mat = q.unwrap();
774
775 const EXPECTED: [bool; 15] = [
776 false, true, false, false, false, false, true, true, false, false, false, false, false,
777 true, true,
778 ];
779
780 {
781 let l = mat.size;
782 #[rustfmt::skip]
783 let tmp = [
784 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
785 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
786 ];
787 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
788
789 #[rustfmt::skip]
790 let tmp = [
791 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
792 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
793 ];
794 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
795 }
796 }
797
798 #[test]
799 fn version_format_q_mask6() {
800 const CONTENT: &str = "4";
801 const MASK: Option<Mask> = Some(Mask::Diamonds);
802 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
803 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
804
805 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
806 if q.is_err() {
807 assert_eq!(true, false, "Couldn't create QR");
808 };
809 let mat = q.unwrap();
810
811 const EXPECTED: [bool; 15] = [
812 false, true, false, true, true, true, false, true, true, false, true, true, false, true,
813 false,
814 ];
815
816 {
817 let l = mat.size;
818 #[rustfmt::skip]
819 let tmp = [
820 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
821 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
822 ];
823 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
824
825 #[rustfmt::skip]
826 let tmp = [
827 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
828 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
829 ];
830 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
831 }
832 }
833
834 #[test]
835 fn version_format_q_mask7() {
836 const CONTENT: &str = "4";
837 const MASK: Option<Mask> = Some(Mask::Meadow);
838 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V01);
839 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
840
841 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
842 if q.is_err() {
843 assert_eq!(true, false, "Couldn't create QR");
844 };
845 let mat = q.unwrap();
846
847 const EXPECTED: [bool; 15] = [
848 false, true, false, true, false, true, true, true, true, true, false, true, true, false,
849 true,
850 ];
851
852 {
853 let l = mat.size;
854 #[rustfmt::skip]
855 let tmp = [
856 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
857 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
858 ];
859 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
860
861 #[rustfmt::skip]
862 let tmp = [
863 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
864 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
865 ];
866 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
867 }
868 }
869
870 #[test]
871 fn version_format_h_mask0() {
872 const CONTENT: &str = "4";
873 const MASK: Option<Mask> = Some(Mask::Checkerboard);
874 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V06);
875 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
876
877 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
878 if q.is_err() {
879 assert_eq!(true, false, "Couldn't create QR");
880 };
881 let mat = q.unwrap();
882
883 const EXPECTED: [bool; 15] = [
884 false, false, true, false, true, true, false, true, false, false, false, true, false,
885 false, true,
886 ];
887
888 {
889 let l = mat.size;
890 #[rustfmt::skip]
891 let tmp = [
892 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
893 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
894 ];
895 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
896
897 #[rustfmt::skip]
898 let tmp = [
899 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
900 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
901 ];
902 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
903 }
904 }
905
906 #[test]
907 fn version_format_h_mask1() {
908 const CONTENT: &str = "4";
909 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
910 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
911 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
912
913 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
914 if q.is_err() {
915 assert_eq!(true, false, "Couldn't create QR");
916 };
917 let mat = q.unwrap();
918
919 const EXPECTED: [bool; 15] = [
920 false, false, true, false, false, true, true, true, false, true, true, true, true, true,
921 false,
922 ];
923
924 {
925 let l = mat.size;
926 #[rustfmt::skip]
927 let tmp = [
928 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
929 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
930 ];
931 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
932
933 #[rustfmt::skip]
934 let tmp = [
935 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
936 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
937 ];
938 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
939 }
940 }
941
942 #[test]
943 fn version_format_h_mask2() {
944 const CONTENT: &str = "4";
945 const MASK: Option<Mask> = Some(Mask::VerticalLines);
946 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V04);
947 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
948
949 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
950 if q.is_err() {
951 assert_eq!(true, false, "Couldn't create QR");
952 };
953 let mat = q.unwrap();
954
955 const EXPECTED: [bool; 15] = [
956 false, false, true, true, true, false, false, true, true, true, false, false, true, true,
957 true,
958 ];
959
960 {
961 let l = mat.size;
962 #[rustfmt::skip]
963 let tmp = [
964 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
965 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
966 ];
967 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
968
969 #[rustfmt::skip]
970 let tmp = [
971 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
972 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
973 ];
974 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
975 }
976 }
977
978 #[test]
979 fn version_format_h_mask3() {
980 const CONTENT: &str = "4";
981 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
982 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V03);
983 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
984
985 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
986 if q.is_err() {
987 assert_eq!(true, false, "Couldn't create QR");
988 };
989 let mat = q.unwrap();
990
991 const EXPECTED: [bool; 15] = [
992 false, false, true, true, false, false, true, true, true, false, true, false, false, false,
993 false,
994 ];
995
996 {
997 let l = mat.size;
998 #[rustfmt::skip]
999 let tmp = [
1000 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1001 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1002 ];
1003 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1004
1005 #[rustfmt::skip]
1006 let tmp = [
1007 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1008 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1009 ];
1010 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1011 }
1012 }
1013
1014 #[test]
1015 fn version_format_h_mask4() {
1016 const CONTENT: &str = "4";
1017 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
1018 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
1019 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
1020
1021 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1022 if q.is_err() {
1023 assert_eq!(true, false, "Couldn't create QR");
1024 };
1025 let mat = q.unwrap();
1026
1027 const EXPECTED: [bool; 15] = [
1028 false, false, false, false, true, true, true, false, true, true, false, false, false, true,
1029 false,
1030 ];
1031
1032 {
1033 let l = mat.size;
1034 #[rustfmt::skip]
1035 let tmp = [
1036 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1037 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1038 ];
1039 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1040
1041 #[rustfmt::skip]
1042 let tmp = [
1043 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1044 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1045 ];
1046 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1047 }
1048 }
1049
1050 #[test]
1051 fn version_format_h_mask5() {
1052 const CONTENT: &str = "4";
1053 const MASK: Option<Mask> = Some(Mask::Fields);
1054 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V04);
1055 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
1056
1057 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1058 if q.is_err() {
1059 assert_eq!(true, false, "Couldn't create QR");
1060 };
1061 let mat = q.unwrap();
1062
1063 const EXPECTED: [bool; 15] = [
1064 false, false, false, false, false, true, false, false, true, false, true, false, true,
1065 false, true,
1066 ];
1067
1068 {
1069 let l = mat.size;
1070 #[rustfmt::skip]
1071 let tmp = [
1072 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1073 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1074 ];
1075 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1076
1077 #[rustfmt::skip]
1078 let tmp = [
1079 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1080 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1081 ];
1082 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1083 }
1084 }
1085
1086 #[test]
1087 fn version_format_h_mask6() {
1088 const CONTENT: &str = "4";
1089 const MASK: Option<Mask> = Some(Mask::Diamonds);
1090 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V02);
1091 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
1092
1093 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1094 if q.is_err() {
1095 assert_eq!(true, false, "Couldn't create QR");
1096 };
1097 let mat = q.unwrap();
1098
1099 const EXPECTED: [bool; 15] = [
1100 false, false, false, true, true, false, true, false, false, false, false, true, true,
1101 false, false,
1102 ];
1103
1104 {
1105 let l = mat.size;
1106 #[rustfmt::skip]
1107 let tmp = [
1108 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1109 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1110 ];
1111 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1112
1113 #[rustfmt::skip]
1114 let tmp = [
1115 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1116 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1117 ];
1118 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1119 }
1120 }
1121
1122 #[test]
1123 fn version_format_h_mask7() {
1124 const CONTENT: &str = "4";
1125 const MASK: Option<Mask> = Some(Mask::Meadow);
1126 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V01);
1127 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
1128
1129 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1130 if q.is_err() {
1131 assert_eq!(true, false, "Couldn't create QR");
1132 };
1133 let mat = q.unwrap();
1134
1135 const EXPECTED: [bool; 15] = [
1136 false, false, false, true, false, false, false, false, false, true, true, true, false,
1137 true, true,
1138 ];
1139
1140 {
1141 let l = mat.size;
1142 #[rustfmt::skip]
1143 let tmp = [
1144 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1145 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1146 ];
1147 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1148
1149 #[rustfmt::skip]
1150 let tmp = [
1151 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1152 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1153 ];
1154 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1155 }
1156 }
1157
1158 #[test]
1159 fn version_format_l_mask0_version23() {
1160 const CONTENT: &str = "4";
1161 const MASK: Option<Mask> = Some(Mask::Checkerboard);
1162 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V23);
1163 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1164
1165 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1166 if q.is_err() {
1167 assert_eq!(true, false, "Couldn't create QR");
1168 };
1169 let mat = q.unwrap();
1170
1171 const EXPECTED: [bool; 15] = [
1172 true, true, true, false, true, true, true, true, true, false, false, false, true, false,
1173 false,
1174 ];
1175 let mut expected2: [bool; 18] = [
1176 false, true, false, true, true, true, false, true, true, true, true, true, true, false,
1177 true, true, false, false,
1178 ];
1179 expected2.reverse();
1180
1181 {
1182 let l = mat.size;
1183 #[rustfmt::skip]
1184 let tmp = [
1185 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1186 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1187 ];
1188 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1189
1190 #[rustfmt::skip]
1191 let tmp = [
1192 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1193 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1194 ];
1195 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1196
1197 let tmp2 = [
1198 mat[l - 11][0],
1199 mat[l - 10][0],
1200 mat[l - 9][0],
1201 mat[l - 11][1],
1202 mat[l - 10][1],
1203 mat[l - 9][1],
1204 mat[l - 11][2],
1205 mat[l - 10][2],
1206 mat[l - 9][2],
1207 mat[l - 11][3],
1208 mat[l - 10][3],
1209 mat[l - 9][3],
1210 mat[l - 11][4],
1211 mat[l - 10][4],
1212 mat[l - 9][4],
1213 mat[l - 11][5],
1214 mat[l - 10][5],
1215 mat[l - 9][5],
1216 ];
1217 assert_eq!(tmp2.map(|x| x.value()), expected2);
1218
1219 let tmp2 = [
1220 mat[0][l - 11],
1221 mat[0][l - 10],
1222 mat[0][l - 9],
1223 mat[1][l - 11],
1224 mat[1][l - 10],
1225 mat[1][l - 9],
1226 mat[2][l - 11],
1227 mat[2][l - 10],
1228 mat[2][l - 9],
1229 mat[3][l - 11],
1230 mat[3][l - 10],
1231 mat[3][l - 9],
1232 mat[4][l - 11],
1233 mat[4][l - 10],
1234 mat[4][l - 9],
1235 mat[5][l - 11],
1236 mat[5][l - 10],
1237 mat[5][l - 9],
1238 ];
1239 assert_eq!(tmp2.map(|x| x.value()), expected2);
1240 }
1241 }
1242
1243 #[test]
1244 fn version_format_l_mask1_version29() {
1245 const CONTENT: &str = "4";
1246 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
1247 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V29);
1248 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1249
1250 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1251 if q.is_err() {
1252 assert_eq!(true, false, "Couldn't create QR");
1253 };
1254 let mat = q.unwrap();
1255
1256 const EXPECTED: [bool; 15] = [
1257 true, true, true, false, false, true, false, true, true, true, true, false, false, true,
1258 true,
1259 ];
1260 let mut expected2: [bool; 18] = [
1261 false, true, true, true, false, true, false, false, true, true, false, false, true, true,
1262 true, true, true, true,
1263 ];
1264 expected2.reverse();
1265
1266 {
1267 let l = mat.size;
1268 #[rustfmt::skip]
1269 let tmp = [
1270 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1271 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1272 ];
1273 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1274
1275 #[rustfmt::skip]
1276 let tmp = [
1277 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1278 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1279 ];
1280 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1281
1282 let tmp2 = [
1283 mat[l - 11][0],
1284 mat[l - 10][0],
1285 mat[l - 9][0],
1286 mat[l - 11][1],
1287 mat[l - 10][1],
1288 mat[l - 9][1],
1289 mat[l - 11][2],
1290 mat[l - 10][2],
1291 mat[l - 9][2],
1292 mat[l - 11][3],
1293 mat[l - 10][3],
1294 mat[l - 9][3],
1295 mat[l - 11][4],
1296 mat[l - 10][4],
1297 mat[l - 9][4],
1298 mat[l - 11][5],
1299 mat[l - 10][5],
1300 mat[l - 9][5],
1301 ];
1302 assert_eq!(tmp2.map(|x| x.value()), expected2);
1303
1304 let tmp2 = [
1305 mat[0][l - 11],
1306 mat[0][l - 10],
1307 mat[0][l - 9],
1308 mat[1][l - 11],
1309 mat[1][l - 10],
1310 mat[1][l - 9],
1311 mat[2][l - 11],
1312 mat[2][l - 10],
1313 mat[2][l - 9],
1314 mat[3][l - 11],
1315 mat[3][l - 10],
1316 mat[3][l - 9],
1317 mat[4][l - 11],
1318 mat[4][l - 10],
1319 mat[4][l - 9],
1320 mat[5][l - 11],
1321 mat[5][l - 10],
1322 mat[5][l - 9],
1323 ];
1324 assert_eq!(tmp2.map(|x| x.value()), expected2);
1325 }
1326 }
1327
1328 #[test]
1329 fn version_format_l_mask2_version40() {
1330 const CONTENT: &str = "4";
1331 const MASK: Option<Mask> = Some(Mask::VerticalLines);
1332 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V40);
1333 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1334
1335 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1336 if q.is_err() {
1337 assert_eq!(true, false, "Couldn't create QR");
1338 };
1339 let mat = q.unwrap();
1340
1341 const EXPECTED: [bool; 15] = [
1342 true, true, true, true, true, false, true, true, false, true, false, true, false, true,
1343 false,
1344 ];
1345 let mut expected2: [bool; 18] = [
1346 true, false, true, false, false, false, true, true, false, false, false, true, true, false,
1347 true, false, false, true,
1348 ];
1349 expected2.reverse();
1350
1351 {
1352 let l = mat.size;
1353 #[rustfmt::skip]
1354 let tmp = [
1355 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1356 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1357 ];
1358 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1359
1360 #[rustfmt::skip]
1361 let tmp = [
1362 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1363 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1364 ];
1365 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1366
1367 let tmp2 = [
1368 mat[l - 11][0],
1369 mat[l - 10][0],
1370 mat[l - 9][0],
1371 mat[l - 11][1],
1372 mat[l - 10][1],
1373 mat[l - 9][1],
1374 mat[l - 11][2],
1375 mat[l - 10][2],
1376 mat[l - 9][2],
1377 mat[l - 11][3],
1378 mat[l - 10][3],
1379 mat[l - 9][3],
1380 mat[l - 11][4],
1381 mat[l - 10][4],
1382 mat[l - 9][4],
1383 mat[l - 11][5],
1384 mat[l - 10][5],
1385 mat[l - 9][5],
1386 ];
1387 assert_eq!(tmp2.map(|x| x.value()), expected2);
1388
1389 let tmp2 = [
1390 mat[0][l - 11],
1391 mat[0][l - 10],
1392 mat[0][l - 9],
1393 mat[1][l - 11],
1394 mat[1][l - 10],
1395 mat[1][l - 9],
1396 mat[2][l - 11],
1397 mat[2][l - 10],
1398 mat[2][l - 9],
1399 mat[3][l - 11],
1400 mat[3][l - 10],
1401 mat[3][l - 9],
1402 mat[4][l - 11],
1403 mat[4][l - 10],
1404 mat[4][l - 9],
1405 mat[5][l - 11],
1406 mat[5][l - 10],
1407 mat[5][l - 9],
1408 ];
1409 assert_eq!(tmp2.map(|x| x.value()), expected2);
1410 }
1411 }
1412
1413 #[test]
1414 fn version_format_l_mask3_version8() {
1415 const CONTENT: &str = "4";
1416 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
1417 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V08);
1418 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1419
1420 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1421 if q.is_err() {
1422 assert_eq!(true, false, "Couldn't create QR");
1423 };
1424 let mat = q.unwrap();
1425
1426 const EXPECTED: [bool; 15] = [
1427 true, true, true, true, false, false, false, true, false, false, true, true, true, false,
1428 true,
1429 ];
1430 let mut expected2: [bool; 18] = [
1431 false, false, true, false, false, false, false, true, false, true, true, false, true, true,
1432 true, true, false, false,
1433 ];
1434 expected2.reverse();
1435
1436 {
1437 let l = mat.size;
1438 #[rustfmt::skip]
1439 let tmp = [
1440 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1441 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1442 ];
1443 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1444
1445 #[rustfmt::skip]
1446 let tmp = [
1447 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1448 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1449 ];
1450 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1451
1452 let tmp2 = [
1453 mat[l - 11][0],
1454 mat[l - 10][0],
1455 mat[l - 9][0],
1456 mat[l - 11][1],
1457 mat[l - 10][1],
1458 mat[l - 9][1],
1459 mat[l - 11][2],
1460 mat[l - 10][2],
1461 mat[l - 9][2],
1462 mat[l - 11][3],
1463 mat[l - 10][3],
1464 mat[l - 9][3],
1465 mat[l - 11][4],
1466 mat[l - 10][4],
1467 mat[l - 9][4],
1468 mat[l - 11][5],
1469 mat[l - 10][5],
1470 mat[l - 9][5],
1471 ];
1472 assert_eq!(tmp2.map(|x| x.value()), expected2);
1473
1474 let tmp2 = [
1475 mat[0][l - 11],
1476 mat[0][l - 10],
1477 mat[0][l - 9],
1478 mat[1][l - 11],
1479 mat[1][l - 10],
1480 mat[1][l - 9],
1481 mat[2][l - 11],
1482 mat[2][l - 10],
1483 mat[2][l - 9],
1484 mat[3][l - 11],
1485 mat[3][l - 10],
1486 mat[3][l - 9],
1487 mat[4][l - 11],
1488 mat[4][l - 10],
1489 mat[4][l - 9],
1490 mat[5][l - 11],
1491 mat[5][l - 10],
1492 mat[5][l - 9],
1493 ];
1494 assert_eq!(tmp2.map(|x| x.value()), expected2);
1495 }
1496 }
1497
1498 #[test]
1499 fn version_format_l_mask4_version36() {
1500 const CONTENT: &str = "4";
1501 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
1502 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V36);
1503 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1504
1505 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1506 if q.is_err() {
1507 assert_eq!(true, false, "Couldn't create QR");
1508 };
1509 let mat = q.unwrap();
1510
1511 const EXPECTED: [bool; 15] = [
1512 true, true, false, false, true, true, false, false, false, true, false, true, true, true,
1513 true,
1514 ];
1515 let mut expected2: [bool; 18] = [
1516 true, false, false, true, false, false, true, false, true, true, false, false, false,
1517 false, true, false, true, true,
1518 ];
1519 expected2.reverse();
1520
1521 {
1522 let l = mat.size;
1523 #[rustfmt::skip]
1524 let tmp = [
1525 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1526 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1527 ];
1528 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1529
1530 #[rustfmt::skip]
1531 let tmp = [
1532 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1533 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1534 ];
1535 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1536
1537 let tmp2 = [
1538 mat[l - 11][0],
1539 mat[l - 10][0],
1540 mat[l - 9][0],
1541 mat[l - 11][1],
1542 mat[l - 10][1],
1543 mat[l - 9][1],
1544 mat[l - 11][2],
1545 mat[l - 10][2],
1546 mat[l - 9][2],
1547 mat[l - 11][3],
1548 mat[l - 10][3],
1549 mat[l - 9][3],
1550 mat[l - 11][4],
1551 mat[l - 10][4],
1552 mat[l - 9][4],
1553 mat[l - 11][5],
1554 mat[l - 10][5],
1555 mat[l - 9][5],
1556 ];
1557 assert_eq!(tmp2.map(|x| x.value()), expected2);
1558
1559 let tmp2 = [
1560 mat[0][l - 11],
1561 mat[0][l - 10],
1562 mat[0][l - 9],
1563 mat[1][l - 11],
1564 mat[1][l - 10],
1565 mat[1][l - 9],
1566 mat[2][l - 11],
1567 mat[2][l - 10],
1568 mat[2][l - 9],
1569 mat[3][l - 11],
1570 mat[3][l - 10],
1571 mat[3][l - 9],
1572 mat[4][l - 11],
1573 mat[4][l - 10],
1574 mat[4][l - 9],
1575 mat[5][l - 11],
1576 mat[5][l - 10],
1577 mat[5][l - 9],
1578 ];
1579 assert_eq!(tmp2.map(|x| x.value()), expected2);
1580 }
1581 }
1582
1583 #[test]
1584 fn version_format_l_mask5_version22() {
1585 const CONTENT: &str = "4";
1586 const MASK: Option<Mask> = Some(Mask::Fields);
1587 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V22);
1588 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1589
1590 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1591 if q.is_err() {
1592 assert_eq!(true, false, "Couldn't create QR");
1593 };
1594 let mat = q.unwrap();
1595
1596 const EXPECTED: [bool; 15] = [
1597 true, true, false, false, false, true, true, false, false, false, true, true, false, false,
1598 false,
1599 ];
1600 let mut expected2: [bool; 18] = [
1601 false, true, false, true, true, false, true, false, false, false, true, true, false, false,
1602 true, false, false, true,
1603 ];
1604 expected2.reverse();
1605
1606 {
1607 let l = mat.size;
1608 #[rustfmt::skip]
1609 let tmp = [
1610 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1611 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1612 ];
1613 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1614
1615 #[rustfmt::skip]
1616 let tmp = [
1617 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1618 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1619 ];
1620 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1621
1622 let tmp2 = [
1623 mat[l - 11][0],
1624 mat[l - 10][0],
1625 mat[l - 9][0],
1626 mat[l - 11][1],
1627 mat[l - 10][1],
1628 mat[l - 9][1],
1629 mat[l - 11][2],
1630 mat[l - 10][2],
1631 mat[l - 9][2],
1632 mat[l - 11][3],
1633 mat[l - 10][3],
1634 mat[l - 9][3],
1635 mat[l - 11][4],
1636 mat[l - 10][4],
1637 mat[l - 9][4],
1638 mat[l - 11][5],
1639 mat[l - 10][5],
1640 mat[l - 9][5],
1641 ];
1642 assert_eq!(tmp2.map(|x| x.value()), expected2);
1643
1644 let tmp2 = [
1645 mat[0][l - 11],
1646 mat[0][l - 10],
1647 mat[0][l - 9],
1648 mat[1][l - 11],
1649 mat[1][l - 10],
1650 mat[1][l - 9],
1651 mat[2][l - 11],
1652 mat[2][l - 10],
1653 mat[2][l - 9],
1654 mat[3][l - 11],
1655 mat[3][l - 10],
1656 mat[3][l - 9],
1657 mat[4][l - 11],
1658 mat[4][l - 10],
1659 mat[4][l - 9],
1660 mat[5][l - 11],
1661 mat[5][l - 10],
1662 mat[5][l - 9],
1663 ];
1664 assert_eq!(tmp2.map(|x| x.value()), expected2);
1665 }
1666 }
1667
1668 #[test]
1669 fn version_format_l_mask6_version10() {
1670 const CONTENT: &str = "4";
1671 const MASK: Option<Mask> = Some(Mask::Diamonds);
1672 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V10);
1673 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1674
1675 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1676 if q.is_err() {
1677 assert_eq!(true, false, "Couldn't create QR");
1678 };
1679 let mat = q.unwrap();
1680
1681 const EXPECTED: [bool; 15] = [
1682 true, true, false, true, true, false, false, false, true, false, false, false, false,
1683 false, true,
1684 ];
1685 let mut expected2: [bool; 18] = [
1686 false, false, true, false, true, false, false, true, false, false, true, true, false, true,
1687 false, false, true, true,
1688 ];
1689 expected2.reverse();
1690
1691 {
1692 let l = mat.size;
1693 #[rustfmt::skip]
1694 let tmp = [
1695 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1696 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1697 ];
1698 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1699
1700 #[rustfmt::skip]
1701 let tmp = [
1702 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1703 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1704 ];
1705 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1706
1707 let tmp2 = [
1708 mat[l - 11][0],
1709 mat[l - 10][0],
1710 mat[l - 9][0],
1711 mat[l - 11][1],
1712 mat[l - 10][1],
1713 mat[l - 9][1],
1714 mat[l - 11][2],
1715 mat[l - 10][2],
1716 mat[l - 9][2],
1717 mat[l - 11][3],
1718 mat[l - 10][3],
1719 mat[l - 9][3],
1720 mat[l - 11][4],
1721 mat[l - 10][4],
1722 mat[l - 9][4],
1723 mat[l - 11][5],
1724 mat[l - 10][5],
1725 mat[l - 9][5],
1726 ];
1727 assert_eq!(tmp2.map(|x| x.value()), expected2);
1728
1729 let tmp2 = [
1730 mat[0][l - 11],
1731 mat[0][l - 10],
1732 mat[0][l - 9],
1733 mat[1][l - 11],
1734 mat[1][l - 10],
1735 mat[1][l - 9],
1736 mat[2][l - 11],
1737 mat[2][l - 10],
1738 mat[2][l - 9],
1739 mat[3][l - 11],
1740 mat[3][l - 10],
1741 mat[3][l - 9],
1742 mat[4][l - 11],
1743 mat[4][l - 10],
1744 mat[4][l - 9],
1745 mat[5][l - 11],
1746 mat[5][l - 10],
1747 mat[5][l - 9],
1748 ];
1749 assert_eq!(tmp2.map(|x| x.value()), expected2);
1750 }
1751 }
1752
1753 #[test]
1754 fn version_format_l_mask7_version17() {
1755 const CONTENT: &str = "4";
1756 const MASK: Option<Mask> = Some(Mask::Meadow);
1757 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V17);
1758 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::L);
1759
1760 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1761 if q.is_err() {
1762 assert_eq!(true, false, "Couldn't create QR");
1763 };
1764 let mat = q.unwrap();
1765
1766 const EXPECTED: [bool; 15] = [
1767 true, true, false, true, false, false, true, false, true, true, true, false, true, true,
1768 false,
1769 ];
1770 let mut expected2: [bool; 18] = [
1771 false, true, false, false, false, true, false, true, false, false, false, true, false,
1772 true, true, true, false, true,
1773 ];
1774 expected2.reverse();
1775
1776 {
1777 let l = mat.size;
1778 #[rustfmt::skip]
1779 let tmp = [
1780 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1781 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1782 ];
1783 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1784
1785 #[rustfmt::skip]
1786 let tmp = [
1787 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1788 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1789 ];
1790 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1791
1792 let tmp2 = [
1793 mat[l - 11][0],
1794 mat[l - 10][0],
1795 mat[l - 9][0],
1796 mat[l - 11][1],
1797 mat[l - 10][1],
1798 mat[l - 9][1],
1799 mat[l - 11][2],
1800 mat[l - 10][2],
1801 mat[l - 9][2],
1802 mat[l - 11][3],
1803 mat[l - 10][3],
1804 mat[l - 9][3],
1805 mat[l - 11][4],
1806 mat[l - 10][4],
1807 mat[l - 9][4],
1808 mat[l - 11][5],
1809 mat[l - 10][5],
1810 mat[l - 9][5],
1811 ];
1812 assert_eq!(tmp2.map(|x| x.value()), expected2);
1813
1814 let tmp2 = [
1815 mat[0][l - 11],
1816 mat[0][l - 10],
1817 mat[0][l - 9],
1818 mat[1][l - 11],
1819 mat[1][l - 10],
1820 mat[1][l - 9],
1821 mat[2][l - 11],
1822 mat[2][l - 10],
1823 mat[2][l - 9],
1824 mat[3][l - 11],
1825 mat[3][l - 10],
1826 mat[3][l - 9],
1827 mat[4][l - 11],
1828 mat[4][l - 10],
1829 mat[4][l - 9],
1830 mat[5][l - 11],
1831 mat[5][l - 10],
1832 mat[5][l - 9],
1833 ];
1834 assert_eq!(tmp2.map(|x| x.value()), expected2);
1835 }
1836 }
1837
1838 #[test]
1839 fn version_format_m_mask0_version14() {
1840 const CONTENT: &str = "4";
1841 const MASK: Option<Mask> = Some(Mask::Checkerboard);
1842 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V14);
1843 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
1844
1845 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1846 if q.is_err() {
1847 assert_eq!(true, false, "Couldn't create QR");
1848 };
1849 let mat = q.unwrap();
1850
1851 const EXPECTED: [bool; 15] = [
1852 true, false, true, false, true, false, false, false, false, false, true, false, false,
1853 true, false,
1854 ];
1855 let mut expected2: [bool; 18] = [
1856 false, false, true, true, true, false, false, true, true, false, false, false, false,
1857 false, true, true, false, true,
1858 ];
1859 expected2.reverse();
1860
1861 {
1862 let l = mat.size;
1863 #[rustfmt::skip]
1864 let tmp = [
1865 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1866 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1867 ];
1868 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1869
1870 #[rustfmt::skip]
1871 let tmp = [
1872 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1873 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1874 ];
1875 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1876
1877 let tmp2 = [
1878 mat[l - 11][0],
1879 mat[l - 10][0],
1880 mat[l - 9][0],
1881 mat[l - 11][1],
1882 mat[l - 10][1],
1883 mat[l - 9][1],
1884 mat[l - 11][2],
1885 mat[l - 10][2],
1886 mat[l - 9][2],
1887 mat[l - 11][3],
1888 mat[l - 10][3],
1889 mat[l - 9][3],
1890 mat[l - 11][4],
1891 mat[l - 10][4],
1892 mat[l - 9][4],
1893 mat[l - 11][5],
1894 mat[l - 10][5],
1895 mat[l - 9][5],
1896 ];
1897 assert_eq!(tmp2.map(|x| x.value()), expected2);
1898
1899 let tmp2 = [
1900 mat[0][l - 11],
1901 mat[0][l - 10],
1902 mat[0][l - 9],
1903 mat[1][l - 11],
1904 mat[1][l - 10],
1905 mat[1][l - 9],
1906 mat[2][l - 11],
1907 mat[2][l - 10],
1908 mat[2][l - 9],
1909 mat[3][l - 11],
1910 mat[3][l - 10],
1911 mat[3][l - 9],
1912 mat[4][l - 11],
1913 mat[4][l - 10],
1914 mat[4][l - 9],
1915 mat[5][l - 11],
1916 mat[5][l - 10],
1917 mat[5][l - 9],
1918 ];
1919 assert_eq!(tmp2.map(|x| x.value()), expected2);
1920 }
1921 }
1922
1923 #[test]
1924 fn version_format_m_mask1_version30() {
1925 const CONTENT: &str = "4";
1926 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
1927 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V30);
1928 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
1929
1930 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
1931 if q.is_err() {
1932 assert_eq!(true, false, "Couldn't create QR");
1933 };
1934 let mat = q.unwrap();
1935
1936 const EXPECTED: [bool; 15] = [
1937 true, false, true, false, false, false, true, false, false, true, false, false, true,
1938 false, true,
1939 ];
1940 let mut expected2: [bool; 18] = [
1941 false, true, true, true, true, false, true, true, false, true, false, true, true, true,
1942 false, true, false, true,
1943 ];
1944 expected2.reverse();
1945
1946 {
1947 let l = mat.size;
1948 #[rustfmt::skip]
1949 let tmp = [
1950 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
1951 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
1952 ];
1953 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1954
1955 #[rustfmt::skip]
1956 let tmp = [
1957 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
1958 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
1959 ];
1960 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
1961
1962 let tmp2 = [
1963 mat[l - 11][0],
1964 mat[l - 10][0],
1965 mat[l - 9][0],
1966 mat[l - 11][1],
1967 mat[l - 10][1],
1968 mat[l - 9][1],
1969 mat[l - 11][2],
1970 mat[l - 10][2],
1971 mat[l - 9][2],
1972 mat[l - 11][3],
1973 mat[l - 10][3],
1974 mat[l - 9][3],
1975 mat[l - 11][4],
1976 mat[l - 10][4],
1977 mat[l - 9][4],
1978 mat[l - 11][5],
1979 mat[l - 10][5],
1980 mat[l - 9][5],
1981 ];
1982 assert_eq!(tmp2.map(|x| x.value()), expected2);
1983
1984 let tmp2 = [
1985 mat[0][l - 11],
1986 mat[0][l - 10],
1987 mat[0][l - 9],
1988 mat[1][l - 11],
1989 mat[1][l - 10],
1990 mat[1][l - 9],
1991 mat[2][l - 11],
1992 mat[2][l - 10],
1993 mat[2][l - 9],
1994 mat[3][l - 11],
1995 mat[3][l - 10],
1996 mat[3][l - 9],
1997 mat[4][l - 11],
1998 mat[4][l - 10],
1999 mat[4][l - 9],
2000 mat[5][l - 11],
2001 mat[5][l - 10],
2002 mat[5][l - 9],
2003 ];
2004 assert_eq!(tmp2.map(|x| x.value()), expected2);
2005 }
2006 }
2007
2008 #[test]
2009 fn version_format_m_mask2_version37() {
2010 const CONTENT: &str = "4";
2011 const MASK: Option<Mask> = Some(Mask::VerticalLines);
2012 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V37);
2013 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
2014
2015 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2016 if q.is_err() {
2017 assert_eq!(true, false, "Couldn't create QR");
2018 };
2019 let mat = q.unwrap();
2020
2021 const EXPECTED: [bool; 15] = [
2022 true, false, true, true, true, true, false, false, true, true, true, true, true, false,
2023 false,
2024 ];
2025 let mut expected2: [bool; 18] = [
2026 true, false, false, true, false, true, false, true, false, false, false, false, true,
2027 false, true, true, true, false,
2028 ];
2029 expected2.reverse();
2030
2031 {
2032 let l = mat.size;
2033 #[rustfmt::skip]
2034 let tmp = [
2035 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2036 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2037 ];
2038 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2039
2040 #[rustfmt::skip]
2041 let tmp = [
2042 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2043 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2044 ];
2045 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2046
2047 let tmp2 = [
2048 mat[l - 11][0],
2049 mat[l - 10][0],
2050 mat[l - 9][0],
2051 mat[l - 11][1],
2052 mat[l - 10][1],
2053 mat[l - 9][1],
2054 mat[l - 11][2],
2055 mat[l - 10][2],
2056 mat[l - 9][2],
2057 mat[l - 11][3],
2058 mat[l - 10][3],
2059 mat[l - 9][3],
2060 mat[l - 11][4],
2061 mat[l - 10][4],
2062 mat[l - 9][4],
2063 mat[l - 11][5],
2064 mat[l - 10][5],
2065 mat[l - 9][5],
2066 ];
2067 assert_eq!(tmp2.map(|x| x.value()), expected2);
2068
2069 let tmp2 = [
2070 mat[0][l - 11],
2071 mat[0][l - 10],
2072 mat[0][l - 9],
2073 mat[1][l - 11],
2074 mat[1][l - 10],
2075 mat[1][l - 9],
2076 mat[2][l - 11],
2077 mat[2][l - 10],
2078 mat[2][l - 9],
2079 mat[3][l - 11],
2080 mat[3][l - 10],
2081 mat[3][l - 9],
2082 mat[4][l - 11],
2083 mat[4][l - 10],
2084 mat[4][l - 9],
2085 mat[5][l - 11],
2086 mat[5][l - 10],
2087 mat[5][l - 9],
2088 ];
2089 assert_eq!(tmp2.map(|x| x.value()), expected2);
2090 }
2091 }
2092
2093 #[test]
2094 fn version_format_m_mask3_version22() {
2095 const CONTENT: &str = "4";
2096 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
2097 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V22);
2098 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
2099
2100 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2101 if q.is_err() {
2102 assert_eq!(true, false, "Couldn't create QR");
2103 };
2104 let mat = q.unwrap();
2105
2106 const EXPECTED: [bool; 15] = [
2107 true, false, true, true, false, true, true, false, true, false, false, true, false, true,
2108 true,
2109 ];
2110 let mut expected2: [bool; 18] = [
2111 false, true, false, true, true, false, true, false, false, false, true, true, false, false,
2112 true, false, false, true,
2113 ];
2114 expected2.reverse();
2115
2116 {
2117 let l = mat.size;
2118 #[rustfmt::skip]
2119 let tmp = [
2120 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2121 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2122 ];
2123 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2124
2125 #[rustfmt::skip]
2126 let tmp = [
2127 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2128 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2129 ];
2130 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2131
2132 let tmp2 = [
2133 mat[l - 11][0],
2134 mat[l - 10][0],
2135 mat[l - 9][0],
2136 mat[l - 11][1],
2137 mat[l - 10][1],
2138 mat[l - 9][1],
2139 mat[l - 11][2],
2140 mat[l - 10][2],
2141 mat[l - 9][2],
2142 mat[l - 11][3],
2143 mat[l - 10][3],
2144 mat[l - 9][3],
2145 mat[l - 11][4],
2146 mat[l - 10][4],
2147 mat[l - 9][4],
2148 mat[l - 11][5],
2149 mat[l - 10][5],
2150 mat[l - 9][5],
2151 ];
2152 assert_eq!(tmp2.map(|x| x.value()), expected2);
2153
2154 let tmp2 = [
2155 mat[0][l - 11],
2156 mat[0][l - 10],
2157 mat[0][l - 9],
2158 mat[1][l - 11],
2159 mat[1][l - 10],
2160 mat[1][l - 9],
2161 mat[2][l - 11],
2162 mat[2][l - 10],
2163 mat[2][l - 9],
2164 mat[3][l - 11],
2165 mat[3][l - 10],
2166 mat[3][l - 9],
2167 mat[4][l - 11],
2168 mat[4][l - 10],
2169 mat[4][l - 9],
2170 mat[5][l - 11],
2171 mat[5][l - 10],
2172 mat[5][l - 9],
2173 ];
2174 assert_eq!(tmp2.map(|x| x.value()), expected2);
2175 }
2176 }
2177
2178 #[test]
2179 fn version_format_m_mask4_version31() {
2180 const CONTENT: &str = "4";
2181 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
2182 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V31);
2183 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
2184
2185 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2186 if q.is_err() {
2187 assert_eq!(true, false, "Couldn't create QR");
2188 };
2189 let mat = q.unwrap();
2190
2191 const EXPECTED: [bool; 15] = [
2192 true, false, false, false, true, false, true, true, true, true, true, true, false, false,
2193 true,
2194 ];
2195 let mut expected2: [bool; 18] = [
2196 false, true, true, true, true, true, false, false, true, false, false, true, false, true,
2197 false, false, false, false,
2198 ];
2199 expected2.reverse();
2200
2201 {
2202 let l = mat.size;
2203 #[rustfmt::skip]
2204 let tmp = [
2205 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2206 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2207 ];
2208 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2209
2210 #[rustfmt::skip]
2211 let tmp = [
2212 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2213 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2214 ];
2215 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2216
2217 let tmp2 = [
2218 mat[l - 11][0],
2219 mat[l - 10][0],
2220 mat[l - 9][0],
2221 mat[l - 11][1],
2222 mat[l - 10][1],
2223 mat[l - 9][1],
2224 mat[l - 11][2],
2225 mat[l - 10][2],
2226 mat[l - 9][2],
2227 mat[l - 11][3],
2228 mat[l - 10][3],
2229 mat[l - 9][3],
2230 mat[l - 11][4],
2231 mat[l - 10][4],
2232 mat[l - 9][4],
2233 mat[l - 11][5],
2234 mat[l - 10][5],
2235 mat[l - 9][5],
2236 ];
2237 assert_eq!(tmp2.map(|x| x.value()), expected2);
2238
2239 let tmp2 = [
2240 mat[0][l - 11],
2241 mat[0][l - 10],
2242 mat[0][l - 9],
2243 mat[1][l - 11],
2244 mat[1][l - 10],
2245 mat[1][l - 9],
2246 mat[2][l - 11],
2247 mat[2][l - 10],
2248 mat[2][l - 9],
2249 mat[3][l - 11],
2250 mat[3][l - 10],
2251 mat[3][l - 9],
2252 mat[4][l - 11],
2253 mat[4][l - 10],
2254 mat[4][l - 9],
2255 mat[5][l - 11],
2256 mat[5][l - 10],
2257 mat[5][l - 9],
2258 ];
2259 assert_eq!(tmp2.map(|x| x.value()), expected2);
2260 }
2261 }
2262
2263 #[test]
2264 fn version_format_m_mask5_version13() {
2265 const CONTENT: &str = "4";
2266 const MASK: Option<Mask> = Some(Mask::Fields);
2267 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V13);
2268 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
2269
2270 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2271 if q.is_err() {
2272 assert_eq!(true, false, "Couldn't create QR");
2273 };
2274 let mat = q.unwrap();
2275
2276 const EXPECTED: [bool; 15] = [
2277 true, false, false, false, false, false, false, true, true, false, false, true, true, true,
2278 false,
2279 ];
2280 let mut expected2: [bool; 18] = [
2281 false, false, true, true, false, true, true, false, false, false, false, true, false,
2282 false, false, true, true, true,
2283 ];
2284 expected2.reverse();
2285
2286 {
2287 let l = mat.size;
2288 #[rustfmt::skip]
2289 let tmp = [
2290 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2291 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2292 ];
2293 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2294
2295 #[rustfmt::skip]
2296 let tmp = [
2297 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2298 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2299 ];
2300 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2301
2302 let tmp2 = [
2303 mat[l - 11][0],
2304 mat[l - 10][0],
2305 mat[l - 9][0],
2306 mat[l - 11][1],
2307 mat[l - 10][1],
2308 mat[l - 9][1],
2309 mat[l - 11][2],
2310 mat[l - 10][2],
2311 mat[l - 9][2],
2312 mat[l - 11][3],
2313 mat[l - 10][3],
2314 mat[l - 9][3],
2315 mat[l - 11][4],
2316 mat[l - 10][4],
2317 mat[l - 9][4],
2318 mat[l - 11][5],
2319 mat[l - 10][5],
2320 mat[l - 9][5],
2321 ];
2322 assert_eq!(tmp2.map(|x| x.value()), expected2);
2323
2324 let tmp2 = [
2325 mat[0][l - 11],
2326 mat[0][l - 10],
2327 mat[0][l - 9],
2328 mat[1][l - 11],
2329 mat[1][l - 10],
2330 mat[1][l - 9],
2331 mat[2][l - 11],
2332 mat[2][l - 10],
2333 mat[2][l - 9],
2334 mat[3][l - 11],
2335 mat[3][l - 10],
2336 mat[3][l - 9],
2337 mat[4][l - 11],
2338 mat[4][l - 10],
2339 mat[4][l - 9],
2340 mat[5][l - 11],
2341 mat[5][l - 10],
2342 mat[5][l - 9],
2343 ];
2344 assert_eq!(tmp2.map(|x| x.value()), expected2);
2345 }
2346 }
2347
2348 #[test]
2349 fn version_format_m_mask6_version22() {
2350 const CONTENT: &str = "4";
2351 const MASK: Option<Mask> = Some(Mask::Diamonds);
2352 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V22);
2353 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
2354
2355 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2356 if q.is_err() {
2357 assert_eq!(true, false, "Couldn't create QR");
2358 };
2359 let mat = q.unwrap();
2360
2361 const EXPECTED: [bool; 15] = [
2362 true, false, false, true, true, true, true, true, false, false, true, false, true, true,
2363 true,
2364 ];
2365 let mut expected2: [bool; 18] = [
2366 false, true, false, true, true, false, true, false, false, false, true, true, false, false,
2367 true, false, false, true,
2368 ];
2369 expected2.reverse();
2370
2371 {
2372 let l = mat.size;
2373 #[rustfmt::skip]
2374 let tmp = [
2375 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2376 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2377 ];
2378 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2379
2380 #[rustfmt::skip]
2381 let tmp = [
2382 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2383 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2384 ];
2385 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2386
2387 let tmp2 = [
2388 mat[l - 11][0],
2389 mat[l - 10][0],
2390 mat[l - 9][0],
2391 mat[l - 11][1],
2392 mat[l - 10][1],
2393 mat[l - 9][1],
2394 mat[l - 11][2],
2395 mat[l - 10][2],
2396 mat[l - 9][2],
2397 mat[l - 11][3],
2398 mat[l - 10][3],
2399 mat[l - 9][3],
2400 mat[l - 11][4],
2401 mat[l - 10][4],
2402 mat[l - 9][4],
2403 mat[l - 11][5],
2404 mat[l - 10][5],
2405 mat[l - 9][5],
2406 ];
2407 assert_eq!(tmp2.map(|x| x.value()), expected2);
2408
2409 let tmp2 = [
2410 mat[0][l - 11],
2411 mat[0][l - 10],
2412 mat[0][l - 9],
2413 mat[1][l - 11],
2414 mat[1][l - 10],
2415 mat[1][l - 9],
2416 mat[2][l - 11],
2417 mat[2][l - 10],
2418 mat[2][l - 9],
2419 mat[3][l - 11],
2420 mat[3][l - 10],
2421 mat[3][l - 9],
2422 mat[4][l - 11],
2423 mat[4][l - 10],
2424 mat[4][l - 9],
2425 mat[5][l - 11],
2426 mat[5][l - 10],
2427 mat[5][l - 9],
2428 ];
2429 assert_eq!(tmp2.map(|x| x.value()), expected2);
2430 }
2431 }
2432
2433 #[test]
2434 fn version_format_m_mask7_version7() {
2435 const CONTENT: &str = "4";
2436 const MASK: Option<Mask> = Some(Mask::Meadow);
2437 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V07);
2438 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::M);
2439
2440 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2441 if q.is_err() {
2442 assert_eq!(true, false, "Couldn't create QR");
2443 };
2444 let mat = q.unwrap();
2445
2446 const EXPECTED: [bool; 15] = [
2447 true, false, false, true, false, true, false, true, false, true, false, false, false,
2448 false, false,
2449 ];
2450 let mut expected2: [bool; 18] = [
2451 false, false, false, true, true, true, true, true, false, false, true, false, false, true,
2452 false, true, false, false,
2453 ];
2454 expected2.reverse();
2455
2456 {
2457 let l = mat.size;
2458 #[rustfmt::skip]
2459 let tmp = [
2460 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2461 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2462 ];
2463 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2464
2465 #[rustfmt::skip]
2466 let tmp = [
2467 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2468 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2469 ];
2470 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2471
2472 let tmp2 = [
2473 mat[l - 11][0],
2474 mat[l - 10][0],
2475 mat[l - 9][0],
2476 mat[l - 11][1],
2477 mat[l - 10][1],
2478 mat[l - 9][1],
2479 mat[l - 11][2],
2480 mat[l - 10][2],
2481 mat[l - 9][2],
2482 mat[l - 11][3],
2483 mat[l - 10][3],
2484 mat[l - 9][3],
2485 mat[l - 11][4],
2486 mat[l - 10][4],
2487 mat[l - 9][4],
2488 mat[l - 11][5],
2489 mat[l - 10][5],
2490 mat[l - 9][5],
2491 ];
2492 assert_eq!(tmp2.map(|x| x.value()), expected2);
2493
2494 let tmp2 = [
2495 mat[0][l - 11],
2496 mat[0][l - 10],
2497 mat[0][l - 9],
2498 mat[1][l - 11],
2499 mat[1][l - 10],
2500 mat[1][l - 9],
2501 mat[2][l - 11],
2502 mat[2][l - 10],
2503 mat[2][l - 9],
2504 mat[3][l - 11],
2505 mat[3][l - 10],
2506 mat[3][l - 9],
2507 mat[4][l - 11],
2508 mat[4][l - 10],
2509 mat[4][l - 9],
2510 mat[5][l - 11],
2511 mat[5][l - 10],
2512 mat[5][l - 9],
2513 ];
2514 assert_eq!(tmp2.map(|x| x.value()), expected2);
2515 }
2516 }
2517
2518 #[test]
2519 fn version_format_q_mask0_version20() {
2520 const CONTENT: &str = "4";
2521 const MASK: Option<Mask> = Some(Mask::Checkerboard);
2522 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V20);
2523 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
2524
2525 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2526 if q.is_err() {
2527 assert_eq!(true, false, "Couldn't create QR");
2528 };
2529 let mat = q.unwrap();
2530
2531 const EXPECTED: [bool; 15] = [
2532 false, true, true, false, true, false, true, false, true, false, true, true, true, true,
2533 true,
2534 ];
2535 let mut expected2: [bool; 18] = [
2536 false, true, false, true, false, false, true, false, false, true, true, false, true, false,
2537 false, true, true, false,
2538 ];
2539 expected2.reverse();
2540
2541 {
2542 let l = mat.size;
2543 #[rustfmt::skip]
2544 let tmp = [
2545 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2546 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2547 ];
2548 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2549
2550 #[rustfmt::skip]
2551 let tmp = [
2552 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2553 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2554 ];
2555 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2556
2557 let tmp2 = [
2558 mat[l - 11][0],
2559 mat[l - 10][0],
2560 mat[l - 9][0],
2561 mat[l - 11][1],
2562 mat[l - 10][1],
2563 mat[l - 9][1],
2564 mat[l - 11][2],
2565 mat[l - 10][2],
2566 mat[l - 9][2],
2567 mat[l - 11][3],
2568 mat[l - 10][3],
2569 mat[l - 9][3],
2570 mat[l - 11][4],
2571 mat[l - 10][4],
2572 mat[l - 9][4],
2573 mat[l - 11][5],
2574 mat[l - 10][5],
2575 mat[l - 9][5],
2576 ];
2577 assert_eq!(tmp2.map(|x| x.value()), expected2);
2578
2579 let tmp2 = [
2580 mat[0][l - 11],
2581 mat[0][l - 10],
2582 mat[0][l - 9],
2583 mat[1][l - 11],
2584 mat[1][l - 10],
2585 mat[1][l - 9],
2586 mat[2][l - 11],
2587 mat[2][l - 10],
2588 mat[2][l - 9],
2589 mat[3][l - 11],
2590 mat[3][l - 10],
2591 mat[3][l - 9],
2592 mat[4][l - 11],
2593 mat[4][l - 10],
2594 mat[4][l - 9],
2595 mat[5][l - 11],
2596 mat[5][l - 10],
2597 mat[5][l - 9],
2598 ];
2599 assert_eq!(tmp2.map(|x| x.value()), expected2);
2600 }
2601 }
2602
2603 #[test]
2604 fn version_format_q_mask1_version33() {
2605 const CONTENT: &str = "4";
2606 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
2607 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V33);
2608 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
2609
2610 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2611 if q.is_err() {
2612 assert_eq!(true, false, "Couldn't create QR");
2613 };
2614 let mat = q.unwrap();
2615
2616 const EXPECTED: [bool; 15] = [
2617 false, true, true, false, false, false, false, false, true, true, false, true, false,
2618 false, false,
2619 ];
2620 let mut expected2: [bool; 18] = [
2621 true, false, false, false, false, true, false, true, true, false, true, true, true, true,
2622 false, false, false, false,
2623 ];
2624 expected2.reverse();
2625
2626 {
2627 let l = mat.size;
2628 #[rustfmt::skip]
2629 let tmp = [
2630 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2631 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2632 ];
2633 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2634
2635 #[rustfmt::skip]
2636 let tmp = [
2637 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2638 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2639 ];
2640 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2641
2642 let tmp2 = [
2643 mat[l - 11][0],
2644 mat[l - 10][0],
2645 mat[l - 9][0],
2646 mat[l - 11][1],
2647 mat[l - 10][1],
2648 mat[l - 9][1],
2649 mat[l - 11][2],
2650 mat[l - 10][2],
2651 mat[l - 9][2],
2652 mat[l - 11][3],
2653 mat[l - 10][3],
2654 mat[l - 9][3],
2655 mat[l - 11][4],
2656 mat[l - 10][4],
2657 mat[l - 9][4],
2658 mat[l - 11][5],
2659 mat[l - 10][5],
2660 mat[l - 9][5],
2661 ];
2662 assert_eq!(tmp2.map(|x| x.value()), expected2);
2663
2664 let tmp2 = [
2665 mat[0][l - 11],
2666 mat[0][l - 10],
2667 mat[0][l - 9],
2668 mat[1][l - 11],
2669 mat[1][l - 10],
2670 mat[1][l - 9],
2671 mat[2][l - 11],
2672 mat[2][l - 10],
2673 mat[2][l - 9],
2674 mat[3][l - 11],
2675 mat[3][l - 10],
2676 mat[3][l - 9],
2677 mat[4][l - 11],
2678 mat[4][l - 10],
2679 mat[4][l - 9],
2680 mat[5][l - 11],
2681 mat[5][l - 10],
2682 mat[5][l - 9],
2683 ];
2684 assert_eq!(tmp2.map(|x| x.value()), expected2);
2685 }
2686 }
2687
2688 #[test]
2689 fn version_format_q_mask2_version24() {
2690 const CONTENT: &str = "4";
2691 const MASK: Option<Mask> = Some(Mask::VerticalLines);
2692 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V24);
2693 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
2694
2695 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2696 if q.is_err() {
2697 assert_eq!(true, false, "Couldn't create QR");
2698 };
2699 let mat = q.unwrap();
2700
2701 const EXPECTED: [bool; 15] = [
2702 false, true, true, true, true, true, true, false, false, true, true, false, false, false,
2703 true,
2704 ];
2705 let mut expected2: [bool; 18] = [
2706 false, true, true, false, false, false, true, true, true, false, true, true, false, false,
2707 false, true, false, false,
2708 ];
2709 expected2.reverse();
2710
2711 {
2712 let l = mat.size;
2713 #[rustfmt::skip]
2714 let tmp = [
2715 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2716 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2717 ];
2718 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2719
2720 #[rustfmt::skip]
2721 let tmp = [
2722 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2723 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2724 ];
2725 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2726
2727 let tmp2 = [
2728 mat[l - 11][0],
2729 mat[l - 10][0],
2730 mat[l - 9][0],
2731 mat[l - 11][1],
2732 mat[l - 10][1],
2733 mat[l - 9][1],
2734 mat[l - 11][2],
2735 mat[l - 10][2],
2736 mat[l - 9][2],
2737 mat[l - 11][3],
2738 mat[l - 10][3],
2739 mat[l - 9][3],
2740 mat[l - 11][4],
2741 mat[l - 10][4],
2742 mat[l - 9][4],
2743 mat[l - 11][5],
2744 mat[l - 10][5],
2745 mat[l - 9][5],
2746 ];
2747 assert_eq!(tmp2.map(|x| x.value()), expected2);
2748
2749 let tmp2 = [
2750 mat[0][l - 11],
2751 mat[0][l - 10],
2752 mat[0][l - 9],
2753 mat[1][l - 11],
2754 mat[1][l - 10],
2755 mat[1][l - 9],
2756 mat[2][l - 11],
2757 mat[2][l - 10],
2758 mat[2][l - 9],
2759 mat[3][l - 11],
2760 mat[3][l - 10],
2761 mat[3][l - 9],
2762 mat[4][l - 11],
2763 mat[4][l - 10],
2764 mat[4][l - 9],
2765 mat[5][l - 11],
2766 mat[5][l - 10],
2767 mat[5][l - 9],
2768 ];
2769 assert_eq!(tmp2.map(|x| x.value()), expected2);
2770 }
2771 }
2772
2773 #[test]
2774 fn version_format_q_mask3_version18() {
2775 const CONTENT: &str = "4";
2776 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
2777 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V18);
2778 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
2779
2780 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2781 if q.is_err() {
2782 assert_eq!(true, false, "Couldn't create QR");
2783 };
2784 let mat = q.unwrap();
2785
2786 const EXPECTED: [bool; 15] = [
2787 false, true, true, true, false, true, false, false, false, false, false, false, true, true,
2788 false,
2789 ];
2790 let mut expected2: [bool; 18] = [
2791 false, true, false, false, true, false, true, false, true, false, false, false, false,
2792 true, false, true, true, true,
2793 ];
2794 expected2.reverse();
2795
2796 {
2797 let l = mat.size;
2798 #[rustfmt::skip]
2799 let tmp = [
2800 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2801 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2802 ];
2803 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2804
2805 #[rustfmt::skip]
2806 let tmp = [
2807 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2808 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2809 ];
2810 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2811
2812 let tmp2 = [
2813 mat[l - 11][0],
2814 mat[l - 10][0],
2815 mat[l - 9][0],
2816 mat[l - 11][1],
2817 mat[l - 10][1],
2818 mat[l - 9][1],
2819 mat[l - 11][2],
2820 mat[l - 10][2],
2821 mat[l - 9][2],
2822 mat[l - 11][3],
2823 mat[l - 10][3],
2824 mat[l - 9][3],
2825 mat[l - 11][4],
2826 mat[l - 10][4],
2827 mat[l - 9][4],
2828 mat[l - 11][5],
2829 mat[l - 10][5],
2830 mat[l - 9][5],
2831 ];
2832 assert_eq!(tmp2.map(|x| x.value()), expected2);
2833
2834 let tmp2 = [
2835 mat[0][l - 11],
2836 mat[0][l - 10],
2837 mat[0][l - 9],
2838 mat[1][l - 11],
2839 mat[1][l - 10],
2840 mat[1][l - 9],
2841 mat[2][l - 11],
2842 mat[2][l - 10],
2843 mat[2][l - 9],
2844 mat[3][l - 11],
2845 mat[3][l - 10],
2846 mat[3][l - 9],
2847 mat[4][l - 11],
2848 mat[4][l - 10],
2849 mat[4][l - 9],
2850 mat[5][l - 11],
2851 mat[5][l - 10],
2852 mat[5][l - 9],
2853 ];
2854 assert_eq!(tmp2.map(|x| x.value()), expected2);
2855 }
2856 }
2857
2858 #[test]
2859 fn version_format_q_mask4_version31() {
2860 const CONTENT: &str = "4";
2861 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
2862 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V31);
2863 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
2864
2865 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2866 if q.is_err() {
2867 assert_eq!(true, false, "Couldn't create QR");
2868 };
2869 let mat = q.unwrap();
2870
2871 const EXPECTED: [bool; 15] = [
2872 false, true, false, false, true, false, false, true, false, true, true, false, true, false,
2873 false,
2874 ];
2875 let mut expected2: [bool; 18] = [
2876 false, true, true, true, true, true, false, false, true, false, false, true, false, true,
2877 false, false, false, false,
2878 ];
2879 expected2.reverse();
2880
2881 {
2882 let l = mat.size;
2883 #[rustfmt::skip]
2884 let tmp = [
2885 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2886 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2887 ];
2888 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2889
2890 #[rustfmt::skip]
2891 let tmp = [
2892 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2893 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2894 ];
2895 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2896
2897 let tmp2 = [
2898 mat[l - 11][0],
2899 mat[l - 10][0],
2900 mat[l - 9][0],
2901 mat[l - 11][1],
2902 mat[l - 10][1],
2903 mat[l - 9][1],
2904 mat[l - 11][2],
2905 mat[l - 10][2],
2906 mat[l - 9][2],
2907 mat[l - 11][3],
2908 mat[l - 10][3],
2909 mat[l - 9][3],
2910 mat[l - 11][4],
2911 mat[l - 10][4],
2912 mat[l - 9][4],
2913 mat[l - 11][5],
2914 mat[l - 10][5],
2915 mat[l - 9][5],
2916 ];
2917 assert_eq!(tmp2.map(|x| x.value()), expected2);
2918
2919 let tmp2 = [
2920 mat[0][l - 11],
2921 mat[0][l - 10],
2922 mat[0][l - 9],
2923 mat[1][l - 11],
2924 mat[1][l - 10],
2925 mat[1][l - 9],
2926 mat[2][l - 11],
2927 mat[2][l - 10],
2928 mat[2][l - 9],
2929 mat[3][l - 11],
2930 mat[3][l - 10],
2931 mat[3][l - 9],
2932 mat[4][l - 11],
2933 mat[4][l - 10],
2934 mat[4][l - 9],
2935 mat[5][l - 11],
2936 mat[5][l - 10],
2937 mat[5][l - 9],
2938 ];
2939 assert_eq!(tmp2.map(|x| x.value()), expected2);
2940 }
2941 }
2942
2943 #[test]
2944 fn version_format_q_mask5_version17() {
2945 const CONTENT: &str = "4";
2946 const MASK: Option<Mask> = Some(Mask::Fields);
2947 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V17);
2948 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
2949
2950 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
2951 if q.is_err() {
2952 assert_eq!(true, false, "Couldn't create QR");
2953 };
2954 let mat = q.unwrap();
2955
2956 const EXPECTED: [bool; 15] = [
2957 false, true, false, false, false, false, true, true, false, false, false, false, false,
2958 true, true,
2959 ];
2960 let mut expected2: [bool; 18] = [
2961 false, true, false, false, false, true, false, true, false, false, false, true, false,
2962 true, true, true, false, true,
2963 ];
2964 expected2.reverse();
2965
2966 {
2967 let l = mat.size;
2968 #[rustfmt::skip]
2969 let tmp = [
2970 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
2971 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
2972 ];
2973 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2974
2975 #[rustfmt::skip]
2976 let tmp = [
2977 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
2978 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
2979 ];
2980 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
2981
2982 let tmp2 = [
2983 mat[l - 11][0],
2984 mat[l - 10][0],
2985 mat[l - 9][0],
2986 mat[l - 11][1],
2987 mat[l - 10][1],
2988 mat[l - 9][1],
2989 mat[l - 11][2],
2990 mat[l - 10][2],
2991 mat[l - 9][2],
2992 mat[l - 11][3],
2993 mat[l - 10][3],
2994 mat[l - 9][3],
2995 mat[l - 11][4],
2996 mat[l - 10][4],
2997 mat[l - 9][4],
2998 mat[l - 11][5],
2999 mat[l - 10][5],
3000 mat[l - 9][5],
3001 ];
3002 assert_eq!(tmp2.map(|x| x.value()), expected2);
3003
3004 let tmp2 = [
3005 mat[0][l - 11],
3006 mat[0][l - 10],
3007 mat[0][l - 9],
3008 mat[1][l - 11],
3009 mat[1][l - 10],
3010 mat[1][l - 9],
3011 mat[2][l - 11],
3012 mat[2][l - 10],
3013 mat[2][l - 9],
3014 mat[3][l - 11],
3015 mat[3][l - 10],
3016 mat[3][l - 9],
3017 mat[4][l - 11],
3018 mat[4][l - 10],
3019 mat[4][l - 9],
3020 mat[5][l - 11],
3021 mat[5][l - 10],
3022 mat[5][l - 9],
3023 ];
3024 assert_eq!(tmp2.map(|x| x.value()), expected2);
3025 }
3026 }
3027
3028 #[test]
3029 fn version_format_q_mask6_version11() {
3030 const CONTENT: &str = "4";
3031 const MASK: Option<Mask> = Some(Mask::Diamonds);
3032 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V11);
3033 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
3034
3035 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3036 if q.is_err() {
3037 assert_eq!(true, false, "Couldn't create QR");
3038 };
3039 let mat = q.unwrap();
3040
3041 const EXPECTED: [bool; 15] = [
3042 false, true, false, true, true, true, false, true, true, false, true, true, false, true,
3043 false,
3044 ];
3045 let mut expected2: [bool; 18] = [
3046 false, false, true, false, true, true, true, false, true, true, true, true, true, true,
3047 false, true, true, false,
3048 ];
3049 expected2.reverse();
3050
3051 {
3052 let l = mat.size;
3053 #[rustfmt::skip]
3054 let tmp = [
3055 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3056 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3057 ];
3058 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3059
3060 #[rustfmt::skip]
3061 let tmp = [
3062 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3063 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3064 ];
3065 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3066
3067 let tmp2 = [
3068 mat[l - 11][0],
3069 mat[l - 10][0],
3070 mat[l - 9][0],
3071 mat[l - 11][1],
3072 mat[l - 10][1],
3073 mat[l - 9][1],
3074 mat[l - 11][2],
3075 mat[l - 10][2],
3076 mat[l - 9][2],
3077 mat[l - 11][3],
3078 mat[l - 10][3],
3079 mat[l - 9][3],
3080 mat[l - 11][4],
3081 mat[l - 10][4],
3082 mat[l - 9][4],
3083 mat[l - 11][5],
3084 mat[l - 10][5],
3085 mat[l - 9][5],
3086 ];
3087 assert_eq!(tmp2.map(|x| x.value()), expected2);
3088
3089 let tmp2 = [
3090 mat[0][l - 11],
3091 mat[0][l - 10],
3092 mat[0][l - 9],
3093 mat[1][l - 11],
3094 mat[1][l - 10],
3095 mat[1][l - 9],
3096 mat[2][l - 11],
3097 mat[2][l - 10],
3098 mat[2][l - 9],
3099 mat[3][l - 11],
3100 mat[3][l - 10],
3101 mat[3][l - 9],
3102 mat[4][l - 11],
3103 mat[4][l - 10],
3104 mat[4][l - 9],
3105 mat[5][l - 11],
3106 mat[5][l - 10],
3107 mat[5][l - 9],
3108 ];
3109 assert_eq!(tmp2.map(|x| x.value()), expected2);
3110 }
3111 }
3112
3113 #[test]
3114 fn version_format_q_mask7_version15() {
3115 const CONTENT: &str = "4";
3116 const MASK: Option<Mask> = Some(Mask::Meadow);
3117 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V15);
3118 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::Q);
3119
3120 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3121 if q.is_err() {
3122 assert_eq!(true, false, "Couldn't create QR");
3123 };
3124 let mat = q.unwrap();
3125
3126 const EXPECTED: [bool; 15] = [
3127 false, true, false, true, false, true, true, true, true, true, false, true, true, false,
3128 true,
3129 ];
3130 let mut expected2: [bool; 18] = [
3131 false, false, true, true, true, true, true, false, false, true, false, false, true, false,
3132 true, false, false, false,
3133 ];
3134 expected2.reverse();
3135
3136 {
3137 let l = mat.size;
3138 #[rustfmt::skip]
3139 let tmp = [
3140 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3141 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3142 ];
3143 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3144
3145 #[rustfmt::skip]
3146 let tmp = [
3147 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3148 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3149 ];
3150 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3151
3152 let tmp2 = [
3153 mat[l - 11][0],
3154 mat[l - 10][0],
3155 mat[l - 9][0],
3156 mat[l - 11][1],
3157 mat[l - 10][1],
3158 mat[l - 9][1],
3159 mat[l - 11][2],
3160 mat[l - 10][2],
3161 mat[l - 9][2],
3162 mat[l - 11][3],
3163 mat[l - 10][3],
3164 mat[l - 9][3],
3165 mat[l - 11][4],
3166 mat[l - 10][4],
3167 mat[l - 9][4],
3168 mat[l - 11][5],
3169 mat[l - 10][5],
3170 mat[l - 9][5],
3171 ];
3172 assert_eq!(tmp2.map(|x| x.value()), expected2);
3173
3174 let tmp2 = [
3175 mat[0][l - 11],
3176 mat[0][l - 10],
3177 mat[0][l - 9],
3178 mat[1][l - 11],
3179 mat[1][l - 10],
3180 mat[1][l - 9],
3181 mat[2][l - 11],
3182 mat[2][l - 10],
3183 mat[2][l - 9],
3184 mat[3][l - 11],
3185 mat[3][l - 10],
3186 mat[3][l - 9],
3187 mat[4][l - 11],
3188 mat[4][l - 10],
3189 mat[4][l - 9],
3190 mat[5][l - 11],
3191 mat[5][l - 10],
3192 mat[5][l - 9],
3193 ];
3194 assert_eq!(tmp2.map(|x| x.value()), expected2);
3195 }
3196 }
3197
3198 #[test]
3199 fn version_format_h_mask0_version35() {
3200 const CONTENT: &str = "4";
3201 const MASK: Option<Mask> = Some(Mask::Checkerboard);
3202 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V35);
3203 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3204
3205 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3206 if q.is_err() {
3207 assert_eq!(true, false, "Couldn't create QR");
3208 };
3209 let mat = q.unwrap();
3210
3211 const EXPECTED: [bool; 15] = [
3212 false, false, true, false, true, true, false, true, false, false, false, true, false,
3213 false, true,
3214 ];
3215 let mut expected2: [bool; 18] = [
3216 true, false, false, false, true, true, false, true, true, true, true, false, false, true,
3217 true, true, true, true,
3218 ];
3219 expected2.reverse();
3220
3221 {
3222 let l = mat.size;
3223 #[rustfmt::skip]
3224 let tmp = [
3225 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3226 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3227 ];
3228 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3229
3230 #[rustfmt::skip]
3231 let tmp = [
3232 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3233 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3234 ];
3235 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3236
3237 let tmp2 = [
3238 mat[l - 11][0],
3239 mat[l - 10][0],
3240 mat[l - 9][0],
3241 mat[l - 11][1],
3242 mat[l - 10][1],
3243 mat[l - 9][1],
3244 mat[l - 11][2],
3245 mat[l - 10][2],
3246 mat[l - 9][2],
3247 mat[l - 11][3],
3248 mat[l - 10][3],
3249 mat[l - 9][3],
3250 mat[l - 11][4],
3251 mat[l - 10][4],
3252 mat[l - 9][4],
3253 mat[l - 11][5],
3254 mat[l - 10][5],
3255 mat[l - 9][5],
3256 ];
3257 assert_eq!(tmp2.map(|x| x.value()), expected2);
3258
3259 let tmp2 = [
3260 mat[0][l - 11],
3261 mat[0][l - 10],
3262 mat[0][l - 9],
3263 mat[1][l - 11],
3264 mat[1][l - 10],
3265 mat[1][l - 9],
3266 mat[2][l - 11],
3267 mat[2][l - 10],
3268 mat[2][l - 9],
3269 mat[3][l - 11],
3270 mat[3][l - 10],
3271 mat[3][l - 9],
3272 mat[4][l - 11],
3273 mat[4][l - 10],
3274 mat[4][l - 9],
3275 mat[5][l - 11],
3276 mat[5][l - 10],
3277 mat[5][l - 9],
3278 ];
3279 assert_eq!(tmp2.map(|x| x.value()), expected2);
3280 }
3281 }
3282
3283 #[test]
3284 fn version_format_h_mask1_version15() {
3285 const CONTENT: &str = "4";
3286 const MASK: Option<Mask> = Some(Mask::HorizontalLines);
3287 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V15);
3288 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3289
3290 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3291 if q.is_err() {
3292 assert_eq!(true, false, "Couldn't create QR");
3293 };
3294 let mat = q.unwrap();
3295
3296 const EXPECTED: [bool; 15] = [
3297 false, false, true, false, false, true, true, true, false, true, true, true, true, true,
3298 false,
3299 ];
3300 let mut expected2: [bool; 18] = [
3301 false, false, true, true, true, true, true, false, false, true, false, false, true, false,
3302 true, false, false, false,
3303 ];
3304 expected2.reverse();
3305
3306 {
3307 let l = mat.size;
3308 #[rustfmt::skip]
3309 let tmp = [
3310 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3311 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3312 ];
3313 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3314
3315 #[rustfmt::skip]
3316 let tmp = [
3317 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3318 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3319 ];
3320 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3321
3322 let tmp2 = [
3323 mat[l - 11][0],
3324 mat[l - 10][0],
3325 mat[l - 9][0],
3326 mat[l - 11][1],
3327 mat[l - 10][1],
3328 mat[l - 9][1],
3329 mat[l - 11][2],
3330 mat[l - 10][2],
3331 mat[l - 9][2],
3332 mat[l - 11][3],
3333 mat[l - 10][3],
3334 mat[l - 9][3],
3335 mat[l - 11][4],
3336 mat[l - 10][4],
3337 mat[l - 9][4],
3338 mat[l - 11][5],
3339 mat[l - 10][5],
3340 mat[l - 9][5],
3341 ];
3342 assert_eq!(tmp2.map(|x| x.value()), expected2);
3343
3344 let tmp2 = [
3345 mat[0][l - 11],
3346 mat[0][l - 10],
3347 mat[0][l - 9],
3348 mat[1][l - 11],
3349 mat[1][l - 10],
3350 mat[1][l - 9],
3351 mat[2][l - 11],
3352 mat[2][l - 10],
3353 mat[2][l - 9],
3354 mat[3][l - 11],
3355 mat[3][l - 10],
3356 mat[3][l - 9],
3357 mat[4][l - 11],
3358 mat[4][l - 10],
3359 mat[4][l - 9],
3360 mat[5][l - 11],
3361 mat[5][l - 10],
3362 mat[5][l - 9],
3363 ];
3364 assert_eq!(tmp2.map(|x| x.value()), expected2);
3365 }
3366 }
3367
3368 #[test]
3369 fn version_format_h_mask2_version15() {
3370 const CONTENT: &str = "4";
3371 const MASK: Option<Mask> = Some(Mask::VerticalLines);
3372 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V15);
3373 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3374
3375 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3376 if q.is_err() {
3377 assert_eq!(true, false, "Couldn't create QR");
3378 };
3379 let mat = q.unwrap();
3380
3381 const EXPECTED: [bool; 15] = [
3382 false, false, true, true, true, false, false, true, true, true, false, false, true, true,
3383 true,
3384 ];
3385 let mut expected2: [bool; 18] = [
3386 false, false, true, true, true, true, true, false, false, true, false, false, true, false,
3387 true, false, false, false,
3388 ];
3389 expected2.reverse();
3390
3391 {
3392 let l = mat.size;
3393 #[rustfmt::skip]
3394 let tmp = [
3395 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3396 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3397 ];
3398 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3399
3400 #[rustfmt::skip]
3401 let tmp = [
3402 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3403 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3404 ];
3405 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3406
3407 let tmp2 = [
3408 mat[l - 11][0],
3409 mat[l - 10][0],
3410 mat[l - 9][0],
3411 mat[l - 11][1],
3412 mat[l - 10][1],
3413 mat[l - 9][1],
3414 mat[l - 11][2],
3415 mat[l - 10][2],
3416 mat[l - 9][2],
3417 mat[l - 11][3],
3418 mat[l - 10][3],
3419 mat[l - 9][3],
3420 mat[l - 11][4],
3421 mat[l - 10][4],
3422 mat[l - 9][4],
3423 mat[l - 11][5],
3424 mat[l - 10][5],
3425 mat[l - 9][5],
3426 ];
3427 assert_eq!(tmp2.map(|x| x.value()), expected2);
3428
3429 let tmp2 = [
3430 mat[0][l - 11],
3431 mat[0][l - 10],
3432 mat[0][l - 9],
3433 mat[1][l - 11],
3434 mat[1][l - 10],
3435 mat[1][l - 9],
3436 mat[2][l - 11],
3437 mat[2][l - 10],
3438 mat[2][l - 9],
3439 mat[3][l - 11],
3440 mat[3][l - 10],
3441 mat[3][l - 9],
3442 mat[4][l - 11],
3443 mat[4][l - 10],
3444 mat[4][l - 9],
3445 mat[5][l - 11],
3446 mat[5][l - 10],
3447 mat[5][l - 9],
3448 ];
3449 assert_eq!(tmp2.map(|x| x.value()), expected2);
3450 }
3451 }
3452
3453 #[test]
3454 fn version_format_h_mask3_version7() {
3455 const CONTENT: &str = "4";
3456 const MASK: Option<Mask> = Some(Mask::DiagonalLines);
3457 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V07);
3458 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3459
3460 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3461 if q.is_err() {
3462 assert_eq!(true, false, "Couldn't create QR");
3463 };
3464 let mat = q.unwrap();
3465
3466 const EXPECTED: [bool; 15] = [
3467 false, false, true, true, false, false, true, true, true, false, true, false, false, false,
3468 false,
3469 ];
3470 let mut expected2: [bool; 18] = [
3471 false, false, false, true, true, true, true, true, false, false, true, false, false, true,
3472 false, true, false, false,
3473 ];
3474 expected2.reverse();
3475
3476 {
3477 let l = mat.size;
3478 #[rustfmt::skip]
3479 let tmp = [
3480 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3481 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3482 ];
3483 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3484
3485 #[rustfmt::skip]
3486 let tmp = [
3487 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3488 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3489 ];
3490 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3491
3492 let tmp2 = [
3493 mat[l - 11][0],
3494 mat[l - 10][0],
3495 mat[l - 9][0],
3496 mat[l - 11][1],
3497 mat[l - 10][1],
3498 mat[l - 9][1],
3499 mat[l - 11][2],
3500 mat[l - 10][2],
3501 mat[l - 9][2],
3502 mat[l - 11][3],
3503 mat[l - 10][3],
3504 mat[l - 9][3],
3505 mat[l - 11][4],
3506 mat[l - 10][4],
3507 mat[l - 9][4],
3508 mat[l - 11][5],
3509 mat[l - 10][5],
3510 mat[l - 9][5],
3511 ];
3512 assert_eq!(tmp2.map(|x| x.value()), expected2);
3513
3514 let tmp2 = [
3515 mat[0][l - 11],
3516 mat[0][l - 10],
3517 mat[0][l - 9],
3518 mat[1][l - 11],
3519 mat[1][l - 10],
3520 mat[1][l - 9],
3521 mat[2][l - 11],
3522 mat[2][l - 10],
3523 mat[2][l - 9],
3524 mat[3][l - 11],
3525 mat[3][l - 10],
3526 mat[3][l - 9],
3527 mat[4][l - 11],
3528 mat[4][l - 10],
3529 mat[4][l - 9],
3530 mat[5][l - 11],
3531 mat[5][l - 10],
3532 mat[5][l - 9],
3533 ];
3534 assert_eq!(tmp2.map(|x| x.value()), expected2);
3535 }
3536 }
3537
3538 #[test]
3539 fn version_format_h_mask4_version7() {
3540 const CONTENT: &str = "4";
3541 const MASK: Option<Mask> = Some(Mask::LargeCheckerboard);
3542 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V07);
3543 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3544
3545 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3546 if q.is_err() {
3547 assert_eq!(true, false, "Couldn't create QR");
3548 };
3549 let mat = q.unwrap();
3550
3551 const EXPECTED: [bool; 15] = [
3552 false, false, false, false, true, true, true, false, true, true, false, false, false, true,
3553 false,
3554 ];
3555 let mut expected2: [bool; 18] = [
3556 false, false, false, true, true, true, true, true, false, false, true, false, false, true,
3557 false, true, false, false,
3558 ];
3559 expected2.reverse();
3560
3561 {
3562 let l = mat.size;
3563 #[rustfmt::skip]
3564 let tmp = [
3565 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3566 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3567 ];
3568 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3569
3570 #[rustfmt::skip]
3571 let tmp = [
3572 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3573 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3574 ];
3575 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3576
3577 let tmp2 = [
3578 mat[l - 11][0],
3579 mat[l - 10][0],
3580 mat[l - 9][0],
3581 mat[l - 11][1],
3582 mat[l - 10][1],
3583 mat[l - 9][1],
3584 mat[l - 11][2],
3585 mat[l - 10][2],
3586 mat[l - 9][2],
3587 mat[l - 11][3],
3588 mat[l - 10][3],
3589 mat[l - 9][3],
3590 mat[l - 11][4],
3591 mat[l - 10][4],
3592 mat[l - 9][4],
3593 mat[l - 11][5],
3594 mat[l - 10][5],
3595 mat[l - 9][5],
3596 ];
3597 assert_eq!(tmp2.map(|x| x.value()), expected2);
3598
3599 let tmp2 = [
3600 mat[0][l - 11],
3601 mat[0][l - 10],
3602 mat[0][l - 9],
3603 mat[1][l - 11],
3604 mat[1][l - 10],
3605 mat[1][l - 9],
3606 mat[2][l - 11],
3607 mat[2][l - 10],
3608 mat[2][l - 9],
3609 mat[3][l - 11],
3610 mat[3][l - 10],
3611 mat[3][l - 9],
3612 mat[4][l - 11],
3613 mat[4][l - 10],
3614 mat[4][l - 9],
3615 mat[5][l - 11],
3616 mat[5][l - 10],
3617 mat[5][l - 9],
3618 ];
3619 assert_eq!(tmp2.map(|x| x.value()), expected2);
3620 }
3621 }
3622
3623 #[test]
3624 fn version_format_h_mask5_version20() {
3625 const CONTENT: &str = "4";
3626 const MASK: Option<Mask> = Some(Mask::Fields);
3627 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V20);
3628 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3629
3630 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3631 if q.is_err() {
3632 assert_eq!(true, false, "Couldn't create QR");
3633 };
3634 let mat = q.unwrap();
3635
3636 const EXPECTED: [bool; 15] = [
3637 false, false, false, false, false, true, false, false, true, false, true, false, true,
3638 false, true,
3639 ];
3640 let mut expected2: [bool; 18] = [
3641 false, true, false, true, false, false, true, false, false, true, true, false, true, false,
3642 false, true, true, false,
3643 ];
3644 expected2.reverse();
3645
3646 {
3647 let l = mat.size;
3648 #[rustfmt::skip]
3649 let tmp = [
3650 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3651 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3652 ];
3653 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3654
3655 #[rustfmt::skip]
3656 let tmp = [
3657 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3658 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3659 ];
3660 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3661
3662 let tmp2 = [
3663 mat[l - 11][0],
3664 mat[l - 10][0],
3665 mat[l - 9][0],
3666 mat[l - 11][1],
3667 mat[l - 10][1],
3668 mat[l - 9][1],
3669 mat[l - 11][2],
3670 mat[l - 10][2],
3671 mat[l - 9][2],
3672 mat[l - 11][3],
3673 mat[l - 10][3],
3674 mat[l - 9][3],
3675 mat[l - 11][4],
3676 mat[l - 10][4],
3677 mat[l - 9][4],
3678 mat[l - 11][5],
3679 mat[l - 10][5],
3680 mat[l - 9][5],
3681 ];
3682 assert_eq!(tmp2.map(|x| x.value()), expected2);
3683
3684 let tmp2 = [
3685 mat[0][l - 11],
3686 mat[0][l - 10],
3687 mat[0][l - 9],
3688 mat[1][l - 11],
3689 mat[1][l - 10],
3690 mat[1][l - 9],
3691 mat[2][l - 11],
3692 mat[2][l - 10],
3693 mat[2][l - 9],
3694 mat[3][l - 11],
3695 mat[3][l - 10],
3696 mat[3][l - 9],
3697 mat[4][l - 11],
3698 mat[4][l - 10],
3699 mat[4][l - 9],
3700 mat[5][l - 11],
3701 mat[5][l - 10],
3702 mat[5][l - 9],
3703 ];
3704 assert_eq!(tmp2.map(|x| x.value()), expected2);
3705 }
3706 }
3707
3708 #[test]
3709 fn version_format_h_mask6_version20() {
3710 const CONTENT: &str = "4";
3711 const MASK: Option<Mask> = Some(Mask::Diamonds);
3712 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V20);
3713 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3714
3715 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3716 if q.is_err() {
3717 assert_eq!(true, false, "Couldn't create QR");
3718 };
3719 let mat = q.unwrap();
3720
3721 const EXPECTED: [bool; 15] = [
3722 false, false, false, true, true, false, true, false, false, false, false, true, true,
3723 false, false,
3724 ];
3725 let mut expected2: [bool; 18] = [
3726 false, true, false, true, false, false, true, false, false, true, true, false, true, false,
3727 false, true, true, false,
3728 ];
3729 expected2.reverse();
3730
3731 {
3732 let l = mat.size;
3733 #[rustfmt::skip]
3734 let tmp = [
3735 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3736 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3737 ];
3738 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3739
3740 #[rustfmt::skip]
3741 let tmp = [
3742 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3743 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3744 ];
3745 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3746
3747 let tmp2 = [
3748 mat[l - 11][0],
3749 mat[l - 10][0],
3750 mat[l - 9][0],
3751 mat[l - 11][1],
3752 mat[l - 10][1],
3753 mat[l - 9][1],
3754 mat[l - 11][2],
3755 mat[l - 10][2],
3756 mat[l - 9][2],
3757 mat[l - 11][3],
3758 mat[l - 10][3],
3759 mat[l - 9][3],
3760 mat[l - 11][4],
3761 mat[l - 10][4],
3762 mat[l - 9][4],
3763 mat[l - 11][5],
3764 mat[l - 10][5],
3765 mat[l - 9][5],
3766 ];
3767 assert_eq!(tmp2.map(|x| x.value()), expected2);
3768
3769 let tmp2 = [
3770 mat[0][l - 11],
3771 mat[0][l - 10],
3772 mat[0][l - 9],
3773 mat[1][l - 11],
3774 mat[1][l - 10],
3775 mat[1][l - 9],
3776 mat[2][l - 11],
3777 mat[2][l - 10],
3778 mat[2][l - 9],
3779 mat[3][l - 11],
3780 mat[3][l - 10],
3781 mat[3][l - 9],
3782 mat[4][l - 11],
3783 mat[4][l - 10],
3784 mat[4][l - 9],
3785 mat[5][l - 11],
3786 mat[5][l - 10],
3787 mat[5][l - 9],
3788 ];
3789 assert_eq!(tmp2.map(|x| x.value()), expected2);
3790 }
3791 }
3792
3793 #[test]
3794 fn version_format_h_mask7_version17() {
3795 const CONTENT: &str = "4";
3796 const MASK: Option<Mask> = Some(Mask::Meadow);
3797 const VERSION: Option<crate::version::Version> = Some(crate::version::Version::V17);
3798 const LEVEL: Option<crate::ecl::ECL> = Some(crate::ecl::ECL::H);
3799
3800 let q = QRCode::new(CONTENT.as_bytes(), LEVEL, VERSION, None, MASK);
3801 if q.is_err() {
3802 assert_eq!(true, false, "Couldn't create QR");
3803 };
3804 let mat = q.unwrap();
3805
3806 const EXPECTED: [bool; 15] = [
3807 false, false, false, true, false, false, false, false, false, true, true, true, false,
3808 true, true,
3809 ];
3810 let mut expected2: [bool; 18] = [
3811 false, true, false, false, false, true, false, true, false, false, false, true, false,
3812 true, true, true, false, true,
3813 ];
3814 expected2.reverse();
3815
3816 {
3817 let l = mat.size;
3818 #[rustfmt::skip]
3819 let tmp = [
3820 mat[l - 1][8], mat[l - 2][8], mat[l - 3][8], mat[l - 4][8], mat[l - 5][8], mat[l - 6][8], mat[l - 7][8],
3821 mat[8][l - 8], mat[8][l - 7], mat[8][l - 6], mat[8][l - 5], mat[8][l - 4], mat[8][l - 3], mat[8][l - 2], mat[8][l - 1]
3822 ];
3823 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3824
3825 #[rustfmt::skip]
3826 let tmp = [
3827 mat[8][0], mat[8][1], mat[8][2], mat[8][3], mat[8][4], mat[8][5], mat[8][7], mat[8][8],
3828 mat[7][8], mat[5][8], mat[4][8], mat[3][8], mat[2][8], mat[1][8], mat[0][8],
3829 ];
3830 assert_eq!(tmp.map(|x| x.value()), EXPECTED);
3831
3832 let tmp2 = [
3833 mat[l - 11][0],
3834 mat[l - 10][0],
3835 mat[l - 9][0],
3836 mat[l - 11][1],
3837 mat[l - 10][1],
3838 mat[l - 9][1],
3839 mat[l - 11][2],
3840 mat[l - 10][2],
3841 mat[l - 9][2],
3842 mat[l - 11][3],
3843 mat[l - 10][3],
3844 mat[l - 9][3],
3845 mat[l - 11][4],
3846 mat[l - 10][4],
3847 mat[l - 9][4],
3848 mat[l - 11][5],
3849 mat[l - 10][5],
3850 mat[l - 9][5],
3851 ];
3852 assert_eq!(tmp2.map(|x| x.value()), expected2);
3853
3854 let tmp2 = [
3855 mat[0][l - 11],
3856 mat[0][l - 10],
3857 mat[0][l - 9],
3858 mat[1][l - 11],
3859 mat[1][l - 10],
3860 mat[1][l - 9],
3861 mat[2][l - 11],
3862 mat[2][l - 10],
3863 mat[2][l - 9],
3864 mat[3][l - 11],
3865 mat[3][l - 10],
3866 mat[3][l - 9],
3867 mat[4][l - 11],
3868 mat[4][l - 10],
3869 mat[4][l - 9],
3870 mat[5][l - 11],
3871 mat[5][l - 10],
3872 mat[5][l - 9],
3873 ];
3874 assert_eq!(tmp2.map(|x| x.value()), expected2);
3875 }
3876 }