Author: mordante
Date: Sun Mar 6 15:14:02 2011
New Revision: 48783
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48783&view=rev
Log:
Improve the unit tests.
Now that we added a hole to get the id of the window use that id in the
error message instead of the cryptic name of typeid.
Modified:
trunk/src/gui/dialogs/dialog.hpp
trunk/src/tests/gui/test_gui2.cpp
Modified: trunk/src/gui/dialogs/dialog.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.hpp?rev=48783&r1=48782&r2=48783&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.hpp (original)
+++ trunk/src/gui/dialogs/dialog.hpp Sun Mar 6 15:14:02 2011
@@ -128,7 +128,7 @@
* This is used in the unit tests, but these implementation details
* shouldn't be used in the normal code.
*/
- friend void unit_test_mark_as_tested(const tdialog& dialog);
+ friend std::string unit_test_mark_as_tested(const tdialog& dialog);
public:
tdialog() :
Modified: trunk/src/tests/gui/test_gui2.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_gui2.cpp?rev=48783&r1=48782&r2=48783&view=diff
==============================================================================
--- trunk/src/tests/gui/test_gui2.cpp (original)
+++ trunk/src/tests/gui/test_gui2.cpp Sun Mar 6 15:14:02 2011
@@ -75,12 +75,13 @@
return result;
}
-void unit_test_mark_as_tested(const tdialog& dialog)
+std::string unit_test_mark_as_tested(const tdialog& dialog)
{
std::vector<std::string>& list = unit_test_registered_window_list();
list.erase(
std::remove(list.begin(), list.end(),
dialog.window_id())
, list.end());
+ return dialog.window_id();
}
}// namespace gui2
@@ -113,11 +114,10 @@
foreach(const tresolution& resolution, resolutions) {
video.make_test_fake(resolution.first,
resolution.second);
- std::auto_ptr<T> dlg(twrapper<T>::create());
+ std::auto_ptr<gui2::tdialog> dlg(twrapper<T>::create());
BOOST_REQUIRE_MESSAGE(dlg.get(), "Failed to create a
dialog.");
- gui2::unit_test_mark_as_tested(
-
dynamic_cast<gui2::tdialog&>(*(dlg.get())));
+ const std::string id =
gui2::unit_test_mark_as_tested(*(dlg.get()));
std::string exception;
try {
@@ -136,8 +136,8 @@
exception = "unknown";
}
BOOST_CHECK_MESSAGE(exception.empty(),
- "Test for " << typeid(T).name()
- << " Failed\nnew widgets = " <<
gui2::new_widgets
+ "Test for '" << id
+ << "' Failed\nnew widgets = " <<
gui2::new_widgets
<< " small gui = " <<
game_config::small_gui
<< " resolution = " << resolution.first
<< 'x' << resolution.second
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits