File: tcbarcodes.pp

package info (click to toggle)
fpc 3.2.0%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, bullseye-backports
  • size: 338,552 kB
  • sloc: pascal: 3,794,737; xml: 191,997; ansic: 9,637; asm: 8,482; java: 5,346; sh: 4,664; yacc: 3,751; makefile: 2,688; lex: 2,538; javascript: 2,375; sql: 929; php: 473; cpp: 145; perl: 134; sed: 132; csh: 34; tcl: 7
file content (769 lines) | stat: -rw-r--r-- 38,295 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
unit tcbarcodes;

{$mode objfpc}{$H+}

interface

uses
  TypInfo, Classes, SysUtils, fpcunit, testutils, testregistry, fpbarcode;

type

  { TTestBarcodes }

  TTestBarcodes = class(TTestCase)
  private
    FText: String;
    FType: TBarcodeEncoding;
    class procedure AssertEquals(Msg: String; AExpected, AActual: TBarColor);
    class procedure AssertEquals(Msg: String; AExpected, AActual: TBarWidth);
    class procedure AssertEquals(Msg: String; AExpected, AActual: TBarHeight);
    procedure AssertParams(aType: TBarType; AColor: TBarColor; AWidth: TBarWidth; AHeight: TBarheight);
  Protected
    Procedure SetEncoding(aType: TBarcodeEncoding);
    Procedure SetText(aText : String);
    Function DoEncode : TBarTypeArray;
    Class Procedure AssertEquals(Msg : String; AExpected : Array of Byte; AActual : TBarTypeArray); overload;
    Property TheType : TBarcodeEncoding Read FType;
    Property TheText : String Read FText;
  published
    procedure TestEan8;
    procedure TestEan13;
    procedure TestCode39;
    procedure TestCode39Extended;
    procedure TestCode128A;
    procedure TestCode128B;
    procedure TestCode128C;
    procedure Testbe2of5industrial;
    procedure Testbe2of5interleaved;
    procedure Testbe2of5matrix;
    procedure TestCode93;
    procedure TestCode93Extended;
    procedure TestCodeCodabar;
    procedure TestCodeMSI;
    procedure TestCodePostNet;
    Procedure CheckParamsType;
    Procedure CheckNumerictypes;
  end;

implementation

procedure TTestBarcodes.SetEncoding(aType: TBarcodeEncoding);
begin
  FType:=aType;
end;

procedure TTestBarcodes.SetText(aText: String);
begin
  FText:=aText;
end;

function TTestBarcodes.DoEncode: TBarTypeArray;
begin
  Result:=StringToBarTypeArray(FText,FType);
  //Writeln(NewToOld(Result));
end;

class procedure TTestBarcodes.AssertEquals(Msg: String; AExpected: array of Byte; AActual: TBarTypeArray);

Var
  I : Integer;

begin
  AssertEquals(Msg+': length equal',Length(aExpected),Length(AActual));
  for I:=0 to Length(aExpected)-1 do
    AssertEquals(Msg+': Element at position ['+intTostr(I)+']',aExpected[i],AActual[i]);
end;

{
  The tests have been generated using the barcode unit distributed with lazarus.
  The string text in the comment is the string as reproduced with the MakeData function of the TBarCode class.
}

procedure TTestBarcodes.TestEan8;

