Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Tests should be aware of the Current Culture Info #34

Merged
merged 1 commit into from
Nov 13, 2014

Conversation

jbuiss0n
Copy link

Hello,

As i'm French, my CultureInfo.CurrentCulture is set to "fr-FR" while running tests.
But for some tests, especially for the ToString() methods, tests are write to check "en-US" Culture.

@gaearon
Copy link

gaearon commented Nov 12, 2014

Take a look at the diff, there seems to be a whitespace issue.

@jbuiss0n
Copy link
Author

Hell, yes it seems, i'm on it.

@FiveTimesTheFun
Copy link
Contributor

#35 #36 @mellinoe

@jbuiss0n
Copy link
Author

Looks better now, thanks !

@nguerrera
Copy link
Contributor

Thanks for this.

Please squash this in to a single commit so that there will be no spaces -> tabs -> spaces noise in the master history if we do merge it.

Vector2 v1 = new Vector2(2.0f, 3.0f);

string v1str = v1.ToString();
Assert.Equal("<2, 3>", v1str);
string expectedv1 = string.Format(CultureInfo.CurrentCulture, "<{0:G}" + separator + "{1:G}>", 2, 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you keep one of these using en-us culture? I think there's some value in at least testing with one explicit culture here. As is, both of these calls will use CultureInfo.CurrentCulture (no-params ToString calls with CultureInfo.CurrentCulture). Same applies to the other tests on the other types.

Copy link
Author

Choose a reason for hiding this comment

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

Yes sure, i have an argument with myself, "should i keep explicit culture or not...".

@mellinoe
Copy link
Contributor

Hey jbuiss0n, thanks for the PR. It looks good overall, but I made a few small notes before we can merge it in. Thanks for fixing the tabs, by the way!


string v2strformatted = v1.ToString("c");
Assert.Equal("<$2.50, $2.00, $3.00, $3.30>", v1strformatted);
string expectedv2formatted = string.Format(CultureInfo.CurrentCulture
, "<{0:c}" + separator + "{1:c}" + separator + "{2:c}" + separator + "{3:c}>"
Copy link
Contributor

Choose a reason for hiding this comment

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

All these concatenations can be replaced with something like:

string.Format(CultureInfo.CurrentCulture, "<{1:c}{0} {2:c}{0} {3:c}{0} {4:c}>", separator, 2.5, 2, 3, 3.3);

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, although make sure there is still only a single space between elements if you go this route.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the separator variable should not have a space appended to it, that should be done in the format.

Copy link
Author

Choose a reason for hiding this comment

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

Totally agreed, i'm on it!

@mellinoe
Copy link
Contributor

The latest commits look good to me (I made one comment about formatting in the diff). If you don't mind, we'd like to get this compressed to a single commit before we merge it in.

@khellang
Copy link
Member

Remember; this is git - you can pull down the branch, squash/touch up the commits, merge and push it, while keeping the original author 😉

@nguerrera
Copy link
Contributor

@khellang Thanks for the suggestion. We realize that we can technically do that, but we'd prefer to ask the author to rebase because otherwise it:

  1. breaks our CI infrastructure's ability to automatically close the PR.
  2. can cause merge issues

I also generally dislike rebasing commits authored by someone else because I would prefer the history to reflect what individuals actually intentionally committed on their own. Where do you draw the line? What's OK to modify under someone else's name and what's not, etc.

I feel that the incoming history represents part of the contribution and it's not too much to ask contributors to take the time to factor it appropriately. This is exactly what we'd ask of any member of our team.

@jbuiss0n
Copy link
Author

Everything should be ok now !

@adamralph
Copy link
Contributor

nice job @jbuiss0n!

@dotnet-bot dotnet-bot merged commit 1e081ed into dotnet:master Nov 13, 2014
@jbuiss0n
Copy link
Author

Thanks guys, it's a pleasure.

@mellinoe
Copy link
Contributor

Thanks a bunch @jbuiss0n, merged this in just now.

@jbuiss0n jbuiss0n deleted the fix-vectors-tests branch November 13, 2014 18:00
pgavlin added a commit to pgavlin/corefx that referenced this pull request Sep 22, 2015
sepidehkh added a commit to sepidehkh/corefx that referenced this pull request Feb 3, 2016
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
9 participants