addon/validation: Add unit test suite

Only addon_name_legal() is covered right now.
This commit is contained in:
Ignacio R. Morelle 2012-02-25 07:41:12 +00:00
parent f3f89c5e8f
commit 0d692f13e9
3 changed files with 37 additions and 0 deletions

View file

@ -887,6 +887,7 @@ if(ENABLE_TESTS)
tests/utils/fake_event_source.cpp
tests/utils/game_config_manager.cpp
tests/utils/play_scenario.cpp
tests/test_addons.cpp
tests/test_commandline_options.cpp
tests/test_config_cache.cpp
tests/test_formula_ai.cpp

View file

@ -555,6 +555,7 @@ libtest_utils = test_env.Library("test_utils", test_utils_sources)
test_sources = Split("""
tests/floating_point_emulation.cpp
tests/main.cpp
tests/test_addons.cpp
tests/test_commandline_options.cpp
tests/test_formula_ai.cpp
tests/test_formula_function.cpp

35
src/tests/test_addons.cpp Normal file
View file

@ -0,0 +1,35 @@
/* $Id$ */
/*
Copyright (C) 2012 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#define GETTEXT_DOMAIN "wesnoth-test"
#include <boost/test/unit_test.hpp>
#include "addon/validation.hpp"
BOOST_AUTO_TEST_SUITE( addons )
BOOST_AUTO_TEST_CASE( validation )
{
BOOST_CHECK( !addon_name_legal("") );
BOOST_CHECK( !addon_name_legal(".") );
BOOST_CHECK( !addon_name_legal("invalid/slash") );
BOOST_CHECK( !addon_name_legal("invalid\\backslash") );
BOOST_CHECK( !addon_name_legal("invalid:colon") );
BOOST_CHECK( !addon_name_legal("invalid~tilde") );
BOOST_CHECK( !addon_name_legal("invalid/../parent") );
}
BOOST_AUTO_TEST_SUITE_END()