Skip to content

Commit

Permalink
Merge pull request #1086 from Orace/fix1069
Browse files Browse the repository at this point in the history
Add tests for french culture ByteSize unit expression
  • Loading branch information
clairernovotny authored Jul 3, 2021
2 parents fee49de + 914a38e commit a910708
Showing 1 changed file with 62 additions and 53 deletions.
115 changes: 62 additions & 53 deletions src/Humanizer.Tests.Shared/Bytes/ByteSizeExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,14 @@ public void LongTerabytes()
}

[Theory]
[InlineData(2, null, "2 TB")]
[InlineData(2, "GB", "2048 GB")]
[InlineData(2.123, "#.#", "2.1 TB")]
public void HumanizesTerabytes(double input, string format, string expectedValue)
{
Assert.Equal(expectedValue, input.Terabytes().Humanize(format));
}

[Theory]
[InlineData(2.1, null, "en-US", "2.1 TB")]
[InlineData(2.123, "#.#", "en-US", "2.1 TB")]
[InlineData(2, null, "en", "2 TB")]
[InlineData(2, null, "fr", "2 To")]
[InlineData(2, "GB", "en", "2048 GB")]
[InlineData(2.1, null, "en", "2.1 TB")]
[InlineData(2.123, "#.#", "en", "2.1 TB")]
[InlineData(2.1, null, "ru-RU", "2,1 TB")]
[InlineData(2.123, "#.#", "ru-RU", "2,1 TB")]
public void HumanizeWithFormatProvider(double input, string format, string cultureName, string expectedValue)
public void HumanizesTerabytes(double input, string format, string cultureName, string expectedValue)
{
var culture = new CultureInfo(cultureName);

Expand Down Expand Up @@ -142,14 +136,17 @@ public void LongGigabytes()
}

[Theory]
[InlineData(0, null, "0 b")]
[InlineData(0, "GB", "0 GB")]
[InlineData(2, null, "2 GB")]
[InlineData(2, "MB", "2048 MB")]
[InlineData(2.123, "#.##", "2.12 GB")]
public void HumanizesGigabytes(double input, string format, string expectedValue)
[InlineData(0, null, "en", "0 b")]
[InlineData(0, "GB", "en", "0 GB")]
[InlineData(2, null, "en", "2 GB")]
[InlineData(2, null, "fr", "2 Go")]
[InlineData(2, "MB", "en", "2048 MB")]
[InlineData(2.123, "#.##", "en", "2.12 GB")]
public void HumanizesGigabytes(double input, string format, string cultureName, string expectedValue)
{
Assert.Equal(expectedValue, input.Gigabytes().Humanize(format));
var cultureInfo = new CultureInfo(cultureName);

Assert.Equal(expectedValue, input.Gigabytes().Humanize(format, cultureInfo));
}

[Fact]
Expand Down Expand Up @@ -209,14 +206,17 @@ public void LongMegabytes()
}

[Theory]
[InlineData(0, null, "0 b")]
[InlineData(0, "MB", "0 MB")]
[InlineData(2, null, "2 MB")]
[InlineData(2, "KB", "2048 KB")]
[InlineData(2.123, "#", "2 MB")]
public void HumanizesMegabytes(double input, string format, string expectedValue)
[InlineData(0, null, "en", "0 b")]
[InlineData(0, "MB", "en", "0 MB")]
[InlineData(2, null, "en", "2 MB")]
[InlineData(2, null, "fr", "2 Mo")]
[InlineData(2, "KB", "en", "2048 KB")]
[InlineData(2.123, "#", "en", "2 MB")]
public void HumanizesMegabytes(double input, string format, string cultureName, string expectedValue)
{
Assert.Equal(expectedValue, input.Megabytes().Humanize(format));
var cultureInfo = new CultureInfo(cultureName);

Assert.Equal(expectedValue, input.Megabytes().Humanize(format, cultureInfo));
}

