[Boost.Test] User Exception handling

Hello. On the webpage I read: In case if your test cases may throw custom exceptions (see here for list of exceptions translated by default), you could register translator specific for that exception. http://www.boost.org/libs/test/doc/components/utf/index.html So, if I understand it right, if I throw some custom exception in my test program and do not catch it, then it is catched by the boost test framework and reported in the proper way - if the exception can be translated by default. Now I look at the exceptions, which can be translated by default and see: In majority of the cases the monitored function doesn't need to throw the boost::execution_exception to report an error in the Execution Monitor. If you want a custom error message to be included into the execution_exception's error message, use one of the following C++ types as an exception: * C string. * std:string. * any exception class in std::exception hierarchy. http://www.boost.org/libs/test/doc/components/execution_monitor/index.html#c... So, I can use a C string for my exception. I have written a small example test case and included throwing of an uncaught exception in it: try{ throw "blub"; } catch(char* ex){ throw; } As I started the testing process I didn't get a "blub"-Exception message, but Boost.Test internal framework error: unknown reason So, what's wrong? Why is "blub" not reported as "blub"? Can anybody explain that? Regards Ewgenij

1. Please provide a complete example
#include<iostream>
#include<vector>
#include
2. What version of boost r u using?
Version 1.33.1 Best regards Ewgenij Sokolovski -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

"Ewgenij Sokolovski"
Yes. At the moment init_unit_test_suite invocation is not guarded. I should probably change this. At the moment you've got 2 options: 1. Use global fixture (1.34.0) instead of init_unit_test_suite 2. use framework::setup_error to report initialization error
And why it is not possible to determine the location of the exception (the line number) when I include it into myTestCase?
Because C++ doesn't provide a way ;). Do you know one? Gennadiy

2. use framework::setup_error to report initialization error
Is it already in the 1.33.1 version? I couldn't find such a function.
Nope:) But I'm not a C++-guru, I'm only a poor computer science student at the beginning of my professional career:) -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

Ewgenij Sokolovski wrote: [SNIP]
Maybe "blub" was interpreted as "char[5]" or "char const *" instead of "char *". At least the first alternate choice is incompatible with "char *" as far as exception type matching is concerned. (The C family of languages is broken in that it treats arrays as pointers with funny settings. And even that breakage is broken because it uses that treatment only 90% of the time; the other 10% of uses treat arrays and pointers differently [e.g. extern], and you probably found one of them.) -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com

Might be a bit OT, but that reminds me of a classical paper from 1966 (Peter Landin, "The next 700 Programming Languages"): "For most programming languages there are certain statements of the kind, "There is a systematic equivalence between pieces of program like this, and pieces like that," that nearly hold but not quite." Just something that came to my mind.
participants (6)
-
Daryle Walker
-
Ewgenij Sokolovski
-
Ewgenij Sokolovski
-
Gennadiy Rozental
-
Gottlob Frege
-
KLINIK Markus STD2-G (AREVA NP GmbH)