void ConstructionTest(stxxl::vector<unsigned> lengths, std::vector<unsigned> offsets) { BOOST_ASSERT(lengths.size() == offsets.size() - 1); TestRangeTable table(lengths); for (unsigned i = 0; i < lengths.size(); i++) { auto range = table.GetRange(i); BOOST_CHECK_EQUAL(range.front(), offsets[i]); BOOST_CHECK_EQUAL(range.back() + 1, offsets[i + 1]); } }
iterator_compare& operator ++ () { if (current_value != *compiter) errors.push_back(error_type(current_value, *compiter)); ++compiter; return *this; }
bool serializeVector(std::ofstream &out_stream, const stxxl::vector<simple_type> &data) { const std::uint64_t size = data.size(); out_stream.write(reinterpret_cast<const char *>(&size), sizeof(size)); simple_type write_buffer[WRITE_BLOCK_BUFFER_SIZE]; std::size_t buffer_len = 0; for (const auto entry : data) { write_buffer[buffer_len++] = entry; if (buffer_len >= WRITE_BLOCK_BUFFER_SIZE) { out_stream.write(reinterpret_cast<const char *>(write_buffer), WRITE_BLOCK_BUFFER_SIZE * sizeof(simple_type)); buffer_len = 0; } } // write remaining entries if (buffer_len > 0) out_stream.write(reinterpret_cast<const char *>(write_buffer), buffer_len * sizeof(simple_type)); return static_cast<bool>(out_stream); }
void ComputeLengthsOffsets(stxxl::vector<unsigned> &lengths, std::vector<unsigned> &offsets, unsigned num) { lengths.resize(num); offsets.resize(num + 1); std::iota(lengths.begin(), lengths.end(), 1); offsets[0] = 0; std::partial_sum(lengths.begin(), lengths.end(), offsets.begin() + 1); std::stringstream l_ss; l_ss << "Lengths: "; for (auto l : lengths) l_ss << l << ", "; BOOST_TEST_MESSAGE(l_ss.str()); std::stringstream o_ss; o_ss << "Offsets: "; for (auto o : offsets) o_ss << o << ", "; BOOST_TEST_MESSAGE(o_ss.str()); }
unsigned_type get_num_errors() { return errors.size(); }