[Fact]
Expand Down Expand Up @@ -276,14 +276,17 @@ public void LongKilobytes()
}

[Theory]
[InlineData(0, null, "0 b")]
[InlineData(0, "KB", "0 KB")]
[InlineData(2, null, "2 KB")]
[InlineData(2, "B", "2048 B")]
[InlineData(2.123, "#.####", "2.123 KB")]
public void HumanizesKilobytes(double input, string format, string expectedValue)
[InlineData(0, null, "en", "0 b")]
[InlineData(0, "KB", "en", "0 KB")]
[InlineData(2, null, "en", "2 KB")]
[InlineData(2, null, "fr", "2 Ko")]
[InlineData(2, "B", "en", "2048 B")]
[InlineData(2.123, "#.####", "en", "2.123 KB")]
public void HumanizesKilobytes(double input, string format, string cultureName, string expectedValue)
{
Assert.Equal(expectedValue, input.Kilobytes().Humanize(format));
var cultureInfo = new CultureInfo(cultureName);

Assert.Equal(expectedValue, input.Kilobytes().Humanize(format, cultureInfo));
}

[Fact]
Expand Down Expand Up @@ -343,19 +346,22 @@ public void LongBytes()
}

[Theory]
[InlineData(0, null, "0 b")]
[InlineData(0, "#.##", "0 b")]
[InlineData(0, "#.## B", "0 B")]
[InlineData(0, "B", "0 B")]
[InlineData(2, null, "2 B")]
[InlineData(2000, "KB", "1.95 KB")]
[InlineData(2123, "#.##", "2.07 KB")]
[InlineData(10000000, "KB", "9765.63 KB")]
[InlineData(10000000, "#,##0 KB", "9,766 KB")]
[InlineData(10000000, "#,##0.# KB", "9,765.6 KB")]
public void HumanizesBytes(double input, string format, string expectedValue)
[InlineData(0, null, "en", "0 b")]
[InlineData(0, "#.##", "en", "0 b")]
[InlineData(0, "#.## B", "en", "0 B")]
[InlineData(0, "B", "en", "0 B")]
[InlineData(2, null, "en", "2 B")]
[InlineData(2, null, "fr", "2 o")]
[InlineData(2000, "KB", "en", "1.95 KB")]
[InlineData(2123, "#.##", "en", "2.07 KB")]
[InlineData(10000000, "KB", "en", "9765.63 KB")]
[InlineData(10000000, "#,##0 KB", "en", "9,766 KB")]
[InlineData(10000000, "#,##0.# KB", "en", "9,765.6 KB")]
public void HumanizesBytes(double input, string format, string cultureName, string expectedValue)
{
Assert.Equal(expectedValue, input.Bytes().Humanize(format));
var cultureInfo = new CultureInfo(cultureName);

Assert.Equal(expectedValue, input.Bytes().Humanize(format, cultureInfo));
}

[Fact]
Expand Down Expand Up @@ -408,14 +414,17 @@ public void LongBits()
}

[Theory]
[InlineData(0, null, "0 b")]
[InlineData(0, "b", "0 b")]
[InlineData(2, null, "2 b")]
[InlineData(12, "B", "1.5 B")]
[InlineData(10000, "#.# KB", "1.2 KB")]
public void HumanizesBits(long input, string format, string expectedValue)
{
Assert.Equal(expectedValue, input.Bits().Humanize(format));
[InlineData(0, null, "en", "0 b")]
[InlineData(0, "b", "en", "0 b")]
[InlineData(2, null, "en", "2 b")]
[InlineData(2, null, "fr", "2 b")]
[InlineData(12, "B", "en", "1.5 B")]
[InlineData(10000, "#.# KB", "en", "1.2 KB")]
public void HumanizesBits(long input, string format, string cultureName, string expectedValue)
{
var cultureInfo = new CultureInfo(cultureName);

Assert.Equal(expectedValue, input.Bits().Humanize(format, cultureInfo));
}
}
}

0 comments on commit a910708

Please sign in to comment.