diff --git a/test/test_filebuf.cpp b/test/test_filebuf.cpp index 1aabe42..763ae20 100644 --- a/test/test_filebuf.cpp +++ b/test/test_filebuf.cpp @@ -143,14 +143,14 @@ void test_64_bit_seek(const std::string& filepath) // Create a value which does not fit into a 32 bit value. // Use an unsigned intermediate to have the truncation defined to wrap to 0 using unsigned_off_type = std::make_unsigned::type; - const nw::filebuf::off_type offset = static_cast(std::uint64_t(1) << 33u); + nw::filebuf::off_type offset = static_cast(std::uint64_t(1) << 33u); #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable : 4127) #endif // coverity[result_independent_of_operands] - if((offset == nw::filebuf::off_type(0))) + if(offset == nw::filebuf::off_type(0)) return; // Can't use 64 bit offsets throught the API, so don't test anything #ifdef BOOST_MSVC #pragma warning(pop) @@ -169,6 +169,11 @@ void test_64_bit_seek(const std::string& filepath) TEST(buf.pubseekoff(0, std::ios_base::cur) == knownPos); else { +#if !BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT + // libc++ may truncate the 64 bit value when calling fseek which yields an offset of 0 + if(newPos == knownPos) + offset = 0; // LCOV_EXCL_LINE +#endif TEST(newPos == offset + knownPos); TEST(buf.pubseekoff(0, std::ios_base::cur) == newPos); } @@ -228,6 +233,7 @@ void test_swap(const std::string& filepath) TEST(buf1.sputc('B') == 'B'); TEST(buf2.sbumpc() == 'H'); buf1.swap(buf2); + // Trying to read in write mode or other way round should fail TEST(buf1.sputc('x') == eof); TEST(buf2.sbumpc() == eof); TEST(buf1.sbumpc() == 'e'); @@ -311,5 +317,9 @@ void test_main(int, char** argv, char**) test_pubseekpos(exampleFilename); test_pubseekoff(exampleFilename); test_64_bit_seek(exampleFilename); +// These tests are only useful for the nowide filebuf and are known to fail for +// std::filebuf due to bugs in libc++ +#if BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT test_swap(exampleFilename); +#endif }