-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix osrm-contract, tests, on Windows #5882
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,18 +25,20 @@ namespace | |
{ | ||
namespace ph = boost::phoenix; | ||
namespace qi = boost::spirit::qi; | ||
} | ||
} // namespace | ||
|
||
template <typename T, char... Fmt> struct no_trailing_dot_policy : qi::real_policies<T> | ||
{ | ||
template <typename Iterator> static bool parse_dot(Iterator &first, Iterator const &last) | ||
{ | ||
if (first == last || *first != '.') | ||
auto diff = std::distance(first, last); | ||
if (diff <= 0 || *first != '.') | ||
return false; | ||
|
||
static const constexpr char fmt[sizeof...(Fmt)] = {Fmt...}; | ||
|
||
if (first + sizeof(fmt) < last && std::equal(fmt, fmt + sizeof(fmt), first + 1u)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (sizeof(fmt) < static_cast<size_t>(diff) && | ||
std::equal(fmt, fmt + sizeof(fmt), first + 1u)) | ||
return false; | ||
|
||
++first; | ||
|
@@ -225,8 +227,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature> | |
qi::symbols<char, engine::Approach> approach_type; | ||
qi::symbols<char, engine::api::BaseParameters::SnappingType> snapping_type; | ||
}; | ||
} | ||
} | ||
} | ||
} // namespace api | ||
} // namespace server | ||
} // namespace osrm | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ template <typename BlockPolicy, storage::Ownership Ownership> | |
inline void write(storage::tar::FileWriter &writer, | ||
const std::string &name, | ||
const detail::IndexedDataImpl<BlockPolicy, Ownership> &index_data); | ||
} | ||
} // namespace serialization | ||
|
||
template <int N, typename T = std::string> struct VariableGroupBlock | ||
{ | ||
|
@@ -346,7 +346,7 @@ template <typename GroupBlockPolicy, storage::Ownership Ownership> struct Indexe | |
const GroupBlockPolicy block; | ||
block.ReadRefrencedBlock(blocks[block_idx], internal_idx, first, last); | ||
|
||
return adapt(&*first, &*last); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For empty container, |
||
return adapt(first, last); | ||
} | ||
|
||
friend void serialization::read<GroupBlockPolicy, Ownership>(storage::tar::FileReader &reader, | ||
|
@@ -359,30 +359,35 @@ template <typename GroupBlockPolicy, storage::Ownership Ownership> struct Indexe | |
const IndexedDataImpl &index_data); | ||
|
||
private: | ||
template <class T = ResultType> | ||
template <typename Iter, typename T> | ||
using IsValueIterator = | ||
std::enable_if_t<std::is_same<T, typename std::iterator_traits<Iter>::value_type>::value>; | ||
|
||
template <typename T = ResultType, typename Iter, typename = IsValueIterator<Iter, ValueType>> | ||
typename std::enable_if<!std::is_same<T, StringView>::value, T>::type | ||
adapt(const ValueType *first, const ValueType *last) const | ||
adapt(const Iter first, const Iter last) const | ||
{ | ||
return ResultType(first, last); | ||
} | ||
|
||
template <class T = ResultType> | ||
template <typename T = ResultType, typename Iter, typename = IsValueIterator<Iter, ValueType>> | ||
typename std::enable_if<std::is_same<T, StringView>::value, T>::type | ||
adapt(const ValueType *first, const ValueType *last) const | ||
adapt(const Iter first, const Iter last) const | ||
{ | ||
return ResultType(first, std::distance(first, last)); | ||
auto diff = std::distance(first, last); | ||
return diff == 0 ? ResultType() : ResultType(&*first, diff); | ||
} | ||
|
||
template <typename T> using Vector = util::ViewOrVector<T, Ownership>; | ||
Vector<BlockReference> blocks; | ||
Vector<ValueType> values; | ||
}; | ||
} | ||
} // namespace detail | ||
|
||
template <typename GroupBlockPolicy> | ||
using IndexedData = detail::IndexedDataImpl<GroupBlockPolicy, storage::Ownership::Container>; | ||
template <typename GroupBlockPolicy> | ||
using IndexedDataView = detail::IndexedDataImpl<GroupBlockPolicy, storage::Ownership::View>; | ||
} | ||
} | ||
} // namespace util | ||
} // namespace osrm | ||
#endif // OSRM_INDEXED_DATA_HPP |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,11 @@ | |
const auto &rhs = {__VA_ARGS__}; \ | ||
BOOST_CHECK_EQUAL_COLLECTIONS(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); \ | ||
} while (0) | ||
#define CHECK_EQUAL_COLLECTIONS(lhs, rhs) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failed if |
||
#define CHECK_EQUAL_COLLECTIONS(coll_lhs, coll_rhs) \ | ||
do \ | ||
{ \ | ||
const auto &lhs = coll_lhs; \ | ||
const auto &rhs = coll_rhs; \ | ||
BOOST_CHECK_EQUAL_COLLECTIONS(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); \ | ||
} while (0) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#include <boost/numeric/conversion/cast.hpp> | ||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <util/integer_range.hpp> | ||
#include <util/msb.hpp> | ||
|
||
#include "partitioner/multi_level_partition.hpp" | ||
|
||
#define CHECK_SIZE_RANGE(range, ref) BOOST_CHECK_EQUAL(range.second - range.first, ref) | ||
|
@@ -175,4 +178,56 @@ BOOST_AUTO_TEST_CASE(mlp_sorted) | |
BOOST_CHECK_EQUAL(mlp.EndChildren(4, 0), 2); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(large_cell_number) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created this to detect #5878, but it also found an issue with 32 bit builds. |
||
{ | ||
size_t num_nodes = 256; | ||
size_t num_levels = 9; | ||
std::vector<std::vector<CellID>> levels(num_levels, std::vector<CellID>(num_nodes)); | ||
std::vector<uint32_t> levels_to_num_cells(num_levels); | ||
|
||
std::iota(levels[0].begin(), levels[0].end(), 0); | ||
levels_to_num_cells[0] = num_nodes; | ||
|
||
for (auto l : util::irange<size_t>(1UL, num_levels)) | ||
{ | ||
std::transform(levels[l - 1].begin(), levels[l - 1].end(), levels[l].begin(), [](auto val) { | ||
return val / 2; | ||
}); | ||
levels_to_num_cells[l] = levels_to_num_cells[l - 1] / 2; | ||
} | ||
|
||
// level 1: 0 1 2 3 ... 252 253 254 255 | ||
// level 2: 0 0 1 1 ... 126 126 127 127 | ||
// level 3: 0 0 0 0 ... 63 63 63 63 | ||
// ... | ||
// level 9: 0 0 0 0 ... 0 0 0 0 | ||
MultiLevelPartition mlp{levels, levels_to_num_cells}; | ||
|
||
for (const auto l : util::irange<size_t>(1UL, num_levels + 1)) | ||
{ | ||
BOOST_REQUIRE_EQUAL(mlp.GetNumberOfCells(l), num_nodes >> (l - 1)); | ||
for (const auto n : util::irange<size_t>(0UL, num_nodes)) | ||
{ | ||
BOOST_REQUIRE_EQUAL(mlp.GetCell(l, n), levels[l - 1][n]); | ||
} | ||
} | ||
|
||
for (const auto m : util::irange<size_t>(0UL, num_nodes)) | ||
{ | ||
for (const auto n : util::irange(m + 1, num_nodes)) | ||
{ | ||
BOOST_REQUIRE_EQUAL(mlp.GetHighestDifferentLevel(m, n), 1 + util::msb(m ^ n)); | ||
} | ||
} | ||
|
||
for (const auto l : util::irange<size_t>(2UL, num_levels + 1)) | ||
{ | ||
for (const auto c : util::irange<size_t>(0UL, levels_to_num_cells[l - 1])) | ||
{ | ||
BOOST_REQUIRE_EQUAL(mlp.BeginChildren(l, c), 2 * c); | ||
BOOST_REQUIRE_EQUAL(mlp.EndChildren(l, c), 2 * (c + 1)); | ||
} | ||
} | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