Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to TestTrim() method for changes made to coreclr Trim* family #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/NuGet.config
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- NOTE: Leave this file here and keep it in sync with list in dir.props. -->
<!-- The command-line doesn't need it, but the IDE does. -->
<config>
<add key="repositoryPath" value="..\packages" />
</config>
<packageSources>
<clear/>
<add key="myget.org dotnet-core" value="https://www.myget.org/F/dotnet-core/" />
<add key="myget.org dotnet-coreclr" value="https://www.myget.org/F/dotnet-coreclr/" />
<add key="myget.org dotnet-corefxtestdata" value="https://www.myget.org/F/dotnet-corefxtestdata/" />
<add key="myget.org dotnet-buildtools" value="https://www.myget.org/F/dotnet-buildtools/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<config>
<add key="repositoryPath" value="..\packages" />
</config>
</configuration>
5 changes: 5 additions & 0 deletions src/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,11 @@ public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, in
public string ToUpper() { return default(string); }
public string ToUpperInvariant() { return default(string); }
public string Trim() { return default(string); }
public string TrimStart() { return default(string); }
public string TrimEnd() { return default(string); }
public string Trim(char trimChars) { return default(string); }
public string TrimStart(char trimChars) { return default(string); }
public string TrimEnd(char trimChars) { return default(string); }
public string Trim(params char[] trimChars) { return default(string); }
public string TrimEnd(params char[] trimChars) { return default(string); }
public string TrimStart(params char[] trimChars) { return default(string); }
Expand Down
5 changes: 5 additions & 0 deletions src/System.Runtime/tests/System.Runtime.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
</ItemGroup>
<ItemGroup>
<!-- Compile tests against the System.Runtime contract, but copy our local-built implementation for testing -->
<ProjectReference Include="..\ref\System.Runtime.csproj">
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<OutputItemType>None</OutputItemType>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</ProjectReference>
<ProjectReference Include="..\src\System.Runtime.CoreCLR.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>Content</OutputItemType>
Expand Down
51 changes: 51 additions & 0 deletions src/System.Runtime/tests/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,17 +1519,68 @@ public static void TestTrim()
s = ". Foo .".Trim('.');
Assert.Equal(" Foo ", s);

s = "..Foo.".Trim('.');
Assert.Equal("Foo", s);

s = ".Foo .".Trim('.');
Assert.Equal("Foo ", s);

s = " Foo ".TrimStart();
Assert.Equal("Foo ", s);

s = ". Foo .".TrimStart('.');
Assert.Equal(" Foo .", s);

s = "..Foo.".TrimStart('.');
Assert.Equal("Foo.", s);

s = ".Foo .".TrimStart('.');
Assert.Equal("Foo .", s);

s = " Foo ".TrimEnd();
Assert.Equal(" Foo", s);

s = ". Foo .".TrimEnd('.');
Assert.Equal(". Foo ", s);

s = "..Foo.".TrimEnd('.');
Assert.Equal("..Foo", s);

s = ".Foo .".TrimEnd('.');
Assert.Equal(".Foo ", s);

s = ". Foo .".Trim('.', 'F');
Assert.Equal(" Foo ", s);

s = ".Foo .".Trim('.', 'F');
Assert.Equal("oo ", s);

s = ".. FFoo .".TrimStart('.', 'F');
Assert.Equal(" FFoo .", s);

s = "..FFoo .".TrimStart('.', 'F');
Assert.Equal("oo .", s);

s = ".. FFoo ..".TrimEnd('.','o');
Assert.Equal(".. FFoo ", s);

s = ".. FFoo..".TrimEnd('.', 'o');
Assert.Equal(".. FF", s);

s = ".Foo .".Trim('.', 'F', 'x');
Assert.Equal("oo ", s);

s = ".. FFoo .".TrimStart('.', 'F', 'x');
Assert.Equal(" FFoo .", s);

s = ".. FFoo ..".TrimEnd('.', 'o', 'x');
Assert.Equal(".. FFoo ", s);

s = ".xFoo .".Trim('.', 'F', 'x');
Assert.Equal("oo ", s);

s = ".Fxoo .".Trim('.', 'F', 'x');
Assert.Equal("oo ", s);
}

[Fact]
Expand Down