fix a case that causes a variable not used warning/error

git-svn-id: https://zxing.googlecode.com/svn/trunk@2604 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2013-04-01 05:59:57 +00:00
parent 4d28115073
commit 9eaaccc985
9 changed files with 30 additions and 22 deletions

View file

@ -129,6 +129,7 @@ public:
#endif
reset(a);
}
/*
ArrayRef(const Array<T> &a) :
array_(0) {
#ifdef DEBUG_COUNTING
@ -136,6 +137,7 @@ public:
#endif
reset(const_cast<Array<T> *>(&a));
}
*/
ArrayRef(const ArrayRef &other) :
Counted(), array_(0) {
#ifdef DEBUG_COUNTING

View file

@ -30,7 +30,7 @@ using zxing::GreyscaleRotatedLuminanceSource;
// rotated.
GreyscaleRotatedLuminanceSource::
GreyscaleRotatedLuminanceSource(ArrayRef<char> greyData,
int dataWidth, int /* dataHeight */,
int dataWidth, int dataHeight,
int left, int top,
int width, int height)
: greyData_(greyData),

View file

@ -66,9 +66,9 @@ void BitArrayTest::testGetArray() {
BitArray array(2 * bits);
array.set(0);
array.set(2 * bits - 1);
vector<unsigned> words(array.getBitArray());
CPPUNIT_ASSERT_EQUAL(1u, words[0]);
CPPUNIT_ASSERT_EQUAL((1u << (bits - 1)), words[1]);
vector<int> words(array.getBitArray());
CPPUNIT_ASSERT_EQUAL(1, words[0]);
CPPUNIT_ASSERT_EQUAL((1 << (bits - 1)), words[1]);
}
void BitArrayTest::testIsRange() {
@ -97,7 +97,7 @@ void BitArrayTest::testIsRange() {
// fills the two arrays with identical random bits
void BitArrayTest::fillRandom(BitArray& test, BitArray& reference) {
srandom(0xDEADBEEFL + test.getSize());
for(size_t i = 0; i < test.getSize(); ++i) {
for(int i = 0; i < test.getSize(); ++i) {
if(random() & 0x1) {
test.set(i);
reference.set(i);

View file

@ -32,18 +32,18 @@ BitMatrixTest::BitMatrixTest() {
}
void BitMatrixTest::testGetSet() {
size_t bits = numeric_limits<unsigned int>::digits;
int bits = numeric_limits<int>::digits;
BitMatrix matrix(bits + 1);
CPPUNIT_ASSERT_EQUAL(bits + 1, matrix.getDimension());
for (size_t i = 0; i < bits + 1; i++) {
for (size_t j = 0; j < bits + 1; j++) {
for (int i = 0; i < bits + 1; i++) {
for (int j = 0; j < bits + 1; j++) {
if (i * j % 3 == 0) {
matrix.set(i, j);
}
}
}
for (size_t i = 0; i < bits + 1; i++) {
for (size_t j = 0; j < bits + 1; j++) {
for (int i = 0; i < bits + 1; i++) {
for (int j = 0; j < bits + 1; j++) {
CPPUNIT_ASSERT_EQUAL(i * j % 3 == 0, matrix.get(i, j));
}
}
@ -64,9 +64,9 @@ void BitMatrixTest::testGetBits() {
BitMatrix matrix(6);
matrix.set(0, 0);
matrix.set(5, 5);
unsigned int* bits = matrix.getBits();
CPPUNIT_ASSERT_EQUAL(1u, bits[0]);
CPPUNIT_ASSERT_EQUAL(8u, bits[1]);
ArrayRef<int> bits = matrix.getBits();
CPPUNIT_ASSERT_EQUAL(1, bits[0]);
CPPUNIT_ASSERT_EQUAL(8, bits[1]);
}
void BitMatrixTest::testGetRow1() {

View file

@ -24,7 +24,7 @@ namespace zxing {
CPPUNIT_TEST_SUITE_REGISTRATION(BitSourceTest);
typedef unsigned char byte;
typedef char byte;
void BitSourceTest::testSource() {
byte rawBytes[] = {(byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5};

View file

@ -29,7 +29,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION(BlackPointEstimatorTest);
void BlackPointEstimatorTest::testBasic() {
int histogramRaw[] = { 0, 0, 11, 43, 37, 18, 3, 1, 0, 0, 13, 36, 24, 0, 11, 2 };
vector<int> histogram(histogramRaw, histogramRaw+16);
size_t point = GlobalHistogramBinarizer::estimate(histogram);
ArrayRef<int> array (new Array<int>(histogram));
size_t point = GlobalHistogramBinarizer::estimateBlackPoint(array);
CPPUNIT_ASSERT_EQUAL((size_t)64, point);
}
@ -37,7 +38,8 @@ void BlackPointEstimatorTest::testTooLittleRange() {
try {
int histogramRaw[] = { 0, 0, 0, 0, 0, 0, 1, 43, 48, 18, 3, 1, 0, 0, 0, 0 };
vector<int> histogram(histogramRaw, histogramRaw+16);
GlobalHistogramBinarizer::estimate(histogram);
ArrayRef<int> array (new Array<int>(histogram));
GlobalHistogramBinarizer::estimateBlackPoint(array);
CPPUNIT_FAIL("Should have thrown an exception");
} catch (IllegalArgumentException ie) {

View file

@ -44,11 +44,15 @@ void CountedTest::test() {
CPPUNIT_ASSERT_EQUAL(0, foo.count());
foo.retain();
CPPUNIT_ASSERT_EQUAL(1, foo.count());
Ref<Foo> foobar(new Foo);
CPPUNIT_ASSERT_EQUAL(1, foobar->count());
{
Ref<Foo> fooRef(foo);
CPPUNIT_ASSERT_EQUAL(2, foo.count());
Ref<Foo> secondRef(foobar);
CPPUNIT_ASSERT_EQUAL(1, foo.count());
CPPUNIT_ASSERT_EQUAL(2, foobar->count());
}
CPPUNIT_ASSERT_EQUAL(1, foo.count());
CPPUNIT_ASSERT_EQUAL(1, foobar->count());
}
}

View file

@ -69,7 +69,7 @@ void ReedSolomonTest::testNoError() {
void ReedSolomonTest::testOneError() {
ArrayRef<int> received(new Array<int>(qrCodeTestWithEc_->size()));
srandom(0xDEADBEEFL);
for (unsigned i = 0; i < received->size(); i++) {
for (int i = 0; i < received->size(); i++) {
*received = *qrCodeTestWithEc_;
received[i] = random() % 256;
checkQRRSDecode(received);
@ -79,7 +79,7 @@ void ReedSolomonTest::testOneError() {
void ReedSolomonTest::testMaxErrors() {
ArrayRef<int> received(new Array<int>(qrCodeTestWithEc_->size()));
srandom(0xDEADBEEFL);
for (unsigned i = 0; i < qrCodeTest_->size(); i++) {
for (int i = 0; i < qrCodeTest_->size(); i++) {
*received = *qrCodeTestWithEc_;
corrupt(received, qrCodeCorrectable_);
checkQRRSDecode(received);
@ -106,7 +106,7 @@ void ReedSolomonTest::testTooManyErrors() {
void ReedSolomonTest::checkQRRSDecode(ArrayRef<int> &received) {
int twoS = 2 * qrCodeCorrectable_;
qrRSDecoder_->decode(received, twoS);
for (unsigned i = 0; i < qrCodeTest_->size(); i++) {
for (int i = 0; i < qrCodeTest_->size(); i++) {
CPPUNIT_ASSERT_EQUAL(qrCodeTest_[i], received[i]);
}
}

View file

@ -59,7 +59,7 @@ void FormatInformationTest::testDecode() {
// Normal case
Ref<FormatInformation> expected =
FormatInformation::decodeFormatInformation(MASKED_TEST_FORMAT_INFO, MASKED_TEST_FORMAT_INFO);
CPPUNIT_ASSERT_EQUAL((unsigned char) 0x07, expected->getDataMask());
CPPUNIT_ASSERT_EQUAL((char)0x07, expected->getDataMask());
CPPUNIT_ASSERT_EQUAL(&ErrorCorrectionLevel::Q,
&expected->getErrorCorrectionLevel());
// where the code forgot the mask!