Esempio n. 1
0
        public void TestAccessors()
        {
            var fp = new Fingerprint(33);

            Assert.Throws(typeof(IndexOutOfRangeException),
                () => { fp.Get(-1); });
            Assert.Throws(typeof(IndexOutOfRangeException),
                () => { fp.Get(33); });

            Assert.False(fp.Get(31));
            fp.Touch(31);
            Assert.True(fp.Get(31));
            fp.Wipe(31);
            Assert.False(fp.Get(31));

            Assert.False(fp.Get(32));
            fp.Touch(32);
            Assert.True(fp.Get(32));
            fp.Wipe(32);
            Assert.False(fp.Get(32));
        }
Esempio n. 2
0
        public void TestAccessors()
        {
            var fp = new Fingerprint(33);

            Assert.Throws(typeof(IndexOutOfRangeException),
                          () => { fp.Get(-1); });
            Assert.Throws(typeof(IndexOutOfRangeException),
                          () => { fp.Get(33); });

            Assert.False(fp.Get(31));
            fp.Touch(31);
            Assert.True(fp.Get(31));
            fp.Wipe(31);
            Assert.False(fp.Get(31));

            Assert.False(fp.Get(32));
            fp.Touch(32);
            Assert.True(fp.Get(32));
            fp.Wipe(32);
            Assert.False(fp.Get(32));
        }
Esempio n. 3
0
        public void TestComparison()
        {
            Fingerprint fp1 = new Fingerprint(65);
            Fingerprint fp2 = new Fingerprint(65);
            Fingerprint fp3 = new Fingerprint(64);
            Fingerprint fp4 = new Fingerprint(66);

            // Length first

            Assert.True(fp3.CompareTo(fp1) < 0);
            Assert.True(fp1.CompareTo(fp3) > 0);
            fp3.Touch(2);
            Assert.True(fp3.CompareTo(fp1) < 0);
            Assert.True(fp1.CompareTo(fp3) > 0);

            Assert.True(fp4.CompareTo(fp2) > 0);
            Assert.True(fp2.CompareTo(fp4) < 0);
            fp2.Touch(64);
            Assert.True(fp4.CompareTo(fp2) > 0);
            Assert.True(fp2.CompareTo(fp4) < 0);
            fp2.Wipe(64);

            // Bits second
            Assert.Equal(0, fp1.CompareTo(fp2));

            fp1.Touch(31);
            Assert.True(fp1.CompareTo(fp2) > 0);
            Assert.True(fp2.CompareTo(fp1) < 0);

            fp2.Touch(32);
            Assert.True(fp1.CompareTo(fp2) < 0);
            Assert.True(fp2.CompareTo(fp1) > 0);

            fp1.Touch(32);
            Assert.True(fp1.CompareTo(fp2) > 0);
            Assert.True(fp2.CompareTo(fp1) < 0);

            fp2.Touch(31);
            Assert.Equal(0, fp1.CompareTo(fp2));
            Assert.Equal(0, fp2.CompareTo(fp1));

            fp2.Touch(64);
            Assert.True(fp1.CompareTo(fp2) < 0);
            Assert.True(fp2.CompareTo(fp1) > 0);
        }
Esempio n. 4
0
        public void TestCapoing()
        {
            var fp = new Fingerprint(8);
            fp.Touch(2);
            fp.Touch(4);

            var window = new Capo<bool>(fp, 3);
            Assert.False(window[0]);
            Assert.True(window[1]);
            Assert.False(window[2]);

            fp.Wipe(4);
            Assert.False(window[1]);

            // Out-of-range indexing never throws
            Assert.False(window[-8]);
            Assert.False(window[8]);
        }
Esempio n. 5
0
        public void TestCapoing()
        {
            var fp = new Fingerprint(8);
            fp.Touch(2);
            fp.Touch(4);

            // Capo just displaces Fingerprint index with a provided offset.

            var window = new Capo<bool>(fp, 3);
            Assert.False(window[0]);
            Assert.True(window[1]);
            Assert.False(window[2]);

            fp.Wipe(4);
            Assert.False(window[1]);

            // Out-of-range indexing never throws
            Assert.False(window[-8]);
            Assert.False(window[8]);
        }
Esempio n. 6
0
        public void TestCapoing()
        {
            var fp = new Fingerprint(8);

            fp.Touch(2);
            fp.Touch(4);

            // Capo just displaces Fingerprint index with a provided offset.

            var window = new Capo <bool>(fp, 3);

            Assert.False(window[0]);
            Assert.True(window[1]);
            Assert.False(window[2]);

            fp.Wipe(4);
            Assert.False(window[1]);

            // Out-of-range indexing never throws
            Assert.False(window[-8]);
            Assert.False(window[8]);
        }
Esempio n. 7
0
        public void TestComparison()
        {
            Fingerprint fp1 = new Fingerprint(65);
            Fingerprint fp2 = new Fingerprint(65);
            Fingerprint fp3 = new Fingerprint(64);
            Fingerprint fp4 = new Fingerprint(66);

            // Length first

            Assert.Less(fp3.CompareTo(fp1), 0);
            Assert.Greater(fp1.CompareTo(fp3), 0);
            fp3.Touch(2);
            Assert.Less(fp3.CompareTo(fp1), 0);
            Assert.Greater(fp1.CompareTo(fp3), 0);

            Assert.Greater(fp4.CompareTo(fp2), 0);
            Assert.Less(fp2.CompareTo(fp4), 0);
            fp2.Touch(64);
            Assert.Greater(fp4.CompareTo(fp2), 0);
            Assert.Less(fp2.CompareTo(fp4), 0);
            fp2.Wipe(64);

            // Bits second
            Assert.AreEqual(0, fp1.CompareTo(fp2));

            fp1.Touch(31);
            Assert.Greater(fp1.CompareTo(fp2), 0);
            Assert.Less(fp2.CompareTo(fp1), 0);

            fp2.Touch(32);
            Assert.Less(fp1.CompareTo(fp2), 0);
            Assert.Greater(fp2.CompareTo(fp1), 0);

            fp1.Touch(32);
            Assert.Greater(fp1.CompareTo(fp2), 0);
            Assert.Less(fp2.CompareTo(fp1), 0);

            fp2.Touch(31);
            Assert.AreEqual(0, fp1.CompareTo(fp2));
            Assert.AreEqual(0, fp2.CompareTo(fp1));

            fp2.Touch(64);
            Assert.Less(fp1.CompareTo(fp2), 0);
            Assert.Greater(fp2.CompareTo(fp1), 0);
        }