The Battle for Wesnoth  1.15.9+dev
Functions
wml_equivalence.hpp File Reference

Tool to check if two WML string are equivalent. More...

#include "serialization/preprocessor.hpp"
Include dependency graph for wml_equivalence.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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. More...
 
void check_wml_equivalence (const std::string &a, const std::string &b)
 Assert two WML strings are equivalent. More...
 

Detailed Description

Tool to check if two WML string are equivalent.

Specifically, the check_wml_equivalence function would first preprocess and parse the two WML string to yield two syntax trees (defined by config objects). Subsequently, the function would assert if the two syntax trees are identical.

Definition in file wml_equivalence.hpp.

Function Documentation

◆ check_wml_equivalence()

void check_wml_equivalence ( const std::string &  a,
const std::string &  b 
)

Assert two WML strings are equivalent.

The function performs two steps:

  1. Make two syntax trees (defined by config objects) by preprocessing and parsing the two WML strings.
  2. Assert the two syntax tree are equal with a macro in Boost Test.
    Warning
    Create and delete two temporary files at the current directory.

Definition at line 64 of file wml_equivalence.cpp.

References preprocess_and_parse().

Referenced by BOOST_AUTO_TEST_CASE().

◆ preprocess_and_parse()

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.

Parameters
[in]wml_strThe string
[out]macro_mapStore preprocessor macros found by the preprocessor
Returns
The syntax tree.
Warning
Create and delete a temporary file at the current directory.

Definition at line 54 of file wml_equivalence.cpp.

References b, tmp_file::path, preprocess_file(), read(), and tmp_file::set().

Referenced by check_wml_equivalence().