Ejemplo n.º 1
0
        public void BadSeed()
        {
            var seed = (0u, 0u, 0u, 0u);
            var rng1 = XorShift.GetFactory().Create(seed);

            var num1 = rng1.NextUInt64();
            var num2 = rng1.NextUInt64();

            Assert.NotEqual(0ul, num1);
            Assert.NotEqual(num1, num2);
        }
Ejemplo n.º 2
0
        public void Construction()
        {
            var byteSeed = new Byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            var uintSeed = MemoryMarshal.Cast <Byte, UInt32>(byteSeed);
            var seed     = (uintSeed[0], uintSeed[1], uintSeed[2], uintSeed[3]);

            var rng1 = XorShift.GetFactory().Create(seed);

            Assert.Equal(4325440999699518727ul, rng1.NextUInt64());

            var rng2 = XorShift.GetFactory().Create(rng1);

            Assert.Equal(15614385950550801700ul, rng1.NextUInt64());
            Assert.Equal(15614385950550801700ul, rng2.NextUInt64());
        }
Ejemplo n.º 3
0
 public void NonNullable()
 {
     Assert.Throws <ArgumentNullException>(() => XorShift.GetFactory().CreateSeed <StepRng>(null));
 }