diff --git a/unit_tests/util/indexed_data.cpp b/unit_tests/util/indexed_data.cpp index c94a40543..3bb5d6dc7 100644 --- a/unit_tests/util/indexed_data.cpp +++ b/unit_tests/util/indexed_data.cpp @@ -1,6 +1,8 @@ #include "util/indexed_data.hpp" #include "util/exception.hpp" +#include + #include #include @@ -34,11 +36,18 @@ BOOST_AUTO_TEST_CASE(check_variable_group_block_bitops) template void test_rw(const Offsets &offsets, const Data &data) { - std::stringstream sstr; IndexedData indexed_data; - indexed_data.write(sstr, offsets.begin(), offsets.end(), data.begin()); + auto path = boost::filesystem::unique_path(); - const std::string str = sstr.str(); + { + storage::io::FileWriter writer(path, storage::io::FileWriter::HasNoFingerprint); + indexed_data.write(writer, offsets.begin(), offsets.end(), data.begin()); + } + + storage::io::FileReader reader(path, storage::io::FileReader::HasNoFingerprint); + auto length = reader.GetSize(); + std::string str(length, '\0'); + reader.ReadInto(const_cast(str.data()), length); #if 0 std::cout << "\n" << typeid(IndexedData).name() << "\nsaved size = " << str.size() << "\n"; @@ -175,14 +184,21 @@ BOOST_AUTO_TEST_CASE(check_corrupted_memory) BOOST_AUTO_TEST_CASE(check_string_view) { - std::stringstream sstr; + auto path = boost::filesystem::unique_path(); std::string name_data = "hellostringview"; std::vector name_offsets = {0, 5, 11, 15}; IndexedData> indexed_data; - indexed_data.write(sstr, name_offsets.begin(), name_offsets.end(), name_data.begin()); + { + storage::io::FileWriter writer(path, storage::io::FileWriter::HasNoFingerprint); + indexed_data.write(writer, name_offsets.begin(), name_offsets.end(), name_data.begin()); + } + + storage::io::FileReader reader(path, storage::io::FileReader::HasNoFingerprint); + auto length = reader.GetSize(); + std::string str(length, '\0'); + reader.ReadInto(const_cast(str.data()), length); - const std::string str = sstr.str(); indexed_data.reset(str.c_str(), str.c_str() + str.size()); BOOST_CHECK_EQUAL(indexed_data.at(0), "hello"); diff --git a/unit_tests/util/name_table.cpp b/unit_tests/util/name_table.cpp index d7b2a6137..a3cd328d5 100644 --- a/unit_tests/util/name_table.cpp +++ b/unit_tests/util/name_table.cpp @@ -1,6 +1,7 @@ #include "util/name_table.hpp" #include "util/exception.hpp" +#include #include #include @@ -19,7 +20,6 @@ using namespace osrm::util; std::string PrapareNameTableData(std::vector &data, bool fill_all) { - std::stringstream sstr; NameTable::IndexedData indexed_data; std::vector name_char_data; std::vector name_offsets; @@ -54,9 +54,19 @@ std::string PrapareNameTableData(std::vector &data, bool fill_all) } name_offsets.push_back(name_char_data.size()); - indexed_data.write(sstr, name_offsets.begin(), name_offsets.end(), name_char_data.begin()); + auto path = boost::filesystem::unique_path(); + { + storage::io::FileWriter writer(path, storage::io::FileWriter::HasNoFingerprint); + indexed_data.write( + writer, name_offsets.begin(), name_offsets.end(), name_char_data.begin()); + } - return sstr.str(); + storage::io::FileReader reader(path, storage::io::FileReader::HasNoFingerprint); + auto length = reader.GetSize(); + std::string str(length, '\0'); + reader.ReadInto(const_cast(str.data()), length); + + return str; } BOOST_AUTO_TEST_CASE(check_name_table_fill)