Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tree_allocation_test.cc File Reference

The balanced trees and their iterators allocate nothing but their nodes: construction, move, iteration and the path stacks of the operations never allocate, so their noexcept specifications hold. More...

#include <gtest/gtest.h>
#include <tpl_avl.H>
#include <tpl_avlRk.H>
#include <tpl_rb_tree.H>
#include <tpl_rbRk.H>
#include <tpl_hRbTree.H>
#include <tpl_hRbTreeRk.H>
#include <tpl_treap.H>
#include <tpl_rand_tree.H>
#include <tpl_splay_tree.H>
#include <tpl_binNodeUtils.H>
#include <tpl_dynBinHeap.H>
#include <tpl_dynSetTree.H>
#include <tpl_dynMapTree.H>
#include <ah-zip.H>
#include <ahFunctional.H>
#include <cstdlib>
#include <memory>
#include <new>
#include <type_traits>
#include <utility>
#include <vector>
Include dependency graph for tree_allocation_test.cc:

Go to the source code of this file.

Macros

#define COUNT_ALLOCATIONS   1
 
#define SKIP_UNLESS_COUNTING_ALLOCATIONS()
 
#define ALEPH_TEST_NOINLINE
 

Functions

void * operator new (std::size_t size)
 
void * operator new[] (std::size_t size)
 
void * operator new (std::size_t size, const std::nothrow_t &) noexcept
 
void * operator new[] (std::size_t size, const std::nothrow_t &) noexcept
 
void operator delete (void *p) noexcept
 
void operator delete[] (void *p) noexcept
 
void operator delete (void *p, std::size_t) noexcept
 
void operator delete[] (void *p, std::size_t) noexcept
 
void operator delete (void *p, const std::nothrow_t &) noexcept
 
void operator delete[] (void *p, const std::nothrow_t &) noexcept
 
 TEST (TreeAllocation, constructing_a_tree_does_not_allocate)
 
 TEST (TreeAllocation, moving_a_tree_does_not_allocate)
 
 TEST (TreeAllocation, insert_and_remove_allocate_only_the_node)
 
 TEST (TreeAllocation, iterating_does_not_allocate)
 
 TEST (TreeAllocation, advancing_on_a_deep_tree_allocates)
 
 TEST (TreeAllocation, adaptors_propagate_the_bad_alloc_of_a_deep_tree)
 
 TEST (TreeAllocation, noexcept_specifications_hold)
 

Detailed Description

The balanced trees and their iterators allocate nothing but their nodes: construction, move, iteration and the path stacks of the operations never allocate, so their noexcept specifications hold.

The allocations are counted by replacing the global allocation functions. A sanitizer that brings its own allocator defines them in its runtime (ThreadSanitizer and MemorySanitizer link them into the program, so a second definition does not link): under one, the replacement is left out and the tests that count are skipped.

Definition in file tree_allocation_test.cc.

Macro Definition Documentation

◆ ALEPH_TEST_NOINLINE

#define ALEPH_TEST_NOINLINE

Definition at line 93 of file tree_allocation_test.cc.

◆ COUNT_ALLOCATIONS

#define COUNT_ALLOCATIONS   1

Definition at line 82 of file tree_allocation_test.cc.

◆ SKIP_UNLESS_COUNTING_ALLOCATIONS

#define SKIP_UNLESS_COUNTING_ALLOCATIONS ( )
Value:
if (not COUNT_ALLOCATIONS) \
GTEST_SKIP() << "a sanitizer provides the allocation functions"
#define COUNT_ALLOCATIONS

Definition at line 86 of file tree_allocation_test.cc.

Function Documentation

◆ operator delete() [1/3]

void operator delete ( void *  p)
noexcept

Definition at line 174 of file tree_allocation_test.cc.

◆ operator delete() [2/3]

void operator delete ( void *  p,
const std::nothrow_t &   
)
noexcept

Definition at line 178 of file tree_allocation_test.cc.

◆ operator delete() [3/3]

void operator delete ( void *  p,
std::size_t   
)
noexcept

Definition at line 176 of file tree_allocation_test.cc.

◆ operator delete[]() [1/3]

void operator delete[] ( void *  p)
noexcept

Definition at line 175 of file tree_allocation_test.cc.

◆ operator delete[]() [2/3]

void operator delete[] ( void *  p,
const std::nothrow_t &   
)
noexcept

Definition at line 179 of file tree_allocation_test.cc.

◆ operator delete[]() [3/3]

void operator delete[] ( void *  p,
std::size_t   
)
noexcept

Definition at line 177 of file tree_allocation_test.cc.

◆ operator new() [1/2]

void * operator new ( std::size_t  size)

Definition at line 147 of file tree_allocation_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ operator new() [2/2]

void * operator new ( std::size_t  size,
const std::nothrow_t &   
)
noexcept

Definition at line 150 of file tree_allocation_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ operator new[]() [1/2]

void * operator new[] ( std::size_t  size)

Definition at line 148 of file tree_allocation_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ operator new[]() [2/2]

void * operator new[] ( std::size_t  size,
const std::nothrow_t &   
)
noexcept

Definition at line 162 of file tree_allocation_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ TEST() [1/7]

TEST ( TreeAllocation  ,
adaptors_propagate_the_bad_alloc_of_a_deep_tree   
)

◆ TEST() [2/7]

TEST ( TreeAllocation  ,
advancing_on_a_deep_tree_allocates   
)

◆ TEST() [3/7]

TEST ( TreeAllocation  ,
constructing_a_tree_does_not_allocate   
)

Definition at line 182 of file tree_allocation_test.cc.

References m, and SKIP_UNLESS_COUNTING_ALLOCATIONS.

◆ TEST() [4/7]

TEST ( TreeAllocation  ,
insert_and_remove_allocate_only_the_node   
)

◆ TEST() [5/7]

◆ TEST() [6/7]

◆ TEST() [7/7]

TEST ( TreeAllocation  ,
noexcept_specifications_hold   
)

Definition at line 405 of file tree_allocation_test.cc.

References Aleph::next_ne().