diff options
author | Hubert Figuière <hub@figuiere.net> | 2023-08-19 19:50:39 -0400 |
---|---|---|
committer | Hubert Figuière <hub@figuiere.net> | 2023-08-19 23:02:59 -0400 |
commit | b338eb81f6dcfc4ed82bda45eb3fa3e39cc6e09b (patch) | |
tree | dc908e8bec7e795618a6e42aff816acb3b50a124 | |
parent | 2e98519b062a6f23a0d4d9e962aa022e2487fd0d (diff) |
build: remove C++ tests
-rw-r--r-- | test/Makefile.am | 41 | ||||
-rw-r--r-- | test/bititerator.t.cpp | 59 | ||||
-rw-r--r-- | test/ciffcontainertest.cpp | 47 | ||||
-rw-r--r-- | test/fileio.t.cpp | 70 | ||||
-rw-r--r-- | test/ljpegtest.cpp | 69 | ||||
-rw-r--r-- | test/missingcoefficients.cpp | 97 | ||||
-rw-r--r-- | test/option.t.cpp | 74 | ||||
-rwxr-xr-x | test/testunpack.cpp | 78 |
8 files changed, 3 insertions, 532 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 24d57bc..1a49eff 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,51 +1,16 @@ -TESTS = testoption extensions -TESTS_ENVIRONMENT = +TESTS = extensions OPENRAW_LIB = $(top_builddir)/lib/libopenraw.la -INTERNAL_OPENRAW_LIB = $(top_builddir)/lib/libopenraw_internals.la \ - @abs_top_builddir@/lib/mp4/target/@CARGO_TARGET_SUBDIR@/libmp4.a \ - -ljpeg -ldl -lpthread \ - $(NULL) - AM_CPPFLAGS = \ @BOOST_CPPFLAGS@ \ -I$(top_srcdir)/include \ -I$(top_srcdir)/lib -check_PROGRAMS = testoption \ - extensions - -EXTRA_DIST = ljpegtest1.jpg - -fileio_SOURCES = fileio.t.cpp -fileio_LDADD = $(INTERNAL_OPENRAW_LIB) - -testoption_SOURCES = option.t.cpp -testoption_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ +check_PROGRAMS = extensions -testbititerator_SOURCES = bititerator.t.cpp -testbititerator_LDADD = $(INTERNAL_OPENRAW_LIB) -testbititerator_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ +EXTRA_DIST = ljpegtest1.jpg iterator_test.tif extensions_SOURCES = extensions.cpp extensions_LDADD = $(OPENRAW_LIB) - -ciffcontainertest_SOURCES = ciffcontainertest.cpp -ciffcontainertest_LDADD = \ - $(INTERNAL_OPENRAW_LIB) \ - $(NULL) - -ljpegtest_SOURCES = ljpegtest.cpp -ljpegtest_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ -ljpegtest_LDADD = \ - $(INTERNAL_OPENRAW_LIB) @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ \ - $(NULL) - -testunpack_SOURCES = testunpack.cpp -testunpack_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@ -testunpack_LDADD = $(INTERNAL_OPENRAW_LIB) @BOOST_UNIT_TEST_FRAMEWORK_LIBS@ - -missingcoefficients_SOURCES = missingcoefficients.cpp -missingcoefficients_LDADD = $(INTERNAL_OPENRAW_LIB) diff --git a/test/bititerator.t.cpp b/test/bititerator.t.cpp deleted file mode 100644 index 96c7e88..0000000 --- a/test/bititerator.t.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- tab-width:4; c-basic-offset:4 -*- */ -/* - * libopenraw - bititerator.t.cpp - * - * Copyright (C) 2022 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 - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - */ -/** @brief unit test for BitIterator */ - -#include <boost/test/included/unit_test.hpp> - -#include "bititerator.hpp" - -using OpenRaw::Internals::BitIterator; - -boost::unit_test::test_suite* init_unit_test_suite(int, char**) -{ - return nullptr; -} - -BOOST_AUTO_TEST_CASE(test_bititerator) -{ - uint8_t buffer[] = { 0xff, 0x10, 0x01, 0x22 }; - BitIterator bits(buffer, 4); - - auto t = bits.peek(9); - BOOST_CHECK_EQUAL(t, 0x1fe); - auto t2 = bits.get(9); - BOOST_CHECK_EQUAL(t, t2); - bits.skip(2); - t = bits.peek(1); - BOOST_CHECK_EQUAL(t, 1); - bits.skip(1); - t = bits.get(4); - BOOST_CHECK_EQUAL(t, 0); - t = bits.get(12); - BOOST_CHECK_EQUAL(t, 0x12); - - // peek the last 4 bits - t = bits.peek(4); - BOOST_CHECK_EQUAL(t, 0x2); - - // peeking past the end. - t = bits.peek(5); - BOOST_CHECK_EQUAL(t, 0x4); -} diff --git a/test/ciffcontainertest.cpp b/test/ciffcontainertest.cpp deleted file mode 100644 index c26a319..0000000 --- a/test/ciffcontainertest.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * libopenraw - ciffcontainertest.cpp - * - * Copyright (C) 2006-2020 Hubert Figuière - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - */ - - -#include <iostream> - -#include "trace.hpp" -#include "ciffcontainer.hpp" -#include "io/file.hpp" - -using namespace OpenRaw::Internals; - -int main(int /*argc*/, char **argv) -{ - Debug::Trace::setDebugLevel(DEBUG2); - - auto file = OpenRaw::IO::File::Ptr( - new OpenRaw::IO::File(argv[1])); - CIFFContainer container(file); - - const CIFF::HeapFileHeader & hdr = container.header(); - - std::cout << "byteOrder = " << hdr.byteOrder[0] << hdr.byteOrder[1] << std::endl; - - CIFF::HeapRef heap = container.heap(); - CIFF::RecordEntries& records = heap->records(); - - std::cout << "vector size " << records.size() << std::endl; -} - diff --git a/test/fileio.t.cpp b/test/fileio.t.cpp deleted file mode 100644 index 07c395b..0000000 --- a/test/fileio.t.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2005 Hubert Figuiere - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - - - -#include <stdio.h> -#include <errno.h> -#include "libopenraw/io.h" - - - - -int main (int argc, char **argv) -{ - IOFileRef f; - int retval; - char buf[128]; - (void)argc; - (void)argv; - - f = raw_open(get_default_io_methods(), "/etc/hosts", O_RDONLY); - - if (f == NULL) { - fprintf(stderr, "failed to open /etc/hosts\n"); - return 1; - } - fprintf(stderr, "error code is %d\n", raw_get_error(f)); - - retval = raw_seek(f, 0, SEEK_SET); - if (retval == -1) { - fprintf(stderr, "failed to seek\n"); - return 2; - } - - fprintf(stderr, "position is %d\n", retval); - - retval = raw_read(f, buf, 10); - if (retval == -1) { - fprintf(stderr, "failed to read with error %d\n", raw_get_error(f)); - return 3; - } - - fprintf(stderr, "read %d bytes\n", retval); - - retval = raw_close(f); - if (retval == -1) { - fprintf(stderr, "failed to close\n"); - return 4; - } - - return 0; -} - - - diff --git a/test/ljpegtest.cpp b/test/ljpegtest.cpp deleted file mode 100644 index 5fca210..0000000 --- a/test/ljpegtest.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2007-2020 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 - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - */ - -#include <memory> -#include <string> - -#include <boost/crc.hpp> // for boost::crc_basic, boost::crc_optimal -#include <boost/test/included/unit_test.hpp> - -#include "io/file.hpp" -#include "jfifcontainer.hpp" -#include "ljpegdecompressor.hpp" -#include "ljpegdecompressor_priv.hpp" -#include "rawcontainer.hpp" -#include "rawdata.hpp" - -using OpenRaw::IO::File; - -std::string g_testfile; - -using namespace OpenRaw::Internals; - -boost::unit_test::test_suite* init_unit_test_suite(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]; - } - return nullptr; -} - -BOOST_AUTO_TEST_CASE(test_ljpeg) -{ - File::Ptr s(new File(g_testfile.c_str())); - auto container = std::make_unique<JfifContainer>(s, 0); - - LJpegDecompressor decompressor(s.get(), container.get()); - - OpenRaw::RawDataPtr decompData = decompressor.decompress(); - - boost::crc_optimal<16, 0x1021, 0xFFFF, 0, false, false> crc_ccitt2; - 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(), 0x20cc); -} diff --git a/test/missingcoefficients.cpp b/test/missingcoefficients.cpp deleted file mode 100644 index e568761..0000000 --- a/test/missingcoefficients.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * libopenraw - missingcoefficients.cpp - * - * Copyright (C) 2018 Hubert Figuière - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - */ - - -/* @brief a utility to list the missing coefficients */ -/* - * This code hooks to internals of libopenraw and is not to be interpreted - * as a sample code. It is instead a helper used by developers to make sure - * of the support of various cameras. - */ - -#include <iostream> -#include <memory> - -#include "../lib/rawfile.hpp" -#include "../lib/rawfile_private.hpp" -#include "../lib/arwfile.hpp" -#include "../lib/cr2file.hpp" -#include "../lib/cr3file.hpp" -#include "../lib/crwfile.hpp" -#include "../lib/dngfile.hpp" -#include "../lib/erffile.hpp" -#include "../lib/mrwfile.hpp" -#include "../lib/neffile.hpp" -#include "../lib/orffile.hpp" -#include "../lib/peffile.hpp" -#include "../lib/raffile.hpp" -#include "../lib/rw2file.hpp" -#include "../lib/io/memstream.hpp" - -using namespace OpenRaw; -using namespace OpenRaw::Internals; - - -namespace OpenRaw { -namespace Internals { - -template<typename T> -void audit_coefficients() -{ - IO::Stream::Ptr s = std::make_shared<IO::MemStream>(nullptr, 0); - T t(s); - const BuiltinColourMatrix* matrices = t._getMatrices(); - if (t.getColourMatrixOrigin() == OR_COLOUR_MATRIX_PROVIDED) { - return; - } - const RawFile::camera_ids_t* def = T::s_def; - for (auto current = def; current->model; current++) { - bool found = false; - for (auto current_mat = matrices; current_mat->camera != 0; current_mat++) { - if (current_mat->camera == current->type_id) { - found = true; - break; - } - } - if (!found) { - std::cout << "Missing coefficient for " << current->model << std::endl; - } - } -} - -} -} - - -int main(int, char**) -{ - OpenRaw::Internals::audit_coefficients<ArwFile>(); - OpenRaw::Internals::audit_coefficients<Cr2File>(); - OpenRaw::Internals::audit_coefficients<Cr3File>(); - OpenRaw::Internals::audit_coefficients<CRWFile>(); - OpenRaw::Internals::audit_coefficients<DngFile>(); - OpenRaw::Internals::audit_coefficients<ERFFile>(); - OpenRaw::Internals::audit_coefficients<MRWFile>(); - OpenRaw::Internals::audit_coefficients<NefFile>(); - OpenRaw::Internals::audit_coefficients<OrfFile>(); - OpenRaw::Internals::audit_coefficients<PEFFile>(); - OpenRaw::Internals::audit_coefficients<RafFile>(); - OpenRaw::Internals::audit_coefficients<Rw2File>(); -} diff --git a/test/option.t.cpp b/test/option.t.cpp deleted file mode 100644 index fd12dc7..0000000 --- a/test/option.t.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * libopenraw - option.t.cpp - * - * Copyright (C) 2017-2020 Hubert Figuière - * - * This library is free software: you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - */ -/** @brief unit test for option */ - -#include <boost/test/included/unit_test.hpp> - -#include <stdlib.h> - -#include <string> - -#include "option.hpp" - -boost::unit_test::test_suite* init_unit_test_suite(int, char**) -{ - return nullptr; -} - -BOOST_AUTO_TEST_CASE(test_option) -{ - Option<std::string> result; - - // Default, option is empty - BOOST_CHECK(result.empty()); - bool unwrapped = false; - try { - result.value(); - unwrapped = true; - } catch(std::runtime_error&) { - BOOST_CHECK(true); - } catch(...) { - BOOST_CHECK(false); - } - BOOST_CHECK(!unwrapped); - BOOST_CHECK(result.empty()); - - // Option with value - result = Option<std::string>("hello world"); - BOOST_CHECK(!result.empty()); - BOOST_CHECK(result); - BOOST_CHECK(result.value() == "hello world"); - BOOST_CHECK(result.empty()); - BOOST_CHECK(!result); - // try unwrapping again - unwrapped = false; - try { - result.value(); - unwrapped = true; - } catch(std::runtime_error&) { - BOOST_CHECK(true); - } catch(...) { - BOOST_CHECK(false); - } - BOOST_CHECK(!unwrapped); - BOOST_CHECK(result.empty()); - BOOST_CHECK(result.value_or("good bye") == "good bye"); -} - diff --git a/test/testunpack.cpp b/test/testunpack.cpp deleted file mode 100755 index 7b77743..0000000 --- a/test/testunpack.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- tab-width:4; indent-tabs-mode:nil; c-basic-offset:4; -*- */ -/* - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2009-2020 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 - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * <http://www.gnu.org/licenses/>. - */ - - -#include <boost/test/included/unit_test.hpp> - -#include "unpack.hpp" -#include "ifd.hpp" - - -BOOST_AUTO_TEST_CASE(test_unpack) -{ - const uint8_t packed[32] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, - 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0x00, - 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, - 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0x00}; - uint16_t unpacked[20]; - - OpenRaw::Internals::Unpack - unpack(32, OpenRaw::Internals::IFD::COMPRESS_NIKON_PACK); - - size_t s; - or_error err = unpack.unpack_be12to16(unpacked, 40, packed, - sizeof(packed), s); - BOOST_CHECK(s = size_t(sizeof(unpacked))); - BOOST_CHECK(err == OR_ERROR_NONE); - for (size_t i = 0; i < 2; ++i) { - 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); - } -} - -BOOST_AUTO_TEST_CASE(test_unpack2) -{ - const uint8_t packed[3] = {0x12, 0x34, 0x56}; - uint16_t unpacked[2]; - - OpenRaw::Internals::Unpack unpack(32, - OpenRaw::Internals::IFD::COMPRESS_NONE); - - size_t s; - or_error err = unpack.unpack_be12to16(unpacked, 4, packed, - sizeof(packed), s); - BOOST_CHECK(s == size_t(sizeof(unpacked))); - BOOST_CHECK(err == OR_ERROR_NONE); - BOOST_CHECK(unpacked[0] == 0x0123); - BOOST_CHECK(unpacked[1] == 0x0456); -} - -boost::unit_test::test_suite* init_unit_test_suite(int, char**) -{ - return nullptr; -} |