// TODO: .ctor(char) // TODO: .ctor(Utf8EncodedCodePoint) public unsafe Utf16LittleEndianEncodedCodePoint(ByteSpan buffer) : this() { fixed (byte* encodedData = &_byte0) { if (buffer.Length == 1 || buffer.Length == 3) throw new ArgumentException("buffer"); if (!buffer.TryCopyTo(encodedData, 4)) throw new ArgumentException("buffer"); } }
public unsafe void SpanOfByteCopyToAnotherSpanOfByteTwoDifferentBuffersValidCases(byte[] expectedManaged, byte[] aManaged, int aidx, int acount, byte[] bManaged, int bidx, int bcount) { fixed (byte* expected = expectedManaged) fixed (byte* a = aManaged) fixed (byte* b = bManaged) { ByteSpan spanA = new ByteSpan(a + aidx, acount); ByteSpan spanB = new ByteSpan(b + bidx, bcount); if (expectedManaged != null) { Assert.True(spanA.TryCopyTo(spanB)); Assert.Equal(expectedManaged, bManaged); ByteSpan spanExpected = new ByteSpan(expected, expectedManaged.Length); ByteSpan spanBAll = new ByteSpan(b, bManaged.Length); Assert.Equal(spanExpected, spanBAll); } else { Assert.False(spanA.TryCopyTo(spanB)); } } }