diff --git a/tests/src/Base/Reader.cpp b/tests/src/Base/Reader.cpp index 25fee6bbc1..c67d463ce0 100644 --- a/tests/src/Base/Reader.cpp +++ b/tests/src/Base/Reader.cpp @@ -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(stringData.length())); fileStream.close(); - std::ifstream inputStream(_tempFile.string()); + inputStream.open(_tempFile.string()); _reader = std::make_unique(_tempFile.string().c_str(), inputStream); } @@ -54,6 +57,7 @@ private: std::unique_ptr _reader; fs::path _tempDir; fs::path _tempFile; + std::ifstream inputStream; }; TEST_F(ReaderTest, beginCharStreamNormal)