barnhill / barcodelib

C# Barcode Image Generation Library
Apache License 2.0
744 stars 239 forks source link

Suggestion for improvement #166

Closed rob313663 closed 1 year ago

rob313663 commented 1 year ago

Hi!

A good thing to improve BarcodeLib would be to make tests for all barcode types using all the valid data characters when generating a barcode and then use ZXing to read the generated barcodes.

Adding a property on every barcode type called ValidDataCharacters (works for Code 39, Interleaved 2 of 5 and Codabar so far, Code 128 will be probably be a bit harder) and using RandomizeString() and running it a couple of hundred times and checking against what ZXing says would a very good test:

image image

/rob

barnhill commented 1 year ago

Then the library is only as strong as ZXing and if they have a bug we follow them down that rabbit hole. I would rather test against known good encoding thats have been tested via several barcode readers which is what the unit tests currently do by testing the encoded values.

barnhill commented 1 year ago

I did utilize the faster numeric check with very marginal differences but it may be faster with my crud testing. https://github.com/barnhill/barcodelib/commit/4b0de50f18b845864b43d1702e7121920f421a20