Tests: fix undefined behaviour in givenDataAsXMLStream

This commit is contained in:
wmayer
2023-10-11 11:20:56 +02:00
committed by wwmayer
parent a6ff03d54b
commit be2aa179b1

View File

@@ -28,6 +28,9 @@ protected:
void TearDown() override
{
if (inputStream.is_open()) {
inputStream.close();
}
if (fs::exists(_tempFile)) {
fs::remove(_tempFile);
}
@@ -41,7 +44,7 @@ protected:
std::ofstream fileStream(_tempFile.string());
fileStream.write(stringData.data(), static_cast<std::streamsize>(stringData.length()));
fileStream.close();
std::ifstream inputStream(_tempFile.string());
inputStream.open(_tempFile.string());
_reader = std::make_unique<Base::XMLReader>(_tempFile.string().c_str(), inputStream);
}
@@ -54,6 +57,7 @@ private:
std::unique_ptr<Base::XMLReader> _reader;
fs::path _tempDir;
fs::path _tempFile;
std::ifstream inputStream;
};
TEST_F(ReaderTest, beginCharStreamNormal)