Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Tests for new string.contains Api - #25448

Merged
Anipik merged 5 commits into
dotnet:masterfrom
Anipik:char
Nov 27, 2017
Merged

Anipik merged 5 commits into
dotnet:masterfrom
Anipik:char

Conversation

@Anipik

@Anipik Anipik commented Nov 22, 2017 •

Copy link
Copy Markdown

Fixes #25094
PR implementation link = dotnet/coreclr#15180

@Anipik
Anipik requested a review from danmoseley November 22, 2017 22:16
@danmoseley

Copy link
Copy Markdown

Please use a better title eg "Tests for new String.Contains API"
Also include a link to the PR for the implementation

@danmoseley

Copy link
Copy Markdown

Looks good but needs tests for the other 2 api

@Anipik Anipik changed the title Api for checking if string contains a char Tests for new string.contains Api Nov 22, 2017
public static void Contains(string s, char value, StringComparison comparisionType, bool expected)
{
Assert.Equal(expected, s.Contains(value, comparisionType));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are for new APIs and will fail to compile here when building against netstandard. They should be moved to StringTests.netcoreapp.cs.

public static string Concat(params string[] values) { throw null; }
public static string Concat<T>(System.Collections.Generic.IEnumerable<T> values) { throw null; }
public bool Contains(string value) { throw null; }
public bool Contains(char value) { throw null; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please sort : c comes before s.

@Anipik

Anipik commented Nov 24, 2017

Copy link
Copy Markdown
Author

@dotnet-bot test this please

@danmoseley danmoseley closed this Nov 25, 2017
@danmoseley danmoseley reopened this Nov 25, 2017
@danmoseley

Copy link
Copy Markdown

@Anipik the UWP builds is failing because the API is not ported into CoreRt. Please add the implementation in the CoreRt repo like you did in coreclr.

@Anipik

Anipik commented Nov 25, 2017

Copy link
Copy Markdown
Author

@danmoseley

Copy link
Copy Markdown

Ah..its shared, you're right. The issue then is it needs to mirror again into the project N branch which might take a few days. You can just sit on this PR and wait for that.

@Anipik

Anipik commented Nov 27, 2017

Copy link
Copy Markdown
Author

@dotnet-bot test this please

@Anipik
Anipik merged commit cba0e2b into dotnet:master Nov 27, 2017
public override int GetHashCode() { throw null; }
public int GetHashCode(System.StringComparison comparisonType) { throw null; }
public int IndexOf(char value) { throw null; }
public int IndexOf(char value, StringComparison comparisonType) { throw null; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests for this new IndexOf overload?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed them. Can you point me to them?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/System.Runtime/tests/System/StringTests.netcoreapp.cs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m sorry I can’t seem to find them. I must be missing something. Can you provide a direct link? I see the new Contains tests you added, but no tests for the new IndexOf overload.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Anipik, that's a test of Contains, not IndexOf. @eerhardt is asking about the new IndexOf overload, for which no new tests were added.

@Anipik Anipik Nov 28, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry you are right. I am not testing indexof. I will add tests

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephentoub should they be added to stringtests.cs or stringtests.netcoreapp.cs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should they be added to stringtests.cs or stringtests.netcoreapp.cs?

They won't compile if they're added to StringTests.cs. They should be added to StringTests.netcoreapp.cs.

@danmoseley

Copy link
Copy Markdown

@Anipik as a general rule please wait for at least one "green checkmark" signoff before merging. (My "Looks good but needs tests for the other 2 api" may have been confusing)

@karelz karelz added this to the 2.1.0 milestone Dec 4, 2017
@Anipik
Anipik deleted the char branch December 19, 2017 01:17
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Changes

* Tests updated

* string comparision overload added

* Moved to stringtestsnetcoreapp

* sorted alphabetically in ref file


Commit migrated from dotnet/corefx@cba0e2b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants