14 typedef bool(*
func)(std::ostream&,bool);
16 typedef bool(*
func3)(std::ostream&,int,
char**);
18 typedef bool(*
cfunc)(FILE*,bool);
46 class utest :
public std::vector< std::pair<std::string,test> > {
47 typedef std::pair<std::string,test> named_test;
48 typedef std::vector<named_test> parent;
57 (*this).push_back(named_test(a_name,
test(
false,a_func)));
60 (*this).push_back(named_test(a_name,
test(
false,a_func)));
63 (*this).push_back(named_test(a_name,
test(
false,a_func)));
66 (*this).push_back(named_test(a_name,
test(
false,a_func)));
69 bool exec(
const args& a_args,
bool a_verbose,
int a_argc=0,
char** a_argv=0) {
70 {
tools_vforit(named_test,*
this,it) (*it).second.m_do_it =
false;}
73 const std::string& key = (*it).first;
76 const std::string& name = (*itn).first;
77 if(key==std::string(
"-"+name)) {
found=
true;
break;}
78 if(key==std::string(
"-no_"+name)) {
found=
true;
break;}
81 m_out <<
"WARNING : arg " <<
sout(key) <<
" is not a test." << std::endl;
87 const std::string& name = (*it).first;
88 if(a_args.
is_arg(
"-"+name)) {
89 (*it).second.m_do_it =
true;
95 tools_vforit(named_test,*
this,it) (*it).second.m_do_it =
true;
99 const std::string& name = (*it).first;
100 if(a_args.
is_arg(
"-no_"+name)) {
101 (*it).second.m_do_it =
false;
108 const std::string& name = (*it).first;
109 if((*it).second.m_do_it && (*it).second.m_func) {
110 if(a_verbose)
m_out <<
"test_" << name <<
" ..." << std::endl;
111 if(!(*it).second.m_func(
m_out,a_verbose)) {
112 m_out <<
"test_" << name <<
" failed." << std::endl;
115 if(a_verbose)
m_out <<
"test_" << name <<
" end." << std::endl;
120 const std::string& name = (*it).first;
121 if((*it).second.m_do_it && (*it).second.m_func2) {
122 if(a_verbose)
m_out <<
"test_" << name <<
" ..." << std::endl;
123 if(!(*it).second.m_func2(
m_out,a_args)) {
124 m_out <<
"test_" << name <<
" failed." << std::endl;
127 if(a_verbose)
m_out <<
"test_" << name <<
" end." << std::endl;
132 const std::string& name = (*it).first;
133 if((*it).second.m_do_it && (*it).second.m_func3) {
134 if(a_verbose)
m_out <<
"test_" << name <<
" ..." << std::endl;
135 if(!(*it).second.m_func3(
m_out,a_argc,a_argv)) {
136 m_out <<
"test_" << name <<
" failed." << std::endl;
139 if(a_verbose)
m_out <<
"test_" << name <<
" end." << std::endl;
144 const std::string& name = (*it).first;
145 if((*it).second.m_do_it && (*it).second.m_cfunc) {
146 if(a_verbose)
m_out <<
"test_" << name <<
" ..." << std::endl;
147 if(!(*it).second.m_cfunc(stdout,a_verbose)) {
148 m_out <<
"test_" << name <<
" failed." << std::endl;
151 if(a_verbose)
m_out <<
"test_" << name <<
" end." << std::endl;
155 tools_vforit(named_test,*
this,it) (*it).second.m_do_it =
false;