Exemple #1
0
        public void SingleRun()
        {
            var runs = BitsetHelpers.ToRuns(0, "------------****------------", new Dictionary <char, ulong>()).ToList();

            Assert.AreEqual(1, runs.Count);
            var run = runs[0];

            Assert.AreEqual(12, run.Start);
            Assert.AreEqual(15, run.End);
            CollectionAssert.AreEqual(new ulong[] { ulong.MaxValue, ulong.MaxValue, ulong.MaxValue, ulong.MaxValue }, run.Values);
        }
        public void NotWithGapRuns()
        {
            var ____left = BitsetHelpers.ToRuns(0, "------------****------------");
            var ____full = BitsetHelpers.ToRuns(0, "********-*******************");
            var __result = BitsetHelpers.ToRuns(0, "********-***----************");

            var leftBitset = ____left.ToOptimizedBitset();
            var fullBitset = ____full.ToOptimizedBitset();
            var actual     = leftBitset.Not(fullBitset).GetValues();
            var expected   = __result.ToOptimizedBitset().GetValues();

            CollectionAssert.AreEqual(actual, expected);
        }
Exemple #3
0
        public void And_With_Right_Enclosing_Run()
        {
            var ____left = BitsetHelpers.ToRuns(0, "-------**************-------");
            var ___right = BitsetHelpers.ToRuns(0, "****************************");
            var __result = BitsetHelpers.ToRuns(0, "-------**************-------");


            var leftBitset  = ____left.ToOptimizedBitset();
            var rightBitset = ___right.ToOptimizedBitset();
            var actual      = leftBitset.And(rightBitset).GetValues();
            var expected    = __result.ToOptimizedBitset().GetValues();

            CollectionAssert.AreEqual(actual, expected);
        }
Exemple #4
0
        public void And_With_End_Synchronized_Right_Advanced_Overlapping_Run_With_Trailing_Runs()
        {
            var ____left = BitsetHelpers.ToRuns(0, "*****************************----***----**-");
            var ___right = BitsetHelpers.ToRuns(0, "--------------***************--------------");
            var __result = BitsetHelpers.ToRuns(0, "--------------***************--------------");


            var leftBitset  = ____left.ToOptimizedBitset();
            var rightBitset = ___right.ToOptimizedBitset();
            var actual      = leftBitset.And(rightBitset).GetValues();
            var expected    = __result.ToOptimizedBitset().GetValues();

            CollectionAssert.AreEqual(actual, expected);
        }
        public void Or_With_Empty_Matching_Runs()
        {
            var ____left = BitsetHelpers.ToRuns(0, "----------------------------");
            var ___right = BitsetHelpers.ToRuns(0, "----------------------------");
            var __result = BitsetHelpers.ToRuns(0, "----------------------------");


            var leftBitset  = ____left.ToOptimizedBitset();
            var rightBitset = ___right.ToOptimizedBitset();
            var actual      = leftBitset.Or(rightBitset).GetValues();
            var expected    = __result.ToOptimizedBitset().GetValues();

            CollectionAssert.AreEqual(actual, expected);
        }
        public void Or_With_Start_Synchronized_Left_Advanced_Ending_Overlapping_Run()
        {
            var ____left = BitsetHelpers.ToRuns(0, "***************--------------");
            var ___right = BitsetHelpers.ToRuns(0, "*********************--------");
            var __result = BitsetHelpers.ToRuns(0, "*********************--------");


            var leftBitset  = ____left.ToOptimizedBitset();
            var rightBitset = ___right.ToOptimizedBitset();
            var actual      = leftBitset.Or(rightBitset).GetValues();
            var expected    = __result.ToOptimizedBitset().GetValues();

            CollectionAssert.AreEqual(actual, expected);
        }
Exemple #7
0
        public void AndNot_With_Left_Full_Right_Empty_Matching_Runs()
        {
            var ____left = BitsetHelpers.ToRuns(0, "****************************");
            var ___right = BitsetHelpers.ToRuns(0, "----------------------------");
            var __result = BitsetHelpers.ToRuns(0, "****************************");
            var ____full = BitsetHelpers.ToRuns(0, "****************************");


            var leftBitset  = ____left.ToOptimizedBitset();
            var rightBitset = ___right.ToOptimizedBitset();
            var fullBitset  = ____full.ToOptimizedBitset();
            var actual      = leftBitset.AndNot(rightBitset, fullBitset).GetValues();
            var expected    = __result.ToOptimizedBitset().GetValues();


            CollectionAssert.AreEqual(actual, expected);
        }
Exemple #8
0
        public void MultipleRuns()
        {
            var runs = BitsetHelpers.ToRuns(0, "--***-----*****-****", new Dictionary <char, ulong>()).ToList();

            Assert.AreEqual(3, runs.Count);
            var run = runs[0];

            Assert.AreEqual(2, run.Start);
            Assert.AreEqual(4, run.End);
            CollectionAssert.AreEqual(new ulong[] { ulong.MaxValue, ulong.MaxValue, ulong.MaxValue }, run.Values);
            run = runs[1];
            Assert.AreEqual(10, run.Start);
            Assert.AreEqual(14, run.End);
            CollectionAssert.AreEqual(new ulong[] { ulong.MaxValue, ulong.MaxValue, ulong.MaxValue, ulong.MaxValue, ulong.MaxValue }, run.Values);
            run = runs[2];
            Assert.AreEqual(16, run.Start);
            Assert.AreEqual(19, run.End);
            CollectionAssert.AreEqual(new ulong[] { ulong.MaxValue, ulong.MaxValue, ulong.MaxValue, ulong.MaxValue }, run.Values);
        }