public void GiveTakeMergeExceptInvertIntersectRangeRandomTest()
        {
            var random = new Random();
            var set    = new HashSet <uint>();
            IUniqueIdentificationSet uidSet = new UniqueIdentificationSet(false);

            for (var it = 0; it < 20000; it++)
            {
                var low  = (uint)(random.NextDouble() * (long)100000);
                var high = low + (uint)(random.NextDouble() * (long)100);

                if (random.Next() % 2 == 0)
                {
                    for (var val = low; val <= high; val++)
                    {
                        AssertEquals(set.Add(val), !uidSet.Contains(val));
                    }
                    if (random.Next() % 2 == 0)
                    {
                        uidSet.GiveRange(low, high);
                    }
                    else
                    {
                        uidSet = uidSet.Merge(new UniqueIdentificationSet(low, high).Invert().Invert());
                    }
                    for (var val = low; val <= high; val++)
                    {
                        AssertTrue(uidSet.Contains(val));
                    }
                }
                else
                {
                    for (var val = low; val <= high; val++)
                    {
                        AssertEquals(set.Remove(val), uidSet.Contains(val));
                    }
                    var rand = random.Next() % 3;
                    if (rand == 0)
                    {
                        uidSet.TakeRange(low, high);
                    }
                    else if (rand == 1)
                    {
                        uidSet = uidSet.Except(new UniqueIdentificationSet(low, high).Invert().Invert());
                    }
                    else
                    {
                        uidSet = uidSet.Intersect(new UniqueIdentificationSet(low, high).Invert());
                    }
                    for (var val = low; val <= high; val++)
                    {
                        AssertFalse(uidSet.Contains(val));
                    }
                }
            }
        }
        public void ContainsTest()
        {
            IUniqueIdentificationSet uidSet = new UniqueIdentificationSet(1, 4);

            uidSet.GiveRange(6, 15);
            uidSet.TakeRange(10, 11);

            AssertFalse(uidSet.Contains(0));
            AssertTrue(uidSet.Contains(1));
            AssertTrue(uidSet.Contains(2));
            AssertTrue(uidSet.Contains(3));
            AssertTrue(uidSet.Contains(4));
            AssertFalse(uidSet.Contains(5));
            AssertTrue(uidSet.Contains(6));
            AssertTrue(uidSet.Contains(7));
            AssertTrue(uidSet.Contains(8));
            AssertTrue(uidSet.Contains(9));
            AssertFalse(uidSet.Contains(10));
            AssertFalse(uidSet.Contains(11));
            AssertTrue(uidSet.Contains(12));
            AssertTrue(uidSet.Contains(13));
            AssertTrue(uidSet.Contains(14));
            AssertTrue(uidSet.Contains(15));
            AssertFalse(uidSet.Contains(16));

            AssertTrue(new UniqueIdentificationSet(0, 4).Contains(0));
        }
      public void ContainsTest() {
         IUniqueIdentificationSet uidSet = new UniqueIdentificationSet(1, 4);
         uidSet.GiveRange(6, 15);
         uidSet.TakeRange(10, 11);

         AssertFalse(uidSet.Contains(0));
         AssertTrue(uidSet.Contains(1));
         AssertTrue(uidSet.Contains(2));
         AssertTrue(uidSet.Contains(3));
         AssertTrue(uidSet.Contains(4));
         AssertFalse(uidSet.Contains(5));
         AssertTrue(uidSet.Contains(6));
         AssertTrue(uidSet.Contains(7));
         AssertTrue(uidSet.Contains(8));
         AssertTrue(uidSet.Contains(9));
         AssertFalse(uidSet.Contains(10));
         AssertFalse(uidSet.Contains(11));
         AssertTrue(uidSet.Contains(12));
         AssertTrue(uidSet.Contains(13));
         AssertTrue(uidSet.Contains(14));
         AssertTrue(uidSet.Contains(15));
         AssertFalse(uidSet.Contains(16));

         AssertTrue(new UniqueIdentificationSet(0, 4).Contains(0));
      }
      public void GiveTakeMergeExceptInvertIntersectRangeRandomTest() {
         var random = new Random();
         var set = new HashSet<uint>();
         IUniqueIdentificationSet uidSet = new UniqueIdentificationSet(false);
         for (var it = 0; it < 20000; it++) {
            var low = (uint)(random.NextDouble() * (long)100000);
            var high = low + (uint)(random.NextDouble() * (long)100);

            if (random.Next() % 2 == 0) {
               for (var val = low; val <= high; val++) {
                  AssertEquals(set.Add(val), !uidSet.Contains(val));
               }
               if (random.Next() % 2 == 0) {
                  uidSet.GiveRange(low, high);
               } else {
                  uidSet = uidSet.Merge(new UniqueIdentificationSet(low, high).Invert().Invert());
               }
               for (var val = low; val <= high; val++) {
                  AssertTrue(uidSet.Contains(val));
               }
            } else {
               for (var val = low; val <= high; val++) {
                  AssertEquals(set.Remove(val), uidSet.Contains(val));
               }
               var rand = random.Next() % 3;
               if (rand == 0) {
                  uidSet.TakeRange(low, high);
               } else if (rand == 1) {
                  uidSet = uidSet.Except(new UniqueIdentificationSet(low, high).Invert().Invert());
               } else {
                  uidSet = uidSet.Intersect(new UniqueIdentificationSet(low, high).Invert());
               }
               for (var val = low; val <= high; val++) {
                  AssertFalse(uidSet.Contains(val));
               }
            }
         }
      }