[go: up one dir, main page]

Menu

[r999]: / mia2 / mia / core / test_core.cc  Maximize  Restore  History

Download this file

146 lines (122 with data), 4.2 kB

  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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* -*- mona-c++ -*-
*
* Copyright (c) Leipzig, Madrid 2004 - 2009
* Max-Planck-Institute for Human Cognitive and Brain Science
* Max-Planck-Institute for Evolutionary Anthropology
* BIT, ETSI Telecomunicacion, UPM
*
* 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 PUcRPOSE. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdexcept>
#include <climits>
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/path.hpp>
#include <mia/core/cmdlineparser.hh>
#include <mia/core/msgstream.hh>
#include <mia/core/file.hh>
NS_MIA_USE
using namespace std;
using namespace boost::unit_test;
namespace bfs = ::boost::filesystem;
extern void add_attribute_tests(test_suite* test);
extern void add_concurrence_tests(test_suite* test);
extern void add_optparam_tests(test_suite* test);
extern void add_optionparser_tests(test_suite* test);
extern void add_param_tests(test_suite* test);
extern void add_filter_tests(test_suite* test);
extern void add_handler_tests(test_suite* test);
extern void add_iohandler_tests(test_suite* test);
extern void add_spacial_kernel__tests(test_suite* test);
extern void add_pixeltype_tests(test_suite* test);
extern void add_histogram_tests(test_suite* test);
extern void add_streamredir_tests(test_suite* test);
extern void add_sqmin_tests(test_suite* test);
//extern void add_cstplan_tests(test_suite* test);
extern void add_register_tests(test_suite* test);
void test_file()
{
try {
COutputFile f("testfile");
unlink("testfile");
}
catch (...) {
BOOST_FAIL("unable to create a file for writing in current directory");
}
try {
#ifdef WIN32
CInputFile f("test-core.exe");
#else
CInputFile f("test-core");
#endif
}
catch (...) {
BOOST_FAIL("unable to open 'test-core' for reading in current directory");
}
try {
CInputFile f("this-file-should-not-exist.11111");
BOOST_FAIL("'this-file-should-not-exist.11111' was opened for reading");
}
catch (runtime_error& x) {
BOOST_MESSAGE(string("caught an expected exception:") + x.what());
}
try {
CInputFile f("/nnananan5676281/7828/1ttgfthis-file-should-not-exist.11111");
BOOST_FAIL("'/nnananan5676281/7828/1ttgf/this-file-should-not-be-created.11111' was opened for writing");
}
catch (runtime_error& x) {
BOOST_MESSAGE(string("caught an expected exception:") + x.what());
}
}
bool init_unit_test_suite()
{
cvdebug() << "init_unit_test_suite \n";
if (bfs::path::default_name_check_writable())
#if WIN32
bfs::path::default_name_check(bfs::windows_name);
#else
bfs::path::default_name_check(bfs::portable_posix_name);
#endif
#ifdef WIN32
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );
#endif
test_suite *suite = &framework::master_test_suite();
add_pixeltype_tests(suite);
add_concurrence_tests(suite);
add_attribute_tests(suite);
add_optionparser_tests(suite);
add_optparam_tests(suite);
add_param_tests(suite);
add_filter_tests(suite);
add_handler_tests(suite);
add_iohandler_tests(suite);
add_spacial_kernel__tests(suite);
add_histogram_tests(suite);
add_sqmin_tests(suite);
add_streamredir_tests(suite);
// add_cstplan_tests(suite);
add_register_tests(suite);
suite->add( BOOST_TEST_CASE( &test_file ));
return true;
}
int BOOST_TEST_CALL_DECL
main( int argc, char* argv[] )
{
CCmdOptionList().parse(argc, argv);
return ::boost::unit_test::unit_test_main( &init_unit_test_suite, argc, argv );
}