Beispiel #1
0
 public void TestNext()
 {
     Assert.AreEqual(178258005L, generator.Next(5L));
     Assert.AreEqual(5651489766934405L, generator.Next(178258005L));
     Assert.AreEqual(-9127299601691290113L, generator.Next(5651489766934405L));
     Assert.AreEqual(146455018630021125L, generator.Next(-9127299601691290113L));
     Assert.AreEqual(2104002940825447L, generator.Next(146455018630021125L));
 }
Beispiel #2
0
        public void TestGenerate_Rotation()
        {
            var      m_atomGenerator = new Mock <IAtomHashGenerator>(); var atomGenerator = m_atomGenerator.Object;
            Xorshift xorshift = new Xorshift();
            var      m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            IMoleculeHashGenerator generator = new BasicMoleculeHashGenerator(atomGenerator, new Xorshift());

            m_atomGenerator.Setup(n => n.Generate(container)).Returns(new long[] { 5L, 5L, 5L, 5L });

            long hashCode = generator.Generate(container);

            m_atomGenerator.Verify(n => n.Generate(container), Times.Exactly(1));

            //VerifyNoMoreInteractions(atomGenerator, container);

            long expected = 2147483647L ^ 5L ^ xorshift.Next(5L) ^ xorshift.Next(xorshift.Next(5L))
                            ^ xorshift.Next(xorshift.Next(xorshift.Next(5L)));

            Assert.AreEqual(expected, hashCode);
        }
        public void TestCombine()
        {
            Xorshift prng = new Xorshift();
            PerturbedAtomHashGenerator generator = new PerturbedAtomHashGenerator(new SeedGenerator(
                                                                                      BasicAtomEncoder.AtomicNumber), new BasicAtomHashGenerator(new SeedGenerator(
                                                                                                                                                     BasicAtomEncoder.AtomicNumber), prng, 8), prng, StereoEncoderFactory.Empty,
                                                                                  new MinimumEquivalentCyclicSet(), AtomSuppression.Unsuppressed);

            long[][] perturbed = new long[][] { new long[] { 1, 2, 3, 4 }, new long[] { 1, 1, 1, 1 }, new long[] { 1, 2, 2, 4 }, new long[] { 2, 2, 2, 2 }, };

            long _0 = 1 ^ 2 ^ 3 ^ 4;
            long _1 = 1 ^ prng.Next(1) ^ prng.Next(prng.Next(1)) ^ prng.Next(prng.Next(prng.Next(1)));
            long _2 = 1 ^ 2 ^ prng.Next(2) ^ 4;
            long _3 = 2 ^ prng.Next(2) ^ prng.Next(prng.Next(2)) ^ prng.Next(prng.Next(prng.Next(2)));

            long[] values = generator.Combine(perturbed);
            Assert.IsTrue(Compares.AreDeepEqual(new long[] { _0, _1, _2, _3 }, values));
        }