"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java" between
zxing-zxing-3.4.1.tar.gz and zxing-zxing-3.5.0.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. Info: Project is in maintenance mode (no active development).

DecoderTest.java  (zxing-zxing-3.4.1):DecoderTest.java  (zxing-zxing-3.5.0)
skipping to change at line 18 skipping to change at line 18
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.zxing.aztec.decoder; package com.google.zxing.aztec.decoder;
import com.google.zxing.aztec.encoder.EncoderTest;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.ResultPoint; import com.google.zxing.ResultPoint;
import com.google.zxing.aztec.AztecDetectorResult; import com.google.zxing.aztec.AztecDetectorResult;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderResult;
import org.junit.Test; import org.junit.Test;
import org.junit.Assert; import org.junit.Assert;
/** /**
* Tests {@link Decoder}. * Tests {@link Decoder}.
*/ */
public final class DecoderTest extends Assert { public final class DecoderTest extends Assert {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
@Test @Test
public void testHighLevelDecode() throws FormatException {
// no ECI codes
testHighLevelDecodeString("A. b.",
// 'A' P/S '. ' L/L b D/L '.'
"...X. ..... ...XX XXX.. ...XX XXXX. XX.X");
// initial ECI code 26 (switch to UTF-8)
testHighLevelDecodeString("Ça",
// P/S FLG(n) 2 '2' '6' B/S 2 0xc3 0x87 L/L 'a'
"..... ..... .X. .X.. X... XXXXX ...X. XX....XX X....XXX XXX.. ...X.");
// initial character without ECI (must be interpreted as ISO_8859_1)
// followed by ECI code 26 (= UTF-8) and UTF-8 text
testHighLevelDecodeString("±Ça",
// B/S 1 0xb1 P/S FLG(n) 2 '2' '6' B/S 2 0xc3 0x8
7 L/L 'a'
"XXXXX ....X X.XX...X ..... ..... .X. .X.. X... XXXXX ...X. XX....XX X..
..XXX XXX.. ...X.");
// GS1 data
testHighLevelDecodeString("101233742",
// P/S FLG(n) 0 D/L 1 0 1 2 3 P/S FLG(n) 0 3 7
4 2
"..... ..... ... XXXX. ..XX ..X. ..XX .X.. .X.X .... ..... ... .X.X X..X
.XX. .X..");
}
private static void testHighLevelDecodeString(String expectedString, String b)
throws FormatException {
BitArray bits = EncoderTest.toBitArray(EncoderTest.stripSpace(b));
assertEquals("highLevelDecode() failed for input bits: " + b,
expectedString, Decoder.highLevelDecode(EncoderTest.toBooleanAr
ray(bits)));
}
@Test
public void testAztecResult() throws FormatException { public void testAztecResult() throws FormatException {
BitMatrix matrix = BitMatrix.parse( BitMatrix matrix = BitMatrix.parse(
"X X X X X X X X X X X X X X \n" + "X X X X X X X X X X X X X X \n" +
"X X X X X X X X X X X X X X X \n" + "X X X X X X X X X X X X X X X \n" +
" X X X X X X X X X X X X \n" + " X X X X X X X X X X X X \n" +
" X X X X X X X X X X \n" + " X X X X X X X X X X \n" +
" X X X X X X X X \n" + " X X X X X X X X \n" +
" X X X X X X X X X X X X X X X X X X \n" + " X X X X X X X X X X X X X X X X X X \n" +
" X X X X X X X X X \n" + " X X X X X X X X X \n" +
" X X X X X X X X X X X X X X X X X \n" + " X X X X X X X X X X X X X X X X X \n" +
skipping to change at line 71 skipping to change at line 104
DecoderResult result = new Decoder().decode(r); DecoderResult result = new Decoder().decode(r);
assertEquals("88888TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", result.getText()); assertEquals("88888TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", result.getText());
assertArrayEquals( assertArrayEquals(
new byte[] {-11, 85, 85, 117, 107, 90, -42, -75, -83, 107, new byte[] {-11, 85, 85, 117, 107, 90, -42, -75, -83, 107,
90, -42, -75, -83, 107, 90, -42, -75, -83, 107, 90, -42, -75, -83, 107, 90, -42, -75, -83, 107,
90, -42, -80}, 90, -42, -80},
result.getRawBytes()); result.getRawBytes());
assertEquals(180, result.getNumBits()); assertEquals(180, result.getNumBits());
} }
@Test
public void testAztecResultECI() throws FormatException {
BitMatrix matrix = BitMatrix.parse(
" X X X X X X \n" +
" X X X X X X X X X X X X \n" +
" X X X X \n" +
" X X X X X X X X X X X X X X X X X \n" +
" X X \n" +
" X X X X X X X X X X X X \n" +
" X X X X X X X X \n" +
" X X X X X X X X X X X X \n" +
" X X X X X X X X \n" +
" X X X X X X X X X \n" +
"X X X X X X X X X \n" +
" X X X X X X X X X X X X \n" +
" X X X X X X \n" +
" X X X X X X X X X X X X X \n" +
" X X X \n" +
"X X X X X X X X X X X X X X X X X \n" +
"X X X X X X X X X \n" +
" X X X X X X X X X X X \n" +
"X X X X X X X X \n",
"X ", " ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 15
, 1);
DecoderResult result = new Decoder().decode(r);
assertEquals("Français", result.getText());
}
@Test(expected = FormatException.class) @Test(expected = FormatException.class)
public void testDecodeTooManyErrors() throws FormatException { public void testDecodeTooManyErrors() throws FormatException {
BitMatrix matrix = BitMatrix.parse("" BitMatrix matrix = BitMatrix.parse(""
+ "X X . X . . . X X . . . X . . X X X . X . X X X X X . \n" + "X X . X . . . X X . . . X . . X X X . X . X X X X X . \n"
+ "X X . . X X . . . . . X X . . . X X . . . X . X . . X \n" + "X X . . X X . . . . . X X . . . X X . . . X . X . . X \n"
+ "X . . . X X . . X X X . X X . X X X X . X X . . X . . \n" + "X . . . X X . . X X X . X X . X X X X . X X . . X . . \n"
+ ". . . . X . X X . . X X . X X . X . X X X X . X . . X \n" + ". . . . X . X X . . X X . X X . X . X X X X . X . . X \n"
+ "X X X . . X X X X X . . . . . X X . . . X . X . X . X \n" + "X X X . . X X X X X . . . . . X X . . . X . X . X . X \n"
+ "X X . . . . . . . . X . . . X . X X X . X . . X . . . \n" + "X X . . . . . . . . X . . . X . X X X . X . . X . . . \n"
+ "X X . . X . . . . . X X . . . . . X . . . . X . . X X \n" + "X X . . X . . . . . X X . . . . . X . . . . X . . X X \n"
 End of changes. 4 change blocks. 
0 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)