Skip to content

Commit

Permalink
OSX: printf debugging.
Browse files Browse the repository at this point in the history
Decreased test data size (to avoid timeouts on GitHub).
  • Loading branch information
psiha committed Oct 11, 2024
1 parent c3e9628 commit 59ba2bb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/b+tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <gtest/gtest.h>

#include <filesystem>
#include <print>
#include <random>
#include <ranges>
#include <utility>
Expand All @@ -19,20 +19,22 @@ static auto const test_file{ "test.bpt" };

TEST( bp_tree, playground )
{
std::println( "Generating test data." );
#ifdef NDEBUG
auto const test_size{ 9137365 };
auto const test_size{ 953735 };
#else
auto const test_size{ 937358 };
auto const test_size{ 98735 };
#endif
std::ranges::iota_view constexpr sorted_numbers{ 0, test_size };
std::mt19937 rng{ std::random_device{}() };
auto numbers{ std::ranges::to<std::vector>( sorted_numbers ) };
std::shuffle( numbers.begin(), numbers.end(), rng );
{
std::println( "B+tree in memory..." );
bp_tree<int> bpt;
bpt.map_memory();
bpt.reserve( numbers.size() );

std::println( " ...insertion" );
{
auto const nums { std::span{ numbers } };
auto const third{ nums.size() / 3 };
Expand All @@ -44,7 +46,7 @@ TEST( bp_tree, playground )
bpt.insert( third_third );
}


std::println( " ...checks" );
static_assert( std::forward_iterator<bp_tree<int>::const_iterator> );

EXPECT_TRUE( std::ranges::is_sorted( std::as_const( bpt ) ) );
Expand All @@ -63,6 +65,7 @@ TEST( bp_tree, playground )
EXPECT_EQ( ra[ n ], n );
}

std::println( " ...erasure" );
std::shuffle( numbers.begin(), numbers.end(), rng );
for ( auto const & n : numbers )
bpt.erase( n );
Expand All @@ -71,6 +74,7 @@ TEST( bp_tree, playground )
}

{
std::println( "B+tree on disk - creation..." );
bp_tree<int> bpt;
bpt.map_file( test_file, flags::named_object_construction_policy::create_new_or_truncate_existing );

Expand All @@ -87,6 +91,7 @@ TEST( bp_tree, playground )
EXPECT_EQ( bpt.find( +42 ), bpt.end() );
}
{
std::println( "B+tree on disk - opening..." );
bp_tree<int> bpt;
bpt.map_file( test_file, flags::named_object_construction_policy::open_existing );

Expand Down

0 comments on commit 59ba2bb

Please sign in to comment.