-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Made char.IsAscii public #41396
Made char.IsAscii public #41396
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Assert.True(char.IsAscii(char.MinValue)); | ||
Assert.True(char.IsAscii('\x007f')); | ||
Assert.False(char.IsAscii('\x0080')); | ||
Assert.False(char.IsAscii(char.MaxValue)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this enough for testing, or should be use the "whole range" ala
public static IEnumerable<object[]> UnicodeInfoTestData_Latin1AndSelectOthers() |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole range. There is probably a similar test for Rune.IsAscii
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just scanned again through the repo, looking for IsAscii-tests. Haven't found one.
I've seen that all IsAscii implementations, like
public bool IsAscii => UnicodeUtility.IsAsciiCodePoint(_value); |
public static bool IsAsciiCodePoint(uint value) => value <= 0x7Fu; |
It's a trivial method (just one compare), but maybe it's better to delegate char.IsAscii
also to this method and add tests over there (as I didn't find some for IsAsciiCodePoint
-- maybe because it's defined in an internal type)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search the file https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime/tests/System/Text/RuneTests.cs for the substring "IsAscii"
. You'll see how we perform tests against the Rune
APIs.
Though to be honest those tests are basically just testing specific values like '\u0000'
, '\u007f'
, etc., as you had here. :)
I have no problem with you leaving the test as you have it here.
This needs to be also exposed in the /ref/ file where Char surface is defined. |
Ahhh, ref-assembly -- thanks for the hint / info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to update the ref asms! Send a ping once that's ready. Otherwise LGTM.
Assert.True(char.IsAscii(char.MinValue)); | ||
Assert.True(char.IsAscii('\x007f')); | ||
Assert.False(char.IsAscii('\x0080')); | ||
Assert.False(char.IsAscii(char.MaxValue)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search the file https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime/tests/System/Text/RuneTests.cs for the substring "IsAscii"
. You'll see how we perform tests against the Rune
APIs.
Though to be honest those tests are basically just testing specific values like '\u0000'
, '\u007f'
, etc., as you had here. :)
I have no problem with you leaving the test as you have it here.
@GrabYourPitchforks I pushed the commit with the ref-assembly update.
I left the test as they are. |
Fixes #40936
Also normalized parameters of other method to
c
(instead ofch
, only two others)./cc: @GrabYourPitchforks