Associative-Container Regression Tests

Description

The library contains a single comprehensive regression test. For a given container type in pb_ds, the test creates an object of the container type and an object of the corresponding STL type (e.g., std::set). It then performs a random sequence of methods with random arguments (e.g., inserts, erases, and so forth) on both objects. At each operation, the test checks the return value of the method, and optionally both compares pb_ds's object with the STL's object as well as performing other consistency checks on pb_ds's object (e.g., order preservation, when applicable, or node invariants, when applicable).

Additionally, the test integrally checks exception safety and resource leaks. This is done as follows. A special allocator type, written for the purpose of the test, both randomly throws an exceptions when allocations are performed, and tracks allocations and de-allocations. The exceptions thrown at allocations simulate memory-allocation failures; the tracking mechanism checks for memory-related bugs (e.g., resource leaks and multiple de-allocations). Both pb_ds's containers and the containers' value-types are configured to use this allocator.

Due to compiler constraints, the test is split into the several sources, each checking only some containers.

Tests

"Set" Tests

The following check all "set" types:

  1. hash_no_data_map_rand.cc checks all hash-based "set" types.
  2. list_update_no_data_map_rand.cc checks all list-based "set" types.
  3. tree_no_data_map_rand.cc checks all tree-based "set" types.
  4. trie_no_data_map_rand.cc checks all PATRICIA-trie-based "set" types.

"Map" Tests

The following check all "map" types:

  1. hash_data_map_rand.cc checks all hash-based "map" types.
  2. list_update_data_map_rand.cc checks all list-based "map" types.
  3. tree_data_map_rand.cc checks all tree-based "map" types.
  4. trie_data_map_rand.cc checks all PATRICIA-trie-based "map" types.