Skip to content

Commit a789b30

Browse files
committed
Add debugecc option and regression tests for RSEC paths
1 parent 9d9d2fa commit a789b30

15 files changed

Lines changed: 279 additions & 3 deletions

src/azteccode.ps.src

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,13 @@ begin
992992
%
993993
% Extend the data codewords with error correction codewords to create the bit string for the data
994994
%
995-
/cws cws ncws cws length sub bpcw rscodes def
995+
/ecws cws ncws cws length sub bpcw rscodes def
996+
997+
options /debugecc known
998+
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
999+
and { /bwipp.debugecc ecws cws length ecws length cws length sub getinterval //raiseerror exec } if
1000+
1001+
/cws ecws def
9961002
format (full) eq {
9971003
/databits layers layers mul 16 mul layers 112 mul add string def
9981004
} {

src/codeone.ps.src

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,10 @@ begin
11271127
ecbs i rscws dcpb ecpb getinterval put
11281128
} for
11291129

1130+
options /debugecc known
1131+
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
1132+
and { /bwipp.debugecc [ ecbs {aload pop} forall ] //raiseerror exec } if
1133+
11301134
%
11311135
% Extend codewords with the interleaved error correction codes
11321136
%

src/datamatrix.ps.src

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,10 @@ begin
10841084
] def
10851085
} if
10861086

1087+
options /debugecc known
1088+
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
1089+
and { /bwipp.debugecc [ ecbs {aload pop} forall ] //raiseerror exec } if
1090+
10871091
%
10881092
% Extend codewords with the interleaved error correction codes
10891093
%

src/dotcode.ps.src

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,10 @@ begin
12001200

12011201
} for
12021202

1203+
options /debugecc known
1204+
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
1205+
and { /bwipp.debugecc rscws //raiseerror exec } if
1206+
12031207
(matrix.layout) //dotcode.before exec
12041208

12051209
%

src/hanxin.ps.src

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,10 @@ begin
814814
/in in e3dcws add def /out out 1 add def
815815
} repeat
816816

