partial working code39

This commit is contained in:
Henry Schimke
2022-12-04 10:42:23 -06:00
parent 34e2473a5d
commit 2a32984d8d
17 changed files with 705 additions and 631 deletions

View File

@@ -1,34 +0,0 @@
/*
* 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;
/**
* @author Sean Owen
*/
public final class Code39BlackBox1TestCase extends AbstractBlackBoxTestCase {
public Code39BlackBox1TestCase() {
super("src/test/resources/blackbox/code39-1", new MultiFormatReader(), BarcodeFormat.CODE_39);
addTest(4, 4, 0.0f);
addTest(4, 4, 180.0f);
}
}

View File

@@ -1,34 +0,0 @@
/*
* 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;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class Code39BlackBox3TestCase extends AbstractBlackBoxTestCase {
public Code39BlackBox3TestCase() {
super("src/test/resources/blackbox/code39-3", new MultiFormatReader(), BarcodeFormat.CODE_39);
addTest(17, 17, 0.0f);
addTest(17, 17, 180.0f);
}
}

View File

@@ -1,33 +0,0 @@
/*
* 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.common.AbstractBlackBoxTestCase;
/**
* @author Sean Owen
*/
public final class Code39ExtendedBlackBox2TestCase extends AbstractBlackBoxTestCase {
public Code39ExtendedBlackBox2TestCase() {
super("src/test/resources/blackbox/code39-2", new Code39Reader(false, true), BarcodeFormat.CODE_39);
addTest(2, 2, 0.0f);
addTest(2, 2, 180.0f);
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright 2017 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 org.junit.Assert;
import org.junit.Test;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.BitArray;
import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import com.google.zxing.RXingResult;
/**
* @author Michael Jahn
*/
public final class Code39ExtendedModeTestCase extends Assert {
@SuppressWarnings("checkstyle:lineLength")
@Test
public void testDecodeExtendedMode() throws FormatException, ChecksumException, NotFoundException {
doTest("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f",
"000001001011011010101001001001011001010101101001001001010110101001011010010010010101011010010110100100100101011011010010101001001001010101011001011010010010010101101011001010100100100101010110110010101001001001010101010011011010010010010101101010011010100100100101010110100110101001001001010101011001101010010010010101101010100110100100100101010110101001101001001001010110110101001010010010010101010110100110100100100101011010110100101001001001010101101101001010010010010101010101100110100100100101011010101100101001001001010101101011001010010010010101010110110010100100100101011001010101101001001001010100110101011010010010010101100110101010100100100101010010110101101001001001010110010110101010010010010101001101101010101001001001011010100101101010010010010101101001011010100100100101101101001010101001001001010101100101101010010010010110101100101010010110110100000");
doTest(" !\"#$%&'()*+,-./0123456789:;<=>?",
"00000100101101101010011010110101001001010010110101001011010010010100101011010010110100100101001011011010010101001001010010101011001011010010010100101101011001010100100101001010110110010101001001010010101010011011010010010100101101010011010100100101001010110100110101001001010010101011001101010010010100101101010100110100100101001010110101001101001010110110110010101101010010010100101101011010010101001101101011010010101101011001010110110110010101010100110101101101001101010101100110101010100101101101101001011010101100101101010010010100101001101101010101001001001010110110010101010010010010101010011011010100100100101101010011010101001001001010110100110101010010010010101011001101010010110110100000");
doTest("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_",
"000010010110110101010010010010100110101011011010100101101011010010110110110100101010101100101101101011001010101101100101010101001101101101010011010101101001101010101100110101101010100110101101010011011011010100101010110100110110101101001010110110100101010101100110110101011001010110101100101010110110010110010101011010011010101101100110101010100101101011011001011010101001101101010101001001001011010101001101010010010010101101010011010100100100101101101010010101001001001010101101001101010010010010110101101001010010110110100000");
doTest("`abcdefghijklmnopqrstuvwxyz{|}~",
"000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000");
}
private static void doTest(String expectedRXingResult, String encodedRXingResult)
throws FormatException, ChecksumException, NotFoundException {
Code39Reader sut = new Code39Reader(false, true);
BitMatrix matrix = BitMatrix.parse(encodedRXingResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth());
matrix.getRow(0, row);
RXingResult result = sut.decodeRow(0, row, null);
assertEquals(expectedRXingResult, result.getText());
}
}

View File

@@ -14,7 +14,10 @@
* limitations under the License.
*/
use rxing::{BarcodeFormat, MultiFormatReader, oned::{OneDReader, CodaBarReader}};
use rxing::{
oned::{CodaBarReader, OneDReader},
BarcodeFormat, MultiFormatReader,
};
mod common;

View File

@@ -0,0 +1,67 @@
/**
* 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.
*/
use rxing::{
oned::{CodaBarReader, Code39Reader, OneDReader},
BarcodeFormat, MultiFormatReader,
};
mod common;
/**
* @author Sean Owen
*/
#[test]
fn code39_black_box1_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/code39-1",
MultiFormatReader::default(),
BarcodeFormat::CODE_39,
);
// super("src/test/resources/blackbox/code39-1", new MultiFormatReader(), BarcodeFormat.CODE_39);
tester.add_test(4, 4, 0.0);
tester.add_test(4, 4, 180.0);
tester.test_black_box();
}
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
#[test]
fn code39_black_box3_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/code39-3",
MultiFormatReader::default(),
BarcodeFormat::CODE_39,
);
// super("src/test/resources/blackbox/code39-3", new MultiFormatReader(), BarcodeFormat.CODE_39);
tester.add_test(17, 17, 0.0);
tester.add_test(17, 17, 180.0);
tester.test_black_box();
}
/**
* @author Sean Owen
*/
#[test]
fn code39_extended_black_box2_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/code39-2",
Code39Reader::with_all_config(false, true),
BarcodeFormat::CODE_39,
);
// super("src/test/resources/blackbox/code39-2", new Code39Reader(false, true), BarcodeFormat.CODE_39);
tester.add_test(2, 2, 0.0);
tester.add_test(2, 2, 180.0);
tester.test_black_box();
}