Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f7fd6ec

Browse files
committed
Add Span Example in test proj
1 parent 25708ee commit f7fd6ec

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/ServiceStack.Text.Tests/ServiceStack.Text.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<PackageReference Include="NUnit" Version="3.9.0" />
2727
<PackageReference Include="protobuf-net" Version="2.3.2" />
2828
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
29+
<PackageReference Include="System.Memory" Version="4.4.0-preview1-25305-02" />
2930
</ItemGroup>
3031
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
3132
<DefineConstants>$(DefineConstants);NET45</DefineConstants>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using NUnit.Framework;
3+
4+
namespace ServiceStack.Text.Tests
5+
{
6+
public class SpanTests
7+
{
8+
[Test]
9+
public void Can_use_Span()
10+
{
11+
//.AsReadOnlySpan() not available in System.Memory v4.4.0-preview1-25305-02 on NuGet yet
12+
ReadOnlySpan<char> a = "foo bar".AsSpan();
13+
14+
var foo = a.Slice(0,3).ToArray();
15+
16+
Assert.That(foo, Is.EqualTo("foo".ToCharArray()));
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)