The Battle for Wesnoth  1.19.0+dev
test_schema_self_validator.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2023
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13  COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-test"
17 
18 #include <boost/test/unit_test.hpp>
19 
20 #include <boost/algorithm/string/predicate.hpp>
21 
23 #include "wml_exception.hpp"
24 
25 BOOST_AUTO_TEST_SUITE(test_schema_self_validator)
26 
27 BOOST_AUTO_TEST_CASE(test_schema_super_self_reference)
28 {
30 
31  constexpr auto schema_path = "src/tests/wml/schema/test_schema_self_validator/test_schema_super_self_reference.cfg";
32 
33  BOOST_CHECK_EXCEPTION(
34  schema_validation::schema_validator(schema_path, true), wml_exception, [](const wml_exception& e) {
35  return boost::algorithm::contains(e.dev_message, "Inheritance loop super=main found");
36  });
37 }
38 
39 BOOST_AUTO_TEST_CASE(test_schema_super_cycle)
40 {
42 
43  constexpr auto schema_path = "src/tests/wml/schema/test_schema_self_validator/test_schema_super_cycle.cfg";
44 
45  BOOST_CHECK_EXCEPTION(
46  schema_validation::schema_validator(schema_path, true), wml_exception, [](const wml_exception& e) {
47  return boost::algorithm::contains(e.dev_message, "Inheritance loop super=main/first found");
48  });
49 }
50 
51 BOOST_AUTO_TEST_SUITE_END()
Realization of serialization/validator.hpp abstract validator.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
Definition: general.hpp:83
One of the realizations of serialization/validator.hpp abstract validator.
Helper class, don't construct this directly.
BOOST_AUTO_TEST_SUITE(filesystem)
BOOST_AUTO_TEST_CASE(test_schema_super_self_reference)
bool strict_validation_enabled
Definition: validator.cpp:21
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define e