Exemplo n.º 1
0
        public unsafe void OneKLongAllBitsLit(GetNthBitOffsetDelegate variant)
        {
            var q = stackalloc ulong[16]
            {
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
                0xFFFFFFFFFFFFFFFF,
            };

            for (var i = 0; i < 1024; i++)
            {
                Assert.That(variant(q, 1024, i + 1), Is.EqualTo(i), $"i=={i}");
            }
        }
Exemplo n.º 2
0
        public unsafe void TwoKLongCheckered3(GetNthBitOffsetDelegate variant)
        {
            var q = stackalloc ulong[32]
            {
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
                0xF0F0F0F0F0F0F0F0, 0xF0F0F0F0F0F0F0F0,
            };

            for (var i = 0; i < 1024; i++)
            {
                var expected = ((i / 4 * 2) * 4) + 4 + (i % 4);
                Assert.That(variant(q, 2048, i + 1), Is.EqualTo(expected), $"i=={i}");
            }
        }
Exemplo n.º 3
0
        public unsafe void Upper32BitsLit(GetNthBitOffsetDelegate variant)
        {
            var q = 0xFFFFFFFF00000000UL;

            for (var i = 0; i < 32; i++)
            {
                Assert.That(variant(&q, 64, i + 1), Is.EqualTo(i + 32), $"i=={i}");
            }
        }
Exemplo n.º 4
0
        public unsafe void OneLongAllBitsLit(GetNthBitOffsetDelegate variant)
        {
            var q = 0xFFFFFFFFFFFFFFFFUL;

            for (var i = 0; i < 64; i++)
            {
                Assert.That(variant(&q, 64, i + 1), Is.EqualTo(i), $"i=={i}");
            }
        }
Exemplo n.º 5
0
        public unsafe void BitGapAtEnd(GetNthBitOffsetDelegate variant)
        {
            var q = stackalloc ulong[16]
            {
                0x0FFFFFFFFFFFFFFF,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0x0000000000000000,
                0xF000000000000000,
            };

            Assert.That(variant(q, 1024, 64), Is.EqualTo(1023));
        }