1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
/*
* libopenraw - testsuite.cpp
*
* Copyright (C) 2008 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/>.
*/
#ifndef _TEST_TESTSUITE_H_
#define _TEST_TESTSUITE_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_CURL
#include <curl/curl.h>
#endif
#include <vector>
#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
namespace OpenRaw {
class RawFile;
class RawData;
}
class Test
{
public:
typedef boost::shared_ptr<Test> Ptr;
Test();
~Test();
std::string & name()
{ return m_name; }
std::string & file()
{ return m_file; }
std::string & source()
{ return m_source; }
std::map<int, std::string> & results()
{ return m_results; }
/** return 0 the test ran perfectly */
int run();
/** a test in another test, only taking new values */
void merge(const Test::Ptr & t);
private:
bool testRawType(const std::string & result);
bool testRawTypeId(const std::string & result);
bool testThumbNum(const std::string & result);
bool testThumbSizes(const std::string & result);
bool testThumbFormats(const std::string & result);
bool testThumbDataSizes(const std::string & result);
bool testRawDataType(const std::string & result);
bool testRawDataSize(const std::string & result);
bool testRawDataDimensions(const std::string & result);
bool testRawCfaPattern(const std::string & result);
bool testRawMinValue(const std::string & result);
bool testRawMaxValue(const std::string & result);
bool testRawMd5(const std::string & result);
bool testRawDecompressedMd5(const std::string & result);
bool testMetaOrientation(const std::string & result);
std::string m_name;
std::string m_file;
std::string m_source;
std::map<int, std::string> m_results;
// runtime data
OpenRaw::RawFile *m_rawfile;
OpenRaw::RawData * m_rawdata;
int m_total, m_success, m_failure;
};
class TestSuite
{
public:
TestSuite();
int load_tests(const char * testsuite_file);
int load_overrides(const std::string & overrides_file);
int bootstrap(const std::string & overrides_file,
const std::string & download_dir);
/** return 0 if all test ran perfectly */
int run_all();
/** add a test. own the test */
void add_test(const Test::Ptr & t);
private:
#if HAVE_CURL
void walk_tests(xmlNode * test, CURL* handle,
const std::string & download_dir);
#endif
std::map<std::string, Test::Ptr> m_tests;
};
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0))
indent-tabs-mode:nil
fill-column:80
End:
*/
|