stuff-from-scratch/test/web/TestXmlParser.cpp

33 lines
720 B
C++
Raw Normal View History

2022-01-01 18:46:31 +00:00
#include <iostream>
#include <fstream>
#include "XmlParser.h"
#include "XmlWriter.h"
2022-12-01 11:49:57 +00:00
#include "XmlDocument.h"
2022-01-01 18:46:31 +00:00
#include "File.h"
2022-11-29 18:00:19 +00:00
#include "TestFramework.h"
2022-12-01 10:52:48 +00:00
#include "TestUtils.h"
2022-11-29 18:00:19 +00:00
TEST_CASE(TestXmlParser, "web")
2022-01-01 18:46:31 +00:00
{
XmlParser parser;
std::ifstream xml_file;
2022-12-01 10:52:48 +00:00
xml_file.open(TestUtils::getTestDataDir() / "test.xml", std::ifstream::in);
2022-01-01 18:46:31 +00:00
while(xml_file.good())
{
std::string line;
std::getline(xml_file, line);
2022-12-01 11:49:57 +00:00
parser.processLine(line);
2022-01-01 18:46:31 +00:00
}
xml_file.close();
XmlWriter writer;
2022-12-01 11:49:57 +00:00
auto content = writer.toString(parser.getDocument().get());
2022-12-01 10:52:48 +00:00
auto outFile = std::make_unique<File>(TestUtils::getTestOutputDir() / "test_out.xml");
outFile->writeText(content);
2022-01-01 18:46:31 +00:00
}