1 #ifndef __DATA_MASK_TEST_H__
2 #define __DATA_MASK_TEST_H__
8 * Created by Christian Brunschen on 19/05/2008.
9 * Copyright 2008 ZXing authors All rights reserved.
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
24 #include <cppunit/TestFixture.h>
25 #include <cppunit/extensions/HelperMacros.h>
26 #include <zxing/qrcode/decoder/DataMask.h>
27 #include <zxing/common/BitMatrix.h>
35 virtual bool isMasked(int i, int j) = 0;
36 virtual ~MaskCondition() { }
40 class DataMaskTest : public CPPUNIT_NS::TestFixture {
41 CPPUNIT_TEST_SUITE(DataMaskTest);
42 CPPUNIT_TEST(testMask0);
43 CPPUNIT_TEST(testMask1);
44 CPPUNIT_TEST(testMask2);
45 CPPUNIT_TEST(testMask3);
46 CPPUNIT_TEST(testMask4);
47 CPPUNIT_TEST(testMask5);
48 CPPUNIT_TEST(testMask6);
49 CPPUNIT_TEST(testMask7);
50 CPPUNIT_TEST_SUITE_END();
65 void testMaskAcrossDimensions(int reference,
66 MaskCondition &condition) {
67 DataMask& mask = DataMask::forReference(reference);
68 for (int version = 1; version <= 40; version++) {
69 int dimension = 17 + 4 * version;
70 testMask(mask, dimension, condition);
74 void testMask(DataMask& mask, int dimension, MaskCondition &condition) {
75 BitMatrix bits(dimension);
76 mask.unmaskBitMatrix(bits, dimension);
77 for (int i = 0; i < dimension; i++) {
78 for (int j = 0; j < dimension; j++) {
79 //TODO: check why the coordinates are swapped
81 //"(" + i + ',' + j + ')',
82 condition.isMasked(i, j),
92 #endif // __DATA_MASK_TEST_H__