5 * Created by Christian Brunschen on 19/05/2008.
6 * Copyright 2008 ZXing authors All rights reserved.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <zxing/qrcode/Version.h>
27 CPPUNIT_TEST_SUITE_REGISTRATION(ModeTest);
29 void ModeTest::testForBits() {
30 CPPUNIT_ASSERT_EQUAL(&Mode::TERMINATOR, &(Mode::forBits(0x00)));
31 CPPUNIT_ASSERT_EQUAL(&Mode::NUMERIC, &(Mode::forBits(0x01)));
32 CPPUNIT_ASSERT_EQUAL(&Mode::ALPHANUMERIC, &(Mode::forBits(0x02)));
33 CPPUNIT_ASSERT_EQUAL(&Mode::BYTE, &(Mode::forBits(0x04)));
34 CPPUNIT_ASSERT_EQUAL(&Mode::KANJI, &(Mode::forBits(0x08)));
37 CPPUNIT_FAIL("should have thrown an exception");
38 } catch (zxing::ReaderException ex) {
43 void ModeTest::testCharacterCount() {
44 CPPUNIT_ASSERT_EQUAL(10, Mode::NUMERIC.getCharacterCountBits(Version::getVersionForNumber(5)));
45 CPPUNIT_ASSERT_EQUAL(12, Mode::NUMERIC.getCharacterCountBits(Version::getVersionForNumber(26)));
46 CPPUNIT_ASSERT_EQUAL(14, Mode::NUMERIC.getCharacterCountBits(Version::getVersionForNumber(40)));
47 CPPUNIT_ASSERT_EQUAL(9, Mode::ALPHANUMERIC.getCharacterCountBits(Version::getVersionForNumber(6)));
48 CPPUNIT_ASSERT_EQUAL(8, Mode::BYTE.getCharacterCountBits(Version::getVersionForNumber(7)));
49 CPPUNIT_ASSERT_EQUAL(8, Mode::KANJI.getCharacterCountBits(Version::getVersionForNumber(8)));