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

The exception contracts of the moves and the swaps of the classes that keep a type of the user. More...

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <limits>
#include <mutex>
#include <optional>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <gtest/gtest.h>
#include <ah-errors.H>
#include <Floyd_Warshall.H>
#include <HLD.H>
#include <LCA.H>
#include <Tree_DP.H>
#include <Tree_Decomposition.H>
#include <thread_pool.H>
#include <tpl_b_tree.H>
#include <tpl_bplus_tree.H>
#include <tpl_ca_async_engine.H>
#include <tpl_ca_engine.H>
#include <tpl_ca_graph_automaton.H>
#include <tpl_ca_lattice.H>
#include <tpl_ca_multi_field_engine.H>
#include <tpl_ca_multi_field_lattice.H>
#include <tpl_ca_multi_field_rule.H>
#include <tpl_ca_neighborhood.H>
#include <tpl_ca_parallel_engine.H>
#include <tpl_ca_rule.H>
#include <tpl_ca_storage.H>
#include <tpl_cartesian_tree.H>
#include <tpl_disjoint_sparse_table.H>
#include <tpl_dynArrayHeap.H>
#include <tpl_dynMapTree.H>
#include <tpl_dynSkipList.H>
#include <tpl_fenwick_tree.H>
#include <tpl_graph.H>
#include <tpl_mo_on_trees.H>
#include <tpl_persistent_hash_map.H>
#include <tpl_rand_tree.H>
#include <tpl_segment_tree.H>
#include <tpl_sparse_table.H>
#include <tpl_tree_node.H>
Include dependency graph for noexcept_contract_test.cc:

Go to the source code of this file.

Classes

class  Noexcept_Contract< T >
 
class  Noexcept_Contract_Rollback< T >
 
struct  std::numeric_limits< Number >
 

Functions

 TYPED_TEST_SUITE (Noexcept_Contract, Classes, Contract_Name)
 
 TYPED_TEST (Noexcept_Contract, MoveConstructor)
 
 TYPED_TEST (Noexcept_Contract, MoveAssignment)
 
 TYPED_TEST (Noexcept_Contract, Swap)
 
 TYPED_TEST_SUITE (Noexcept_Contract_Rollback, Rollback_Classes, Contract_Name)
 
 TYPED_TEST (Noexcept_Contract_Rollback, Swap)
 
 TYPED_TEST (Noexcept_Contract_Rollback, MoveAssignment)
 
 TYPED_TEST (Noexcept_Contract_Rollback, SwapThatThrowsTwice)
 
 TYPED_TEST (Noexcept_Contract_Rollback, MoveAssignmentThatThrowsTwice)
 
 TEST (Noexcept_Contract_Engines, RuleThatOwnsAResource)
 
 TEST (Noexcept_Contract_Skip_List, MoveConstructorWhenTheComparisonAssignmentThrows)
 
 TEST (Noexcept_Contract_Floyd, InfinityWhoseCopyThrows)
 
 TEST (Noexcept_Contract_Dyn_Set, MovesOverARandTreeWhoseComparisonSwapThrows)
 
 TEST (Noexcept_Contract_Dyn_Set, MovesOverARankedSplayTreeWhoseComparisonSwapThrows)
 

Detailed Description

The exception contracts of the moves and the swaps of the classes that keep a type of the user.

A class that keeps a comparison, an operation, a policy or a filter of the user declares its move constructor, its move assignment and its swap() noexcept, or not, from what the type of the user does. A swap() whose specification asks std::is_nothrow_swappable_v, which evaluates the swap that the arguments find, but that calls std::swap(), which moves through a temporary, declares noexcept a move that may throw; a move that throws inside a noexcept function ends the program.

Each class is instantiated with adversarial types of the user, built on the type that it takes by default, of five kinds: a noexcept swap of its own and moves that throw, a move assignment that throws, a copy that throws, a swap of its own that throws, and a move constructor that throws with no swap of its own. The operations of those types that may throw count their calls, and throw while a test arms them. For each special member the test checks that it declares noexcept exactly when it runs none of them (a move constructor may also allocate), and then, armed, that it either completes or throws their exception and leaves both objects usable; a swap or a move assignment that throws must leave both objects as they were.

A swap exchanges the members of the types of the user before the storage, and, if one of them throws, those before it back: the classes with two or more types of the user are instantiated with all of them of the fourth kind, and their swaps throw at each of them in turn. The engines are also instantiated with lattices whose swap throws, which go in the same sequence. When a swap that puts one back throws too, the objects may be neither as they were nor exchanged, but they can be destroyed and assigned: the swaps also throw at each pair of them.

A class is one more line in Contract_Classes, with a case: the class with its types of the user made by A, an object of about n items, and what an ordinary user does with one.

Definition in file noexcept_contract_test.cc.

Function Documentation

◆ TEST() [1/5]

TEST ( Noexcept_Contract_Dyn_Set  ,
MovesOverARandTreeWhoseComparisonSwapThrows   
)

Definition at line 1996 of file noexcept_contract_test.cc.

◆ TEST() [2/5]

TEST ( Noexcept_Contract_Dyn_Set  ,
MovesOverARankedSplayTreeWhoseComparisonSwapThrows   
)

Definition at line 2001 of file noexcept_contract_test.cc.

◆ TEST() [3/5]

TEST ( Noexcept_Contract_Engines  ,
RuleThatOwnsAResource   
)

Definition at line 1847 of file noexcept_contract_test.cc.

◆ TEST() [4/5]

TEST ( Noexcept_Contract_Floyd  ,
InfinityWhoseCopyThrows   
)

Definition at line 1916 of file noexcept_contract_test.cc.

◆ TEST() [5/5]

TEST ( Noexcept_Contract_Skip_List  ,
MoveConstructorWhenTheComparisonAssignmentThrows   
)

Definition at line 1860 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [1/7]

TYPED_TEST ( Noexcept_Contract  ,
MoveAssignment   
)

Definition at line 1589 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [2/7]

TYPED_TEST ( Noexcept_Contract  ,
MoveConstructor   
)

Definition at line 1573 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [3/7]

TYPED_TEST ( Noexcept_Contract  ,
Swap   
)

Definition at line 1617 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [4/7]

TYPED_TEST ( Noexcept_Contract_Rollback  ,
MoveAssignment   
)

Definition at line 1757 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [5/7]

TYPED_TEST ( Noexcept_Contract_Rollback  ,
MoveAssignmentThatThrowsTwice   
)

Definition at line 1771 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [6/7]

TYPED_TEST ( Noexcept_Contract_Rollback  ,
Swap   
)

Definition at line 1750 of file noexcept_contract_test.cc.

◆ TYPED_TEST() [7/7]

TYPED_TEST ( Noexcept_Contract_Rollback  ,
SwapThatThrowsTwice   
)

Definition at line 1764 of file noexcept_contract_test.cc.

◆ TYPED_TEST_SUITE() [1/2]

TYPED_TEST_SUITE ( Noexcept_Contract  ,
Classes  ,
Contract_Name   
)

◆ TYPED_TEST_SUITE() [2/2]

TYPED_TEST_SUITE ( Noexcept_Contract_Rollback  ,
Rollback_Classes  ,
Contract_Name   
)