Esempio n. 1
0
        public void NonNullable()
        {
            var seedSource = new StepRng(0);
            var rngFactory = new StepRng.Factory(increment: 0);

            Assert.Throws <ArgumentNullException>(() => RngSeeder.Create <StepRng, StepRng, UInt64>(rngFactory, null !));
            Assert.Throws <ArgumentNullException>(() => RngSeeder.Create <StepRng, StepRng, UInt64>(null !, seedSource));
            Assert.Throws <ArgumentNullException>(() => RngSeeder.Create <StepRng, StepRng, UInt64>(null !, null !));
            Assert.Throws <ArgumentNullException>(() => RngSeeder.Create <StepRng, StepRng>(null !));
        }
Esempio n. 2
0
        public void Shuffle()
        {
            var list = new List <Int32> {
                1, 2, 3, 4, 5, 6, 7
            };
            var rng = new StepRng(0)
            {
                Increment = 0
            };

            rng.ShuffleInPlace(list);
            Assert.Equal(new[] { 2, 3, 4, 5, 6, 7, 1 }, list);

            Assert.Throws <ArgumentNullException>(() => rng.ShuffleInPlace <StepRng, Int32>(null !));
        }
Esempio n. 3
0
        public void SequentialSeedStaticRng()
        {
            var seedSource = new StepRng(0);
            var rngFactory = new StepRng.Factory(increment: 0);

            using var rngSeeder = RngSeeder.Create(rngFactory, seedSource);

            for (UInt64 i = 0; i < 10; i++)
            {
                var rng = rngSeeder.Create();
                Assert.Equal(i, rng.NextUInt64());
                Assert.Equal(i, rng.NextUInt64());
                Assert.Equal(i, rng.NextUInt64());
                Assert.Equal(i, rng.NextUInt64());
            }
        }