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

Tests of the messages of the macros of ah-errors.H that throw. More...

#include <gtest/gtest.h>
#include <atomic>
#include <cstring>
#include <iomanip>
#include <ios>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <thread>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include <ah-errors.H>
#include <bitArray.H>
#include <tpl_array.H>
#include <tpl_arrayQueue.H>
#include <tpl_dynArray.H>
#include <tpl_memArray.H>
#include <tpl_small_vector.H>
Include dependency graph for ah_errors_message_test.cc:

Go to the source code of this file.

Namespaces

namespace  overload_of_the_caller
 

Macros

#define EXPECT_THE_WHOLE(E, call, items)
 
#define EXPECT_THE_ITEMS(E, call, items)
 
#define EXPECT_THE_TEXT(E, statement, text)
 
#define EXPECT_THE_MESSAGES_OF(E, base)
 
#define ITEMS   << "value " << n << ", " << s << ' ' << 2.5
 

Functions

 TEST (ErrorMessage, EveryMacroGivesItsPlaceAndItsItems)
 
 TEST (ErrorMessage, AMessageWithoutItemsIsItsPlace)
 
 TEST (ErrorMessage, TakesTheItemsThatAStreamTakes)
 
 TEST (ErrorMessage, TakesTheManipulatorsOfAStream)
 
 TEST (ErrorMessage, KeepsTheTemporariesOfItsItemsUntilItThrows)
 
 TEST (ErrorMessage, EvaluatesItsItemsOnceInOrderAndOnlyToThrow)
 
 TEST (ErrorMessage, ReadsEachItemWhenItIsInserted)
 
 TEST (ErrorMessage, GoesThroughAMacroThatTakesItAsAnArgument)
 
 TEST (ErrorMessage, TheStreamOfAMessageTakesAPointerOfTheFrame)
 
 TEST (ErrorMessage, TheStreamDiesWhenItsExceptionLeaves)
 
 TEST (ErrorMessage, AnOverloadOfTheCallerTakesItsItemsAndNotThePlace)
 
 TEST (ErrorMessage, EachThreadWritesItsOwnMessages)
 
 TEST (ErrorMessage, AMessageInsideAnotherKeepsBoth)
 
 TEST (ErrorMessage, ACheckedAccessOutOfRangeThrowsWithItsText)
 

Detailed Description

Tests of the messages of the macros of ah-errors.H that throw.

A macro writes its message in a stream that an object of one pointer owns out of the frame of the function that checks. These tests check that the text is the one that a stream gives for the same items, behind the place of the call; that each item is evaluated once, in order and only to throw, and read when it is inserted; that the stream has the type of the temporary stream that the macros had, and dies when its exception leaves, also when an item throws; that the place is written by the library and each thread writes its own messages; and that the checked accesses of the arrays still throw with their text.

Definition in file ah_errors_message_test.cc.

Macro Definition Documentation

◆ EXPECT_THE_ITEMS

#define EXPECT_THE_ITEMS (   E,
  call,
  items 
)
Value:
do \
{ \
std::ostringstream expected; \
expected items; \
const std::string message = message_of<E>([&] { call items; }); \
EXPECT_EQ(file_of(message), __FILE__); \
EXPECT_EQ(text_of(message), expected.str()); \
} \
while (false)
Minimal std::expected-style result type for C++20.
void message(const char *file, int line, const char *format,...)
Print an informational message with file and line info.
Definition ahDefs.C:95

Definition at line 247 of file ah_errors_message_test.cc.

◆ EXPECT_THE_MESSAGES_OF

