2 * Copyright (C) 2010 ZXing authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * These authors would like to acknowledge the Spanish Ministry of Industry,
19 * Tourism and Trade, for the support in the project TSI020301-2008-2
20 * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21 * Mobile Dynamic Environments", led by Treelogic
22 * ( http://www.treelogic.com/ ):
24 * http://www.piramidepse.com/
27 package com.google.zxing.oned.rss.expanded.decoders;
29 import com.google.zxing.NotFoundException;
30 import com.google.zxing.common.BitArray;
31 import com.google.zxing.oned.rss.expanded.BinaryUtil;
33 import org.junit.Assert;
36 * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
38 public abstract class AbstractDecoderTest extends Assert {
40 protected static final String numeric_10 = "..X..XX";
41 protected static final String numeric_12 = "..X.X.X";
42 protected static final String numeric_1FNC1 = "..XXX.X";
43 protected static final String numeric_FNC11 = "XXX.XXX";
45 protected static final String numeric2alpha = "....";
47 protected static final String alpha_A = "X.....";
48 protected static final String alpha_FNC1 = ".XXXX";
49 protected static final String alpha2numeric = "...";
50 protected static final String alpha2isoiec646 = "..X..";
52 protected static final String i646_B = "X.....X";
53 protected static final String i646_C = "X....X.";
54 protected static final String i646_FNC1 = ".XXXX";
55 protected static final String isoiec646_2alpha = "..X..";
57 protected static final String compressedGtin_900123456798908 = ".........X..XXX.X.X.X...XX.XXXXX.XXXX.X.";
58 protected static final String compressedGtin_900000000000008 = "........................................";
60 protected static final String compressed15bitWeight_1750 = "....XX.XX.X.XX.";
61 protected static final String compressed15bitWeight_11750 = ".X.XX.XXXX..XX.";
62 protected static final String compressed15bitWeight_0 = "...............";
64 protected static final String compressed20bitWeight_1750 = ".........XX.XX.X.XX.";
66 protected static final String compressedDate_March_12th_2010 = "....XXXX.X..XX..";
67 protected static final String compressedDate_End = "X..X.XX.........";
69 protected void assertCorrectBinaryString(String binaryString, String expectedNumber) throws NotFoundException {
70 BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(binaryString);
71 AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
72 String result = decoder.parseInformation();
73 assertEquals(expectedNumber, result);