-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Support GetCultureInfo with predefinedOnly flag (#654)…
- Loading branch information
Showing
10 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/libraries/System.Globalization/tests/CultureInfo/GetCultureInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace System.Globalization.Tests | ||
{ | ||
public class GetCultureInfoTests | ||
{ | ||
public static bool PlatformSupportsFakeCulture => !PlatformDetection.IsWindows || (PlatformDetection.WindowsVersion >= 10 && !PlatformDetection.IsFullFramework); | ||
|
||
[ConditionalTheory(nameof(PlatformSupportsFakeCulture))] | ||
[InlineData("en")] | ||
[InlineData("en-US")] | ||
[InlineData("ja-JP")] | ||
[InlineData("ar-SA")] | ||
[InlineData("xx-XX")] | ||
public void GetCultureInfo(string name) | ||
{ | ||
Assert.Equal(name, CultureInfo.GetCultureInfo(name).Name); | ||
Assert.Equal(name, CultureInfo.GetCultureInfo(name, predefinedOnly: false).Name); | ||
} | ||
|
||
[ConditionalTheory(nameof(PlatformSupportsFakeCulture))] | ||
[InlineData("en@US")] | ||
[InlineData("\uFFFF")] | ||
public void TestInvalidCultureNames(string name) | ||
{ | ||
Assert.Throws<CultureNotFoundException>(() => CultureInfo.GetCultureInfo(name)); | ||
Assert.Throws<CultureNotFoundException>(() => CultureInfo.GetCultureInfo(name, predefinedOnly: false)); | ||
Assert.Throws<CultureNotFoundException>(() => CultureInfo.GetCultureInfo(name, predefinedOnly: true)); | ||
} | ||
|
||
[ConditionalTheory(nameof(PlatformSupportsFakeCulture))] | ||
[InlineData("xx")] | ||
[InlineData("xx-XX")] | ||
[InlineData("xx-YY")] | ||
public void TestFakeCultureNames(string name) | ||
{ | ||
Assert.Equal(name, CultureInfo.GetCultureInfo(name).Name); | ||
Assert.Equal(name, CultureInfo.GetCultureInfo(name, predefinedOnly: false).Name); | ||
Assert.Throws<CultureNotFoundException>(() => CultureInfo.GetCultureInfo(name, predefinedOnly: true)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters