00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <string>
00022
00023 #include <boost/test/auto_unit_test.hpp>
00024 #include <boost/crc.hpp>
00025
00026 #include <libopenraw++/rawdata.h>
00027
00028 #include "io/file.h"
00029 #include "rawcontainer.h"
00030 #include "jfifcontainer.h"
00031 #include "ljpegdecompressor.h"
00032 #include "ljpegdecompressor_priv.h"
00033
00034 using boost::unit_test::test_suite;
00035 using OpenRaw::RawData;
00036 using OpenRaw::IO::File;
00037
00038 std::string g_testfile;
00039
00040 using namespace OpenRaw::Internals;
00041
00042 void test_ljpeg()
00043 {
00044 RawData *decompData;
00045 File *s = new File(g_testfile.c_str());
00046 RawContainer *container = new JFIFContainer(s, 0);
00047
00048 LJpegDecompressor decompressor(s, container);
00049
00050 decompData = decompressor.decompress();
00051
00052 boost::crc_optimal<8, 0x1021, 0xFFFF, 0, false, false> crc_ccitt2;
00053 const uint8_t * data = static_cast<uint8_t *>(decompData->data());
00054 size_t data_len = decompData->size();
00055 crc_ccitt2 = std::for_each( data, data + data_len, crc_ccitt2 );
00056 BOOST_CHECK_EQUAL(crc_ccitt2(), 0x49);
00057
00058 delete decompData;
00059 delete container;
00060 delete s;
00061 }
00062
00063
00064
00065 test_suite*
00066 init_unit_test_suite( int argc, char * argv[] )
00067 {
00068 test_suite* test = BOOST_TEST_SUITE("test ljpeg");
00069
00070 if (argc == 1) {
00071
00072 const char * srcdir = getenv("srcdir");
00073
00074 BOOST_ASSERT(srcdir != NULL);
00075 g_testfile = std::string(srcdir);
00076 g_testfile += "/ljpegtest1.jpg";
00077 }
00078 else {
00079 g_testfile = argv[1];
00080 }
00081
00082 test->add(BOOST_TEST_CASE(&test_ljpeg));
00083
00084 return test;
00085 }