diff options
author | Hubert Figuiere <hub@figuiere.net> | 2009-02-21 15:25:58 -0500 |
---|---|---|
committer | Hubert Figuiere <hub@figuiere.net> | 2009-02-21 15:25:58 -0500 |
commit | 41ce42de0c4b7d64a593effb617ede3a4a3d1fe3 (patch) | |
tree | a461bffbf8e8846f0283ac5ffbc5d2b98cdd8682 | |
parent | 48d07cc207fada007f84a4654b425561a4765dc3 (diff) |
* test/testunpack.cpp:
* test/ljpegtest.cpp:
Use Boost test minimal instead of autotest.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | test/ljpegtest.cpp | 47 | ||||
-rw-r--r-- | test/testunpack.cpp | 51 |
3 files changed, 49 insertions, 55 deletions
@@ -1,3 +1,9 @@ +2009-02-21 Hubert Figuiere <hub@figuiere.net> + + * test/testunpack.cpp: + * test/ljpegtest.cpp: + Use Boost test minimal instead of autotest. + 2009-02-20 Hubert Figuiere <hub@figuiere.net> * configure.in: diff --git a/test/ljpegtest.cpp b/test/ljpegtest.cpp index 8b0f997..e7bc767 100644 --- a/test/ljpegtest.cpp +++ b/test/ljpegtest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Hubert Figuiere + * Copyright (C) 2007, 2009 Hubert Figuiere * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -20,7 +20,7 @@ #include <string> -#include <boost/test/auto_unit_test.hpp> +#include <boost/test/minimal.hpp> #include <boost/crc.hpp> // for boost::crc_basic, boost::crc_optimal #include <libopenraw++/rawdata.h> @@ -31,7 +31,6 @@ #include "ljpegdecompressor.h" #include "ljpegdecompressor_priv.h" -using boost::unit_test::test_suite; using OpenRaw::RawData; using OpenRaw::IO::File; @@ -39,8 +38,21 @@ std::string g_testfile; using namespace OpenRaw::Internals; -void test_ljpeg() +int test_main(int argc, char *argv[]) { + if (argc == 1) { + // no argument, lets run like we are in "check" + const char * srcdir = getenv("srcdir"); + + BOOST_ASSERT(srcdir != NULL); + g_testfile = std::string(srcdir); + g_testfile += "/ljpegtest1.jpg"; + } + else { + g_testfile = argv[1]; + } + + RawData *decompData; File *s = new File(g_testfile.c_str()); RawContainer *container = new JFIFContainer(s, 0); @@ -53,33 +65,12 @@ void test_ljpeg() const uint8_t * data = static_cast<uint8_t *>(decompData->data()); size_t data_len = decompData->size(); crc_ccitt2 = std::for_each( data, data + data_len, crc_ccitt2 ); - BOOST_CHECK_EQUAL(crc_ccitt2(), 0x49); + BOOST_CHECK(crc_ccitt2() == 0x49); delete decompData; delete container; delete s; -} - - -test_suite* -init_unit_test_suite( int argc, char * argv[] ) -{ - test_suite* test = BOOST_TEST_SUITE("test ljpeg"); - - if (argc == 1) { - // no argument, lets run like we are in "check" - const char * srcdir = getenv("srcdir"); - - BOOST_ASSERT(srcdir != NULL); - g_testfile = std::string(srcdir); - g_testfile += "/ljpegtest1.jpg"; - } - else { - g_testfile = argv[1]; - } - - test->add(BOOST_TEST_CASE(&test_ljpeg)); - - return test; + return 0; } + diff --git a/test/testunpack.cpp b/test/testunpack.cpp index 6b0009e..6a25e06 100644 --- a/test/testunpack.cpp +++ b/test/testunpack.cpp @@ -1,6 +1,7 @@ /* -*- tab-width:4; indent-tabs-mode:'t c-file-style:"stroustrup" -*- */ /* * Copyright (C) 2008 Novell, Inc. + * Copyright (C) 2009 Hubert Figuiere * * This library is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -18,15 +19,13 @@ */ -#include <boost/test/auto_unit_test.hpp> +#include <boost/test/minimal.hpp> #include "unpack.h" #include "ifd.h" -using boost::unit_test::test_suite; - -void test_unpack() +int test_unpack() { const uint8_t packed[32] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0x00, @@ -39,22 +38,23 @@ void test_unpack() size_t s = unpack.unpack_be12to16((uint8_t*)unpacked, packed, sizeof(packed)); - BOOST_CHECK_EQUAL(s, size_t(sizeof(unpacked))); + BOOST_CHECK(s = size_t(sizeof(unpacked))); for (size_t i = 0; i < 2; ++i) { - BOOST_CHECK_EQUAL(unpacked[10 * i + 0], 0x0123); - BOOST_CHECK_EQUAL(unpacked[10 * i + 1], 0x0456); - BOOST_CHECK_EQUAL(unpacked[10 * i + 2], 0x0789); - BOOST_CHECK_EQUAL(unpacked[10 * i + 3], 0x00AB); - BOOST_CHECK_EQUAL(unpacked[10 * i + 4], 0x0CDE); - BOOST_CHECK_EQUAL(unpacked[10 * i + 5], 0x0F12); - BOOST_CHECK_EQUAL(unpacked[10 * i + 6], 0x0345); - BOOST_CHECK_EQUAL(unpacked[10 * i + 7], 0x0678); - BOOST_CHECK_EQUAL(unpacked[10 * i + 8], 0x090A); - BOOST_CHECK_EQUAL(unpacked[10 * i + 9], 0x0BCD); + BOOST_CHECK(unpacked[10 * i + 0] == 0x0123); + BOOST_CHECK(unpacked[10 * i + 1] == 0x0456); + BOOST_CHECK(unpacked[10 * i + 2] == 0x0789); + BOOST_CHECK(unpacked[10 * i + 3] == 0x00AB); + BOOST_CHECK(unpacked[10 * i + 4] == 0x0CDE); + BOOST_CHECK(unpacked[10 * i + 5] == 0x0F12); + BOOST_CHECK(unpacked[10 * i + 6] == 0x0345); + BOOST_CHECK(unpacked[10 * i + 7] == 0x0678); + BOOST_CHECK(unpacked[10 * i + 8] == 0x090A); + BOOST_CHECK(unpacked[10 * i + 9] == 0x0BCD); } + return 0; } -void test_unpack2() +int test_unpack2() { const uint8_t packed[3] = {0x12, 0x34, 0x56}; uint16_t unpacked[2]; @@ -64,18 +64,15 @@ void test_unpack2() size_t s = unpack.unpack_be12to16((uint8_t*)unpacked, packed, sizeof(packed)); - BOOST_CHECK_EQUAL(s, size_t(sizeof(unpacked))); - BOOST_CHECK_EQUAL(unpacked[0], 0x0123); - BOOST_CHECK_EQUAL(unpacked[1], 0x0456); + BOOST_CHECK(s == size_t(sizeof(unpacked))); + BOOST_CHECK(unpacked[0] == 0x0123); + BOOST_CHECK(unpacked[1] == 0x0456); + return 0; } -test_suite* -init_unit_test_suite( int /*argc*/, char ** /*argv*/ ) +int test_main( int /*argc*/, char * /*argv*/[] ) { - test_suite* test = BOOST_TEST_SUITE("test unpack"); - - test->add(BOOST_TEST_CASE(&test_unpack)); - test->add(BOOST_TEST_CASE(&test_unpack2)); - - return test; + test_unpack(); + test_unpack2(); + return 0; } |