Beispiel #1
0
        public void NotDequeFromEmptyQueue()
        {
            var hasher = new PolynomialSequenceHasher(137);

            hasher.Enqueue("some_string");
            hasher.Dequeue();
            Assert.Throws <InvalidOperationException>(() => hasher.Dequeue());
        }
        public void TestWithPolynomBase(int polynomBase)
        {
            var hasher = new PolynomialSequenceHasher(polynomBase);

            hasher.Enqueue("first");
            Assert.AreEqual("first".GetHashCode(), hasher.GetCurrentHash());
            hasher.Enqueue("second");
            Assert.AreEqual(unchecked (polynomBase * "first".GetHashCode() + "second".GetHashCode()), hasher.GetCurrentHash());
            hasher.Dequeue();
            Assert.AreEqual("second".GetHashCode(), hasher.GetCurrentHash());
        }
Beispiel #3
0
        public void WorkWithPolynomBase1()
        {
            var hasher = new PolynomialSequenceHasher(1);

            hasher.Enqueue("first");
            Assert.AreEqual("first".GetHashCode(), hasher.GetCurrentHash());
            hasher.Enqueue("second");
            Assert.AreEqual("first".GetHashCode() + "second".GetHashCode(), hasher.GetCurrentHash());
            hasher.Dequeue();
            Assert.AreEqual("second".GetHashCode(), hasher.GetCurrentHash());
        }
        public void TestDequeue()
        {
            const int count  = 100;
            var       hasher = new PolynomialSequenceHasher(137);

            for (var i = 0; i < count; i++)
            {
                hasher.Enqueue("some_string");
            }
            for (var i = 0; i < count - 1; i++)
            {
                hasher.Dequeue();
            }
            Assert.AreEqual("some_string".GetHashCode(), hasher.GetCurrentHash());
        }