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

[tests] Fix integer rounding error in GetTestFileName #52266

Merged
3 commits merged into from
May 5, 2021

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented May 4, 2021

Fixes #52257

There seemed to be an integer rounding error when getting a portion of the test file name. Using the suggestion #52257 (comment) led to the tests running to completion with no crashes or hangs.

@ghost
Copy link

ghost commented May 4, 2021

Tagging subscribers to this area: @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #52257

Author: mdh1418
Assignees: -
Labels:

area-System.IO

Milestone: -

@@ -102,7 +102,9 @@ protected string GetTestFileName(int? index = null, [CallerMemberName] string me
if (excessLength < memberName.Length + "...".Length)
{
// Take a chunk out of the middle as perhaps it's the least interesting part of the name
memberName = memberName.Substring(0, memberName.Length / 2 - excessLength / 2) + "..." + memberName.Substring(memberName.Length / 2 + excessLength / 2);
int halfMemberNameLength = (int)Math.Floor((double)memberName.Length / 2);
int halfExcessLength = (int)Math.Floor((double)excessLength / 2);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be Ceil not Floor, and then we don't need the +1 on the math.

@ghost
Copy link

ghost commented May 5, 2021

Hello @danmoseley!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 69ac4c5 into dotnet:main May 5, 2021
@runfoapp runfoapp bot mentioned this pull request May 5, 2021
@mdh1418 mdh1418 deleted the fix_integer_rounding_gettestfilename branch May 17, 2021 13:41
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants