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

The macros of ah-errors.H that throw, when their stream fails. More...

#include <gtest/gtest.h>
#include "allocation_failure.H"
#include <cstdio>
#include <ios>
#include <new>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <ah-errors.H>
Include dependency graph for ah_errors_stream_failure_test.cc:

Go to the source code of this file.

Classes

struct  ErrorStreamFailure
 

Functions

std::ostringstream & operator<< (std::ostringstream &out, const char *str)
 
 TEST_F (ErrorStreamFailure, WithoutMemoryForItsStreamAMacroThrowsBadAlloc)
 
 TEST_F (ErrorStreamFailure, AnyAllocationThatFailsGivesBadAllocOrTheException)
 
 TEST_F (ErrorStreamFailure, APlaceThatThrowsFreesTheStream)
 

Detailed Description

The macros of ah-errors.H that throw, when their stream fails.

A macro that throws allocates the stream of its message. This program replaces the global operator new, so that a test can make an allocation fail, and declares before ah-errors.H an inserter that the place of a message takes, so that a test can make that place throw. Without memory for its stream, a macro throws std::bad_alloc and evaluates no item; whatever allocation fails, it throws std::bad_alloc or its exception; and a place that throws frees the stream.

Definition in file ah_errors_stream_failure_test.cc.

Function Documentation

◆ operator<<()

std::ostringstream & operator<< ( std::ostringstream &  out,
const char *  str 
)

Definition at line 74 of file ah_errors_stream_failure_test.cc.

References out.

◆ TEST_F() [1/3]

TEST_F ( ErrorStreamFailure  ,
AnyAllocationThatFailsGivesBadAllocOrTheException   
)

Definition at line 175 of file ah_errors_stream_failure_test.cc.

References k.

◆ TEST_F() [2/3]

TEST_F ( ErrorStreamFailure  ,
APlaceThatThrowsFreesTheStream   
)

Definition at line 225 of file ah_errors_stream_failure_test.cc.

◆ TEST_F() [3/3]

TEST_F ( ErrorStreamFailure  ,
WithoutMemoryForItsStreamAMacroThrowsBadAlloc   
)

Definition at line 144 of file ah_errors_stream_failure_test.cc.