示例#1
0
        public void CompareToEqual()
        {
            var v1 = new Fingerprint("AA");
            var v2 = new Fingerprint("AA");

            Assert.Equal(0, v1.CompareTo(v2));
        }
示例#2
0
        public void CompareToGreaterThan()
        {
            var v1 = new Fingerprint("AB");
            var v2 = new Fingerprint("AA");

            Assert.Equal(1, v1.CompareTo(v2));
        }
示例#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.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);
        }
示例#4
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);
        }