public void TestUInt16() { UInt16 v1 = 0b1001_1001; UInt16 i1 = 0b0000_0010; UInt16 a1 = 0b1001_0001; v1.Pack(5, 2, i1); Assert.Equal(a1.ToBitStringPadded(), v1.ToBitStringPadded()); for (var i = 0; i < Iterations; i++) { var v = _rnd.NextUInt16(); var sv = _rnd.NextUInt16(); for (var offset = 1; offset < sizeof(UInt16) * 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); } } } }