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

set_hash_fct() of a hash container with keys when an allocation fails: the container keeps its function and its keys. More...

#include <gtest/gtest.h>
#include <gtest/gtest-spi.h>
#include "allocation_failure.H"
#include <cstddef>
#include <new>
#include <string>
#include <utility>
#include <tpl_dynMapOhash.H>
#include <tpl_dynSetHash.H>
#include <tpl_lhash.H>
#include <tpl_odhash.H>
#include <tpl_olhash.H>
Include dependency graph for hash_function_allocation_test.cc:

Go to the source code of this file.

Detailed Description

set_hash_fct() of a hash container with keys when an allocation fails: the container keeps its function and its keys.

The chained and the open tables place their keys again with the new function, in lists or buckets that they allocate first; the maps of tpl_dynSetHash.H also build the function of their table. When one of those allocations fails, set_hash_fct() throws std::bad_alloc and the container must go on finding its keys by its old function.

This program replaces the global operator new, so that a test can make an allocation fail.

Definition in file hash_function_allocation_test.cc.