Exemplo n.º 1
0
        public void TestUInt64()
        {
            UInt64 v1 = 0b1001_1001;
            UInt64 i1 = 0b0000_0010;
            UInt64 a1 = 0b1001_0001;

            v1.Pack(5, 2, i1);
            Assert.Equal(a1.ToBitStringPadded(), v1.ToBitStringPadded());

            for (var i = 0; i < Iterations; i++)
            {
                var v  = _rnd.NextUInt64();
                var sv = _rnd.NextUInt64();
                for (var offset = 1; offset < sizeof(UInt64) * 8; offset++)
                {
                    for (var len = 1; len < offset; len++)
                    {
                        var ov = v;
                        v.Pack(offset, len, sv);

                        var ss = sv.ToBitStringPadded();
                        ss = ss.Substring(ss.Length - len, len);
                        var ovs = ov.ToBitStringPadded();
                        ovs = ovs.Substring(0, ovs.Length - offset)
                              + ss
                              + ovs.Substring(ovs.Length - offset + len);
                        Assert.Equal(v.ToBitStringPadded(), ovs);
                        //_outputHelper.WriteLine(ovs);
                    }
                }
            }
        }