diff --git a/include/gp/containers/flat_tree.hpp b/include/gp/containers/flat_tree.hpp index 5722efb..4c1068c 100644 --- a/include/gp/containers/flat_tree.hpp +++ b/include/gp/containers/flat_tree.hpp @@ -34,9 +34,9 @@ namespace gp { size_t pivot; if(value_workspace.size()%2) { - pivot = value_workspace.size()/2 + 1; - } else { pivot = value_workspace.size()/2; + } else { + pivot = value_workspace.size()/2 + 1; } destination_space[idx] = gp::move(value_workspace[pivot]); @@ -140,7 +140,7 @@ namespace gp { if(!ok) return false; - gp::sort(workspace.begin(), workspace.end(), [](const node_t& lhs, const node_t& rhs){ return lhs.has_value() > rhs.has_value(); }); + gp::sort(workspace.begin(), workspace.end(), [](const node_t& lhs, const node_t& rhs){ return lhs.has_value() < rhs.has_value(); }); size_t cnt = 0; for(auto& elem : workspace) { diff --git a/tests.cpp b/tests.cpp index dbcf701..706b1b2 100644 --- a/tests.cpp +++ b/tests.cpp @@ -36,6 +36,8 @@ void print_logs() { } } +#define CATCH_EXCEPTIONS 0 + std::vector> tests; int main() @@ -46,13 +48,16 @@ int main() { ++runned; int value; +#if CATCH_EXCEPTIONS try{ +#endif value = test->run(); if(value) { std::cout << std::dec << test->name << " failed with "<< value << std::endl; print_logs(); } +#if CATCH_EXCEPTIONS } catch (gp::runtime_error err) { std::cout << test->name << " failed with an exception: " << err.what() << std::endl; print_logs(); @@ -66,6 +71,7 @@ int main() print_logs(); value = -1; } +#endif logger.clear(); failed += (value != 0); }