1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <nel/misc/types_nl.h>
22 #include <nel/misc/debug.h>
27 # define NEL_UNIT_DATA ""
33 // Add a line here when adding a new test MODULE
39 /** A special stream buffer that output in the 'output debug string' feature of windows.
41 class CDebugOutput
: public streambuf
43 int_type
overflow(int_type c
)
45 string
str(pbase(), pptr());
47 if (c
!= traits_type::eof())
49 OutputDebugString(str
.c_str() );
54 // The instance of the streambug
55 ostream
msvDebug(new CDebugOutput
);
61 cout
<< "usage: mytest [MODE]\n"
62 << "where MODE may be one of:\n"
65 << " --text-terse (default)\n"
66 << " --text-verbose\n";
70 static CUniquePtr
<Test::Output
> cmdline(int argc
, char* argv
[])
73 usage(); // will not return
75 Test::Output
* output
= 0;
78 output
= new Test::TextOutput(Test::TextOutput::Verbose
);
81 const char* arg
= argv
[1];
82 if (strcmp(arg
, "--compiler") == 0)
85 output
= new Test::CompilerOutput(Test::CompilerOutput::MSVC
, msvDebug
);
86 #elif defined(__GNUC__)
87 output
= new Test::CompilerOutput(Test::CompilerOutput::GCC
);
89 output
= new Test::CompilerOutput
;
92 else if (strcmp(arg
, "--html") == 0)
93 output
= new Test::HtmlOutput
;
94 else if (strcmp(arg
, "--text-terse") == 0)
95 output
= new Test::TextOutput(Test::TextOutput::Terse
);
96 else if (strcmp(arg
, "--text-verbose") == 0)
97 output
= new Test::TextOutput(Test::TextOutput::Verbose
);
100 cout
<< "invalid commandline argument: " << arg
<< endl
;
101 usage(); // will not return
105 return CUniquePtr
<Test::Output
>(output
);
110 int main(int argc
, char *argv
[])
112 static const char *outputFileName
= "result.html";
115 new NLMISC::CApplicationContext
;
117 // disable nldebug messages in logs in Release
119 NLMISC::DisableNLDebug
= true;
122 NLMISC::createDebug(NULL
);
125 NLMISC::INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD");
126 NLMISC::INelContext::getInstance().getInfoLog()->removeDisplayer("DEFAULT_SD");
127 NLMISC::INelContext::getInstance().getWarningLog()->removeDisplayer("DEFAULT_SD");
128 NLMISC::INelContext::getInstance().getErrorLog()->removeDisplayer("DEFAULT_SD");
131 bool noerrors
= false;
137 ts
.add(std::auto_ptr
<Test::Suite
>(new CUTMisc
));
138 ts
.add(std::auto_ptr
<Test::Suite
>(new CUTNet
));
139 ts
.add(std::auto_ptr
<Test::Suite
>(new CUTLigo
));
140 // Add a line here when adding a new test MODULE
142 CUniquePtr
<Test::Output
> output(cmdline(argc
, argv
));
143 noerrors
= ts
.run(*output
);
145 Test::HtmlOutput
* const html
= dynamic_cast<Test::HtmlOutput
*>(output
.get());
148 std::ofstream
fout(outputFileName
);
149 html
->generate(fout
, true, "NeL");
154 cout
<< "unexpected exception encountered";
158 nlinfo("No errors during unit testing");
160 nlwarning("Errors during unit testing");
161 return noerrors
?EXIT_SUCCESS
:EXIT_FAILURE
;