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

Symbols that enter a Huffman encoder when memory runs out. More...

#include <gtest/gtest.h>
#include "allocation_failure.H"
#include <algorithm>
#include <iterator>
#include <new>
#include <string>
#include <utility>
#include <vector>
#include <Huffman.H>
Include dependency graph for huffman_allocation_test.cc:

Go to the source code of this file.

Functions

 TEST_F (HuffmanWithoutMemory, SetFreqLeavesTheEncoderAsItWas)
 
 TEST_F (HuffmanWithoutMemory, SetEndOfStreamLeavesTheEncoderAsItWas)
 
 TEST_F (HuffmanWithoutMemory, GenerateLeavesTheEncoderAsItWas)
 
 TEST_F (HuffmanWithoutMemory, AFailedGenerationTakesMoreSymbols)
 
 TEST_F (HuffmanWithoutMemory, OneSymbolGeneratesItsLeaf)
 
 TEST_F (HuffmanWithoutMemory, AFailedGenerationKeepsNoFrequencyOfItsOwn)
 

Variables

char abc_input [] = "abracadabra, a cab"
 

Detailed Description

Symbols that enter a Huffman encoder when memory runs out.

This program replaces the global operator new, so that a test can make one allocation fail. set_freq() and set_end_of_stream(), as read_input() for each new symbol, make the leaf of the symbol and its node, and enter the node in the map of the symbols and in the heap. The node entered the heap first: without memory for the map, the leaf was freed while the heap kept the node, so the tree had a freed leaf, and the destructor freed it again.

Definition in file huffman_allocation_test.cc.

Function Documentation

◆ TEST_F() [1/6]

◆ TEST_F() [2/6]

TEST_F ( HuffmanWithoutMemory  ,
AFailedGenerationTakesMoreSymbols   
)

◆ TEST_F() [3/6]

◆ TEST_F() [4/6]

◆ TEST_F() [5/6]

TEST_F ( HuffmanWithoutMemory  ,
SetEndOfStreamLeavesTheEncoderAsItWas   
)

◆ TEST_F() [6/6]

TEST_F ( HuffmanWithoutMemory  ,
SetFreqLeavesTheEncoderAsItWas   
)

Variable Documentation

◆ abc_input

char abc_input[] = "abracadabra, a cab"

Definition at line 384 of file huffman_allocation_test.cc.

Referenced by TEST_F().