Reduce coupling between refdata and libxml2
authorTeemu Murtola <teemu.murtola@gmail.com>
Mon, 3 Aug 2015 17:52:53 +0000 (20:52 +0300)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 8 Sep 2015 11:14:32 +0000 (13:14 +0200)
commit085281cecdc3c780119fe6d7f3b083ce0ca756b7
tree16e833685a44231f6fb8daff2e703254a6eb2d0b
parent6e4b7f9bf393c4b4b26028f7518b1bb4157f0481
Reduce coupling between refdata and libxml2

Instead of directly manipulating the libxml2 XML tree in refdata.cpp,
make the reference data operations act on an internal data structure
(declared in refdata-impl.h).  Move all libxml2 interaction into
separate refdata-xml.* files.

This has several advantages:
- The internal data structure more clearly communicates the organization
  of the reference data, making the code easier to understand.
- The internal data structure can be extended to include information
  that is not easily possible to store in the XML tree, such as state
  information about what reference data items have been actually used in
  the test.
- Coupling to libxml2 is reduced, and the operations in refdata-xml.cpp
  are very standard XML manipulation commands (basically, just writing
  out a tree of elements sequentially, or reading them in), making it
  easier to make these use a common wrapper if such a wrapper is needed
  in the future for other XML operations.

One behavior change affects the tests, where the old behavior was not
worth preserving: now checkString() and checkStringBlock() can check
against the same reference data, instead of giving very obscure
assertion failures if a mismatch occurred.

Change-Id: Ie067ba65eb4ccf017ab1950b3746a9abd30da2b6
src/testutils/CMakeLists.txt
src/testutils/refdata-impl.h [new file with mode: 0644]
src/testutils/refdata-xml.cpp [new file with mode: 0644]
src/testutils/refdata-xml.h [new file with mode: 0644]
src/testutils/refdata.cpp
src/testutils/tests/refdata_tests.cpp