WLoader_test.h 2.16 KB
Newer Older
1 2
//---------------------------------------------------------------------------
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5 6
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

#ifndef WLOADER_TEST_H
#define WLOADER_TEST_H

28 29
#include <string>

30 31 32 33 34
#include <cxxtest/TestSuite.h>

#include "../WLoader.h"

/**
35 36 37 38 39
 * Just a dummy for testing the base class
 */
class DummyLoader : public WLoader
{
public:
40 41
    explicit DummyLoader( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
        : WLoader( fileName, dataHandler )
42 43 44 45 46 47 48 49 50 51
    {
    }

    virtual void operator()()
    {
    }
};

/**
 * Unit tests the Loader base class.
52 53 54 55 56
 */
class WLoaderTest : public CxxTest::TestSuite
{
public:
    /**
57
     * If the given file name is invalid an exception should be thrown.
58
     */
59
    void testExceptionOnInvalidFilename( void )
60
    {
61 62
        boost::shared_ptr< WDataHandler > dummyDH = boost::shared_ptr< WDataHandler >( new WDataHandler() );
        TS_ASSERT_THROWS_EQUALS( DummyLoader( "no such file", dummyDH ),
63 64 65
                                 const WDHIOFailure &e,
                                 e.what(),
                                 std::string( "file 'no such file' doesn't exists." ) );
66
        TS_ASSERT_THROWS_NOTHING( DummyLoader( "fixtures/scalar_float.nii.gz", dummyDH ) );
67 68 69 70
    }
};

#endif  // WLOADER_TEST_H