4 #include "ParserEventGeneratorKit.h"
6 std::string CharStringtostring(const SGMLApplication::CharString source)
8 // The CharString type might have multi-byte characters if SP_MULTI_BYTE was
11 result.resize(source.len);
12 for (size_t i = 0; i < source.len; i++) {
13 result[i] = static_cast<char>(source.ptr[i]);
18 class OutlineApplication : public SGMLApplication
25 void startElement(const StartElementEvent& event)
27 for (unsigned i = 0; i < depth_; i++)
29 parsedOutput += CharStringtostring(event.gi);
32 void endElement(const EndElementEvent&) { depth_--; }
33 std::string parsedOutput;
41 std::string expectedOutput = "TESTDOC\tTESTELEMENT";
42 char file_name[] = "test.sgml";
43 char* files[] = { file_name, 0 };
45 ParserEventGeneratorKit parserKit;
46 EventGenerator* egp = parserKit.makeEventGenerator(1, files);
47 OutlineApplication app;
48 unsigned nErrors = egp->run(app);
51 assert(app.parsedOutput.compare(expectedOutput) == 0);