diff --git a/include/seqan3/io/stream/detail/fast_istreambuf_iterator.hpp b/include/seqan3/io/stream/detail/fast_istreambuf_iterator.hpp index 78a61cb145..9032e8903a 100644 --- a/include/seqan3/io/stream/detail/fast_istreambuf_iterator.hpp +++ b/include/seqan3/io/stream/detail/fast_istreambuf_iterator.hpp @@ -69,7 +69,9 @@ class fast_istreambuf_iterator stream_buf{reinterpret_cast *>(&ibuf)} { assert(stream_buf != nullptr); - stream_buf->underflow(); // ensure the stream buffer has content on construction + if (!stream_buf->in_avail()) + stream_buf->underflow(); // ensure the stream buffer has content on construction + assert(stream_buf.in_avail()); } //!\} diff --git a/test/unit/io/sam_file/sam_file_format_test_template.hpp b/test/unit/io/sam_file/sam_file_format_test_template.hpp index 6a07e4a9fe..08202042b3 100644 --- a/test/unit/io/sam_file/sam_file_format_test_template.hpp +++ b/test/unit/io/sam_file/sam_file_format_test_template.hpp @@ -223,31 +223,23 @@ TYPED_TEST_P(sam_file_read, read_in_all_data) class null_filter_buf : public std::streambuf { + static constexpr std::streamsize buffer_size{10}; std::streambuf * src; - std::array bufl{}; + std::array bufl{}; public: - - null_filter_buf() = delete; //!< Defaulted. - null_filter_buf(null_filter_buf const &) = delete; //!< Defaulted. - null_filter_buf & operator=(null_filter_buf const &) = delete; //!< Defaulted. - null_filter_buf(null_filter_buf &&) = delete; //!< Defaulted. - null_filter_buf & operator=(null_filter_buf &&) = delete; //!< Defaulted. - ~null_filter_buf() = default; //!< Defaulted. - int underflow() { - std::streamsize number_of_characters_read = src->sgetn(bufl.data(), 10); + std::streamsize number_of_characters_read = src->sgetn(bufl.data(), buffer_size); setg(bufl.data(), bufl.data(), bufl.data() + number_of_characters_read); // make read position available - return (number_of_characters_read == 10) ? *bufl.data() : traits_type::eof(); + return (number_of_characters_read == buffer_size) ? *bufl.data() : traits_type::eof(); } - null_filter_buf(std::streambuf* buf) : src(buf) + null_filter_buf(std::streambuf * buf) : src(buf) { - std::cout << "I'm getting consstructed and I'm filling my buffer" << std::endl; - underflow(); + setg(bufl.data(), bufl.data(), bufl.data() + buffer_size); } };