begin
  SetEncoding(beEAN8);
  // 0 --> 5052605260526052605050507150715071507150505
  SetText('0');
  AssertEquals('Test for "0"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,0,4],DoEncode);
  // 1 --> 5052605260526052605050507150715061607150505
  SetText('1');
  AssertEquals('Test for "1"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,5,1,5,0,6,1,4,0,4,0,4],DoEncode);
  // 2 --> 5052605260526052605050507150715060617150505
  SetText('2');
  AssertEquals('Test for "2"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,5,0,5,1,6,1,4,0,4,0,4],DoEncode);
  // 3 --> 5052605260526052605050507150715053507150505
  SetText('3');
  AssertEquals('Test for "3"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,4,3,4,0,6,1,4,0,4,0,4],DoEncode);
  // 4 --> 5052605260526052605050507150715050717150505
  SetText('4');
  AssertEquals('Test for "4"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,4,0,6,1,6,1,4,0,4,0,4],DoEncode);
  // 5 --> 5052605260526052605050507150715051707150505
  SetText('5');
  AssertEquals('Test for "5"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,4,1,6,0,6,1,4,0,4,0,4],DoEncode);
  // 6 --> 5052605260526052605050507150715050537150505
  SetText('6');
  AssertEquals('Test for "6"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,4,0,4,3,6,1,4,0,4,0,4],DoEncode);
  // 7 --> 5052605260526052605050507150715052517150505
  SetText('7');
  AssertEquals('Test for "7"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,4,2,4,1,6,1,4,0,4,0,4],DoEncode);
  // 8 --> 5052605260526052605050507150715051527150505
  SetText('8');
  AssertEquals('Test for "8"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,4,1,4,2,6,1,4,0,4,0,4],DoEncode);
  // 9 --> 5052605260526052605050507150715070517150505
  SetText('9');
  AssertEquals('Test for "9"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,0,4,1,6,1,4,0,4,0,4],DoEncode);
  // 12345678 --> 5051615151608050526050505170505352515152505
  SetText('12345678');
  AssertEquals('Test for "12345678"',[4,0,4,1,5,1,4,1,4,1,5,0,7,0,4,0,4,2,5,0,4,0,4,0,4,1,6,0,4,0,4,3,4,2,4,1,4,1,4,2,4,0,4],DoEncode);
end;

procedure TTestBarcodes.TestEan13;
begin
  SetEncoding(beEAN13);
  // 0 --> 50526052605260526052605260505050715071507150715071507150505
  SetText('0');
  AssertEquals('Test for "0"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,0,4],DoEncode);
  // 1 --> 50526052605260526052605260505050715071507150715061607150505
  SetText('1');
  AssertEquals('Test for "1"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,5,1,5,0,6,1,4,0,4,0,4],DoEncode);
  // 2 --> 50526052605260526052605260505050715071507150715060617150505
  SetText('2');
  AssertEquals('Test for "2"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,5,0,5,1,6,1,4,0,4,0,4],DoEncode);
  // 3 --> 50526052605260526052605260505050715071507150715053507150505
  SetText('3');
  AssertEquals('Test for "3"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,3,4,0,6,1,4,0,4,0,4],DoEncode);
  // 4 --> 50526052605260526052605260505050715071507150715050717150505
  SetText('4');
  AssertEquals('Test for "4"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,0,6,1,6,1,4,0,4,0,4],DoEncode);
  // 5 --> 50526052605260526052605260505050715071507150715051707150505
  SetText('5');
  AssertEquals('Test for "5"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,1,6,0,6,1,4,0,4,0,4],DoEncode);
  // 6 --> 50526052605260526052605260505050715071507150715050537150505
  SetText('6');
  AssertEquals('Test for "6"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,0,4,3,6,1,4,0,4,0,4],DoEncode);
  // 7 --> 50526052605260526052605260505050715071507150715052517150505
  SetText('7');
  AssertEquals('Test for "7"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,2,4,1,6,1,4,0,4,0,4],DoEncode);
  // 8 --> 50526052605260526052605260505050715071507150715051527150505
  SetText('8');
  AssertEquals('Test for "8"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,4,1,4,2,6,1,4,0,4,0,4],DoEncode);
  // 9 --> 50526052605260526052605260505050715071507150715070517150505
  SetText('9');
  AssertEquals('Test for "9"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,2,5,0,4,0,4,0,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,1,4,0,6,0,4,1,6,1,4,0,4,0,4],DoEncode);
  // 12345678 --> 50526052605260516151516080505050507151705053525151527150505
  SetText('12345678');
  AssertEquals('Test for "12345678"',[4,0,4,2,5,0,4,2,5,0,4,2,5,0,4,1,5,1,4,1,4,1,5,0,7,0,4,0,4,0,4,0,4,0,6,1,4,1,6,0,4,0,4,3,4,2,4,1,4,1,4,2,6,1,4,0,4,0,4],DoEncode);
  // 1234567890123 --> 50515160805170506253505152505050515270517150616060615350505
  SetText('1234567890123');
  AssertEquals('Test for "1234567890123"',[4,0,4,1,4,1,5,0,7,0,4,1,6,0,4,0,5,2,4,3,4,0,4,1,4,2,4,0,4,0,4,0,4,1,4,2,6,0,4,1,6,1,4,0,5,1,5,0,5,0,5,1,4,3,4,0,4,0,4],DoEncode);
end;

procedure TTestBarcodes.TestCode39;
begin
  SetEncoding(be39);
  // 0 --> 51506060505051606050515060605
  SetText('0');
  AssertEquals('Test for "0"',[4,1,4,0,5,0,5,0,4,0,4,0,4,1,5,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 1 --> 51506060506051505060515060605
  SetText('1');
  AssertEquals('Test for "1"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,4,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 2 --> 51506060505061505060515060605
  SetText('2');
  AssertEquals('Test for "2"',[4,1,4,0,5,0,5,0,4,0,4,0,5,1,4,0,4,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 3 --> 51506060506061505050515060605
  SetText('3');
  AssertEquals('Test for "3"',[4,1,4,0,5,0,5,0,4,0,5,0,5,1,4,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 4 --> 51506060505051605060515060605
  SetText('4');
  AssertEquals('Test for "4"',[4,1,4,0,5,0,5,0,4,0,4,0,4,1,5,0,4,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 5 --> 51506060506051605050515060605
  SetText('5');
  AssertEquals('Test for "5"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 6 --> 51506060505061605050515060605
  SetText('6');
  AssertEquals('Test for "6"',[4,1,4,0,5,0,5,0,4,0,4,0,5,1,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 7 --> 51506060505051506060515060605
  SetText('7');
  AssertEquals('Test for "7"',[4,1,4,0,5,0,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 8 --> 51506060506051506050515060605
  SetText('8');
  AssertEquals('Test for "8"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 9 --> 51506060505061506050515060605
  SetText('9');
  AssertEquals('Test for "9"',[4,1,4,0,5,0,5,0,4,0,4,0,5,1,4,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 12345678 --> 515060605060515050605061505060606150505050516050606051605050506160505050515060606051506050515060605
  SetText('12345678');
  AssertEquals('Test for "12345678"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,4,0,5,0,4,0,5,1,4,0,4,0,5,0,5,0,5,1,4,0,4,0,4,0,4,0,4,1,5,0,4,0,5,0,5,0,4,1,5,0,4,0,4,0,4,0,5,1,5,0,4,0,4,0,4,0,4,1,4,0,5,0,5,0,5,0,4,1,4,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 123456789ABCDE --> 515060605060515050605061505060606150505050516050606051605050506160505050515060606051506050506150605060505150605060515060606051505050506150606050615050515060605
  SetText('123456789ABCDE');
  AssertEquals('Test for "123456789ABCDE"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,4,0,5,0,4,0,5,1,4,0,4,0,5,0,5,0,5,1,4,0,4,0,4,0,4,0,4,1,5,0,4,0,5,0,5,0,4,1,5,0,4,0,4,0,4,0,5,1,5,0,4,0,4,0,4,0,4,1,4,0,5,0,5,0,5,0,4,1,4,0,5,0,4,0,4,0,5,1,4,0,5,0,4,0,5,0,4,0,4,1,4,0,5,0,4,0,5,0,4,1,4,0,5,0,5,0,5,0,4,1,4,0,4,0,4,0,4,0,5,1,4,0,5,0,5,0,4,0,5,1,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
end;

procedure TTestBarcodes.TestCode39Extended;

begin
  SetEncoding(be39extended);
  // 0 --> 51506060505051606050515060605
  SetText('0');
  AssertEquals('Test for "0"',[4,1,4,0,5,0,5,0,4,0,4,0,4,1,5,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 1 --> 51506060506051505060515060605
  SetText('1');
  AssertEquals('Test for "1"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,4,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 2 --> 51506060505061505060515060605
  SetText('2');
  AssertEquals('Test for "2"',[4,1,4,0,5,0,5,0,4,0,4,0,5,1,4,0,4,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 3 --> 51506060506061505050515060605
  SetText('3');
  AssertEquals('Test for "3"',[4,1,4,0,5,0,5,0,4,0,5,0,5,1,4,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 4 --> 51506060505051605060515060605
  SetText('4');
  AssertEquals('Test for "4"',[4,1,4,0,5,0,5,0,4,0,4,0,4,1,5,0,4,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 5 --> 51506060506051605050515060605
  SetText('5');
  AssertEquals('Test for "5"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 6 --> 51506060505061605050515060605
  SetText('6');
  AssertEquals('Test for "6"',[4,1,4,0,5,0,5,0,4,0,4,0,5,1,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 7 --> 51506060505051506060515060605
  SetText('7');
  AssertEquals('Test for "7"',[4,1,4,0,5,0,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 8 --> 51506060506051506050515060605
  SetText('8');
  AssertEquals('Test for "8"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 9 --> 51506060505061506050515060605
  SetText('9');
  AssertEquals('Test for "9"',[4,1,4,0,5,0,5,0,4,0,4,0,5,1,4,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 1234567800 --> 51506060506051505060506150506060615050505051605060605160505050616050505051506060605150605050516060505051606050515060605
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,4,0,5,0,4,0,5,1,4,0,4,0,5,0,5,0,5,1,4,0,4,0,4,0,4,0,4,1,5,0,4,0,5,0,5,0,4,1,5,0,4,0,4,0,4,0,5,1,5,0,4,0,4,0,4,0,4,1,4,0,5,0,5,0,5,0,4,1,4,0,5,0,4,0,4,0,4,1,5,0,5,0,4,0,4,0,4,1,5,0,5,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
  // 123456789ABCDEwxyz --> 51506060506051505060506150506060615050505051605060605160505050616050505051506060605150605050615060506050515060506051506060605150505050615060605061505051505151506160505050515051515051506050605150515150615060505051505151505160605050515060605
  SetText('123456789ABCDEwxyz');
  AssertEquals('Test for "123456789ABCDEwxyz"',[4,1,4,0,5,0,5,0,4,0,5,0,4,1,4,0,4,0,5,0,4,0,5,1,4,0,4,0,5,0,5,0,5,1,4,0,4,0,4,0,4,0,4,1,5,0,4,0,5,0,5,0,4,1,5,0,4,0,4,0,4,0,5,1,5,0,4,0,4,0,4,0,4,1,4,0,5,0,5,0,5,0,4,1,4,0,5,0,4,0,4,0,5,1,4,0,5,0,4,0,5,0,4,0,4,1,4,0,5,0,4,0,5,0,4,1,4,0,5,0,5,0,5,0,4,1,4,0,4,0,4,0,4,0,5,1,4,0,5,0,5,0,4,0,5,1,4,0,4,0,4,1,4,0,4,1,4,1,4,0,5,1,5,0,4,0,4,0,4,0,4,1,4,0,4,1,4,1,4,0,4,1,4,0,5,0,4,0,5,0,4,1,4,0,4,1,4,1,4,0,5,1,4,0,5,0,4,0,4,0,4,1,4,0,4,1,4,1,4,0,4,1,5,0,5,0,4,0,4,0,4,1,4,0,5,0,5,0,4],DoEncode);
end;

Procedure TTestBarcodes.TestCode128A;


begin
  SetEncoding(be128A);
  // 0 --> 6053515170615170616270506
  SetText('0');
  AssertEquals('Test for "0"',[5,0,4,3,4,1,4,1,6,0,5,1,4,1,6,0,5,1,5,2,6,0,4,0,5],DoEncode);
  // 1 --> 6053515171605171606270506
  SetText('1');
  AssertEquals('Test for "1"',[5,0,4,3,4,1,4,1,6,1,5,0,4,1,6,1,5,0,5,2,6,0,4,0,5],DoEncode);
  // 2 --> 6053516171506171506270506
  SetText('2');
  AssertEquals('Test for "2"',[5,0,4,3,4,1,5,1,6,1,4,0,5,1,6,1,4,0,5,2,6,0,4,0,5],DoEncode);
  // 3 --> 6053516150716150716270506
  SetText('3');
  AssertEquals('Test for "3"',[5,0,4,3,4,1,5,1,4,0,6,1,5,1,4,0,6,1,5,2,6,0,4,0,5],DoEncode);
  // 4 --> 6053516151706151706270506
  SetText('4');
  AssertEquals('Test for "4"',[5,0,4,3,4,1,5,1,4,1,6,0,5,1,4,1,6,0,5,2,6,0,4,0,5],DoEncode);
  // 5 --> 6053516071516071516270506
  SetText('5');
  AssertEquals('Test for "5"',[5,0,4,3,4,1,5,0,6,1,4,1,5,0,6,1,4,1,5,2,6,0,4,0,5],DoEncode);
  // 6 --> 6053516170516170516270506
  SetText('6');
  AssertEquals('Test for "6"',[5,0,4,3,4,1,5,1,6,0,4,1,5,1,6,0,4,1,5,2,6,0,4,0,5],DoEncode);
  // 7 --> 6053517060707060706270506
  SetText('7');
  AssertEquals('Test for "7"',[5,0,4,3,4,1,6,0,5,0,6,0,6,0,5,0,6,0,5,2,6,0,4,0,5],DoEncode);
  // 8 --> 6053517051617051616270506
  SetText('8');
  AssertEquals('Test for "8"',[5,0,4,3,4,1,6,0,4,1,5,1,6,0,4,1,5,1,5,2,6,0,4,0,5],DoEncode);
  // 9 --> 6053517150617150616270506
  SetText('9');
  AssertEquals('Test for "9"',[5,0,4,3,4,1,6,1,4,0,5,1,6,1,4,0,5,1,5,2,6,0,4,0,5],DoEncode);
  // 1234567800 --> 6053515171606171506150716151706071516170517060707051615170615170617050626270506
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[5,0,4,3,4,1,4,1,6,1,5,0,5,1,6,1,4,0,5,1,4,0,6,1,5,1,4,1,6,0,5,0,6,1,4,1,5,1,6,0,4,1,6,0,5,0,6,0,6,0,4,1,5,1,4,1,6,0,5,1,4,1,6,0,5,1,6,0,4,0,5,2,5,2,6,0,4,0,5],DoEncode);
  // 123456789ABCD --> 6053515171606171506150716151706071516170517060707051617150615052625250625252605062526170516270506
  SetText('123456789ABCD');
  AssertEquals('Test for "123456789ABCD"',[5,0,4,3,4,1,4,1,6,1,5,0,5,1,6,1,4,0,5,1,4,0,6,1,5,1,4,1,6,0,5,0,6,1,4,1,5,1,6,0,4,1,6,0,5,0,6,0,6,0,4,1,5,1,6,1,4,0,5,1,4,0,4,2,5,2,4,2,4,0,5,2,4,2,4,2,5,0,4,0,5,2,4,2,5,1,6,0,4,1,5,2,6,0,4,0,5],DoEncode);
end;

procedure TTestBarcodes.TestCode128B;

begin
  SetEncoding(be128B);
  // 0 --> 6051535170615171606270506
  SetText('0');
  AssertEquals('Test for "0"',[5,0,4,1,4,3,4,1,6,0,5,1,4,1,6,1,5,0,5,2,6,0,4,0,5],DoEncode);
  // 1 --> 6051535171606171506270506
  SetText('1');
  AssertEquals('Test for "1"',[5,0,4,1,4,3,4,1,6,1,5,0,5,1,6,1,4,0,5,2,6,0,4,0,5],DoEncode);
  // 2 --> 6051536171506150716270506
  SetText('2');
  AssertEquals('Test for "2"',[5,0,4,1,4,3,5,1,6,1,4,0,5,1,4,0,6,1,5,2,6,0,4,0,5],DoEncode);
  // 3 --> 6051536150716151706270506
  SetText('3');
  AssertEquals('Test for "3"',[5,0,4,1,4,3,5,1,4,0,6,1,5,1,4,1,6,0,5,2,6,0,4,0,5],DoEncode);
  // 4 --> 6051536151706071516270506
  SetText('4');
  AssertEquals('Test for "4"',[5,0,4,1,4,3,5,1,4,1,6,0,5,0,6,1,4,1,5,2,6,0,4,0,5],DoEncode);
  // 5 --> 6051536071516170516270506
  SetText('5');
  AssertEquals('Test for "5"',[5,0,4,1,4,3,5,0,6,1,4,1,5,1,6,0,4,1,5,2,6,0,4,0,5],DoEncode);
  // 6 --> 6051536170517060706270506
  SetText('6');
  AssertEquals('Test for "6"',[5,0,4,1,4,3,5,1,6,0,4,1,6,0,5,0,6,0,5,2,6,0,4,0,5],DoEncode);
  // 7 --> 6051537060707051616270506
  SetText('7');
  AssertEquals('Test for "7"',[5,0,4,1,4,3,6,0,5,0,6,0,6,0,4,1,5,1,5,2,6,0,4,0,5],DoEncode);
  // 8 --> 6051537051617150616270506
  SetText('8');
  AssertEquals('Test for "8"',[5,0,4,1,4,3,6,0,4,1,5,1,6,1,4,0,5,1,5,2,6,0,4,0,5],DoEncode);
  // 9 --> 6051537150617151606270506
  SetText('9');
  AssertEquals('Test for "9"',[5,0,4,1,4,3,6,1,4,0,5,1,6,1,4,1,5,0,5,2,6,0,4,0,5],DoEncode);
  // 1234567800 --> 6051535171606171506150716151706071516170517060707051615170615170617052606270506
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[5,0,4,1,4,3,4,1,6,1,5,0,5,1,6,1,4,0,5,1,4,0,6,1,5,1,4,1,6,0,5,0,6,1,4,1,5,1,6,0,4,1,6,0,5,0,6,0,6,0,4,1,5,1,4,1,6,0,5,1,4,1,6,0,5,1,6,0,4,2,5,0,5,2,6,0,4,0,5],DoEncode);
  // 123456789ABCD --> 6051535171606171506150716151706071516170517060707051617150615052625250625252605062527060706270506
  SetText('123456789ABCD');
  AssertEquals('Test for "123456789ABCD"',[5,0,4,1,4,3,4,1,6,1,5,0,5,1,6,1,4,0,5,1,4,0,6,1,5,1,4,1,6,0,5,0,6,1,4,1,5,1,6,0,4,1,6,0,5,0,6,0,6,0,4,1,5,1,6,1,4,0,5,1,4,0,4,2,5,2,4,2,4,0,5,2,4,2,4,2,5,0,4,0,5,2,4,2,6,0,5,0,6,0,5,2,6,0,4,0,5],DoEncode);
end;


Procedure TTestBarcodes.TestCode128C;

begin
  SetEncoding(be128C);
  // 0 --> 6051716061616161606270506
  SetText('0');
  AssertEquals('Test for "0"',[5,0,4,1,6,1,5,0,5,1,5,1,5,1,5,1,5,0,5,2,6,0,4,0,5],DoEncode);
  // 1 --> 6051716160615151626270506
  SetText('1');
  AssertEquals('Test for "1"',[5,0,4,1,6,1,5,1,5,0,5,1,4,1,4,1,5,2,5,2,6,0,4,0,5],DoEncode);
  // 2 --> 6051716161605152616270506
  SetText('2');
  AssertEquals('Test for "2"',[5,0,4,1,6,1,5,1,5,1,5,0,4,1,4,2,5,1,5,2,6,0,4,0,5],DoEncode);
  // 3 --> 6051715151625251616270506
  SetText('3');
  AssertEquals('Test for "3"',[5,0,4,1,6,1,4,1,4,1,5,2,4,2,4,1,5,1,5,2,6,0,4,0,5],DoEncode);
  // 4 --> 6051715152615161526270506
  SetText('4');
  AssertEquals('Test for "4"',[5,0,4,1,6,1,4,1,4,2,5,1,4,1,5,1,4,2,5,2,6,0,4,0,5],DoEncode);
  // 5 --> 6051715251615162516270506
  SetText('5');
  AssertEquals('Test for "5"',[5,0,4,1,6,1,4,2,4,1,5,1,4,1,5,2,4,1,5,2,6,0,4,0,5],DoEncode);
  // 6 --> 6051715161525261516270506
  SetText('6');
  AssertEquals('Test for "6"',[5,0,4,1,6,1,4,1,5,1,4,2,4,2,5,1,4,1,5,2,6,0,4,0,5],DoEncode);
  // 7 --> 6051715162516151526270506
  SetText('7');
  AssertEquals('Test for "7"',[5,0,4,1,6,1,4,1,5,2,4,1,5,1,4,1,4,2,5,2,6,0,4,0,5],DoEncode);
  // 8 --> 6051715261516152516270506
  SetText('8');
  AssertEquals('Test for "8"',[5,0,4,1,6,1,4,2,5,1,4,1,5,1,4,2,4,1,5,2,6,0,4,0,5],DoEncode);
  // 9 --> 6051716151526251516270506
  SetText('9');
  AssertEquals('Test for "9"',[5,0,4,1,6,1,5,1,4,1,4,2,5,2,4,1,4,1,5,2,6,0,4,0,5],DoEncode);
  // 1234567800 --> 6051715061715250627250606350516061615270606270506
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[5,0,4,1,6,1,4,0,5,1,6,1,4,2,4,0,5,2,6,2,4,0,5,0,5,3,4,0,4,1,5,0,5,1,5,1,4,2,6,0,5,0,5,2,6,0,4,0,5],DoEncode);
end;


Procedure TTestBarcodes.Testbe2of5industrial;

begin
  SetEncoding(be2of5industrial);
  // 00 --> 60605050506060505050606050605060
  SetText('00');
  AssertEquals('Test for "00"',[5,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,5,0,4,0,5,0],DoEncode);
  // 11 --> 60605060505050606050505060605060
  SetText('11');
  AssertEquals('Test for "11"',[5,0,5,0,4,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,5,0],DoEncode);
  // 22 --> 60605050605050605060505060605060
  SetText('22');
  AssertEquals('Test for "22"',[5,0,5,0,4,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,5,0,4,0,5,0],DoEncode);
  // 33 --> 60605060605050506060505050605060
  SetText('33');
  AssertEquals('Test for "33"',[5,0,5,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,4,0,5,0],DoEncode);
  // 44 --> 60605050506050605050605060605060
  SetText('44');
  AssertEquals('Test for "44"',[5,0,5,0,4,0,4,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0,5,0,4,0,5,0],DoEncode);
  // 55 --> 60605060506050506050605050605060
  SetText('55');
  AssertEquals('Test for "55"',[5,0,5,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0],DoEncode);
  // 66 --> 60605050606050505060605050605060
  SetText('66');
  AssertEquals('Test for "66"',[5,0,5,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,5,0,4,0,5,0],DoEncode);
  // 77 --> 60605050505060605050506060605060
  SetText('77');
  AssertEquals('Test for "77"',[5,0,5,0,4,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,5,0,5,0,4,0,5,0],DoEncode);
  // 88 --> 60605060505060506050506050605060
  SetText('88');
  AssertEquals('Test for "88"',[5,0,5,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0,4,0,5,0],DoEncode);
  // 99 --> 60605050605060505060506050605060
  SetText('99');
  AssertEquals('Test for "99"',[5,0,5,0,4,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,4,0,5,0,4,0,5,0,4,0,5,0],DoEncode);
  // 1234567800 --> 6060506050505060506050506060605050505050605060605060505050606050505050506060605050605050506060505050606050605060
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[5,0,5,0,4,0,5,0,4,0,4,0,4,0,5,0,4,0,5,0,4,0,4,0,5,0,5,0,5,0,4,0,4,0,4,0,4,0,4,0,5,0,4,0,5,0,5,0,4,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,4,0,4,0,5,0,5,0,5,0,4,0,4,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,4,0,4,0,5,0,5,0,4,0,5,0,4,0,5,0],DoEncode);
end;


Procedure TTestBarcodes.Testbe2of5interleaved;

begin
  SetEncoding(be2of5interleaved);
   // 00 --> 50505050616150605
   SetText('00');
   AssertEquals('Test for "00"',[4,0,4,0,4,0,4,0,5,1,5,1,4,0,5,0,4],DoEncode);
   // 11 --> 50506150505061605
   SetText('11');
   AssertEquals('Test for "11"',[4,0,4,0,5,1,4,0,4,0,4,0,5,1,5,0,4],DoEncode);
   // 22 --> 50505061505061605
   SetText('22');
   AssertEquals('Test for "22"',[4,0,4,0,4,0,5,1,4,0,4,0,5,1,5,0,4],DoEncode);
   // 33 --> 50506161505050605
   SetText('33');
   AssertEquals('Test for "33"',[4,0,4,0,5,1,5,1,4,0,4,0,4,0,5,0,4],DoEncode);
   // 44 --> 50505050615061605
   SetText('44');
   AssertEquals('Test for "44"',[4,0,4,0,4,0,4,0,5,1,4,0,5,1,5,0,4],DoEncode);
   // 55 --> 50506150615050605
   SetText('55');
   AssertEquals('Test for "55"',[4,0,4,0,5,1,4,0,5,1,4,0,4,0,5,0,4],DoEncode);
   // 66 --> 50505061615050605
   SetText('66');
   AssertEquals('Test for "66"',[4,0,4,0,4,0,5,1,5,1,4,0,4,0,5,0,4],DoEncode);
   // 77 --> 50505050506161605
   SetText('77');
   AssertEquals('Test for "77"',[4,0,4,0,4,0,4,0,4,0,5,1,5,1,5,0,4],DoEncode);
   // 88 --> 50506150506150605
   SetText('88');
   AssertEquals('Test for "88"',[4,0,4,0,5,1,4,0,4,0,5,1,4,0,5,0,4],DoEncode);
   // 99 --> 50505061506150605
   SetText('99');
   AssertEquals('Test for "99"',[4,0,4,0,4,0,5,1,4,0,5,1,4,0,5,0,4],DoEncode);
   // 1234567800 --> 505060515050616060515051605161505051505061605050616150605
   SetText('1234567800');
   AssertEquals('Test for "1234567800"',[4,0,4,0,5,0,4,1,4,0,4,0,5,1,5,0,5,0,4,1,4,0,4,1,5,0,4,1,5,1,4,0,4,0,4,1,4,0,4,0,5,1,5,0,4,0,4,0,5,1,5,1,4,0,5,0,4],DoEncode);
end;


Procedure TTestBarcodes.Testbe2of5matrix;

begin
  SetEncoding(be2of5matrix);
  // 00 --> 70505050615050615070505
  SetText('00');
  AssertEquals('Test for "00"',[6,0,4,0,4,0,4,0,5,1,4,0,4,0,5,1,4,0,6,0,4,0,4],DoEncode);
  // 11 --> 70505060506060506070505
  SetText('11');
  AssertEquals('Test for "11"',[6,0,4,0,4,0,5,0,4,0,5,0,5,0,4,0,5,0,6,0,4,0,4],DoEncode);
  // 22 --> 70505051506051506070505
  SetText('22');
  AssertEquals('Test for "22"',[6,0,4,0,4,0,4,1,4,0,5,0,4,1,4,0,5,0,6,0,4,0,4],DoEncode);
  // 33 --> 70505061505061505070505
  SetText('33');
  AssertEquals('Test for "33"',[6,0,4,0,4,0,5,1,4,0,4,0,5,1,4,0,4,0,6,0,4,0,4],DoEncode);
  // 44 --> 70505050606050606070505
  SetText('44');
  AssertEquals('Test for "44"',[6,0,4,0,4,0,4,0,5,0,5,0,4,0,5,0,5,0,6,0,4,0,4],DoEncode);
  // 55 --> 70505060605060605070505
  SetText('55');
  AssertEquals('Test for "55"',[6,0,4,0,4,0,5,0,5,0,4,0,5,0,5,0,4,0,6,0,4,0,4],DoEncode);
  // 66 --> 70505051605051605070505
  SetText('66');
  AssertEquals('Test for "66"',[6,0,4,0,4,0,4,1,5,0,4,0,4,1,5,0,4,0,6,0,4,0,4],DoEncode);
  // 77 --> 70505050516050516070505
  SetText('77');
  AssertEquals('Test for "77"',[6,0,4,0,4,0,4,0,4,1,5,0,4,0,4,1,5,0,6,0,4,0,4],DoEncode);
  // 88 --> 70505060515060515070505
  SetText('88');
  AssertEquals('Test for "88"',[6,0,4,0,4,0,5,0,4,1,4,0,5,0,4,1,4,0,6,0,4,0,4],DoEncode);
  // 99 --> 70505051515051515070505
  SetText('99');
  AssertEquals('Test for "99"',[6,0,4,0,4,0,4,1,4,1,4,0,4,1,4,1,4,0,6,0,4,0,4],DoEncode);
  // 1234567800 --> 70505060506051506061505050606060605051605050516060515050615050615070505
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[6,0,4,0,4,0,5,0,4,0,5,0,4,1,4,0,5,0,5,1,4,0,4,0,4,0,5,0,5,0,5,0,5,0,4,0,4,1,5,0,4,0,4,0,4,1,5,0,5,0,4,1,4,0,4,0,5,1,4,0,4,0,5,1,4,0,6,0,4,0,4],DoEncode);
end;


Procedure TTestBarcodes.TestCode93;

begin
  SetEncoding(be93);
  // 0 --> 5050805250515250515250515050805
  SetText('0');
  AssertEquals('Test for "0"',[4,0,4,0,7,0,4,2,4,0,4,1,4,2,4,0,4,1,4,2,4,0,4,1,4,0,4,0,7,0,4],DoEncode);
  // 1 --> 5050805051525051525053505050805
  SetText('1');
  AssertEquals('Test for "1"',[4,0,4,0,7,0,4,0,4,1,4,2,4,0,4,1,4,2,4,0,4,3,4,0,4,0,4,0,7,0,4],DoEncode);
  // 2 --> 5050805052515052515152505050805
  SetText('2');
  AssertEquals('Test for "2"',[4,0,4,0,7,0,4,0,4,2,4,1,4,0,4,2,4,1,4,1,4,2,4,0,4,0,4,0,7,0,4],DoEncode);
  // 3 --> 5050805053505053505350505050805
  SetText('3');
  AssertEquals('Test for "3"',[4,0,4,0,7,0,4,0,4,3,4,0,4,0,4,3,4,0,4,3,4,0,4,0,4,0,4,0,7,0,4],DoEncode);
  // 4 --> 5050805150525150526052505050805
  SetText('4');
  AssertEquals('Test for "4"',[4,0,4,0,7,0,4,1,4,0,4,2,4,1,4,0,4,2,5,0,4,2,4,0,4,0,4,0,7,0,4],DoEncode);
  // 5 --> 5050805151515151516250505050805
  SetText('5');
  AssertEquals('Test for "5"',[4,0,4,0,7,0,4,1,4,1,4,1,4,1,4,1,4,1,5,2,4,0,4,0,4,0,4,0,7,0,4],DoEncode);
  // 6 --> 5050805152505152505062505050805
  SetText('6');
  AssertEquals('Test for "6"',[4,0,4,0,7,0,4,1,4,2,4,0,4,1,4,2,4,0,4,0,5,2,4,0,4,0,4,0,7,0,4],DoEncode);
  // 7 --> 5050805050535050535050625050805
  SetText('7');
  AssertEquals('Test for "7"',[4,0,4,0,7,0,4,0,4,0,4,3,4,0,4,0,4,3,4,0,4,0,5,2,4,0,4,0,7,0,4],DoEncode);
  // 8 --> 5050805251505251505150615050805
  SetText('8');
  AssertEquals('Test for "8"',[4,0,4,0,7,0,4,2,4,1,4,0,4,2,4,1,4,0,4,1,4,0,5,1,4,0,4,0,7,0,4],DoEncode);
  // 9 --> 5050805350505350506061505050805
  SetText('9');
  AssertEquals('Test for "9"',[4,0,4,0,7,0,4,3,4,0,4,0,4,3,4,0,4,0,5,0,5,1,4,0,4,0,4,0,7,0,4],DoEncode);
  // 1234567800 --> 5050805051525052515053505150525151515152505050535251505250515250515150527060505050805
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[4,0,4,0,7,0,4,0,4,1,4,2,4,0,4,2,4,1,4,0,4,3,4,0,4,1,4,0,4,2,4,1,4,1,4,1,4,1,4,2,4,0,4,0,4,0,4,3,4,2,4,1,4,0,4,2,4,0,4,1,4,2,4,0,4,1,4,1,4,0,4,2,6,0,5,0,4,0,4,0,4,0,7,0,4],DoEncode);
  // 123456789ABCD --> 5050805051525052515053505150525151515152505050535251505350506050526051516052506150515060616151505050805
  SetText('123456789ABCD');
  AssertEquals('Test for "123456789ABCD"',[4,0,4,0,7,0,4,0,4,1,4,2,4,0,4,2,4,1,4,0,4,3,4,0,4,1,4,0,4,2,4,1,4,1,4,1,4,1,4,2,4,0,4,0,4,0,4,3,4,2,4,1,4,0,4,3,4,0,4,0,5,0,4,0,4,2,5,0,4,1,4,1,5,0,4,2,4,0,5,1,4,0,4,1,4,0,5,0,5,1,5,1,4,1,4,0,4,0,4,0,7,0,4],DoEncode);
end;


Procedure TTestBarcodes.TestCode93Extended;

begin
  SetEncoding(be93Extended);
  // 00 --> 5050805250515250515250515250515050805
  SetText('00');
  AssertEquals('Test for "00"',[4,0,4,0,7,0,4,2,4,0,4,1,4,2,4,0,4,1,4,2,4,0,4,1,4,2,4,0,4,1,4,0,4,0,7,0,4],DoEncode);
  // 11 --> 5050805051525051525053505251505050805
  SetText('11');
  AssertEquals('Test for "11"',[4,0,4,0,7,0,4,0,4,1,4,2,4,0,4,1,4,2,4,0,4,3,4,0,4,2,4,1,4,0,4,0,4,0,7,0,4],DoEncode);
  // 22 --> 5050805052515052515152505060525050805
  SetText('22');
  AssertEquals('Test for "22"',[4,0,4,0,7,0,4,0,4,2,4,1,4,0,4,2,4,1,4,1,4,2,4,0,4,0,5,0,4,2,4,0,4,0,7,0,4],DoEncode);
  // 33 --> 5050805053505053505350505150615050805
  SetText('33');
  AssertEquals('Test for "33"',[4,0,4,0,7,0,4,0,4,3,4,0,4,0,4,3,4,0,4,3,4,0,4,0,4,1,4,0,5,1,4,0,4,0,7,0,4],DoEncode);
  // 44 --> 5050805150525150526052505060615050805
  SetText('44');
  AssertEquals('Test for "44"',[4,0,4,0,7,0,4,1,4,0,4,2,4,1,4,0,4,2,5,0,4,2,4,0,4,0,5,0,5,1,4,0,4,0,7,0,4],DoEncode);
  // 55 --> 5050805151515151516250505060705050805
  SetText('55');
  AssertEquals('Test for "55"',[4,0,4,0,7,0,4,1,4,1,4,1,4,1,4,1,4,1,5,2,4,0,4,0,4,0,5,0,6,0,4,0,4,0,7,0,4],DoEncode);
  // 66 --> 5050805152505152505062505051525050805
  SetText('66');
  AssertEquals('Test for "66"',[4,0,4,0,7,0,4,1,4,2,4,0,4,1,4,2,4,0,4,0,5,2,4,0,4,0,4,1,4,2,4,0,4,0,7,0,4],DoEncode);
  // 77 --> 5050805050535050535050625350505050805
  SetText('77');
  AssertEquals('Test for "77"',[4,0,4,0,7,0,4,0,4,0,4,3,4,0,4,0,4,3,4,0,4,0,5,2,4,3,4,0,4,0,4,0,4,0,7,0,4],DoEncode);
  // 88 --> 5050805251505251505150615061515050805
  SetText('88');
  AssertEquals('Test for "88"',[4,0,4,0,7,0,4,2,4,1,4,0,4,2,4,1,4,0,4,1,4,0,5,1,4,0,5,1,4,1,4,0,4,0,7,0,4],DoEncode);
  // 99 --> 5050805350505350506061505250605050805
  SetText('99');
  AssertEquals('Test for "99"',[4,0,4,0,7,0,4,3,4,0,4,0,4,3,4,0,4,0,5,0,5,1,4,0,4,2,4,0,5,0,4,0,4,0,7,0,4],DoEncode);
  // 1234567800 --> 5050805051525052515053505150525151515152505050535251505250515250515150527060505050805
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[4,0,4,0,7,0,4,0,4,1,4,2,4,0,4,2,4,1,4,0,4,3,4,0,4,1,4,0,4,2,4,1,4,1,4,1,4,1,4,2,4,0,4,0,4,0,4,3,4,2,4,1,4,0,4,2,4,0,4,1,4,2,4,0,4,1,4,1,4,0,4,2,6,0,5,0,4,0,4,0,4,0,7,0,4],DoEncode);
  // 123456789ABCD --> 5050805051525052515053505150525151515152505050535251505350506050526051516052506150515060616151505050805
  SetText('123456789ABCD');
  AssertEquals('Test for "123456789ABCD"',[4,0,4,0,7,0,4,0,4,1,4,2,4,0,4,2,4,1,4,0,4,3,4,0,4,1,4,0,4,2,4,1,4,1,4,1,4,1,4,2,4,0,4,0,4,0,4,3,4,2,4,1,4,0,4,3,4,0,4,0,5,0,4,0,4,2,5,0,4,1,4,1,5,0,4,2,4,0,5,1,4,0,4,1,4,0,5,0,5,1,5,1,4,1,4,0,4,0,4,0,7,0,4],DoEncode);
end;


Procedure TTestBarcodes.TestCodeCodabar;

begin
  SetEncoding(beCodabar);
  // 0 --> 50615150505051605151506
  SetText('0');
  AssertEquals('Test for "0"',[4,0,5,1,4,1,4,0,4,0,4,0,4,1,5,0,4,1,4,1,4,0,5],DoEncode);
  // 1 --> 50615150505061505151506
  SetText('1');
  AssertEquals('Test for "1"',[4,0,5,1,4,1,4,0,4,0,4,0,5,1,4,0,4,1,4,1,4,0,5],DoEncode);
  // 2 --> 50615150505150605151506
  SetText('2');
  AssertEquals('Test for "2"',[4,0,5,1,4,1,4,0,4,0,4,1,4,0,5,0,4,1,4,1,4,0,5],DoEncode);
  // 3 --> 50615150615050505151506
  SetText('3');
  AssertEquals('Test for "3"',[4,0,5,1,4,1,4,0,5,1,4,0,4,0,4,0,4,1,4,1,4,0,5],DoEncode);
  // 4 --> 50615150506051505151506
  SetText('4');
  AssertEquals('Test for "4"',[4,0,5,1,4,1,4,0,4,0,5,0,4,1,4,0,4,1,4,1,4,0,5],DoEncode);
  // 5 --> 50615150605051505151506
  SetText('5');
  AssertEquals('Test for "5"',[4,0,5,1,4,1,4,0,5,0,4,0,4,1,4,0,4,1,4,1,4,0,5],DoEncode);
  // 6 --> 50615150515050605151506
  SetText('6');
  AssertEquals('Test for "6"',[4,0,5,1,4,1,4,0,4,1,4,0,4,0,5,0,4,1,4,1,4,0,5],DoEncode);
  // 7 --> 50615150515060505151506
  SetText('7');
  AssertEquals('Test for "7"',[4,0,5,1,4,1,4,0,4,1,4,0,5,0,4,0,4,1,4,1,4,0,5],DoEncode);
  // 8 --> 50615150516050505151506
  SetText('8');
  AssertEquals('Test for "8"',[4,0,5,1,4,1,4,0,4,1,5,0,4,0,4,0,4,1,4,1,4,0,5],DoEncode);
  // 9 --> 50615150605150505151506
  SetText('9');
  AssertEquals('Test for "9"',[4,0,5,1,4,1,4,0,5,0,4,1,4,0,4,0,4,1,4,1,4,0,5],DoEncode);
  // 1234567800 --> 50615150505061505051506061505050506051506050515051505060515060505160505050505160505051605151506
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[4,0,5,1,4,1,4,0,4,0,4,0,5,1,4,0,4,0,4,1,4,0,5,0,5,1,4,0,4,0,4,0,4,0,5,0,4,1,4,0,5,0,4,0,4,1,4,0,4,1,4,0,4,0,5,0,4,1,4,0,5,0,4,0,4,1,5,0,4,0,4,0,4,0,4,0,4,1,5,0,4,0,4,0,4,1,5,0,4,1,4,1,4,0,5],DoEncode);
  // 123456789ABCD --> 50615150505061505051506061505050506051506050515051505060515060505160505060515050506151505151506050515160505161505151506
  SetText('123456789ABCD');
  AssertEquals('Test for "123456789ABCD"',[4,0,5,1,4,1,4,0,4,0,4,0,5,1,4,0,4,0,4,1,4,0,5,0,5,1,4,0,4,0,4,0,4,0,5,0,4,1,4,0,5,0,4,0,4,1,4,0,4,1,4,0,4,0,5,0,4,1,4,0,5,0,4,0,4,1,5,0,4,0,4,0,5,0,4,1,4,0,4,0,4,0,5,1,4,1,4,0,4,1,4,1,4,0,5,0,4,0,4,1,4,1,5,0,4,0,4,1,5,1,4,0,4,1,4,1,4,0,5],DoEncode);
end;


Procedure TTestBarcodes.TestCodeMSI;

begin
  SetEncoding(beMSI);
  // 0 --> 605151515151516051515
  SetText('0');
  AssertEquals('Test for "0"',[5,0,4,1,4,1,4,1,4,1,4,1,4,1,5,0,4,1,4,1,4],DoEncode);
  // 1 --> 605151516051515160515
  SetText('1');
  AssertEquals('Test for "1"',[5,0,4,1,4,1,4,1,5,0,4,1,4,1,4,1,5,0,4,1,4],DoEncode);
  // 2 --> 605151605151515151515
  SetText('2');
  AssertEquals('Test for "2"',[5,0,4,1,4,1,5,0,4,1,4,1,4,1,4,1,4,1,4,1,4],DoEncode);
  // 3 --> 605151606060515160515
  SetText('3');
  AssertEquals('Test for "3"',[5,0,4,1,4,1,5,0,5,0,5,0,4,1,4,1,5,0,4,1,4],DoEncode);
  // 4 --> 605160515160515151515
  SetText('4');
  AssertEquals('Test for "4"',[5,0,4,1,5,0,4,1,4,1,5,0,4,1,4,1,4,1,4,1,4],DoEncode);
  // 5 --> 605160516051606060515
  SetText('5');
  AssertEquals('Test for "5"',[5,0,4,1,5,0,4,1,5,0,4,1,5,0,5,0,5,0,4,1,4],DoEncode);
  // 6 --> 605160605151606051515
  SetText('6');
  AssertEquals('Test for "6"',[5,0,4,1,5,0,5,0,4,1,4,1,5,0,5,0,4,1,4,1,4],DoEncode);
  // 7 --> 605160606051605160515
  SetText('7');
  AssertEquals('Test for "7"',[5,0,4,1,5,0,5,0,5,0,4,1,5,0,4,1,5,0,4,1,4],DoEncode);
  // 8 --> 606051515151605151515
  SetText('8');
  AssertEquals('Test for "8"',[5,0,5,0,4,1,4,1,4,1,4,1,5,0,4,1,4,1,4,1,4],DoEncode);
  // 9 --> 606051516051516060515
  SetText('9');
  AssertEquals('Test for "9"',[5,0,5,0,4,1,4,1,5,0,4,1,4,1,5,0,5,0,4,1,4],DoEncode);
  // 1234567800 --> 605151516051516051515160605160515151605160516060515160606060515151515151515151515160515151515
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[5,0,4,1,4,1,4,1,5,0,4,1,4,1,5,0,4,1,4,1,4,1,5,0,5,0,4,1,5,0,4,1,4,1,4,1,5,0,4,1,5,0,4,1,5,0,5,0,4,1,4,1,5,0,5,0,5,0,5,0,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,5,0,4,1,4,1,4,1,4,1,4],DoEncode);
end;


Procedure TTestBarcodes.TestCodePostNet;

begin
  SetEncoding(bePostNet);
  // 0 --> 515151A1A1A15
  SetText('0');
  AssertEquals('Test for "0"',[4,1,4,1,4,1,8,1,8,1,8,1,4],DoEncode);
  // 1 --> 51A1A1A151515
  SetText('1');
  AssertEquals('Test for "1"',[4,1,8,1,8,1,8,1,4,1,4,1,4],DoEncode);
  // 2 --> 51A1A151A1515
  SetText('2');
  AssertEquals('Test for "2"',[4,1,8,1,8,1,4,1,8,1,4,1,4],DoEncode);
  // 3 --> 51A1A15151A15
  SetText('3');
  AssertEquals('Test for "3"',[4,1,8,1,8,1,4,1,4,1,8,1,4],DoEncode);
  // 4 --> 51A151A1A1515
  SetText('4');
  AssertEquals('Test for "4"',[4,1,8,1,4,1,8,1,8,1,4,1,4],DoEncode);
  // 5 --> 51A151A151A15
  SetText('5');
  AssertEquals('Test for "5"',[4,1,8,1,4,1,8,1,4,1,8,1,4],DoEncode);
  // 6 --> 51A15151A1A15
  SetText('6');
  AssertEquals('Test for "6"',[4,1,8,1,4,1,4,1,8,1,8,1,4],DoEncode);
  // 7 --> 5151A1A1A1515
  SetText('7');
  AssertEquals('Test for "7"',[4,1,4,1,8,1,8,1,8,1,4,1,4],DoEncode);
  // 8 --> 5151A1A151A15
  SetText('8');
  AssertEquals('Test for "8"',[4,1,4,1,8,1,8,1,4,1,8,1,4],DoEncode);
  // 9 --> 5151A151A1A15
  SetText('9');
  AssertEquals('Test for "9"',[4,1,4,1,8,1,4,1,8,1,8,1,4],DoEncode);
  // 1234567800 --> 51A1A1A15151A1A151A151A1A15151A1A151A1A151A151A151A1A15151A1A151A1A1A15151A1A151A15151A1A1A15151A1A1A15
  SetText('1234567800');
  AssertEquals('Test for "1234567800"',[4,1,8,1,8,1,8,1,4,1,4,1,8,1,8,1,4,1,8,1,4,1,8,1,8,1,4,1,4,1,8,1,8,1,4,1,8,1,8,1,4,1,8,1,4,1,8,1,4,1,8,1,8,1,4,1,4,1,8,1,8,1,4,1,8,1,8,1,8,1,4,1,4,1,8,1,8,1,4,1,8,1,4,1,4,1,8,1,8,1,8,1,4,1,4,1,8,1,8,1,8,1,4],DoEncode);
end;
{
BarTypes : TBarTypeParams = (
);

}
Class procedure TTestBarcodes.AssertEquals(Msg : String; AExpected,AActual : TBarColor);
begin
  AssertEquals(Msg,GetEnumName(TypeInfo(TBarColor),Ord(AExpected)),
                   GetEnumName(TypeInfo(TBarColor),Ord(AActual)));
end;

Class procedure TTestBarcodes.AssertEquals(Msg : String; AExpected,AActual : TBarWidth);
begin
  AssertEquals(Msg,GetEnumName(TypeInfo(TBarWidth),Ord(AExpected)),
                   GetEnumName(TypeInfo(TBarWidth),Ord(AActual)));
end;
Class procedure TTestBarcodes.AssertEquals(Msg : String; AExpected,AActual : TBarHeight);
begin
  AssertEquals(Msg,GetEnumName(TypeInfo(TBarHeight),Ord(AExpected)),
                   GetEnumName(TypeInfo(TBarHeight),Ord(AActual)));
end;

// AWidth : TBarWidth; AHeight : TBarheight);
// AColor : TBarColor; AWidth : TBarWidth; AHeight : TBarheight

procedure TTestBarcodes.AssertParams(aType : TBarType; AColor : TBarColor; AWidth : TBarWidth; AHeight : TBarheight);

Var
  S : String;
  P : TBarParams;

begin
  S:=Format('Bar type %d: ',[aType]);
  P:=BarTypeToBarParams(aType);
  AssertEquals(S+'Color',aColor,P.c);
  AssertEquals(S+'Width',aWidth,P.w);
  AssertEquals(S+'Height',aHeight,P.h);
end;

procedure TTestBarcodes.CheckParamsType;

begin
  AssertParams(0, bcWhite, bw100,  bhFull);
  AssertParams(1, bcWhite, bwWeighted, bhFull);
  AssertParams(2, bcWhite, bw150, bhFull);
  AssertParams(3, bcWhite, bw200, bhFull);
  AssertParams(4, bcBlack, bw100,  bhFull);
  AssertParams(5, bcBlack, bwWeighted, bhFull);
  AssertParams(6, bcBlack, bw150, bhFull);
  AssertParams(7, bcBlack, bw200, bhFull);
  AssertParams(8, bcBlack, bw100,  bhTwoFifth);
  AssertParams(9, bcBlack, bwWeighted, bhTwoFifth);
  AssertParams(10, bcBlack, bw150, bhTwoFifth);
  AssertParams(11, bcBlack, bw200, bhTwoFifth);
end;

procedure TTestBarcodes.CheckNumerictypes;
begin
  AssertTrue('Numerical types',NumericalEncodings=[beEAN8,beEAN13,
    be2of5industrial,be2of5interleaved, be2of5matrix,
    bePostNet,
    beMSI,
    be128C]);
end;



initialization
  RegisterTest(TTestBarcodes);
end.