testunpack.cpp

00001 /*
00002  * Copyright (C) 2008 Novell, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00017  */
00018 
00019 
00020 #include <boost/test/auto_unit_test.hpp>
00021 
00022 #include "unpack.h"
00023 
00024 using boost::unit_test::test_suite;
00025 
00026 
00027 void test_unpack()
00028 {
00029     const uint8_t packed[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB };
00030     uint16_t unpacked[4];
00031 
00032     OpenRaw::Internals::Unpack unpack(10, 10, 1);
00033 
00034     size_t s = unpack.unpack_be12to16((uint8_t*)unpacked, 8, 
00035                                       packed, 6);
00036     BOOST_CHECK_EQUAL(s, (size_t)8);
00037     BOOST_CHECK_EQUAL(unpacked[0], 0x0123);
00038     BOOST_CHECK_EQUAL(unpacked[1], 0x0456);
00039     BOOST_CHECK_EQUAL(unpacked[2], 0x0789);
00040     BOOST_CHECK_EQUAL(unpacked[3], 0x00AB);
00041 }
00042 
00043 
00044 test_suite*
00045 init_unit_test_suite( int /*argc*/, char ** /*argv*/ ) 
00046 {
00047     test_suite* test = BOOST_TEST_SUITE("test unpack");
00048     
00049     test->add(BOOST_TEST_CASE(&test_unpack));
00050 
00051     return test;
00052 }
00053 

Generated on Sat Nov 7 19:23:19 2009 for libopenraw by  doxygen 1.5.8