diff --git a/apps/openmw_test_suite/files/hash.cpp b/apps/openmw_test_suite/files/hash.cpp index f87edd4e6e..645258f60e 100644 --- a/apps/openmw_test_suite/files/hash.cpp +++ b/apps/openmw_test_suite/files/hash.cpp @@ -22,6 +22,16 @@ namespace struct FilesGetHash : TestWithParam {}; + TEST(FilesGetHash, shouldClearErrors) + { + const std::string fileName = "fileName"; + std::string content; + std::fill_n(std::back_inserter(content), 1, 'a'); + std::istringstream stream(content); + stream.exceptions(std::ios::failbit | std::ios::badbit); + EXPECT_THAT(getHash(fileName, stream), ElementsAre(9607679276477937801ull, 16624257681780017498ull)); + } + TEST_P(FilesGetHash, shouldReturnHashForStringStream) { const std::string fileName = "fileName"; diff --git a/components/files/hash.cpp b/components/files/hash.cpp index 079a169ae5..b11ecbf838 100644 --- a/components/files/hash.cpp +++ b/components/files/hash.cpp @@ -28,8 +28,8 @@ namespace Files MurmurHash3_x64_128(value.data(), static_cast(read), hash.data(), blockHash.data()); hash = blockHash; } - stream.exceptions(exceptions); stream.clear(); + stream.exceptions(exceptions); stream.seekg(start); } catch (const std::exception& e)