The Battle for Wesnoth  1.17.0-dev
wml_equivalence.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 - 2021
3  by CrawlCycle <73139676+CrawlCycle@users.noreply.github.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 /**
17  * @file
18  * Tool to check if two WML string are equivalent. Specifically, the @ref
19  * check_wml_equivalence function would first preprocess and parse the two WML
20  * string to yield two syntax trees (defined by config objects). Subsequently,
21  * the function would assert if the two syntax trees are identical.
22  */
23 
24 #pragma once
26 
27 /**
28  * Make a syntax tree by preprocessing and parsing a WML string
29  * @param[in] wml_str The string
30  * @param[out] macro_map Store preprocessor macros found by the preprocessor
31  * @return The syntax tree.
32  * @warning Create and delete a temporary file at the current directory.
33  */
34 config preprocess_and_parse(const std::string& wml_str, preproc_map* macro_map = nullptr);
35 
36 /**
37  * Assert two WML strings are equivalent. The function performs two steps:
38  * 1. Make two syntax trees (defined by config objects) by preprocessing and
39  * parsing the two WML strings.
40  * 2. Assert the two syntax tree are equal with a macro in Boost Test.
41  * @warning Create and delete two temporary files at the current directory.
42  */
43 void check_wml_equivalence(const std::string& a, const std::string& b);
#define a
void check_wml_equivalence(const std::string &a, const std::string &b)
Assert two WML strings are equivalent.
#define b
config preprocess_and_parse(const std::string &wml_str, preproc_map *macro_map=nullptr)
Make a syntax tree by preprocessing and parsing a WML string.
std::map< std::string, struct preproc_define > preproc_map
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61