Finally actually fix the Code-128 bug and add tests

git-svn-id: https://zxing.googlecode.com/svn/trunk@588 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-09-24 12:16:41 +00:00
parent 78af16ca34
commit 6db50e0b79
6 changed files with 43 additions and 3 deletions

View file

@ -268,9 +268,6 @@ public final class Code128Reader extends AbstractOneDReader {
while (!done) {
// Remember whether the last code was printable or not (excluding CODE_STOP)
lastCharacterWasPrintable = true;
boolean unshift = isNextShifted;
isNextShifted = false;
@ -280,6 +277,11 @@ public final class Code128Reader extends AbstractOneDReader {
// Decode another code from image
code = decodeCode(row, counters, nextStart);
// Remember whether the last code was printable or not (excluding CODE_STOP)
if (code != CODE_STOP) {
lastCharacterWasPrintable = true;
}
// Add to checksum computation (if not CODE_STOP of course)
if (code != CODE_STOP) {
multiplier++;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -0,0 +1 @@
10064908

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

View file

@ -0,0 +1 @@
10068408

View file

@ -0,0 +1,36 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import java.io.File;
/**
* @author srowen@google.com (Sean Owen)
*/
public final class Code128BlackBox3TestCase extends AbstractBlackBoxTestCase {
public Code128BlackBox3TestCase() {
super(new File("test/data/blackbox/code128-3"), new MultiFormatReader(), BarcodeFormat.CODE_128);
addTest(2, 2, 0.0f);
addTest(2, 2, 180.0f);
}
}