public static unsafe void GetAsciiSpanFromSByteReferenceTest() { Assert.That(() => MarshalUtilities.GetAsciiSpan(UnsafeUtilities.NullRef <sbyte>(), -1).ToArray(), Is.EqualTo(Array.Empty <sbyte>()) ); var source = new sbyte[] { (sbyte)'A', (sbyte)'B', (sbyte)'C' }; Assert.That(() => MarshalUtilities.GetAsciiSpan(in source[0], -1).ToArray(), Is.EqualTo(new sbyte[] { (sbyte)'A', (sbyte)'B', (sbyte)'C' }) ); Assert.That(() => MarshalUtilities.GetAsciiSpan(in source[0], 2).ToArray(), Is.EqualTo(new sbyte[] { (sbyte)'A', (sbyte)'B' }) ); }
public static unsafe void GetUtf16SpanFromSByteReferenceTest() { Assert.That(() => MarshalUtilities.GetUtf16Span(UnsafeUtilities.NullRef <ushort>(), -1).ToArray(), Is.EqualTo(Array.Empty <ushort>()) ); var source = new ushort[] { 'A', 'B', 'C' }; Assert.That(() => MarshalUtilities.GetUtf16Span(in source[0], -1).ToArray(), Is.EqualTo(new ushort[] { 'A', 'B', 'C' }) ); Assert.That(() => MarshalUtilities.GetUtf16Span(in source[0], 2).ToArray(), Is.EqualTo(new ushort[] { 'A', 'B' }) ); }