diff --git a/src/oned/Code93ReaderTestCase.java b/src/oned/Code93ReaderTestCase.java deleted file mode 100644 index ae5ef31..0000000 --- a/src/oned/Code93ReaderTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2018 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 Daisuke Makiuchi - */ -public final class Code93ReaderTestCase extends Assert { - - @SuppressWarnings("checkstyle:lineLength") - @Test - public void testDecode() throws FormatException, ChecksumException, NotFoundException { - doTest("Code93!\n$%/+ :\u001b;[{\u007f\u0000@`\u007f\u007f\u007f", - "0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111"); - } - - private static void doTest(String expectedRXingResult, String encodedRXingResult) - throws FormatException, ChecksumException, NotFoundException { - Code93Reader sut = new Code93Reader(); - 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()); - } - -} diff --git a/src/oned/code_93_reader.rs b/src/oned/code_93_reader.rs index 90e5b2a..8df2747 100644 --- a/src/oned/code_93_reader.rs +++ b/src/oned/code_93_reader.rs @@ -340,3 +340,35 @@ impl Code93Reader { } } } + +/** + * @author Daisuke Makiuchi + */ +#[cfg(test)] +mod Code93ReaderTestCase { + use std::collections::HashMap; + + use crate::{ + common::{BitArray, BitMatrix}, + oned::OneDReader, + }; + + use super::Code93Reader; + + #[test] + fn testDecode() { + doTest("Code93!\n$%/+ :\u{001b};[{\u{007f}\u{0000}@`\u{007f}\u{007f}\u{007f}", + "0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111"); + } + + fn doTest(expectedRXingResult: &str, encodedRXingResult: &str) { + let mut sut = Code93Reader::new(); + let matrix = BitMatrix::parse_strings(encodedRXingResult, "1", "0").expect("must parse"); + let mut row = BitArray::with_size(matrix.getWidth() as usize); + row = matrix.getRow(0, row); + let result = sut + .decodeRow(0, &row, &HashMap::new()) + .expect("must decode"); + assert_eq!(expectedRXingResult, result.getText()); + } +}