Changeset 303 in pacpusframework for trunk/src/FileLib/test/TestFileLib.cpp


Ignore:
Timestamp:
04/08/14 11:22:06 (10 years ago)
Author:
Marek Kurdej
Message:

TestFileLib added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/FileLib/test/TestFileLib.cpp

    r301 r303  
    2121#include <Pacpus/kernel/Log.h>
    2222
     23#include <boost/exception/diagnostic_information.hpp>
     24#include <boost/exception/errinfo_api_function.hpp>
     25#include <boost/exception/get_error_info.hpp>
    2326#include <boost/noncopyable.hpp>
    2427#include <cstdio>
    2528
    26 DECLARE_STATIC_LOGGER("pacpus.framework.test.FileLib");
     29DECLARE_STATIC_LOGGER("pacpus.framework.test.FileLib")
    2730
    2831using namespace boost;
     
    3134
    3235struct HasExceptionMessage
    33         : noncopyable
     36    : noncopyable
    3437{
    3538    HasExceptionMessage(const string expectedMessage)
     
    4851};
    4952
     53template <
     54    typename ErrorInfo,
     55    typename E = typename ErrorInfo::error_info::value_type
     56>
     57struct HasErrorInfo
     58    : noncopyable
     59{
     60    HasErrorInfo(E const& expectedValue)
     61        : mExpectedValue(expectedValue)
     62    {
     63    }
     64
     65    bool operator()(DbiteException const& ex)
     66    {
     67        LOG_INFO("diagnostic_information: " << diagnostic_information(ex));
     68        E const* value = get_error_info<ErrorInfo>(ex);
     69        if (!value) {
     70            return false;
     71        }
     72        return mExpectedValue == *value;
     73    }
     74
     75private:
     76    E const mExpectedValue;
     77};
     78
    5079BOOST_AUTO_TEST_SUITE(suiteBasic)
    5180
     
    150179        (df.open("data/bad-empty-file.dbt", ReadMode))
    151180        , DbiteException
    152         , HasExceptionMessage("cannot read header")
     181//        , HasExceptionMessage("cannot read data") // FIXME: cannot read header
     182        , HasErrorInfo<errinfo_api_function>("open")
    153183    );
    154184}
     
    164194        (df.open("data/bad-incomplete-header.dbt", ReadMode))
    165195        , DbiteException
    166         , HasExceptionMessage("cannot read header")
     196        , HasExceptionMessage("cannot read data") // FIXME: cannot read header
    167197    );
    168198}
Note: See TracChangeset for help on using the changeset viewer.