Exemplo n.º 1
0
        public void TestSerialization()
        {
            var numWords = Int64BitSet.Bits2words(10);
            var expected = new long[numWords];

            for (int i = 0; i < numWords; i++)
            {
                expected[i] = i;
            }

            var set = new Int64BitSet(expected, 10);


            Assert.AreEqual(expected, set.bits);
            Assert.AreSame(expected, set.bits);
            Assert.AreEqual(numWords, set.numWords);
            Assert.AreEqual(10L, set.Length);

            var clone = Clone(set);

            Assert.AreEqual(expected, clone.bits);
            Assert.AreNotSame(expected, clone.bits);
            Assert.AreEqual(numWords, clone.numWords);
            Assert.AreEqual(10L, clone.Length);
        }
Exemplo n.º 2
0
        private Int64BitSet MakeLongFixedBitSet(int[] a, int numBits)
        {
            Int64BitSet bs;

            if (Random().NextBoolean())
            {
                int    bits2words = Int64BitSet.Bits2words(numBits);
                long[] words      = new long[bits2words + Random().Next(100)];
                for (int i = bits2words; i < words.Length; i++)
                {
                    words[i] = Random().NextLong();
                }
                bs = new Int64BitSet(words, numBits);
            }
            else
            {
                bs = new Int64BitSet(numBits);
            }
            foreach (int e in a)
            {
                bs.Set(e);
            }
            return(bs);
        }