Skip to content
Snippets Groups Projects
Commit 9fc8c0aa authored by Andreas Schenk's avatar Andreas Schenk
Browse files

added tests for io exceptions

parent c0238266
Branches
Tags
No related merge requests found
......@@ -15,6 +15,7 @@ set(OST_IO_UNIT_TESTS
)
if (ENABLE_IMG)
list(APPEND OST_IO_UNIT_TESTS test_io_img.cc)
list(APPEND OST_IO_UNIT_TESTS test_exceptions.cc)
endif()
ost_unittest(MODULE io
SOURCES "${OST_IO_UNIT_TESTS}"
......
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2011 by the OpenStructure authors
//
// 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.0 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, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
/*
Author: Andreas Schenk
*/
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <boost/test/auto_unit_test.hpp>
#include <ost/io/load_map.hh>
#include <ost/img/image.hh>
#include <ost/io/io_exception.hh>
using namespace ost;
using namespace ost::io;
BOOST_AUTO_TEST_SUITE( io );
BOOST_AUTO_TEST_CASE(exception)
{
try {
BOOST_CHECK_THROW(ost::img::ImageHandle loadedimage=LoadImage("nonexistent.mrc"),IOException);
}catch(...){
BOOST_ERROR( "Failed to catch IOException." );
}
ost::img::ImageHandle ih=ost::img::CreateImage();
try {
BOOST_CHECK_THROW(SaveImage(ih,"nonexistent.ABC"),IOUnknownFormatException);
}catch(...){
BOOST_ERROR( "Failed to catch IOUnknownFormatException." );
}
}
BOOST_AUTO_TEST_SUITE_END();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment