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

Phase 26 — property-based tests for the cellular-automata core. More...

#include <cstdint>
#include <random>
#include <gtest/gtest.h>
#include <ca-traits.H>
#include <tpl_ca_storage.H>
#include <tpl_ca_lattice.H>
#include <tpl_ca_neighborhood.H>
#include <tpl_ca_rule.H>
#include <tpl_ca_engine.H>
#include <tpl_ca_async_engine.H>
#include <tpl_ca_update_scheme.H>
#include <tpl_ca_block_rule.H>
Include dependency graph for ca_properties_test.cc:

Go to the source code of this file.

Functions

 TEST (CAProperties, BBMConservesParticleCountAcrossRandomGrids)
 
 TEST (CAProperties, TMGasConservesParticleCountAcrossRandomGrids)
 
 TEST (CAProperties, MargolusBBMIsReversibleAcrossRandomGrids)
 
 TEST (CAProperties, MargolusTMGasIsReversibleAcrossRandomGrids)
 
 TEST (CAProperties, MargolusCrittersIsReversibleAcrossRandomGrids)
 
 TEST (CAProperties, SynchronousEngineIsDeterministic)
 
 TEST (CAProperties, AtSafeIsWellDefinedForAnyCoordinate)
 

Detailed Description

Phase 26 — property-based tests for the cellular-automata core.

Unlike the case-designed GoogleTests, these checks generate many random initial grids and assert invariants that must hold for every input:

  • BBM_Rule and TM_Gas_Rule under Margolus_Update conserve the whole-lattice particle count for any initial grid.
  • Margolus_Update with an involutive block rule is reversible: forward(N) followed by backward(N) restores the initial state bit-for-bit, for any initial grid.
  • Synchronous_Engine is deterministic: the same initial state yields the same trajectory.
  • Lattice::at_safe(c) is well-defined for any (possibly far out-of-range or negative) coordinate: it never reads out of bounds (validated under ASan/UBSan in CI) and agrees with the boundary policy.

Each property sweeps a grid of {seed} x {side} random instances via the for_random_grids helper.

Definition in file ca_properties_test.cc.

Function Documentation

◆ TEST() [1/7]

TEST ( CAProperties  ,
AtSafeIsWellDefinedForAnyCoordinate   
)

Definition at line 263 of file ca_properties_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), k, r, rng, and seed.

◆ TEST() [2/7]

TEST ( CAProperties  ,
BBMConservesParticleCountAcrossRandomGrids   
)

Definition at line 143 of file ca_properties_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), and seed.

◆ TEST() [3/7]

TEST ( CAProperties  ,
MargolusBBMIsReversibleAcrossRandomGrids   
)

◆ TEST() [4/7]

TEST ( CAProperties  ,
MargolusCrittersIsReversibleAcrossRandomGrids   
)

◆ TEST() [5/7]

TEST ( CAProperties  ,
MargolusTMGasIsReversibleAcrossRandomGrids   
)

◆ TEST() [6/7]

◆ TEST() [7/7]

TEST ( CAProperties  ,
TMGasConservesParticleCountAcrossRandomGrids   
)

Definition at line 164 of file ca_properties_test.cc.

References Aleph::blossom_maximum_cardinality_matching(), and seed.