Fix a few issues in test raised by the stricter gcc flags. Closes issue 1085.

- Some of the cpp tests still fail to compile, but that's covered in issue 1066.
- I tweaked the SConscript to be a little happier with OS X and cppunit and imagemagick
in /opt/local.  These should be benign on other systems but let me know if they aren't
and I'll back tweak them or back them out.

git-svn-id: https://zxing.googlecode.com/svn/trunk@2057 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2011-11-30 00:47:33 +00:00
parent 06ac4a110d
commit 1a53f4f875
4 changed files with 10 additions and 11 deletions

View file

@ -24,7 +24,7 @@ flags.append("-Wextra -Werror")
# flags.append("-pedantic") # flags.append("-pedantic")
compile_options['CXXFLAGS'] = ' '.join(flags) compile_options['CXXFLAGS'] = ' '.join(flags)
compile_options['LINKFLAGS'] = "-ldl" compile_options['LINKFLAGS'] = "-ldl -L/usr/lib -L/opt/local/lib"
def all_files(dir, ext='.cpp', level=6): def all_files(dir, ext='.cpp', level=6):
files = [] files = []
@ -35,8 +35,9 @@ def all_files(dir, ext='.cpp', level=6):
magick_include = ['/usr/include/ImageMagick/', '/opt/local/include/ImageMagick/'] magick_include = ['/usr/include/ImageMagick/', '/opt/local/include/ImageMagick/']
magick_libs = ['Magick++', 'MagickWand', 'MagickCore'] magick_libs = ['Magick++', 'MagickWand', 'MagickCore', 'iconv']
cppunit_include = ['/opt/local/include/']
cppunit_libs = ['cppunit'] cppunit_libs = ['cppunit']
zxing_files = all_files('core/src') zxing_files = all_files('core/src')
@ -45,10 +46,10 @@ zxing_include = ['core/src']
zxing_libs = env.Library('zxing', source=zxing_files, CPPPATH=zxing_include, **compile_options) zxing_libs = env.Library('zxing', source=zxing_files, CPPPATH=zxing_include, **compile_options)
app_files = ['magick/src/MagickBitmapSource.cpp', 'magick/src/main.cpp'] app_files = ['magick/src/MagickBitmapSource.cpp', 'magick/src/main.cpp']
app_executable = env.Program('zxing', app_files, CPPPATH=magick_include + zxing_include, LIBS=magick_libs + zxing_libs, **compile_options) app_executable = env.Program('zxing', app_files, CPPPATH=magick_include + zxing_include, LIBS=zxing_libs + magick_libs, **compile_options)
test_files = all_files('core/tests/src') test_files = all_files('core/tests/src')
test_executable = env.Program('testrunner', test_files, CPPPATH=zxing_include, LIBS=zxing_libs + cppunit_libs, **compile_options) test_executable = env.Program('testrunner', test_files, CPPPATH=zxing_include + cppunit_include, LIBS=zxing_libs + cppunit_libs, **compile_options)
Alias('lib', zxing_libs) Alias('lib', zxing_libs)

View file

@ -21,7 +21,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h> #include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h> #include <cppunit/ui/text/TestRunner.h>
int main(int argc, char **argv) { int main(int, char**) {
CppUnit::TextUi::TestRunner runner; CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry(); CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest()); runner.addTest(registry.makeTest());

View file

@ -1,7 +1,5 @@
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
/* /*
* DataMaskTest.cpp
* zxing
*
* Created by Christian Brunschen on 19/05/2008. * Created by Christian Brunschen on 19/05/2008.
* Copyright 2008 ZXing authors All rights reserved. * Copyright 2008 ZXing authors All rights reserved.
* *
@ -36,7 +34,7 @@ public:
class Mask1Condition : public MaskCondition { class Mask1Condition : public MaskCondition {
public: public:
Mask1Condition() { } Mask1Condition() { }
bool isMasked(int i, int j) { bool isMasked(int i, int) {
return i % 2 == 0; return i % 2 == 0;
} }
}; };
@ -44,7 +42,7 @@ public:
class Mask2Condition : public MaskCondition { class Mask2Condition : public MaskCondition {
public: public:
Mask2Condition() { } Mask2Condition() { }
bool isMasked(int i, int j) { bool isMasked(int, int j) {
return j % 3 == 0; return j % 3 == 0;
} }
}; };

View file

@ -116,7 +116,7 @@ int test_image(Image& image, bool hybrid, string expected = "") {
res = -6; res = -6;
if (!raw_dump) { if (!raw_dump) {
cout << (hybrid ? "Hybrid" : "Global") << " binarizer failed:\n"; cout << (hybrid ? "Hybrid" : "Global") << " binarizer failed:\n";
if (expected.length() >= 0) { if (!expected.empty()) {
cout << " Expected: " << expected << "\n"; cout << " Expected: " << expected << "\n";
} }
cout << " Detected: " << cell_result << endl; cout << " Detected: " << cell_result << endl;