blob: 545ece3c1bb61ed87163169593390f77586977fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef CPPUNITTEST_XMLUNIFORMISER_H
#define CPPUNITTEST_XMLUNIFORMISER_H
#include <cppunit/SourceLine.h>
#include <cppunit/TestAssert.h>
#include <string>
/*! Uniformise an XML string.
*
* Strips spaces between attribut in Element.
* \warning Attribute values must be double-quoted (att="value").
* No support for embedded DTD declaration
*/
class XmlUniformiser
{
public:
XmlUniformiser( const std::string &xml );
std::string stripped();
private:
void skipSpaces();
bool isValidIndex();
void skipNext( int count =1 );
void copyNext( int count =1 );
void skipProcessed();
void skipComment();
void copyElement();
void copyElementContent();
bool isSpace( char c );
bool isSpace();
bool startsWith( std::string expected );
void copyElementName();
void copyElementAttributes();
void copyAttributeName();
bool isEndOfAttributeName();
void copyAttributeValue();
void copyUntilDoubleQuote();
void removeTrailingSpaces();
private:
unsigned int m_index;
std::string m_xml;
std::string m_stripped;
};
void
checkXmlEqual( std::string expectedXml,
std::string actualXml,
CPPUNIT_NS::SourceLine sourceLine );
/// Asserts that two XML strings are equivalent.
#define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \
::checkXmlEqual( expected, actual, \
CPPUNIT_SOURCELINE() )
#endif // XMLUNIFORMISER_H
|