817+
options /debugecc known
818+
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
819+
and { /bwipp.debugecc [ ecwsb {aload pop} forall ] //raiseerror exec } if
820+
817821
(codewords.finalise) //hanxin.before exec
818822

819823
%

src/maxicode.ps.src

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,13 @@ begin
11131113
/secchk [ 0 1 scodes 1 sub { dup secochk exch get exch secechk exch get } for ] def
11141114

11151115
%
1116-
% Concatenate the data into final codewords
1116+
% Compute primary parity and concatenate the data into final codewords
11171117
%
1118+
/prichk pri 10 rscodes exec def
1119+
11181120
/codewords [
11191121
pri aload pop
1120-
pri 10 rscodes exec aload pop
1122+
prichk aload pop
11211123
sec aload pop
11221124
secchk aload pop
11231125
] def
@@ -1126,6 +1128,10 @@ begin
11261128
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
11271129
and { /bwipp.debugcws codewords //raiseerror exec } if
11281130

1131+
options /debugecc known
1132+
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
1133+
and { /bwipp.debugecc [ prichk aload pop secchk aload pop ] //raiseerror exec } if
1134+
11291135
(ecc.cws) //maxicode.after exec
11301136

11311137
(matrix.layout) //maxicode.before exec

tests/ps_tests/azteccode.ps.test

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,49 @@
1111

1212
/azteccode dup /uk.co.terryburton.bwipp findresource cvx def
1313

14+
% ECC check: error correction codewords for the data stream.
15+
% compact layers=1 uses bpcw=6 (GF 64).
16+
{
17+
(Aztec) (format=compact debugecc) azteccode
18+
} [46 34 26 4 41 36 60 18 32 49 20 60] debugIsEqual
19+
20+
% ECC check: full layers=3 uses bpcw=8 (GF 256).
21+
{
22+
(Aztec full) (format=full layers=3 debugecc) azteccode
23+
} [
24+
121 34 121 11 162 33 210 190 97 25 208 8 178 121 36
25+
191 192 25 249 167 26 217 47 65 166 76 88 162 251 188
26+
12 79 35 246 111 133 236 53 192 82 132 195 39 137 61
27+
180 228 66 102 78 89 159 22
28+
] debugIsEqual
29+
30+
% ECC check: full layers=10 uses bpcw=10 (GF 1024).
31+
{
32+
(Aztec big) (format=full layers=10 debugecc) azteccode
33+
} [
34+
154 433 456 972 906 104 413 47 324 2 1003 761 593 91 931
35+
830 854 919 898 18 401 15 811 681 666 391 1009 781 236 138
36+
116 489 840 132 730 839 107 130 722 816 793 353 863 97 767
37+
37 458 645 673 884 680 465 226 565 71 188 517 833 55 929
38+
444 180 151 934 425 567 755 757 585 147 274 640 329 777 970
39+
697 609 83 504 929 169 950 981 524 364 219 180 595 90 953
40+
823 208 613 238 439 682 666 917 288 160 606 143 993 617 27
41+
576 896 452 896 87 60 719 167 667 788 587 446 497 489 936
42+
40 91 382 789 708 730 326 279 297 14 531 98 902 140 61
43+
821 812 439 158 304 985 571 1020 712 868 796 633 430 132 899
44+
351 97 398 235 360 39 716 815 264 631 647 901 846 56 915
45+
250 516 155 348 612 155 355 988 512 585 136 11 203 521 491
46+
611 63 946 310 643 273 515 917 818 20 178 595 331 288 608
47+
814 709 806 705 903 612 297 855 961 134 641 424 631 372 386
48+
379 502 566 487 600 270 532 49 993 554 918 975 493 969 249
49+
415 438 190 471 602 993 111 41 962 629 994 39 609 328 97
50+
478 605 681 70 532 13 131 939 533 646 320 82 396 779 179
51+
295 453 194 333 987 290 512 656 400 572 1023 179
52+
] debugIsEqual
53+
54+
% ECC check: rune format has no main-cws ECC pass (ncws=0), so empty array.
55+
{ (42) (format=rune debugecc) azteccode } [] debugIsEqual
56+
1457
/_bitsEqual {
1558
% Stack: errorname errorinfo (expected)
1659
ne {/testError pstack quit} if

tests/ps_tests/codeone.ps.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111

1212
/codeone dup /uk.co.terryburton.bwipp findresource cvx def
1313

14+
% ECC check: flat concat of per-block ECC codewords (ecbs). Version B uses rsbl=2.
15+
{
16+
(TESTING 123) (version=B debugecc) codeone
17+
} [7 248 244 66 132 61 242 13 72 183 231 84 75 96 176 166] debugIsEqual
18+
19+
% ECC check: T-32 (truncated) variant.
20+
/coT32data 30 string def 0 1 29 { coT32data exch 65 put } for
21+
{
22+
coT32data (version=T-32 debugecc) codeone
23+
} [174 132 164 249 157 181 7 170 101 58 195 217 144 3 84 105] debugIsEqual
24+
25+
% ECC check: S-20 uses 5-bit GF(32) codewords (digit-packing symbology).
26+
{
27+
(12345678) (version=S-20 debugecc) codeone
28+
} [27 19 21 1 28 15 27 26] debugIsEqual
29+
1430
/er_tmpl {
1531
3 1 roll { 0 0 codeone }
1632
dup 3 -1 roll 1 exch put

tests/ps_tests/datamatrix.ps.test

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,58 @@
88

99
/datamatrix dup /uk.co.terryburton.bwipp findresource cvx def
1010

11+
% ECC check: flat concat of per-block ECC codewords (ecbs, post-v144-fixup if applicable).
12+
{
13+
(TEST) (version=12x12 debugecc) datamatrix
14+
} [125 231 139 243 125 208 115] debugIsEqual
15+
16+
% ECC check: 32x32 is multi-block (rsbl > 1).
17+
{
18+
(ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789) (version=32x32 debugecc) datamatrix
19+
} [
20+
29 28 34 181 198 186 38 222 17 155 153 139 108 163 119 199 172 177 78
21+
180 74 224 109 194 122 190 143 226 80 96 58 88 228 144 88 201
22+
] debugIsEqual
23+
24+
% ECC check: 144x144 triggers the v144 fixup (ecbs[8..9] reshuffled ahead of [0..7]).
25+
% Input is 1000 'A' codewords.
26+
/dm144data 1000 string def 0 1 999 { dm144data exch 65 put } for
27+
{
28+
dm144data (version=144x144 debugecc) datamatrix
29+
} [
30+
232 110 83 28 200 76 106 115 62 220 240 114 92 161 242 42 133 141 226 62
31+
59 65 231 184 41 26 43 12 72 243 96 161 43 233 46 243 178 169 174 69
32+
115 89 243 112 186 136 239 136 21 203 230 118 216 235 104 160 76 131 173 38
33+
59 147 123 60 246 127 158 233 210 177 149 38 128 185 198 211 76 33 181 244
34+
99 201 43 9 239 227 117 162 69 156 72 156 41 141 174 59 187 59 208 60
35+
74 86 187 241 89 3 135 45 208 83 65 11 132 174 177 42 224 70 202 178
36+
113 167 230 101 172 93 59 18 149 36 209 14 62 246 41 11 146 34 59 186
37+
74 243 82 198 102 225 217 197 214 3 243 169 185 137 203 238 143 37 146 25
38+
78 50 84 78 137 138 9 60 159 193 91 109 104 125 114 89 98 14 135 241
39+
210 41 48 12 224 124 10 141 68 232 218 140 22 196 5 92 145 126 122 251
40+
25 61 73 151 158 3 14 70 119 169 182 207 41 77 18 149 170 26 107 151
41+
68 242 241 13 150 45 206 102 70 222 250 182 168 249 219 64 59 158 201 38
42+
47 119 25 237 229 99 3 61 213 114 10 165 90 130 82 163 73 255 203 217
43+
9 38 181 92 165 240 65 19 250 66 129 165 202 128 75 105 190 176 28 148
44+
176 55 231 79 88 189 207 223 13 117 133 90 21 180 234 6 219 36 210 219
45+
61 158 42 165 49 138 17 203 174 211 47 41 55 91 143 31 220 148 48 136
46+
237 154 48 13 171 193 221 54 218 245 7 46 219 56 109 112 194 52 56 14
47+
197 171 10 97 105 90 44 115 53 12 105 53 3 10 153 169 209 86 155 133
48+
167 23 30 48 32 134 248 47 158 166 123 69 192 114 119 192 143 214 237 211
49+
121 213 225 112 158 25 117 226 147 43 27 238 193 244 202 98 158 255 81 50
50+
118 93 141 36 219 67 232 152 13 4 134 200 82 144 148 22 187 27 147 63
51+
50 47 89 28 66 60 17 154 30 33 105 178 110 164 124 7 187 252 14 215
52+
49 11 79 237 95 130 53 33 136 234 51 213 180 142 250 34 135 96 160 200
53+
199 40 160 80 240 172 93 199 16 227 100 128 75 64 135 171 140 144 194 133
54+
194 173 182 23 78 255 23 194 250 89 104 217 250 42 94 183 25 222 180 248
55+
107 102 242 145 114 165 144 247 17 68 210 119 205 9 126 217 153 49 229 176
56+
50 246 106 57 233 162 182 112 237 156 11 230 202 82 66 42 135 39 151 128
57+
96 175 170 48 205 78 26 19 192 239 8 213 149 106 31 42 80 212 34 15
58+
176 224 226 20 245 11 238 46 216 85 113 5 179 252 10 10 199 41 20 80
59+
26 96 235 101 70 26 82 22 29 222 203 121 37 225 232 250 43 182 110 150
60+
245 48 51 4 197 11 78 161 222 14 136 2 187 194 233 249 131 87 243 215
61+
] debugIsEqual
62+
1163
/er_tmpl {
1264
3 1 roll { 0 0 datamatrix }
1365
dup 3 -1 roll 1 exch put

tests/ps_tests/dotcode.ps.test

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,46 @@
5858
(^128^128a) (parse debugcws) dotcode % Binary latch ending in single non-binary
5959
} [112 3 14 11 110 65] debugIsEqual
6060

61+
% ECC check: step=1 (no interleaving). rscws layout = [mask, mixed_cws ..., ECC ...].
62+
% mask forced for deterministic output.
63+
{
64+
(2741) (mask=0 debugecc) dotcode
65+
} [0 107 27 41 85 10 91 83] debugIsEqual
66+
67+
% ECC check: step=2 (112 <= nw < 224): 2-way interleaved RSEC. 80 'A' chars -> nw=125.
68+
/dc2data 80 string def 0 1 79 { dc2data exch 65 put } for
69+
{
70+
dc2data (mask=0 debugecc) dotcode
71+
} [
72+
0 106 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
73+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
74+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
75+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
76+
33 33 59 47 61 2 27 24 71 59 40 37 91 8 0 106 16 90 101 10
77+
85 61 103 29 100 72 53 59 83 43 75 77 39 45 34 109 108 83 43 51
78+
85 90 50 35 76
79+
] debugIsEqual
80+
81+
% ECC check: step=3 (nw >= 224): 3-way interleaved RSEC with stride-3 data read.
82+
% 150 'A' chars -> nw=229.
83+
/dc3data 150 string def 0 1 149 { dc3data exch 65 put } for
84+
{
85+
dc3data (mask=0 debugecc) dotcode
86+
} [
87+
0 106 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
88+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
89+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
90+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
91+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
92+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
93+
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
94+
33 33 33 33 33 33 33 33 33 33 33 33 90 90 2 71 71 59 10 10
95+
60 94 94 89 2 2 55 19 19 105 101 101 38 44 44 111 21 21 9 87
96+
87 110 79 79 112 8 8 68 75 75 88 15 15 87 41 41 66 68 68 2
97+
78 78 98 49 49 31 110 110 92 85 85 102 2 2 0 68 68 29 30 30
98+
84 64 64 46 46 46 0 54 54 102
99+
] debugIsEqual
100+
61101

62102
% Figures
63103

0 commit comments

Comments
 (0)