Commit 0c05383f authored by thomas.forbriger's avatar thomas.forbriger

libdatrwxx [WP]: test formatting of error messages

parent 6ba3a85c
......@@ -42,6 +42,7 @@
#include <fstream>
#include <string>
#include <tfxx/commandline.h>
#include <datrwxx/debug.h>
#include <datrwxx/error.h>
#include <datrwxx/util.h>
#include <datrwxx/types.h>
......@@ -429,8 +430,9 @@ int main(int iargc, char* argv[])
if (opt.testerror)
{
cout << "Test format modifiers" << endl;
cout << "=====================" << endl;
cout << "Test error reports (formatting of messages)" << endl;
cout << "===========================================" << endl;
cout << endl;
if (opt.nerrortest == 0)
{
cout << "available tests:" << endl;
......@@ -444,29 +446,46 @@ int main(int iargc, char* argv[])
{
cout << "report assert" << endl;
cout << "-------------" << endl;
DATRW_report_assert(false, "message");
cout << "warning" << endl;
cout << "-------" << endl;
DATRW_warning("main", "message");
DATRW_report_assert(false, "This message is produced after testing"
" a condition to report\n"
"that the test fails.");
cout << "\nwarning" << endl;
cout << "-------" << endl;
DATRW_warning("main", "This is a warning message from a specific"
" function in the library.\n"
"The macro takes a multiline message output too.");
}
else if (opt.nerrortest == 2)
{
cout << "direct abort" << endl;
cout << "------------" << endl;
DATRW_abort("abort program intentionally");
DATRW_abort("Abort program intentionally.\n"
"A multi-line message my be passed too in this case.\n"
"Pass one of the non-specified values for the error\n"
"test to see the output for DATRW_illegal.");
}
else if ((opt.nerrortest == 3) || (opt.nerrortest == 4))
{
cout << "fatal/non-fatal assert" << endl;
cout << "----------------------" << endl;
DATRW_nonfatal_assert(opt.nerrortest==3, false,
"fatal/non-fatal assert");
DATRW_nonfatal_assert(opt.nerrortest==3,
(opt.nerrortest<=1)||(opt.nerrortest>=6),
"This is a test of a fatal/non-fatal assert.\n"
"The error is made non-fatal, if the option"
"opt.nerrortest equals 3.\n"
"Currently " << DATRW_value(opt.nerrortest));
}
else if (opt.nerrortest == 5)
{
cout << "standard assertion" << endl;
cout << "------------------" << endl;
DATRW_assert(false, "faild assertion");
DATRW_assert(false,
"This type of error is emitted,"
" if an assertion is failed.\n"
"Several lines of explanation can be provided"
" to the user.\n"
"This can include the output of variables like "
<< DATRW_value(opt.nerrortest));
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment