示例#1
0
        public void ArbitraryValue()
        {
            var value    = BitsetHelpers.ToValue("-------- -------- *****--* -------- -------- -------* -------- --------");
            var expected = 0b00000000_00000000_11111001_00000000_00000000_00000001_00000000_00000000L;

            Assert.AreEqual(expected, value);
        }
示例#2
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);
        }
        public void Or_With_Right_Enclosing_Value()
        {
            var ____left = BitsetHelpers.ToValues(0, "-------**************-------");
            var ___right = BitsetHelpers.ToValues(0, "****************************");
            var __result = BitsetHelpers.ToValues(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_End_Synchronized_Right_Advanced_Overlapping_Value_With_Trailing_Values()
        {
            var ____left = BitsetHelpers.ToValues(0, "*****************************----***----**-");
            var ___right = BitsetHelpers.ToValues(0, "--------------***************--------------");
            var __result = BitsetHelpers.ToValues(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 And_With_Empty_Matching_Values()
        {
            var ____left = BitsetHelpers.ToValues(0, "----------------------------");
            var ___right = BitsetHelpers.ToValues(0, "----------------------------");
            var __result = BitsetHelpers.ToValues(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 And_With_Start_Synchronized_Left_Advanced_Ending_Overlapping_Value()
        {
            var ____left = BitsetHelpers.ToValues(0, "***************--------------");
            var ___right = BitsetHelpers.ToValues(0, "*********************--------");
            var __result = BitsetHelpers.ToValues(0, "***************--------------");


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

            CollectionAssert.AreEqual(actual, expected);
        }
示例#8
0
        public void And_With_Right_Advanced_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.And(rightBitset).GetValues();
            var expected    = __result.ToOptimizedBitset().GetValues();

            CollectionAssert.AreEqual(actual, expected);
        }
        public void Or_With_Left_Full_Right_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_Non_Overlapping_Runs_Returns_Empty()
        {
            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 AndNot_With_Left_Empty_Right_Full_Matching_Values()
        {
            var ____left = BitsetHelpers.ToValues(0, "----------------------------");
            var ___right = BitsetHelpers.ToValues(0, "****************************");
            var __result = BitsetHelpers.ToValues(0, "----------------------------");
            var ____full = BitsetHelpers.ToValues(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);
        }
示例#12
0
        public void AndNot_With_End_Synchronized_Left_Advanced_Overlapping_Run_With_Trailing_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);
        }
示例#13
0
        public void AndNot_With_Alternate_Bridging_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);
        }
示例#14
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);
        }
示例#15
0
        public void MaxValue()
        {
            var value = BitsetHelpers.ToValue("******** ******** ******** ******** ******** ******** ******** ********");

            Assert.AreEqual(ulong.MaxValue, value);
        }
示例#16
0
        public void Value()
        {
            var value = BitsetHelpers.ToValue("-------- -------- -------- -------- -------- -------- -------- --------");

            Assert.AreEqual(0, value);
        }