|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Every small multigraph, on every kind of graph, for the tests. More...
#include <algorithm>#include <array>#include <cstddef>#include <cstdlib>#include <iostream>#include <random>#include <sstream>#include <string>#include <type_traits>#include <utility>#include <vector>#include <gtest/gtest.h>#include <tpl_graph.H>#include <tpl_sgraph.H>#include <tpl_agraph.H>#include "graph_filter_catalog.H"Go to the source code of this file.
Classes | |
| struct | graph_harness::Spec |
| A small multigraph: its nodes are 0 . More... | |
| struct | graph_harness::Domain |
| Which multigraphs for_each_spec() gives. More... | |
| struct | graph_harness::Built< GT > |
| A graph made from a spec, with its nodes and arcs by number. More... | |
| class | graph_harness::Check |
| The failures of one property over a domain. More... | |
Namespaces | |
| namespace | graph_harness |
Macros | |
| #define | ALEPH_GRAPH_HARNESS_HAS_SMALL_STACK 0 |
| #define | ALEPH_GRAPH_HARNESS_SANITIZED 0 |
| #define | EXPECT_THROW_OR_FILTER(statement, type) |
| EXPECT_THROW(statement, type), for a statement that calls a filter: in a call of graph_harness::with_each_throw(), in which the filter throws at one of its calls, what the filter throws goes on, and type is taken if it comes first. | |
Enumerations | |
| enum class | graph_harness::Mode { graph_harness::light , graph_harness::normal , graph_harness::heavy } |
| The sizes of the domains. More... | |
Functions | |
| Mode | graph_harness::mode () |
| ALEPH_GRAPH_HARNESS=light, normal or heavy, or else light in a build with a sanitizer and normal without one. | |
| bool | graph_harness::heavy () |
| Whether the mode is heavy, which asks for the larger domains. | |
| Domain | graph_harness::domain (int max_nodes, int max_arcs) |
| The domain of max_nodes nodes and max_arcs arcs, of one more of each in heavy mode, and of one arc less in light mode. | |
| unsigned | graph_harness::seed (unsigned seed) |
| The seed of the random tests: ALEPH_GRAPH_HARNESS_SEED, or seed. | |
| size_t | graph_harness::failures_shown () |
| How many failures a check prints: ALEPH_GRAPH_HARNESS_SHOW, or 8. | |
| template<class F > | |
| size_t | graph_harness::for_each_spec (const Domain &d, bool directed, F &&f) |
| Calls f(spec) with every spec of d, smallest first, and returns how many there were. | |
| template<class F > | |
| size_t | graph_harness::for_each_simple_graph (int min_nodes, int max_nodes, bool directed, F &&f) |
| Calls f(spec) with every simple graph of n nodes, for n from min_nodes to max_nodes: each set of pairs of distinct nodes, or of ordered pairs in a digraph, as arcs from the smaller node unless directed. | |
| Spec | graph_harness::random_spec (std::mt19937 &rng, int n, int m, bool directed, bool loops=true, bool parallel=true) |
| A random spec of n nodes and m arcs, with loops and parallel arcs if asked; parallel is ignored when m exceeds the number of places. | |
| void | graph_harness::random_weights (std::mt19937 &rng, Spec &s, long long lo, long long hi) |
| Gives each arc of s a weight from lo to hi. | |
| template<class Node > | |
| int | graph_harness::num (Node *p) |
| The number of a node of a built graph. | |
| template<class GT > | |
| GT::Node * | graph_harness::node_of (const GT &g, int i) |
| The node of a graph whose number is i. | |
| template<class F > | |
| bool | graph_harness::run_with_small_stack (F &&f, size_t kb=256) |
| Runs f in a thread whose stack has kb KiB, and returns false if the thread could not run; without POSIX threads, it runs f in this thread. | |
| template<class F , class Filt > | |
| void | graph_harness::with_each_throw (F &f, const Filt &filt, const char *name) |
| Calls f(filt, name), as the loop over the filters of a test does, and again for each call k of the filter in that first call, with the filter throwing graph_filters::Thrown_By_Filter at its call k: what it throws has to come out of f, through the algorithm that f calls, if f calls the filter that many times again. | |
Every small multigraph, on every kind of graph, for the tests.
A Spec describes a small multigraph by its number of nodes and the list of its arcs in the order in which they are inserted, each as the pair (source, target) given to insert_arc(). for_each_spec() calls a function with every Spec of a Domain: every labeled multigraph of up to max_nodes nodes and max_arcs arcs, with loops and parallel arcs if the domain allows them, with each arc inserted from either end (a graph that is not directed takes u-v and v-u for the same arc, but stores it from the end it was given) and with the arcs in two orders. The specs come smallest first, so the first one that fails a test is minimal.
build() makes a graph of any kind from a Spec. The info of each node is its number and that of each arc its number in the Spec, so that the tests compare by those numbers: the order of the nodes of List_SGraph, of Ady_Mat and of some results follows their addresses.
The type lists name the six kinds of graph for typed tests, and run_with_small_stack() runs a function in a thread with a small stack, where a search that recurses once per node overflows.
The environment variable ALEPH_GRAPH_HARNESS sets the size of the domains: heavy enlarges them, light takes one arc less, and normal is the size that a build without a sanitizer takes; with one, the harness runs many times slower, and takes light. ALEPH_GRAPH_HARNESS_SEED sets the seed of the random tests and ALEPH_GRAPH_HARNESS_SHOW how many failures each check prints (8).
Definition in file graph_harness.H.
| #define ALEPH_GRAPH_HARNESS_HAS_SMALL_STACK 0 |
Definition at line 89 of file graph_harness.H.
| #define ALEPH_GRAPH_HARNESS_SANITIZED 0 |
Definition at line 102 of file graph_harness.H.
| #define EXPECT_THROW_OR_FILTER | ( | statement, | |
| type | |||
| ) |
EXPECT_THROW(statement, type), for a statement that calls a filter: in a call of graph_harness::with_each_throw(), in which the filter throws at one of its calls, what the filter throws goes on, and type is taken if it comes first.
Definition at line 542 of file graph_harness.H.