The Battle for Wesnoth  1.15.12+dev
wml_equivalence.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 by CrawlCycle <73139676+CrawlCycle@users.noreply.github.com>
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 */
14 
15 /**
16  * @file
17  * Tool to check if two WML string are equivalent. Specifically, the @ref
18  * check_wml_equivalence function would first preprocess and parse the two WML
19  * string to yield two syntax trees (defined by config objects). Subsequently,
20  * the function would assert if the two syntax trees are identical.
21  */
22 
23 #pragma once
25 
26 /**
27  * Make a syntax tree by preprocessing and parsing a WML string
28  * @param[in] wml_str The string
29  * @param[out] macro_map Store preprocessor macros found by the preprocessor
30  * @return The syntax tree.
31  * @warning Create and delete a temporary file at the current directory.
32  */
33 config preprocess_and_parse(const std::string& wml_str, preproc_map* macro_map = nullptr);
34 
35 /**
36  * Assert two WML strings are equivalent. The function performs two steps:
37  * 1. Make two syntax trees (defined by config objects) by preprocessing and
38  * parsing the two WML strings.
39  * 2. Assert the two syntax tree are equal with a macro in Boost Test.
40  * @warning Create and delete two temporary files at the current directory.
41  */
42 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:59