#define EXPECT_THE_MESSAGES_OF (   E,
  base 
)
Value:
do \
{ \
EXPECT_THE_WHOLE(E, base ## _if(n == 7), ITEMS); \
EXPECT_THE_WHOLE(E, base ## _unless(n != 7), ITEMS); \
EXPECT_THE_WHOLE(E, base(), ITEMS); \
EXPECT_THE_WHOLE(E, base ## _if_constexpr(true), ITEMS); \
EXPECT_THE_WHOLE(E, base ## _unless_constexpr(false), ITEMS); \
} \
while (false)
#define ITEMS

Definition at line 269 of file ah_errors_message_test.cc.

◆ EXPECT_THE_TEXT

#define EXPECT_THE_TEXT (   E,
  statement,
  text 
)
Value:
do \
{ \
const std::string message = message_of<E>([&] { statement; }); \
EXPECT_EQ(file_of(message), __FILE__); \
EXPECT_EQ(text_of(message), text); \
} \
while (false)

Definition at line 259 of file ah_errors_message_test.cc.

◆ EXPECT_THE_WHOLE

#define EXPECT_THE_WHOLE (   E,
  call,
  items 
)
Value:
do \
{ \
std::ostringstream expected; \
expected items; \
EXPECT_EQ(message_of<E>([&] { call items; }), \
place(__LINE__) + expected.str()); \
} \
while (false)

Definition at line 234 of file ah_errors_message_test.cc.

◆ ITEMS

#define ITEMS   << "value " << n << ", " << s << ' ' << 2.5

Function Documentation

◆ TEST() [1/14]

◆ TEST() [2/14]

TEST ( ErrorMessage  ,
AMessageInsideAnotherKeepsBoth   
)

Definition at line 516 of file ah_errors_message_test.cc.

References ah_runtime_error, and EXPECT_THE_TEXT.

◆ TEST() [3/14]

TEST ( ErrorMessage  ,
AMessageWithoutItemsIsItsPlace   
)

◆ TEST() [4/14]

TEST ( ErrorMessage  ,
AnOverloadOfTheCallerTakesItsItemsAndNotThePlace   
)

Definition at line 474 of file ah_errors_message_test.cc.

References Aleph::message().

◆ TEST() [5/14]

TEST ( ErrorMessage  ,
EachThreadWritesItsOwnMessages   
)

Definition at line 486 of file ah_errors_message_test.cc.

References Aleph::Array< T >::append().

◆ TEST() [6/14]

TEST ( ErrorMessage  ,
EvaluatesItsItemsOnceInOrderAndOnlyToThrow   
)

◆ TEST() [7/14]

◆ TEST() [8/14]

TEST ( ErrorMessage  ,
GoesThroughAMacroThatTakesItAsAnArgument   
)

Definition at line 411 of file ah_errors_message_test.cc.

References ah_domain_error_if, and ah_out_of_range_error.

◆ TEST() [9/14]

TEST ( ErrorMessage  ,
KeepsTheTemporariesOfItsItemsUntilItThrows   
)

Definition at line 351 of file ah_errors_message_test.cc.

References ah_runtime_error, ah_runtime_error_if, and EXPECT_THE_TEXT.

◆ TEST() [10/14]

TEST ( ErrorMessage  ,
ReadsEachItemWhenItIsInserted   
)

Definition at line 382 of file ah_errors_message_test.cc.

References ah_logic_error, EXPECT_THE_TEXT, and value.

◆ TEST() [11/14]

TEST ( ErrorMessage  ,
TakesTheItemsThatAStreamTakes   
)

Definition at line 307 of file ah_errors_message_test.cc.

References ah_domain_error, and EXPECT_THE_ITEMS.

◆ TEST() [12/14]

TEST ( ErrorMessage  ,
TakesTheManipulatorsOfAStream   
)

Definition at line 338 of file ah_errors_message_test.cc.

References ah_domain_error, and EXPECT_THE_ITEMS.

◆ TEST() [13/14]

TEST ( ErrorMessage  ,
TheStreamDiesWhenItsExceptionLeaves   
)

Definition at line 452 of file ah_errors_message_test.cc.

References ah_runtime_error, and ah_runtime_error_if.

◆ TEST() [14/14]

TEST ( ErrorMessage  ,
TheStreamOfAMessageTakesAPointerOfTheFrame   
)

Definition at line 428 of file ah_errors_message_test.cc.

References Aleph::message().