Browse Source

Fixed a dumb bounds infringement

master
Ludovic 'Archivist' Lagouardette 2 years ago
parent
commit
f50388e8d3
2 changed files with 9 additions and 3 deletions
  1. +3
    -3
      include/gp/containers/flat_tree.hpp
  2. +6
    -0
      tests.cpp

+ 3
- 3
include/gp/containers/flat_tree.hpp View File

@ -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) {

+ 6
- 0
tests.cpp View File

@ -36,6 +36,8 @@ void print_logs() {
}
}
#define CATCH_EXCEPTIONS 0
std::vector<std::unique_ptr<test_scaffold>> 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);
}

Loading…
Cancel
Save