The Battle for Wesnoth  1.19.0-dev
Classes | Functions
wml_equivalence.cpp File Reference
#include "wml_equivalence.hpp"
#include "serialization/parser.hpp"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/test/unit_test.hpp>
Include dependency graph for wml_equivalence.cpp:

Go to the source code of this file.

Classes

class  tmp_file
 Self destructive temporary file at the current directory. More...
 

Functions

config preprocess_and_parse (const std::string &wml_str, preproc_map *macro_map)
 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...
 

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 67 of file wml_equivalence.cpp.

References a, b, and 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 57 of file wml_equivalence.cpp.

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

Referenced by check_wml_equivalence().