diff --git a/qsimcirq_tests/qsimcirq_test.py b/qsimcirq_tests/qsimcirq_test.py index 0b5cdbc8e..215407e8f 100644 --- a/qsimcirq_tests/qsimcirq_test.py +++ b/qsimcirq_tests/qsimcirq_test.py @@ -2196,3 +2196,21 @@ def test_1d_representation(): want = np.array([0.0 - 0.5j, 0.0 + 0.5j, 0.0 - 0.5j, 0.0 + 0.5j]) _, res, _ = qsim_sim.simulate_into_1d_array(c) np.testing.assert_allclose(res, np.array(want, dtype=np.complex64)) + + +def test_get_seed(): + # Test range. + qsim_sim = qsimcirq.QSimSimulator(seed=42) + for _ in range(100): + seed = qsim_sim.get_seed() + assert 0 <= seed < 2**31 - 1 + + # Test determinism. + sim1 = qsimcirq.QSimSimulator(seed=42) + sim2 = qsimcirq.QSimSimulator(seed=42) + assert sim1.get_seed() == sim2.get_seed() + + # Test subsequent calls. + sim = qsimcirq.QSimSimulator(seed=42) + seeds = {sim.get_seed() for _ in range(10)} + assert len(seeds) > 1