diff --git a/src/Humanizer.Tests/ArticlePrefixSortTests.cs b/src/Humanizer.Tests/ArticlePrefixSortTests.cs index bca7cc7c3..40a989ded 100644 --- a/src/Humanizer.Tests/ArticlePrefixSortTests.cs +++ b/src/Humanizer.Tests/ArticlePrefixSortTests.cs @@ -1,22 +1,21 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class ArticlePrefixSortTests { - public class ArticlePrefixSortTests - { - [Theory] - [InlineData(new[] { "Ant", "The Theater", "The apple", "Fox", "Bear" }, new[] { "Ant", "The apple", "Bear", "Fox", "The Theater" })] - [InlineData(new[] { "An Ant", "The Theater", "the apple", "a Fox", "Bear" }, new[] { "An Ant", "the apple", "Bear", "a Fox", "The Theater" })] - [InlineData(new[] { "Ant", "A Theater", "an apple", "Fox", "Bear" }, new[] { "Ant", "an apple", "Bear", "Fox", "A Theater" })] - [InlineData(new[] { " Ant ", " A Theater ", " an apple ", " Fox", "Bear " }, new[] { "A Theater", "an apple", "Ant", "Bear", "Fox" })] - [InlineData(new[] { "The General Theory of Relativity" }, new[] { "The General Theory of Relativity" })] - public void SortStringArrayIgnoringArticlePrefixes(string[] input, string[] expectedOutput) => - Assert.Equal(expectedOutput, EnglishArticle.PrependArticleSuffix(EnglishArticle.AppendArticlePrefix(input))); + [Theory] + [InlineData(new[] { "Ant", "The Theater", "The apple", "Fox", "Bear" }, new[] { "Ant", "The apple", "Bear", "Fox", "The Theater" })] + [InlineData(new[] { "An Ant", "The Theater", "the apple", "a Fox", "Bear" }, new[] { "An Ant", "the apple", "Bear", "a Fox", "The Theater" })] + [InlineData(new[] { "Ant", "A Theater", "an apple", "Fox", "Bear" }, new[] { "Ant", "an apple", "Bear", "Fox", "A Theater" })] + [InlineData(new[] { " Ant ", " A Theater ", " an apple ", " Fox", "Bear " }, new[] { "A Theater", "an apple", "Ant", "Bear", "Fox" })] + [InlineData(new[] { "The General Theory of Relativity" }, new[] { "The General Theory of Relativity" })] + public void SortStringArrayIgnoringArticlePrefixes(string[] input, string[] expectedOutput) => + Assert.Equal(expectedOutput, EnglishArticle.PrependArticleSuffix(EnglishArticle.AppendArticlePrefix(input))); - [Fact] - public void An_Empty_String_Array_Throws_ArgumentOutOfRangeException() - { + [Fact] + public void An_Empty_String_Array_Throws_ArgumentOutOfRangeException() + { string[] items = []; void action() => EnglishArticle.AppendArticlePrefix(items); Assert.Throws(action); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/BitFieldEnumHumanizeTests.cs b/src/Humanizer.Tests/BitFieldEnumHumanizeTests.cs index 1a9cfb41e..51ae8ccd3 100644 --- a/src/Humanizer.Tests/BitFieldEnumHumanizeTests.cs +++ b/src/Humanizer.Tests/BitFieldEnumHumanizeTests.cs @@ -1,40 +1,39 @@ -namespace Humanizer.Tests -{ - [UseCulture("en")] - public class BitFieldEnumHumanizeTests - { - [Fact] - public void CanHumanizeSingleWordDescriptionAttribute() => - Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, BitFieldEnumUnderTest.RED.Humanize()); +namespace Humanizer.Tests; - [Fact] - public void CanHumanizeMultipleWordDescriptionAttribute() => - Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, BitFieldEnumUnderTest.DARK_GRAY.Humanize()); +[UseCulture("en")] +public class BitFieldEnumHumanizeTests +{ + [Fact] + public void CanHumanizeSingleWordDescriptionAttribute() => + Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, BitFieldEnumUnderTest.RED.Humanize()); - [Fact] - public void CanHumanizeMultipleValueBitFieldEnum() - { - var xoredBitFlag = BitFieldEnumUnderTest.RED | BitFieldEnumUnderTest.DARK_GRAY; - Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); - } + [Fact] + public void CanHumanizeMultipleWordDescriptionAttribute() => + Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, BitFieldEnumUnderTest.DARK_GRAY.Humanize()); - [Fact] - public void CanHumanizeShortSingleWordDescriptionAttribute() => - Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, ShortBitFieldEnumUnderTest.RED.Humanize()); + [Fact] + public void CanHumanizeMultipleValueBitFieldEnum() + { + var xoredBitFlag = BitFieldEnumUnderTest.RED | BitFieldEnumUnderTest.DARK_GRAY; + Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); + } - [Fact] - public void CanHumanizeShortMultipleWordDescriptionAttribute() => - Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, ShortBitFieldEnumUnderTest.DARK_GRAY.Humanize()); + [Fact] + public void CanHumanizeShortSingleWordDescriptionAttribute() => + Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, ShortBitFieldEnumUnderTest.RED.Humanize()); - [Fact] - public void CanHumanizeShortMultipleValueBitFieldEnum() - { - var xoredBitFlag = ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY; - Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); - } + [Fact] + public void CanHumanizeShortMultipleWordDescriptionAttribute() => + Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, ShortBitFieldEnumUnderTest.DARK_GRAY.Humanize()); - [Fact] - public void CanHumanizeBitFieldEnumWithZeroValue() => - Assert.Equal(BitFlagEnumTestsResources.None, BitFieldEnumUnderTest.NONE.Humanize()); + [Fact] + public void CanHumanizeShortMultipleValueBitFieldEnum() + { + var xoredBitFlag = ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY; + Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); } -} + + [Fact] + public void CanHumanizeBitFieldEnumWithZeroValue() => + Assert.Equal(BitFlagEnumTestsResources.None, BitFieldEnumUnderTest.NONE.Humanize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/BitFieldEnumUnderTest.cs b/src/Humanizer.Tests/BitFieldEnumUnderTest.cs index e0fd7d628..fa1cb4f20 100644 --- a/src/Humanizer.Tests/BitFieldEnumUnderTest.cs +++ b/src/Humanizer.Tests/BitFieldEnumUnderTest.cs @@ -1,33 +1,32 @@ using System.ComponentModel.DataAnnotations; -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[Flags] +public enum BitFieldEnumUnderTest : int { - [Flags] - public enum BitFieldEnumUnderTest : int - { - [Display(Description = BitFlagEnumTestsResources.None)] - NONE = 0, - [Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] - RED = 1, - [Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] - DARK_GRAY = 2 - } + [Display(Description = BitFlagEnumTestsResources.None)] + NONE = 0, + [Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] + RED = 1, + [Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] + DARK_GRAY = 2 +} - [Flags] - public enum ShortBitFieldEnumUnderTest : short - { - [Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] - RED = 1, - [Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] - DARK_GRAY = 2 - } +[Flags] +public enum ShortBitFieldEnumUnderTest : short +{ + [Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] + RED = 1, + [Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] + DARK_GRAY = 2 +} - public class BitFlagEnumTestsResources - { - public const string None = "None"; - public const string MemberWithSingleWordDisplayAttribute = "Red"; - public const string MemberWithMultipleWordDisplayAttribute = "Dark Gray"; +public class BitFlagEnumTestsResources +{ + public const string None = "None"; + public const string MemberWithSingleWordDisplayAttribute = "Red"; + public const string MemberWithMultipleWordDisplayAttribute = "Dark Gray"; - public const string ExpectedResultWhenBothValuesXored = "Red and Dark Gray"; - } -} + public const string ExpectedResultWhenBothValuesXored = "Red and Dark Gray"; +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ArithmeticTests.cs b/src/Humanizer.Tests/Bytes/ArithmeticTests.cs index a3b84063b..f7aaa8a8e 100644 --- a/src/Humanizer.Tests/Bytes/ArithmeticTests.cs +++ b/src/Humanizer.Tests/Bytes/ArithmeticTests.cs @@ -1,10 +1,10 @@ -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +public class ArithmeticTests { - public class ArithmeticTests + [Fact] + public void Add() { - [Fact] - public void Add() - { var size1 = ByteSize.FromBytes(1); var result = size1.Add(size1); @@ -12,27 +12,27 @@ public void Add() Assert.Equal(16, result.Bits); } - [Fact] - public void AddBits() - { + [Fact] + public void AddBits() + { var size = ByteSize.FromBytes(1).AddBits(8); Assert.Equal(2, size.Bytes); Assert.Equal(16, size.Bits); } - [Fact] - public void AddBytes() - { + [Fact] + public void AddBytes() + { var size = ByteSize.FromBytes(1).AddBytes(1); Assert.Equal(2, size.Bytes); Assert.Equal(16, size.Bits); } - [Fact] - public void AddKilobytes() - { + [Fact] + public void AddKilobytes() + { var size = ByteSize.FromKilobytes(2).AddKilobytes(2); Assert.Equal(4 * 1024 * 8, size.Bits); @@ -40,9 +40,9 @@ public void AddKilobytes() Assert.Equal(4, size.Kilobytes); } - [Fact] - public void AddMegabytes() - { + [Fact] + public void AddMegabytes() + { var size = ByteSize.FromMegabytes(2).AddMegabytes(2); Assert.Equal(4 * 1024 * 1024 * 8, size.Bits); @@ -51,9 +51,9 @@ public void AddMegabytes() Assert.Equal(4, size.Megabytes); } - [Fact] - public void AddGigabytes() - { + [Fact] + public void AddGigabytes() + { var size = ByteSize.FromGigabytes(2).AddGigabytes(2); Assert.Equal(4d * 1024 * 1024 * 1024 * 8, size.Bits); @@ -63,9 +63,9 @@ public void AddGigabytes() Assert.Equal(4d, size.Gigabytes); } - [Fact] - public void AddTerabytes() - { + [Fact] + public void AddTerabytes() + { var size = ByteSize.FromTerabytes(2).AddTerabytes(2); Assert.Equal(4d * 1024 * 1024 * 1024 * 1024 * 8, size.Bits); @@ -76,18 +76,18 @@ public void AddTerabytes() Assert.Equal(4d, size.Terabytes); } - [Fact] - public void Subtract() - { + [Fact] + public void Subtract() + { var size = ByteSize.FromBytes(4).Subtract(ByteSize.FromBytes(2)); Assert.Equal(16, size.Bits); Assert.Equal(2, size.Bytes); } - [Fact] - public void IncrementOperator() - { + [Fact] + public void IncrementOperator() + { var size = ByteSize.FromBytes(2); size++; @@ -95,9 +95,9 @@ public void IncrementOperator() Assert.Equal(3, size.Bytes); } - [Fact] - public void NegativeOperator() - { + [Fact] + public void NegativeOperator() + { var size = ByteSize.FromBytes(2); size = -size; @@ -106,9 +106,9 @@ public void NegativeOperator() Assert.Equal(-2, size.Bytes); } - [Fact] - public void DecrementOperator() - { + [Fact] + public void DecrementOperator() + { var size = ByteSize.FromBytes(2); size--; @@ -116,9 +116,9 @@ public void DecrementOperator() Assert.Equal(1, size.Bytes); } - [Fact] - public void PlusOperator() - { + [Fact] + public void PlusOperator() + { var size1 = ByteSize.FromBytes(1); var size2 = ByteSize.FromBytes(1); @@ -127,9 +127,9 @@ public void PlusOperator() Assert.Equal(2, result.Bytes); } - [Fact] - public void MinusOperator() - { + [Fact] + public void MinusOperator() + { var size1 = ByteSize.FromBytes(2); var size2 = ByteSize.FromBytes(1); @@ -137,5 +137,4 @@ public void MinusOperator() Assert.Equal(1, result.Bytes); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ByteRateTests.cs b/src/Humanizer.Tests/Bytes/ByteRateTests.cs index 5723f52e3..192be18b6 100644 --- a/src/Humanizer.Tests/Bytes/ByteRateTests.cs +++ b/src/Humanizer.Tests/Bytes/ByteRateTests.cs @@ -1,17 +1,17 @@ -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +[UseCulture("en")] +public class ByteRateTests { - [UseCulture("en")] - public class ByteRateTests + [Theory] + [InlineData(400, 1, "400 B/s")] + [InlineData(4 * 1024, 1, "4 KB/s")] + [InlineData(4 * 1024 * 1024, 1, "4 MB/s")] + [InlineData(4 * 2 * 1024 * 1024, 2, "4 MB/s")] + [InlineData(4 * 1024, 0.1, "40 KB/s")] + [InlineData(15 * 60 * 1024 * 1024, 60, "15 MB/s")] + public void HumanizesRates(long inputBytes, double perSeconds, string expectedValue) { - [Theory] - [InlineData(400, 1, "400 B/s")] - [InlineData(4 * 1024, 1, "4 KB/s")] - [InlineData(4 * 1024 * 1024, 1, "4 MB/s")] - [InlineData(4 * 2 * 1024 * 1024, 2, "4 MB/s")] - [InlineData(4 * 1024, 0.1, "40 KB/s")] - [InlineData(15 * 60 * 1024 * 1024, 60, "15 MB/s")] - public void HumanizesRates(long inputBytes, double perSeconds, string expectedValue) - { var size = new ByteSize(inputBytes); var interval = TimeSpan.FromSeconds(perSeconds); @@ -20,18 +20,18 @@ public void HumanizesRates(long inputBytes, double perSeconds, string expectedVa Assert.Equal(expectedValue, rate); } - [Theory] - [InlineData(1, 1, TimeUnit.Second, "1 MB/s")] - [InlineData(1, 60, TimeUnit.Minute, "1 MB/min")] - [InlineData(1, 60 * 60, TimeUnit.Hour, "1 MB/h")] - [InlineData(10, 1, TimeUnit.Second, "10 MB/s")] - [InlineData(10, 60, TimeUnit.Minute, "10 MB/min")] - [InlineData(10, 60 * 60, TimeUnit.Hour, "10 MB/h")] - [InlineData(1, 10 * 1, TimeUnit.Second, "102.4 KB/s")] - [InlineData(1, 10 * 60, TimeUnit.Minute, "102.4 KB/min")] - [InlineData(1, 10 * 60 * 60, TimeUnit.Hour, "102.4 KB/h")] - public void TimeUnitTests(long megabytes, double measurementIntervalSeconds, TimeUnit displayInterval, string expectedValue) - { + [Theory] + [InlineData(1, 1, TimeUnit.Second, "1 MB/s")] + [InlineData(1, 60, TimeUnit.Minute, "1 MB/min")] + [InlineData(1, 60 * 60, TimeUnit.Hour, "1 MB/h")] + [InlineData(10, 1, TimeUnit.Second, "10 MB/s")] + [InlineData(10, 60, TimeUnit.Minute, "10 MB/min")] + [InlineData(10, 60 * 60, TimeUnit.Hour, "10 MB/h")] + [InlineData(1, 10 * 1, TimeUnit.Second, "102.4 KB/s")] + [InlineData(1, 10 * 60, TimeUnit.Minute, "102.4 KB/min")] + [InlineData(1, 10 * 60 * 60, TimeUnit.Hour, "102.4 KB/h")] + public void TimeUnitTests(long megabytes, double measurementIntervalSeconds, TimeUnit displayInterval, string expectedValue) + { var size = ByteSize.FromMegabytes(megabytes); var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds); @@ -41,11 +41,11 @@ public void TimeUnitTests(long megabytes, double measurementIntervalSeconds, Tim Assert.Equal(expectedValue, text); } - [Theory] - [InlineData(19854651984, 1, TimeUnit.Second, null, "18.49 GB/s")] - [InlineData(19854651984, 1, TimeUnit.Second, "#.##", "18.49 GB/s")] - public void FormattedTimeUnitTests(long bytes, int measurementIntervalSeconds, TimeUnit displayInterval, string? format, string expectedValue) - { + [Theory] + [InlineData(19854651984, 1, TimeUnit.Second, null, "18.49 GB/s")] + [InlineData(19854651984, 1, TimeUnit.Second, "#.##", "18.49 GB/s")] + public void FormattedTimeUnitTests(long bytes, int measurementIntervalSeconds, TimeUnit displayInterval, string? format, string expectedValue) + { var size = ByteSize.FromBytes(bytes); var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds); var rate = size.Per(measurementInterval); @@ -54,14 +54,14 @@ public void FormattedTimeUnitTests(long bytes, int measurementIntervalSeconds, T Assert.Equal(expectedValue, text); } - [Theory] - [InlineData(TimeUnit.Millisecond)] - [InlineData(TimeUnit.Day)] - [InlineData(TimeUnit.Month)] - [InlineData(TimeUnit.Week)] - [InlineData(TimeUnit.Year)] - public void ThrowsOnUnsupportedData(TimeUnit units) - { + [Theory] + [InlineData(TimeUnit.Millisecond)] + [InlineData(TimeUnit.Day)] + [InlineData(TimeUnit.Month)] + [InlineData(TimeUnit.Week)] + [InlineData(TimeUnit.Year)] + public void ThrowsOnUnsupportedData(TimeUnit units) + { var dummyRate = ByteSize.FromBits(1).Per(TimeSpan.FromSeconds(1)); Assert.Throws(() => @@ -70,5 +70,4 @@ public void ThrowsOnUnsupportedData(TimeUnit units) }); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ByteSizeExtensionsTests.cs b/src/Humanizer.Tests/Bytes/ByteSizeExtensionsTests.cs index b5a0a3fe9..18e37dc87 100644 --- a/src/Humanizer.Tests/Bytes/ByteSizeExtensionsTests.cs +++ b/src/Humanizer.Tests/Bytes/ByteSizeExtensionsTests.cs @@ -1,425 +1,424 @@ -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +[UseCulture("en")] +public class ByteSizeExtensionsTests { - [UseCulture("en")] - public class ByteSizeExtensionsTests + [Fact] + public void ByteTerabytes() { - [Fact] - public void ByteTerabytes() - { const byte size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void SbyteTerabytes() - { + [Fact] + public void SbyteTerabytes() + { const sbyte size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void ShortTerabytes() - { + [Fact] + public void ShortTerabytes() + { const short size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void UshortTerabytes() - { + [Fact] + public void UshortTerabytes() + { const ushort size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void IntTerabytes() - { + [Fact] + public void IntTerabytes() + { const int size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void UintTerabytes() - { + [Fact] + public void UintTerabytes() + { const uint size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void DoubleTerabytes() - { + [Fact] + public void DoubleTerabytes() + { const double size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Fact] - public void LongTerabytes() - { + [Fact] + public void LongTerabytes() + { const long size = 2; Assert.Equal(ByteSize.FromTerabytes(size), size.Terabytes()); } - [Theory] - [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 HumanizesTerabytes(double input, string? format, string cultureName, string expectedValue) - { + [Theory] + [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 HumanizesTerabytes(double input, string? format, string cultureName, string expectedValue) + { var culture = new CultureInfo(cultureName); Assert.Equal(expectedValue, input.Terabytes().Humanize(format, culture)); } - [Fact] - public void ByteGigabytes() - { + [Fact] + public void ByteGigabytes() + { const byte size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void SbyteGigabytes() - { + [Fact] + public void SbyteGigabytes() + { const sbyte size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void ShortGigabytes() - { + [Fact] + public void ShortGigabytes() + { const short size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void UshortGigabytes() - { + [Fact] + public void UshortGigabytes() + { const ushort size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void IntGigabytes() - { + [Fact] + public void IntGigabytes() + { const int size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void UintGigabytes() - { + [Fact] + public void UintGigabytes() + { const uint size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void DoubleGigabytes() - { + [Fact] + public void DoubleGigabytes() + { const double size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Fact] - public void LongGigabytes() - { + [Fact] + public void LongGigabytes() + { const long size = 2; Assert.Equal(ByteSize.FromGigabytes(size), size.Gigabytes()); } - [Theory] - [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) - { + [Theory] + [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) + { var cultureInfo = new CultureInfo(cultureName); Assert.Equal(expectedValue, input.Gigabytes().Humanize(format, cultureInfo)); } - [Fact] - public void ByteMegabytes() - { + [Fact] + public void ByteMegabytes() + { const byte size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void SbyteMegabytes() - { + [Fact] + public void SbyteMegabytes() + { const sbyte size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void ShortMegabytes() - { + [Fact] + public void ShortMegabytes() + { const short size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void UshortMegabytes() - { + [Fact] + public void UshortMegabytes() + { const ushort size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void IntMegabytes() - { + [Fact] + public void IntMegabytes() + { const int size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void UintMegabytes() - { + [Fact] + public void UintMegabytes() + { const uint size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void DoubleMegabytes() - { + [Fact] + public void DoubleMegabytes() + { const double size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Fact] - public void LongMegabytes() - { + [Fact] + public void LongMegabytes() + { const long size = 2; Assert.Equal(ByteSize.FromMegabytes(size), size.Megabytes()); } - [Theory] - [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) - { + [Theory] + [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) + { var cultureInfo = new CultureInfo(cultureName); Assert.Equal(expectedValue, input.Megabytes().Humanize(format, cultureInfo)); } - [Fact] - public void ByteKilobytes() - { + [Fact] + public void ByteKilobytes() + { const byte size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void SbyteKilobytes() - { + [Fact] + public void SbyteKilobytes() + { const sbyte size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void ShortKilobytes() - { + [Fact] + public void ShortKilobytes() + { const short size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void UshortKilobytes() - { + [Fact] + public void UshortKilobytes() + { const ushort size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void IntKilobytes() - { + [Fact] + public void IntKilobytes() + { const int size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void UintKilobytes() - { + [Fact] + public void UintKilobytes() + { const uint size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void DoubleKilobytes() - { + [Fact] + public void DoubleKilobytes() + { const double size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Fact] - public void LongKilobytes() - { + [Fact] + public void LongKilobytes() + { const long size = 2; Assert.Equal(ByteSize.FromKilobytes(size), size.Kilobytes()); } - [Theory] - [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) - { + [Theory] + [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) + { var cultureInfo = new CultureInfo(cultureName); Assert.Equal(expectedValue, input.Kilobytes().Humanize(format, cultureInfo)); } - [Fact] - public void ByteBytes() - { + [Fact] + public void ByteBytes() + { const byte size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void SbyteBytes() - { + [Fact] + public void SbyteBytes() + { const sbyte size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void ShortBytes() - { + [Fact] + public void ShortBytes() + { const short size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void UshortBytes() - { + [Fact] + public void UshortBytes() + { const ushort size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void IntBytes() - { + [Fact] + public void IntBytes() + { const int size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void UintBytes() - { + [Fact] + public void UintBytes() + { const uint size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void DoubleBytes() - { + [Fact] + public void DoubleBytes() + { const double size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Fact] - public void LongBytes() - { + [Fact] + public void LongBytes() + { const long size = 2; Assert.Equal(ByteSize.FromBytes(size), size.Bytes()); } - [Theory] - [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) - { + [Theory] + [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) + { var cultureInfo = new CultureInfo(cultureName); Assert.Equal(expectedValue, input.Bytes().Humanize(format, cultureInfo)); } - [Fact] - public void ByteBits() - { + [Fact] + public void ByteBits() + { const byte size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Fact] - public void SbyteBits() - { + [Fact] + public void SbyteBits() + { const sbyte size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Fact] - public void ShortBits() - { + [Fact] + public void ShortBits() + { const short size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Fact] - public void UshortBits() - { + [Fact] + public void UshortBits() + { const ushort size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Fact] - public void IntBits() - { + [Fact] + public void IntBits() + { const int size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Fact] - public void UintBits() - { + [Fact] + public void UintBits() + { const uint size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Fact] - public void LongBits() - { + [Fact] + public void LongBits() + { const long size = 2; Assert.Equal(ByteSize.FromBits(size), size.Bits()); } - [Theory] - [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) - { + [Theory] + [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)); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ComparingTests.cs b/src/Humanizer.Tests/Bytes/ComparingTests.cs index 133ba9e0d..f6fe56c4a 100644 --- a/src/Humanizer.Tests/Bytes/ComparingTests.cs +++ b/src/Humanizer.Tests/Bytes/ComparingTests.cs @@ -1,14 +1,14 @@  -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +public class ComparingTests { - public class ComparingTests + [Theory] + [InlineData(13, 23, -1)] + [InlineData(23, 23, 0)] + [InlineData(45, 23, 1)] + public void CompareStrongTyped(double value, double valueToCompareWith, int expectedResult) { - [Theory] - [InlineData(13, 23, -1)] - [InlineData(23, 23, 0)] - [InlineData(45, 23, 1)] - public void CompareStrongTyped(double value, double valueToCompareWith, int expectedResult) - { var valueSize = new ByteSize(value); var otherSize = new ByteSize(valueToCompareWith); var result = valueSize.CompareTo(otherSize); @@ -16,12 +16,12 @@ public void CompareStrongTyped(double value, double valueToCompareWith, int expe Assert.Equal(expectedResult, result); } - [Theory] - [InlineData(13, 23, -1)] - [InlineData(23, 23, 0)] - [InlineData(45, 23, 1)] - public void CompareUntyped(double value, double valueToCompareWith, int expectedResult) - { + [Theory] + [InlineData(13, 23, -1)] + [InlineData(23, 23, 0)] + [InlineData(45, 23, 1)] + public void CompareUntyped(double value, double valueToCompareWith, int expectedResult) + { var valueSize = new ByteSize(value); object otherSize = new ByteSize(valueToCompareWith); var result = valueSize.CompareTo(otherSize); @@ -29,15 +29,14 @@ public void CompareUntyped(double value, double valueToCompareWith, int expected Assert.Equal(expectedResult, result); } - [Theory] - [InlineData(new[] { "1GB", "3KB", "5MB" }, new[] { "3KB", "5MB", "1GB" })] - [InlineData(new[] { "1MB", "3KB", "5MB" }, new[] { "3KB", "1MB", "5MB" })] - public void SortList(IEnumerable values, IEnumerable expected) - { + [Theory] + [InlineData(new[] { "1GB", "3KB", "5MB" }, new[] { "3KB", "5MB", "1GB" })] + [InlineData(new[] { "1MB", "3KB", "5MB" }, new[] { "3KB", "1MB", "5MB" })] + public void SortList(IEnumerable values, IEnumerable expected) + { var list = values.Select(ByteSize.Parse).ToList(); list.Sort(); Assert.Equal(expected.Select(ByteSize.Parse), list); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/CreatingTests.cs b/src/Humanizer.Tests/Bytes/CreatingTests.cs index 191259253..4f6b270b1 100644 --- a/src/Humanizer.Tests/Bytes/CreatingTests.cs +++ b/src/Humanizer.Tests/Bytes/CreatingTests.cs @@ -20,13 +20,13 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +public class CreatingTests { - public class CreatingTests + [Fact] + public void Constructor() { - [Fact] - public void Constructor() - { var result = new ByteSize(1099511627776); Assert.Equal(8.796093022208e12, result.Bits); @@ -37,58 +37,57 @@ public void Constructor() Assert.Equal(1, result.Terabytes); } - [Fact] - public void FromBits() - { + [Fact] + public void FromBits() + { var result = ByteSize.FromBits(8); Assert.Equal(8, result.Bits); Assert.Equal(1, result.Bytes); } - [Fact] - public void FromBytes() - { + [Fact] + public void FromBytes() + { var result = ByteSize.FromBytes(1.5); Assert.Equal(12, result.Bits); Assert.Equal(1.5, result.Bytes); } - [Fact] - public void FromKilobytes() - { + [Fact] + public void FromKilobytes() + { var result = ByteSize.FromKilobytes(1.5); Assert.Equal(1536, result.Bytes); Assert.Equal(1.5, result.Kilobytes); } - [Fact] - public void FromMegabytes() - { + [Fact] + public void FromMegabytes() + { var result = ByteSize.FromMegabytes(1.5); Assert.Equal(1572864, result.Bytes); Assert.Equal(1.5, result.Megabytes); } - [Fact] - public void FromGigabytes() - { + [Fact] + public void FromGigabytes() + { var result = ByteSize.FromGigabytes(1.5); Assert.Equal(1610612736, result.Bytes); Assert.Equal(1.5, result.Gigabytes); } - [Fact] - public void FromTerabytes() - { + [Fact] + public void FromTerabytes() + { var result = ByteSize.FromTerabytes(1.5); Assert.Equal(1649267441664, result.Bytes); Assert.Equal(1.5, result.Terabytes); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ParsingTests.cs b/src/Humanizer.Tests/Bytes/ParsingTests.cs index 167eaa173..650f80a3f 100644 --- a/src/Humanizer.Tests/Bytes/ParsingTests.cs +++ b/src/Humanizer.Tests/Bytes/ParsingTests.cs @@ -20,43 +20,43 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +[UseCulture("en")] +public class ParsingTests { - [UseCulture("en")] - public class ParsingTests - { - [Fact] - public void Parse() => - Assert.Equal(ByteSize.FromKilobytes(1020), ByteSize.Parse("1020KB")); + [Fact] + public void Parse() => + Assert.Equal(ByteSize.FromKilobytes(1020), ByteSize.Parse("1020KB")); - [Fact] - public void TryParseReturnsFalseOnNull() - { + [Fact] + public void TryParseReturnsFalseOnNull() + { Assert.False(ByteSize.TryParse(null, out var result)); Assert.Equal(default, result); } - [Fact] - public void TryParse() - { + [Fact] + public void TryParse() + { var resultBool = ByteSize.TryParse("1020KB", out var resultByteSize); Assert.True(resultBool); Assert.Equal(ByteSize.FromKilobytes(1020), resultByteSize); } - [Theory] - [InlineData("2000.01KB", "")] // Invariant - [InlineData("2,000.01KB", "")] - [InlineData("+2000.01KB", "")] - [InlineData("2000.01KB", "en")] - [InlineData("2,000.01KB", "en")] - [InlineData("+2000.01KB", "en")] - [InlineData("2000,01KB", "de")] - [InlineData("2.000,01KB", "de")] - [InlineData("+2000,01KB", "de")] - public void TryParseWithCultureInfo(string value, string cultureName) - { + [Theory] + [InlineData("2000.01KB", "")] // Invariant + [InlineData("2,000.01KB", "")] + [InlineData("+2000.01KB", "")] + [InlineData("2000.01KB", "en")] + [InlineData("2,000.01KB", "en")] + [InlineData("+2000.01KB", "en")] + [InlineData("2000,01KB", "de")] + [InlineData("2.000,01KB", "de")] + [InlineData("+2000,01KB", "de")] + public void TryParseWithCultureInfo(string value, string cultureName) + { var culture = new CultureInfo(cultureName); Assert.True(ByteSize.TryParse(value, culture, out var resultByteSize)); @@ -65,9 +65,9 @@ public void TryParseWithCultureInfo(string value, string cultureName) Assert.Equal(resultByteSize, ByteSize.Parse(value, culture)); } - [Fact] - public void TryParseWithNumberFormatInfo() - { + [Fact] + public void TryParseWithNumberFormatInfo() + { var numberFormat = new NumberFormatInfo { NumberDecimalSeparator = "_", @@ -83,22 +83,22 @@ public void TryParseWithNumberFormatInfo() Assert.Equal(resultByteSize, ByteSize.Parse(value, numberFormat)); } - [Fact] - public void ParseDecimalMegabytes() => - Assert.Equal(ByteSize.FromMegabytes(100.5), ByteSize.Parse("100.5MB")); - - [Theory] - [InlineData("")] - [InlineData(" ")] - [InlineData("\t")] - [InlineData("Unexpected Value")] - [InlineData("1000")] - [InlineData(" 1000 ")] - [InlineData("KB")] - [InlineData("1000.5b")] // Partial bits - [InlineData("1000KBB")] // Bad suffix - public void TryParseReturnsFalseOnBadValue(string input) - { + [Fact] + public void ParseDecimalMegabytes() => + Assert.Equal(ByteSize.FromMegabytes(100.5), ByteSize.Parse("100.5MB")); + + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData("\t")] + [InlineData("Unexpected Value")] + [InlineData("1000")] + [InlineData(" 1000 ")] + [InlineData("KB")] + [InlineData("1000.5b")] // Partial bits + [InlineData("1000KBB")] // Bad suffix + public void TryParseReturnsFalseOnBadValue(string input) + { var resultBool = ByteSize.TryParse(input, out var resultByteSize); Assert.False(resultBool); @@ -107,36 +107,35 @@ public void TryParseReturnsFalseOnBadValue(string input) Assert.Throws(() => { ByteSize.Parse(input); }); } - [Fact] - public void TryParseWorksWithLotsOfSpaces() => - Assert.Equal(ByteSize.FromKilobytes(100), ByteSize.Parse(" 100 KB ")); + [Fact] + public void TryParseWorksWithLotsOfSpaces() => + Assert.Equal(ByteSize.FromKilobytes(100), ByteSize.Parse(" 100 KB ")); - [Fact] - public void ParseThrowsOnNull() => - Assert.Throws(() => { ByteSize.Parse(null!); }); + [Fact] + public void ParseThrowsOnNull() => + Assert.Throws(() => { ByteSize.Parse(null!); }); - [Fact] - public void ParseBits() => - Assert.Equal(ByteSize.FromBits(1), ByteSize.Parse("1b")); + [Fact] + public void ParseBits() => + Assert.Equal(ByteSize.FromBits(1), ByteSize.Parse("1b")); - [Fact] - public void ParseBytes() => - Assert.Equal(ByteSize.FromBytes(1), ByteSize.Parse("1B")); + [Fact] + public void ParseBytes() => + Assert.Equal(ByteSize.FromBytes(1), ByteSize.Parse("1B")); - [Fact] - public void ParseKilobytes() => - Assert.Equal(ByteSize.FromKilobytes(1020), ByteSize.Parse("1020KB")); + [Fact] + public void ParseKilobytes() => + Assert.Equal(ByteSize.FromKilobytes(1020), ByteSize.Parse("1020KB")); - [Fact] - public void ParseMegabytes() => - Assert.Equal(ByteSize.FromMegabytes(1000), ByteSize.Parse("1000MB")); + [Fact] + public void ParseMegabytes() => + Assert.Equal(ByteSize.FromMegabytes(1000), ByteSize.Parse("1000MB")); - [Fact] - public void ParseGigabytes() => - Assert.Equal(ByteSize.FromGigabytes(805), ByteSize.Parse("805GB")); + [Fact] + public void ParseGigabytes() => + Assert.Equal(ByteSize.FromGigabytes(805), ByteSize.Parse("805GB")); - [Fact] - public void ParseTerabytes() => - Assert.Equal(ByteSize.FromTerabytes(100), ByteSize.Parse("100TB")); - } -} + [Fact] + public void ParseTerabytes() => + Assert.Equal(ByteSize.FromTerabytes(100), ByteSize.Parse("100TB")); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ToFullWordsTests.cs b/src/Humanizer.Tests/Bytes/ToFullWordsTests.cs index a5ffb3252..a966d834f 100644 --- a/src/Humanizer.Tests/Bytes/ToFullWordsTests.cs +++ b/src/Humanizer.Tests/Bytes/ToFullWordsTests.cs @@ -20,63 +20,62 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +[UseCulture("en")] +public class ToFullWordsTests { - [UseCulture("en")] - public class ToFullWordsTests - { - [Fact] - public void ReturnsSingularBit() => - Assert.Equal("1 bit", ByteSize.FromBits(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBits() => - Assert.Equal("2 bits", ByteSize.FromBits(2).ToFullWords()); - - [Fact] - public void ReturnsSingularByte() => - Assert.Equal("1 byte", ByteSize.FromBytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBytes() => - Assert.Equal("10 bytes", ByteSize.FromBytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularKiloByte() => - Assert.Equal("1 kilobyte", ByteSize.FromKilobytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralKilobytes() => - Assert.Equal("10 kilobytes", ByteSize.FromKilobytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularMegabyte() => - Assert.Equal("1 megabyte", ByteSize.FromMegabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralMegabytes() => - Assert.Equal("10 megabytes", ByteSize.FromMegabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularGigabyte() => - Assert.Equal("1 gigabyte", ByteSize.FromGigabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralGigabytes() => - Assert.Equal("10 gigabytes", ByteSize.FromGigabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularTerabyte() => - Assert.Equal("1 terabyte", ByteSize.FromTerabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralTerabytes() => - Assert.Equal("10 terabytes", ByteSize.FromTerabytes(10).ToFullWords()); - - [Theory] - [InlineData(229376, "B", "229376 bytes")] - [InlineData(229376, "# KB", "224 kilobytes")] - public void ToFullWordsFormatted(double input, string format, string expectedValue) => - Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); - } -} + [Fact] + public void ReturnsSingularBit() => + Assert.Equal("1 bit", ByteSize.FromBits(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBits() => + Assert.Equal("2 bits", ByteSize.FromBits(2).ToFullWords()); + + [Fact] + public void ReturnsSingularByte() => + Assert.Equal("1 byte", ByteSize.FromBytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBytes() => + Assert.Equal("10 bytes", ByteSize.FromBytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularKiloByte() => + Assert.Equal("1 kilobyte", ByteSize.FromKilobytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralKilobytes() => + Assert.Equal("10 kilobytes", ByteSize.FromKilobytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularMegabyte() => + Assert.Equal("1 megabyte", ByteSize.FromMegabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralMegabytes() => + Assert.Equal("10 megabytes", ByteSize.FromMegabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularGigabyte() => + Assert.Equal("1 gigabyte", ByteSize.FromGigabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralGigabytes() => + Assert.Equal("10 gigabytes", ByteSize.FromGigabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularTerabyte() => + Assert.Equal("1 terabyte", ByteSize.FromTerabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralTerabytes() => + Assert.Equal("10 terabytes", ByteSize.FromTerabytes(10).ToFullWords()); + + [Theory] + [InlineData(229376, "B", "229376 bytes")] + [InlineData(229376, "# KB", "224 kilobytes")] + public void ToFullWordsFormatted(double input, string format, string expectedValue) => + Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Bytes/ToStringTests.cs b/src/Humanizer.Tests/Bytes/ToStringTests.cs index 748fede4b..beab71fb9 100644 --- a/src/Humanizer.Tests/Bytes/ToStringTests.cs +++ b/src/Humanizer.Tests/Bytes/ToStringTests.cs @@ -20,64 +20,63 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN //THE SOFTWARE. -namespace Humanizer.Tests.Bytes +namespace Humanizer.Tests.Bytes; + +[UseCulture("en")] +public class ToStringTests { - [UseCulture("en")] - public class ToStringTests - { - [Fact] - public void ReturnsLargestMetricSuffix() => - Assert.Equal("10.5 KB", ByteSize.FromKilobytes(10.5).ToString()); + [Fact] + public void ReturnsLargestMetricSuffix() => + Assert.Equal("10.5 KB", ByteSize.FromKilobytes(10.5).ToString()); - [Fact] - public void ReturnsDefaultNumberFormat() - { + [Fact] + public void ReturnsDefaultNumberFormat() + { Assert.Equal("10.5 KB", ByteSize.FromKilobytes(10.501).ToString()); Assert.Equal("10.5 KB", ByteSize.FromKilobytes(10.5).ToString("KB")); } - [Fact] - public void ReturnsProvidedNumberFormat() => - Assert.Equal("10.1234 KB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); + [Fact] + public void ReturnsProvidedNumberFormat() => + Assert.Equal("10.1234 KB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); - [Fact] - public void ReturnsBits() => - Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); + [Fact] + public void ReturnsBits() => + Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); - [Fact] - public void ReturnsBytes() => - Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B")); + [Fact] + public void ReturnsBytes() => + Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B")); - [Fact] - public void ReturnsKilobytes() => - Assert.Equal("10 KB", ByteSize.FromKilobytes(10).ToString("##.#### KB")); + [Fact] + public void ReturnsKilobytes() => + Assert.Equal("10 KB", ByteSize.FromKilobytes(10).ToString("##.#### KB")); - [Fact] - public void ReturnsMegabytes() => - Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB")); + [Fact] + public void ReturnsMegabytes() => + Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB")); - [Fact] - public void ReturnsGigabytes() => - Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB")); + [Fact] + public void ReturnsGigabytes() => + Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB")); - [Fact] - public void ReturnsTerabytes() => - Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB")); + [Fact] + public void ReturnsTerabytes() => + Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB")); - [Fact] - public void ReturnsSelectedFormat() => - Assert.Equal("10.0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB")); + [Fact] + public void ReturnsSelectedFormat() => + Assert.Equal("10.0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB")); - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZero() => - Assert.Equal("512 KB", ByteSize.FromMegabytes(.5).ToString("#.#")); + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZero() => + Assert.Equal("512 KB", ByteSize.FromMegabytes(.5).ToString("#.#")); - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => - Assert.Equal("-512 KB", ByteSize.FromMegabytes(-.5).ToString("#.#")); + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => + Assert.Equal("-512 KB", ByteSize.FromMegabytes(-.5).ToString("#.#")); - [Fact] - public void ReturnsBytesViaGeneralFormat() => - Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}"); - } -} + [Fact] + public void ReturnsBytesViaGeneralFormat() => + Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}"); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/CasingTests.cs b/src/Humanizer.Tests/CasingTests.cs index 1fabe8436..b70bcef12 100644 --- a/src/Humanizer.Tests/CasingTests.cs +++ b/src/Humanizer.Tests/CasingTests.cs @@ -1,36 +1,35 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class CasingTests { - public class CasingTests - { - [Theory] - [InlineData("lower case statement", "Lower Case Statement")] - [InlineData("Sentence casing", "Sentence Casing")] - [InlineData("honors UPPER case", "Honors UPPER Case")] - [InlineData("Title Case", "Title Case")] - [InlineData("title case (with parenthesis)", "Title Case (With Parenthesis)")] - public void ApplyCaseTitle(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.Title)); + [Theory] + [InlineData("lower case statement", "Lower Case Statement")] + [InlineData("Sentence casing", "Sentence Casing")] + [InlineData("honors UPPER case", "Honors UPPER Case")] + [InlineData("Title Case", "Title Case")] + [InlineData("title case (with parenthesis)", "Title Case (With Parenthesis)")] + public void ApplyCaseTitle(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.Title)); - [Theory] - [InlineData("lower case statement", "lower case statement")] - [InlineData("Sentence casing", "sentence casing")] - [InlineData("No honor for UPPER case", "no honor for upper case")] - [InlineData("Title Case", "title case")] - public void ApplyCaseLower(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.LowerCase)); + [Theory] + [InlineData("lower case statement", "lower case statement")] + [InlineData("Sentence casing", "sentence casing")] + [InlineData("No honor for UPPER case", "no honor for upper case")] + [InlineData("Title Case", "title case")] + public void ApplyCaseLower(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.LowerCase)); - [Theory] - [InlineData("lower case statement", "Lower case statement")] - [InlineData("Sentence casing", "Sentence casing")] - [InlineData("honors UPPER case", "Honors UPPER case")] - public void ApplyCaseSentence(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.Sentence)); + [Theory] + [InlineData("lower case statement", "Lower case statement")] + [InlineData("Sentence casing", "Sentence casing")] + [InlineData("honors UPPER case", "Honors UPPER case")] + public void ApplyCaseSentence(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.Sentence)); - [Theory] - [InlineData("lower case statement", "LOWER CASE STATEMENT")] - [InlineData("Sentence casing", "SENTENCE CASING")] - [InlineData("Title Case", "TITLE CASE")] - public void ApplyCaseAllCaps(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.AllCaps)); - } -} + [Theory] + [InlineData("lower case statement", "LOWER CASE STATEMENT")] + [InlineData("Sentence casing", "SENTENCE CASING")] + [InlineData("Title Case", "TITLE CASE")] + public void ApplyCaseAllCaps(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.ApplyCase(LetterCasing.AllCaps)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/CollectionHumanizeTests.cs b/src/Humanizer.Tests/CollectionHumanizeTests.cs index 51a12e29d..25d4d1e4a 100644 --- a/src/Humanizer.Tests/CollectionHumanizeTests.cs +++ b/src/Humanizer.Tests/CollectionHumanizeTests.cs @@ -1,131 +1,130 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class SomeClass +{ + public string? SomeString; + public int SomeInt; + public override string ToString() => + "ToString"; +} + +[UseCulture("en")] +public class CollectionHumanizeTests { - public class SomeClass + [Fact] + public void HumanizeReturnsOnlyNameWhenCollectionContainsOneItem() { - public string? SomeString; - public int SomeInt; - public override string ToString() => - "ToString"; + var collection = new List { "A String" }; + + Assert.Equal("A String", collection.Humanize()); } - [UseCulture("en")] - public class CollectionHumanizeTests + [Fact] + public void HumanizeUsesSeparatorWhenMoreThanOneItemIsInCollection() { - [Fact] - public void HumanizeReturnsOnlyNameWhenCollectionContainsOneItem() + var collection = new List { - var collection = new List { "A String" }; + "A String", + "Another String", + }; - Assert.Equal("A String", collection.Humanize()); - } + Assert.Equal("A String or Another String", collection.Humanize("or")); + } - [Fact] - public void HumanizeUsesSeparatorWhenMoreThanOneItemIsInCollection() + [Fact] + public void HumanizeDefaultsSeparatorToAnd() + { + var collection = new List { - var collection = new List - { - "A String", - "Another String", - }; + "A String", + "Another String", + }; - Assert.Equal("A String or Another String", collection.Humanize("or")); - } + Assert.Equal("A String and Another String", collection.Humanize()); + } - [Fact] - public void HumanizeDefaultsSeparatorToAnd() + [Fact] + public void HumanizeUsesOxfordComma() + { + var collection = new List { - var collection = new List - { - "A String", - "Another String", - }; + "A String", + "Another String", + "A Third String", + }; - Assert.Equal("A String and Another String", collection.Humanize()); - } + Assert.Equal("A String, Another String, or A Third String", collection.Humanize("or")); + } - [Fact] - public void HumanizeUsesOxfordComma() - { - var collection = new List - { - "A String", - "Another String", - "A Third String", - }; - - Assert.Equal("A String, Another String, or A Third String", collection.Humanize("or")); - } - - readonly List _testCollection = - [ - new() { SomeInt = 1, SomeString = "One" }, - new() { SomeInt = 2, SomeString = "Two" }, - new() { SomeInt = 3, SomeString = "Three" } - ]; - - [Fact] - public void HumanizeDefaultsToToString() => - Assert.Equal("ToString, ToString, or ToString", _testCollection.Humanize("or")); - - [Fact] - public void HumanizeUsesStringDisplayFormatter() - { - var humanized = _testCollection.Humanize(sc => $"SomeObject #{sc.SomeInt} - {sc.SomeString}"); - Assert.Equal("SomeObject #1 - One, SomeObject #2 - Two, and SomeObject #3 - Three", humanized); - } + readonly List _testCollection = + [ + new() { SomeInt = 1, SomeString = "One" }, + new() { SomeInt = 2, SomeString = "Two" }, + new() { SomeInt = 3, SomeString = "Three" } + ]; - [Fact] - public void HumanizeUsesObjectDisplayFormatter() - { - var humanized = _testCollection.Humanize(sc => sc.SomeInt); - Assert.Equal("1, 2, and 3", humanized); - } + [Fact] + public void HumanizeDefaultsToToString() => + Assert.Equal("ToString, ToString, or ToString", _testCollection.Humanize("or")); - [Fact] - public void HumanizeUsesStringDisplayFormatterWhenSeparatorIsProvided() - { - var humanized = _testCollection.Humanize(sc => $"SomeObject #{sc.SomeInt} - {sc.SomeString}", "or"); - Assert.Equal("SomeObject #1 - One, SomeObject #2 - Two, or SomeObject #3 - Three", humanized); - } + [Fact] + public void HumanizeUsesStringDisplayFormatter() + { + var humanized = _testCollection.Humanize(sc => $"SomeObject #{sc.SomeInt} - {sc.SomeString}"); + Assert.Equal("SomeObject #1 - One, SomeObject #2 - Two, and SomeObject #3 - Three", humanized); + } - [Fact] - public void HumanizeUsesObjectDisplayFormatterWhenSeparatorIsProvided() - { - var humanized = _testCollection.Humanize(sc => sc.SomeInt, "or"); - Assert.Equal("1, 2, or 3", humanized); - } - - [Fact] - public void HumanizeHandlesNullItemsWithoutAnException() => - Assert.Null(Record.Exception(() => new object?[] { null, null }.Humanize())); - - [Fact] - public void HumanizeHandlesNullStringDisplayFormatterReturnsWithoutAnException() => - Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => null!))); - - [Fact] - public void HumanizeHandlesNullObjectDisplayFormatterReturnsWithoutAnException() => - Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => (object)null!))); - - [Fact] - public void HumanizeRunsStringDisplayFormatterOnNulls() => - Assert.Equal("1, (null), and 3", new int?[] { 1, null, 3 }.Humanize(_ => _?.ToString() ?? "(null)")); - - [Fact] - public void HumanizeRunsObjectDisplayFormatterOnNulls() => - Assert.Equal("1, 2, and 3", new int?[] { 1, null, 3 }.Humanize(_ => _ ?? 2)); - - [Fact] - public void HumanizeRemovesEmptyItemsByDefault() => - Assert.Equal("A and C", new[] { "A", " ", "C" }.Humanize(dummyFormatter)); - - [Fact] - public void HumanizeTrimsItemsByDefault() => - Assert.Equal("A, B, and C", new[] { "A", " B ", "C" }.Humanize(dummyFormatter)); - - /// - /// Use the dummy formatter to ensure tests are testing formatter output rather than input - /// - static readonly Func dummyFormatter = input => input; + [Fact] + public void HumanizeUsesObjectDisplayFormatter() + { + var humanized = _testCollection.Humanize(sc => sc.SomeInt); + Assert.Equal("1, 2, and 3", humanized); + } + + [Fact] + public void HumanizeUsesStringDisplayFormatterWhenSeparatorIsProvided() + { + var humanized = _testCollection.Humanize(sc => $"SomeObject #{sc.SomeInt} - {sc.SomeString}", "or"); + Assert.Equal("SomeObject #1 - One, SomeObject #2 - Two, or SomeObject #3 - Three", humanized); } + + [Fact] + public void HumanizeUsesObjectDisplayFormatterWhenSeparatorIsProvided() + { + var humanized = _testCollection.Humanize(sc => sc.SomeInt, "or"); + Assert.Equal("1, 2, or 3", humanized); + } + + [Fact] + public void HumanizeHandlesNullItemsWithoutAnException() => + Assert.Null(Record.Exception(() => new object?[] { null, null }.Humanize())); + + [Fact] + public void HumanizeHandlesNullStringDisplayFormatterReturnsWithoutAnException() => + Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => null!))); + + [Fact] + public void HumanizeHandlesNullObjectDisplayFormatterReturnsWithoutAnException() => + Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => (object)null!))); + + [Fact] + public void HumanizeRunsStringDisplayFormatterOnNulls() => + Assert.Equal("1, (null), and 3", new int?[] { 1, null, 3 }.Humanize(_ => _?.ToString() ?? "(null)")); + + [Fact] + public void HumanizeRunsObjectDisplayFormatterOnNulls() => + Assert.Equal("1, 2, and 3", new int?[] { 1, null, 3 }.Humanize(_ => _ ?? 2)); + + [Fact] + public void HumanizeRemovesEmptyItemsByDefault() => + Assert.Equal("A and C", new[] { "A", " ", "C" }.Humanize(dummyFormatter)); + + [Fact] + public void HumanizeTrimsItemsByDefault() => + Assert.Equal("A, B, and C", new[] { "A", " B ", "C" }.Humanize(dummyFormatter)); + + /// + /// Use the dummy formatter to ensure tests are testing formatter output rather than input + /// + static readonly Func dummyFormatter = input => input; } \ No newline at end of file diff --git a/src/Humanizer.Tests/DateHumanize.cs b/src/Humanizer.Tests/DateHumanize.cs index c06b91d6a..0897f6ff2 100644 --- a/src/Humanizer.Tests/DateHumanize.cs +++ b/src/Humanizer.Tests/DateHumanize.cs @@ -1,11 +1,11 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class DateHumanize { - public class DateHumanize - { - static readonly object LockObject = new(); + static readonly object LockObject = new(); - static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow, CultureInfo? culture) - { + static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow, CultureInfo? culture) + { var utcNow = DateTime.UtcNow; var localNow = DateTime.Now; @@ -13,16 +13,16 @@ static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow, VerifyWithDate(expectedString, deltaFromNow, culture, localNow, utcNow); } - static void VerifyWithDateInjection(string expectedString, TimeSpan deltaFromNow, CultureInfo? culture) - { + static void VerifyWithDateInjection(string expectedString, TimeSpan deltaFromNow, CultureInfo? culture) + { var utcNow = new DateTime(2013, 6, 20, 9, 58, 22, DateTimeKind.Utc); var now = new DateTime(2013, 6, 20, 11, 58, 22, DateTimeKind.Local); VerifyWithDate(expectedString, deltaFromNow, culture, now, utcNow); } - static void VerifyWithDate(string expectedString, TimeSpan deltaFromBase, CultureInfo? culture, DateTime baseDate, DateTime baseDateUtc) - { + static void VerifyWithDate(string expectedString, TimeSpan deltaFromBase, CultureInfo? culture, DateTime baseDate, DateTime baseDateUtc) + { Assert.Equal(expectedString, baseDateUtc.Add(deltaFromBase).Humanize(utcDate: true, dateToCompareAgainst: baseDateUtc, culture: culture)); Assert.Equal(expectedString, baseDate.Add(deltaFromBase).Humanize(false, baseDate, culture: culture)); @@ -31,8 +31,8 @@ static void VerifyWithDate(string expectedString, TimeSpan deltaFromBase, Cultur Assert.Equal(expectedString, baseDate.Add(deltaFromBase).Humanize(null, baseDate, culture: culture)); } - public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense, double? precision = null, CultureInfo? culture = null, DateTime? baseDate = null, DateTime? baseDateUtc = null) - { + public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense, double? precision = null, CultureInfo? culture = null, DateTime? baseDate = null, DateTime? baseDateUtc = null) + { // We lock this as these tests can be multi-threaded and we're setting a static lock (LockObject) { @@ -89,5 +89,4 @@ public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Te } } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/DateHumanizeDefaultStrategyTests.cs b/src/Humanizer.Tests/DateHumanizeDefaultStrategyTests.cs index 7a248257f..c7f0f86ed 100644 --- a/src/Humanizer.Tests/DateHumanizeDefaultStrategyTests.cs +++ b/src/Humanizer.Tests/DateHumanizeDefaultStrategyTests.cs @@ -1,67 +1,67 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class DateHumanizeDefaultStrategyTests { - [UseCulture("en-US")] - public class DateHumanizeDefaultStrategyTests + [Theory] + [InlineData(1, "one second ago")] + [InlineData(10, "10 seconds ago")] + [InlineData(59, "59 seconds ago")] + [InlineData(60, "a minute ago")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + + [Theory] + [InlineData(1, "one second from now")] + [InlineData(10, "10 seconds from now")] + [InlineData(59, "59 seconds from now")] + [InlineData(60, "a minute from now")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + + [Theory] + [InlineData(1, "a minute ago")] + [InlineData(10, "10 minutes ago")] + [InlineData(44, "44 minutes ago")] + [InlineData(45, "45 minutes ago")] + [InlineData(59, "59 minutes ago")] + [InlineData(60, "an hour ago")] + [InlineData(119, "an hour ago")] + [InlineData(120, "2 hours ago")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + + [Theory] + [InlineData(1, "a minute from now")] + [InlineData(10, "10 minutes from now")] + [InlineData(44, "44 minutes from now")] + [InlineData(45, "45 minutes from now")] + [InlineData(119, "an hour from now")] + [InlineData(120, "2 hours from now")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + + [Theory] + [InlineData(1, "an hour ago")] + [InlineData(10, "10 hours ago")] + [InlineData(23, "23 hours ago")] + [InlineData(24, "yesterday")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + + [Theory] + [InlineData(1, "an hour from now")] + [InlineData(10, "10 hours from now")] + [InlineData(23, "23 hours from now")] + [InlineData(24, "tomorrow")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + + [Theory] + [InlineData(38, "tomorrow")] + [InlineData(40, "2 days from now")] + public void HoursFromNowNotTomorrow(int hours, string expected) { - [Theory] - [InlineData(1, "one second ago")] - [InlineData(10, "10 seconds ago")] - [InlineData(59, "59 seconds ago")] - [InlineData(60, "a minute ago")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - - [Theory] - [InlineData(1, "one second from now")] - [InlineData(10, "10 seconds from now")] - [InlineData(59, "59 seconds from now")] - [InlineData(60, "a minute from now")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - - [Theory] - [InlineData(1, "a minute ago")] - [InlineData(10, "10 minutes ago")] - [InlineData(44, "44 minutes ago")] - [InlineData(45, "45 minutes ago")] - [InlineData(59, "59 minutes ago")] - [InlineData(60, "an hour ago")] - [InlineData(119, "an hour ago")] - [InlineData(120, "2 hours ago")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - - [Theory] - [InlineData(1, "a minute from now")] - [InlineData(10, "10 minutes from now")] - [InlineData(44, "44 minutes from now")] - [InlineData(45, "45 minutes from now")] - [InlineData(119, "an hour from now")] - [InlineData(120, "2 hours from now")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - - [Theory] - [InlineData(1, "an hour ago")] - [InlineData(10, "10 hours ago")] - [InlineData(23, "23 hours ago")] - [InlineData(24, "yesterday")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - - [Theory] - [InlineData(1, "an hour from now")] - [InlineData(10, "10 hours from now")] - [InlineData(23, "23 hours from now")] - [InlineData(24, "tomorrow")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - - [Theory] - [InlineData(38, "tomorrow")] - [InlineData(40, "2 days from now")] - public void HoursFromNowNotTomorrow(int hours, string expected) - { //Only test with injected date, as results are dependent on time of day var utcNow = new DateTime(2014, 6, 28, 9, 58, 22, DateTimeKind.Utc); var now = new DateTime(2014, 6, 28, 9, 58, 22, DateTimeKind.Local); @@ -69,74 +69,73 @@ public void HoursFromNowNotTomorrow(int hours, string expected) DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future, null, null, now, utcNow); } - [Theory] - [InlineData(1, "yesterday")] - [InlineData(10, "10 days ago")] - [InlineData(27, "27 days ago")] - [InlineData(32, "one month ago")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - - [Theory] - [InlineData(1, "tomorrow")] - [InlineData(10, "10 days from now")] - [InlineData(27, "27 days from now")] - [InlineData(32, "one month from now")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - - [Theory] - [InlineData(1, "one month ago")] - [InlineData(10, "10 months ago")] - [InlineData(11, "11 months ago")] - [InlineData(12, "one year ago")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - - [Theory] - [InlineData(1, "one month from now")] - [InlineData(10, "10 months from now")] - [InlineData(11, "11 months from now")] - [InlineData(12, "one year from now")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - - [Theory] - [InlineData(1, "one year ago")] - [InlineData(2, "2 years ago")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - - [Theory] - [InlineData(1, "one year from now")] - [InlineData(2, "2 years from now")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - - [Fact] - public void Now() => - DateHumanize.Verify("now", 0, TimeUnit.Year, Tense.Future); - - [Fact] - public void Never() - { + [Theory] + [InlineData(1, "yesterday")] + [InlineData(10, "10 days ago")] + [InlineData(27, "27 days ago")] + [InlineData(32, "one month ago")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + + [Theory] + [InlineData(1, "tomorrow")] + [InlineData(10, "10 days from now")] + [InlineData(27, "27 days from now")] + [InlineData(32, "one month from now")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + + [Theory] + [InlineData(1, "one month ago")] + [InlineData(10, "10 months ago")] + [InlineData(11, "11 months ago")] + [InlineData(12, "one year ago")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + + [Theory] + [InlineData(1, "one month from now")] + [InlineData(10, "10 months from now")] + [InlineData(11, "11 months from now")] + [InlineData(12, "one year from now")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + + [Theory] + [InlineData(1, "one year ago")] + [InlineData(2, "2 years ago")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + + [Theory] + [InlineData(1, "one year from now")] + [InlineData(2, "2 years from now")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + + [Fact] + public void Now() => + DateHumanize.Verify("now", 0, TimeUnit.Year, Tense.Future); + + [Fact] + public void Never() + { DateTime? never = null; Assert.Equal("never", never.Humanize()); } - [Fact] - public void Nullable_ExpectSame() - { + [Fact] + public void Nullable_ExpectSame() + { DateTime? never = new DateTime(2015, 12, 7, 9, 0, 0); Assert.Equal(never.Value.Humanize(), never.Humanize()); } - [Theory] - [InlineData(1, TimeUnit.Year, Tense.Future, "en-US", "one year from now")] - [InlineData(40, TimeUnit.Second, Tense.Past, "ru-RU", "40 секунд назад")] - [InlineData(2, TimeUnit.Day, Tense.Past, "sv-SE", "för 2 dagar sedan")] - public void CanSpecifyCultureExplicitly(int unit, TimeUnit timeUnit, Tense tense, string culture, string expected) => - DateHumanize.Verify(expected, unit, timeUnit, tense, culture: new(culture)); - } -} + [Theory] + [InlineData(1, TimeUnit.Year, Tense.Future, "en-US", "one year from now")] + [InlineData(40, TimeUnit.Second, Tense.Past, "ru-RU", "40 секунд назад")] + [InlineData(2, TimeUnit.Day, Tense.Past, "sv-SE", "för 2 dagar sedan")] + public void CanSpecifyCultureExplicitly(int unit, TimeUnit timeUnit, Tense tense, string culture, string expected) => + DateHumanize.Verify(expected, unit, timeUnit, tense, culture: new(culture)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/DateTimeHumanizePrecisionStrategyTests.cs b/src/Humanizer.Tests/DateTimeHumanizePrecisionStrategyTests.cs index 608b9047e..4ec2f2f79 100644 --- a/src/Humanizer.Tests/DateTimeHumanizePrecisionStrategyTests.cs +++ b/src/Humanizer.Tests/DateTimeHumanizePrecisionStrategyTests.cs @@ -1,159 +1,158 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class DateTimeHumanizePrecisionStrategyTests { - [UseCulture("en-US")] - public class DateTimeHumanizePrecisionStrategyTests - { - const double DefaultPrecision = .75; + const double DefaultPrecision = .75; - [Theory] - [InlineData(1, "now")] - [InlineData(749, "now")] - [InlineData(750, "one second ago")] - [InlineData(1000, "one second ago")] - [InlineData(1749, "one second ago")] - [InlineData(1750, "2 seconds ago")] - public void MillisecondsAgo(int milliseconds, string expected) => - DateHumanize.Verify(expected, milliseconds, TimeUnit.Millisecond, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "now")] + [InlineData(749, "now")] + [InlineData(750, "one second ago")] + [InlineData(1000, "one second ago")] + [InlineData(1749, "one second ago")] + [InlineData(1750, "2 seconds ago")] + public void MillisecondsAgo(int milliseconds, string expected) => + DateHumanize.Verify(expected, milliseconds, TimeUnit.Millisecond, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "now")] - [InlineData(749, "now")] - [InlineData(750, "one second from now")] - [InlineData(1000, "one second from now")] - [InlineData(1749, "one second from now")] - [InlineData(1750, "2 seconds from now")] - public void MillisecondsFromNow(int milliseconds, string expected) => - DateHumanize.Verify(expected, milliseconds, TimeUnit.Millisecond, Tense.Future, DefaultPrecision); + [Theory] + [InlineData(1, "now")] + [InlineData(749, "now")] + [InlineData(750, "one second from now")] + [InlineData(1000, "one second from now")] + [InlineData(1749, "one second from now")] + [InlineData(1750, "2 seconds from now")] + public void MillisecondsFromNow(int milliseconds, string expected) => + DateHumanize.Verify(expected, milliseconds, TimeUnit.Millisecond, Tense.Future, DefaultPrecision); - [Theory] - [InlineData(1, "one second ago")] - [InlineData(10, "10 seconds ago")] - [InlineData(44, "44 seconds ago")] - [InlineData(45, "a minute ago")] - [InlineData(60, "a minute ago")] - [InlineData(104, "a minute ago")] - [InlineData(105, "2 minutes ago")] - [InlineData(120, "2 minutes ago")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "one second ago")] + [InlineData(10, "10 seconds ago")] + [InlineData(44, "44 seconds ago")] + [InlineData(45, "a minute ago")] + [InlineData(60, "a minute ago")] + [InlineData(104, "a minute ago")] + [InlineData(105, "2 minutes ago")] + [InlineData(120, "2 minutes ago")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "one second from now")] - [InlineData(10, "10 seconds from now")] - [InlineData(44, "44 seconds from now")] - [InlineData(45, "a minute from now")] - [InlineData(60, "a minute from now")] - [InlineData(104, "a minute from now")] - [InlineData(105, "2 minutes from now")] - [InlineData(120, "2 minutes from now")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future, DefaultPrecision); + [Theory] + [InlineData(1, "one second from now")] + [InlineData(10, "10 seconds from now")] + [InlineData(44, "44 seconds from now")] + [InlineData(45, "a minute from now")] + [InlineData(60, "a minute from now")] + [InlineData(104, "a minute from now")] + [InlineData(105, "2 minutes from now")] + [InlineData(120, "2 minutes from now")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future, DefaultPrecision); - [Theory] - [InlineData(1, "a minute ago")] - [InlineData(10, "10 minutes ago")] - [InlineData(44, "44 minutes ago")] - [InlineData(45, "an hour ago")] - [InlineData(60, "an hour ago")] - [InlineData(104, "an hour ago")] - [InlineData(105, "2 hours ago")] - [InlineData(120, "2 hours ago")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "a minute ago")] + [InlineData(10, "10 minutes ago")] + [InlineData(44, "44 minutes ago")] + [InlineData(45, "an hour ago")] + [InlineData(60, "an hour ago")] + [InlineData(104, "an hour ago")] + [InlineData(105, "2 hours ago")] + [InlineData(120, "2 hours ago")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "a minute from now")] - [InlineData(10, "10 minutes from now")] - [InlineData(44, "44 minutes from now")] - [InlineData(45, "an hour from now")] - [InlineData(60, "an hour from now")] - [InlineData(104, "an hour from now")] - [InlineData(105, "2 hours from now")] - [InlineData(120, "2 hours from now")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future, DefaultPrecision); + [Theory] + [InlineData(1, "a minute from now")] + [InlineData(10, "10 minutes from now")] + [InlineData(44, "44 minutes from now")] + [InlineData(45, "an hour from now")] + [InlineData(60, "an hour from now")] + [InlineData(104, "an hour from now")] + [InlineData(105, "2 hours from now")] + [InlineData(120, "2 hours from now")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future, DefaultPrecision); - [Theory] - [InlineData(1, "an hour ago")] - [InlineData(10, "10 hours ago")] - [InlineData(17, "17 hours ago")] - [InlineData(18, "yesterday")] - [InlineData(24, "yesterday")] - [InlineData(41, "yesterday")] - [InlineData(42, "2 days ago")] - [InlineData(48, "2 days ago")] - [InlineData(60, "2 days ago")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "an hour ago")] + [InlineData(10, "10 hours ago")] + [InlineData(17, "17 hours ago")] + [InlineData(18, "yesterday")] + [InlineData(24, "yesterday")] + [InlineData(41, "yesterday")] + [InlineData(42, "2 days ago")] + [InlineData(48, "2 days ago")] + [InlineData(60, "2 days ago")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "an hour from now")] - [InlineData(10, "10 hours from now")] - [InlineData(18, "tomorrow")] - [InlineData(24, "tomorrow")] - [InlineData(41, "tomorrow")] - [InlineData(42, "2 days from now")] - [InlineData(48, "2 days from now")] - [InlineData(60, "2 days from now")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future, DefaultPrecision); + [Theory] + [InlineData(1, "an hour from now")] + [InlineData(10, "10 hours from now")] + [InlineData(18, "tomorrow")] + [InlineData(24, "tomorrow")] + [InlineData(41, "tomorrow")] + [InlineData(42, "2 days from now")] + [InlineData(48, "2 days from now")] + [InlineData(60, "2 days from now")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future, DefaultPrecision); - [Theory] - [InlineData(1, "yesterday")] - [InlineData(10, "10 days ago")] - [InlineData(20, "20 days ago")] - [InlineData(22, "22 days ago")] - [InlineData(23, "one month ago")] - [InlineData(31, "one month ago")] - [InlineData(43, "one month ago")] - [InlineData(53, "2 months ago")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "yesterday")] + [InlineData(10, "10 days ago")] + [InlineData(20, "20 days ago")] + [InlineData(22, "22 days ago")] + [InlineData(23, "one month ago")] + [InlineData(31, "one month ago")] + [InlineData(43, "one month ago")] + [InlineData(53, "2 months ago")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "tomorrow")] - [InlineData(10, "10 days from now")] - [InlineData(20, "20 days from now")] - [InlineData(22, "22 days from now")] - [InlineData(23, "one month from now")] - [InlineData(31, "one month from now")] - [InlineData(43, "one month from now")] - [InlineData(53, "2 months from now")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future, DefaultPrecision); + [Theory] + [InlineData(1, "tomorrow")] + [InlineData(10, "10 days from now")] + [InlineData(20, "20 days from now")] + [InlineData(22, "22 days from now")] + [InlineData(23, "one month from now")] + [InlineData(31, "one month from now")] + [InlineData(43, "one month from now")] + [InlineData(53, "2 months from now")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future, DefaultPrecision); - [Theory] - [InlineData(1, "one month ago")] - [InlineData(8, "8 months ago")] - [InlineData(9, "one year ago")] - [InlineData(12, "one year ago")] - [InlineData(19, "one year ago")] - [InlineData(21, "2 years ago")] - [InlineData(24, "2 years ago")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "one month ago")] + [InlineData(8, "8 months ago")] + [InlineData(9, "one year ago")] + [InlineData(12, "one year ago")] + [InlineData(19, "one year ago")] + [InlineData(21, "2 years ago")] + [InlineData(24, "2 years ago")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "one month from now")] - [InlineData(8, "8 months from now")] - [InlineData(9, "one year from now")] - [InlineData(12, "one year from now")] - [InlineData(19, "one year from now")] - [InlineData(21, "2 years from now")] - [InlineData(24, "2 years from now")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future, DefaultPrecision); + [Theory] + [InlineData(1, "one month from now")] + [InlineData(8, "8 months from now")] + [InlineData(9, "one year from now")] + [InlineData(12, "one year from now")] + [InlineData(19, "one year from now")] + [InlineData(21, "2 years from now")] + [InlineData(24, "2 years from now")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future, DefaultPrecision); - [Theory] - [InlineData(1, "one year ago")] - [InlineData(2, "2 years ago")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past, DefaultPrecision); + [Theory] + [InlineData(1, "one year ago")] + [InlineData(2, "2 years ago")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past, DefaultPrecision); - [Theory] - [InlineData(1, "one year from now")] - [InlineData(2, "2 years from now")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future, DefaultPrecision); - } -} + [Theory] + [InlineData(1, "one year from now")] + [InlineData(2, "2 years from now")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future, DefaultPrecision); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/DateTimeOffsetHumanizeTests.cs b/src/Humanizer.Tests/DateTimeOffsetHumanizeTests.cs index e0b647658..f1abab918 100644 --- a/src/Humanizer.Tests/DateTimeOffsetHumanizeTests.cs +++ b/src/Humanizer.Tests/DateTimeOffsetHumanizeTests.cs @@ -1,77 +1,76 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class DateTimeOffsetHumanizeTests { - [UseCulture("en-US")] - public class DateTimeOffsetHumanizeTests + [Fact] + public void DefaultStrategy_SameOffset() { - [Fact] - public void DefaultStrategy_SameOffset() - { - Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy(); + Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy(); - var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero); - var baseTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, TimeSpan.Zero); + var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero); + var baseTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, TimeSpan.Zero); - const string expectedResult = "an hour from now"; - var actualResult = inputTime.Humanize(baseTime); + const string expectedResult = "an hour from now"; + var actualResult = inputTime.Humanize(baseTime); - Assert.Equal(expectedResult, actualResult); - } + Assert.Equal(expectedResult, actualResult); + } - [Fact] - public void DefaultStrategy_DifferentOffsets() - { - Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy(); + [Fact] + public void DefaultStrategy_DifferentOffsets() + { + Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy(); - var inputTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, new(2, 0, 0)); - var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new(1, 0, 0)); + var inputTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, new(2, 0, 0)); + var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new(1, 0, 0)); - const string expectedResult = "30 minutes ago"; - var actualResult = inputTime.Humanize(baseTime); + const string expectedResult = "30 minutes ago"; + var actualResult = inputTime.Humanize(baseTime); - Assert.Equal(expectedResult, actualResult); - } + Assert.Equal(expectedResult, actualResult); + } - [Fact] - public void PrecisionStrategy_SameOffset() - { - Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75); + [Fact] + public void PrecisionStrategy_SameOffset() + { + Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75); - var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero); - var baseTime = new DateTimeOffset(2015, 07, 04, 05, 0, 0, TimeSpan.Zero); + var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero); + var baseTime = new DateTimeOffset(2015, 07, 04, 05, 0, 0, TimeSpan.Zero); - const string expectedResult = "tomorrow"; - var actualResult = inputTime.Humanize(baseTime); + const string expectedResult = "tomorrow"; + var actualResult = inputTime.Humanize(baseTime); - Assert.Equal(expectedResult, actualResult); - } + Assert.Equal(expectedResult, actualResult); + } - [Fact] - public void PrecisionStrategy_DifferentOffsets() - { - Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75); + [Fact] + public void PrecisionStrategy_DifferentOffsets() + { + Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75); - var inputTime = new DateTimeOffset(2015, 07, 05, 03, 45, 0, new(2, 0, 0)); - var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new(-5, 0, 0)); + var inputTime = new DateTimeOffset(2015, 07, 05, 03, 45, 0, new(2, 0, 0)); + var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new(-5, 0, 0)); - const string expectedResult = "6 hours ago"; - var actualResult = inputTime.Humanize(baseTime); + const string expectedResult = "6 hours ago"; + var actualResult = inputTime.Humanize(baseTime); - Assert.Equal(expectedResult, actualResult); - } + Assert.Equal(expectedResult, actualResult); + } - [Fact] - public void Never() - { - DateTimeOffset? never = null; - Assert.Equal("never", never.Humanize()); - } + [Fact] + public void Never() + { + DateTimeOffset? never = null; + Assert.Equal("never", never.Humanize()); + } - [Fact] - public void Nullable_ExpectSame() - { - DateTimeOffset? never = new DateTimeOffset(2015, 12, 7, 9, 0, 0, TimeSpan.FromHours(1)); + [Fact] + public void Nullable_ExpectSame() + { + DateTimeOffset? never = new DateTimeOffset(2015, 12, 7, 9, 0, 0, TimeSpan.FromHours(1)); - Assert.Equal(never.Value.Humanize(), never.Humanize()); - } + Assert.Equal(never.Value.Humanize(), never.Humanize()); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/FluentDate/InTests.cs b/src/Humanizer.Tests/FluentDate/InTests.cs index 868c40495..9152c1d11 100644 --- a/src/Humanizer.Tests/FluentDate/InTests.cs +++ b/src/Humanizer.Tests/FluentDate/InTests.cs @@ -1,113 +1,112 @@ -namespace Humanizer.Tests.FluentDate +namespace Humanizer.Tests.FluentDate; + +public class InTests { - public class InTests + [Fact] + public void InJanuary() => + Assert.Equal(new(DateTime.Now.Year, 1, 1), In.January); + + [Fact] + public void InJanuaryOf2009() => + Assert.Equal(new(2009, 1, 1), In.JanuaryOf(2009)); + + [Fact] + public void InFebruary() => + Assert.Equal(new(DateTime.Now.Year, 2, 1), In.February); + + [Fact] + public void InFebruaryOf2009() => + Assert.Equal(new(2009, 2, 1), In.FebruaryOf(2009)); + + [Fact] + public void InMarch() => + Assert.Equal(new(DateTime.Now.Year, 3, 1), In.March); + + [Fact] + public void InMarchOf2009() => + Assert.Equal(new(2009, 3, 1), In.MarchOf(2009)); + + [Fact] + public void InApril() => + Assert.Equal(new(DateTime.Now.Year, 4, 1), In.April); + + [Fact] + public void InAprilOf2009() => + Assert.Equal(new(2009, 4, 1), In.AprilOf(2009)); + + [Fact] + public void InMay() => + Assert.Equal(new(DateTime.Now.Year, 5, 1), In.May); + + [Fact] + public void InMayOf2009() => + Assert.Equal(new(2009, 5, 1), In.MayOf(2009)); + + [Fact] + public void InJune() => + Assert.Equal(new(DateTime.Now.Year, 6, 1), In.June); + + [Fact] + public void InJuneOf2009() => + Assert.Equal(new(2009, 6, 1), In.JuneOf(2009)); + + [Fact] + public void InJuly() => + Assert.Equal(new(DateTime.Now.Year, 7, 1), In.July); + + [Fact] + public void InJulyOf2009() => + Assert.Equal(new(2009, 7, 1), In.JulyOf(2009)); + + [Fact] + public void InAugust() => + Assert.Equal(new(DateTime.Now.Year, 8, 1), In.August); + + [Fact] + public void InAugustOf2009() => + Assert.Equal(new(2009, 8, 1), In.AugustOf(2009)); + + [Fact] + public void InSeptember() => + Assert.Equal(new(DateTime.Now.Year, 9, 1), In.September); + + [Fact] + public void InSeptemberOf2009() => + Assert.Equal(new(2009, 9, 1), In.SeptemberOf(2009)); + + [Fact] + public void InOctober() => + Assert.Equal(new(DateTime.Now.Year, 10, 1), In.October); + + [Fact] + public void InOctoberOfIn2009() => + Assert.Equal(new(2009, 10, 1), In.OctoberOf(2009)); + + [Fact] + public void InNovember() => + Assert.Equal(new(DateTime.Now.Year, 11, 1), In.November); + + [Fact] + public void InNovemberOf2009() => + Assert.Equal(new(2009, 11, 1), In.NovemberOf(2009)); + + [Fact] + public void InDecember() => + Assert.Equal(new(DateTime.Now.Year, 12, 1), In.December); + + [Fact] + public void InDecemberOf2009() => + Assert.Equal(new(2009, 12, 1), In.DecemberOf(2009)); + + [Fact] + public void InTheYear() => + Assert.Equal(new(2009, 1, 1), In.TheYear(2009)); + + [Fact] + public void InFiveDays() { - [Fact] - public void InJanuary() => - Assert.Equal(new(DateTime.Now.Year, 1, 1), In.January); - - [Fact] - public void InJanuaryOf2009() => - Assert.Equal(new(2009, 1, 1), In.JanuaryOf(2009)); - - [Fact] - public void InFebruary() => - Assert.Equal(new(DateTime.Now.Year, 2, 1), In.February); - - [Fact] - public void InFebruaryOf2009() => - Assert.Equal(new(2009, 2, 1), In.FebruaryOf(2009)); - - [Fact] - public void InMarch() => - Assert.Equal(new(DateTime.Now.Year, 3, 1), In.March); - - [Fact] - public void InMarchOf2009() => - Assert.Equal(new(2009, 3, 1), In.MarchOf(2009)); - - [Fact] - public void InApril() => - Assert.Equal(new(DateTime.Now.Year, 4, 1), In.April); - - [Fact] - public void InAprilOf2009() => - Assert.Equal(new(2009, 4, 1), In.AprilOf(2009)); - - [Fact] - public void InMay() => - Assert.Equal(new(DateTime.Now.Year, 5, 1), In.May); - - [Fact] - public void InMayOf2009() => - Assert.Equal(new(2009, 5, 1), In.MayOf(2009)); - - [Fact] - public void InJune() => - Assert.Equal(new(DateTime.Now.Year, 6, 1), In.June); - - [Fact] - public void InJuneOf2009() => - Assert.Equal(new(2009, 6, 1), In.JuneOf(2009)); - - [Fact] - public void InJuly() => - Assert.Equal(new(DateTime.Now.Year, 7, 1), In.July); - - [Fact] - public void InJulyOf2009() => - Assert.Equal(new(2009, 7, 1), In.JulyOf(2009)); - - [Fact] - public void InAugust() => - Assert.Equal(new(DateTime.Now.Year, 8, 1), In.August); - - [Fact] - public void InAugustOf2009() => - Assert.Equal(new(2009, 8, 1), In.AugustOf(2009)); - - [Fact] - public void InSeptember() => - Assert.Equal(new(DateTime.Now.Year, 9, 1), In.September); - - [Fact] - public void InSeptemberOf2009() => - Assert.Equal(new(2009, 9, 1), In.SeptemberOf(2009)); - - [Fact] - public void InOctober() => - Assert.Equal(new(DateTime.Now.Year, 10, 1), In.October); - - [Fact] - public void InOctoberOfIn2009() => - Assert.Equal(new(2009, 10, 1), In.OctoberOf(2009)); - - [Fact] - public void InNovember() => - Assert.Equal(new(DateTime.Now.Year, 11, 1), In.November); - - [Fact] - public void InNovemberOf2009() => - Assert.Equal(new(2009, 11, 1), In.NovemberOf(2009)); - - [Fact] - public void InDecember() => - Assert.Equal(new(DateTime.Now.Year, 12, 1), In.December); - - [Fact] - public void InDecemberOf2009() => - Assert.Equal(new(2009, 12, 1), In.DecemberOf(2009)); - - [Fact] - public void InTheYear() => - Assert.Equal(new(2009, 1, 1), In.TheYear(2009)); - - [Fact] - public void InFiveDays() - { - var baseDate = On.January.The21st; - var date = In.Five.DaysFrom(baseDate); - Assert.Equal(baseDate.AddDays(5), date); - } + var baseDate = On.January.The21st; + var date = In.Five.DaysFrom(baseDate); + Assert.Equal(baseDate.AddDays(5), date); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/FluentDate/OnTests.cs b/src/Humanizer.Tests/FluentDate/OnTests.cs index feb02e098..40269f169 100644 --- a/src/Humanizer.Tests/FluentDate/OnTests.cs +++ b/src/Humanizer.Tests/FluentDate/OnTests.cs @@ -1,17 +1,16 @@ -namespace Humanizer.Tests.FluentDate +namespace Humanizer.Tests.FluentDate; + +public class OnTests { - public class OnTests - { - [Fact] - public void OnJanuaryThe23rd() => - Assert.Equal(new(DateTime.Now.Year, 1, 23), On.January.The23rd); + [Fact] + public void OnJanuaryThe23rd() => + Assert.Equal(new(DateTime.Now.Year, 1, 23), On.January.The23rd); - [Fact] - public void OnDecemberThe4th() => - Assert.Equal(new(DateTime.Now.Year, 12, 4), On.December.The4th); + [Fact] + public void OnDecemberThe4th() => + Assert.Equal(new(DateTime.Now.Year, 12, 4), On.December.The4th); - [Fact] - public void OnFebruaryThe() => - Assert.Equal(new(DateTime.Now.Year, 2, 11), On.February.The(11)); - } -} + [Fact] + public void OnFebruaryThe() => + Assert.Equal(new(DateTime.Now.Year, 2, 11), On.February.The(11)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/FluentDate/PrepositionTests.cs b/src/Humanizer.Tests/FluentDate/PrepositionTests.cs index 79ab5f9cb..dd25cf37c 100644 --- a/src/Humanizer.Tests/FluentDate/PrepositionTests.cs +++ b/src/Humanizer.Tests/FluentDate/PrepositionTests.cs @@ -1,29 +1,28 @@ -namespace Humanizer.Tests.FluentDate +namespace Humanizer.Tests.FluentDate; + +public class PrepositionTests { - public class PrepositionTests + [Fact] + public void AtMidnight() { - [Fact] - public void AtMidnight() - { - var now = DateTime.Now; - var midnight = now.AtMidnight(); - Assert.Equal(new(now.Year, now.Month, now.Day), midnight); - } + var now = DateTime.Now; + var midnight = now.AtMidnight(); + Assert.Equal(new(now.Year, now.Month, now.Day), midnight); + } - [Fact] - public void AtNoon() - { - var now = DateTime.Now; - var noon = now.AtNoon(); - Assert.Equal(new(now.Year, now.Month, now.Day, 12, 0, 0), noon); - } + [Fact] + public void AtNoon() + { + var now = DateTime.Now; + var noon = now.AtNoon(); + Assert.Equal(new(now.Year, now.Month, now.Day, 12, 0, 0), noon); + } - [Fact] - public void InYear() - { - var now = DateTime.Now; - var in2011 = now.In(2011); - Assert.Equal(new(2011, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond), in2011); - } + [Fact] + public void InYear() + { + var now = DateTime.Now; + var in2011 = now.In(2011); + Assert.Equal(new(2011, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond), in2011); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/HeadingTests.cs b/src/Humanizer.Tests/HeadingTests.cs index 2d75d5857..91010380f 100644 --- a/src/Humanizer.Tests/HeadingTests.cs +++ b/src/Humanizer.Tests/HeadingTests.cs @@ -1,190 +1,189 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class HeadingTests { - [UseCulture("en-US")] - public class HeadingTests - { - [InlineData(0, "N")] - [InlineData(11.2, "N")] - [InlineData(11.3, "NNE")] - [InlineData(22.5, "NNE")] - [InlineData(33.7, "NNE")] - [InlineData(33.8, "NE")] - [InlineData(45, "NE")] - [InlineData(56.2, "NE")] - [InlineData(56.3, "ENE")] - [InlineData(67.5, "ENE")] - [InlineData(78.7, "ENE")] - [InlineData(78.8, "E")] - [InlineData(90, "E")] - [InlineData(101.2, "E")] - [InlineData(101.3, "ESE")] - [InlineData(112.5, "ESE")] - [InlineData(123.7, "ESE")] - [InlineData(123.8, "SE")] - [InlineData(135, "SE")] - [InlineData(146.2, "SE")] - [InlineData(146.3, "SSE")] - [InlineData(157.5, "SSE")] - [InlineData(168.7, "SSE")] - [InlineData(168.8, "S")] - [InlineData(180, "S")] - [InlineData(191.2, "S")] - [InlineData(191.3, "SSW")] - [InlineData(202.5, "SSW")] - [InlineData(213.7, "SSW")] - [InlineData(213.8, "SW")] - [InlineData(225, "SW")] - [InlineData(236.2, "SW")] - [InlineData(236.3, "WSW")] - [InlineData(247.5, "WSW")] - [InlineData(258.7, "WSW")] - [InlineData(258.8, "W")] - [InlineData(270, "W")] - [InlineData(281.2, "W")] - [InlineData(281.3, "WNW")] - [InlineData(292.5, "WNW")] - [InlineData(303.7, "WNW")] - [InlineData(303.8, "NW")] - [InlineData(315, "NW")] - [InlineData(326.2, "NW")] - [InlineData(326.3, "NNW")] - [InlineData(337.5, "NNW")] - [InlineData(348.7, "NNW")] - [InlineData(348.8, "N")] - [InlineData(360, "N")] - [InlineData(720, "N")] - [Theory] - public void ToHeadingAbbreviated(double heading, string expected) => - Assert.Equal(expected, heading.ToHeading()); + [InlineData(0, "N")] + [InlineData(11.2, "N")] + [InlineData(11.3, "NNE")] + [InlineData(22.5, "NNE")] + [InlineData(33.7, "NNE")] + [InlineData(33.8, "NE")] + [InlineData(45, "NE")] + [InlineData(56.2, "NE")] + [InlineData(56.3, "ENE")] + [InlineData(67.5, "ENE")] + [InlineData(78.7, "ENE")] + [InlineData(78.8, "E")] + [InlineData(90, "E")] + [InlineData(101.2, "E")] + [InlineData(101.3, "ESE")] + [InlineData(112.5, "ESE")] + [InlineData(123.7, "ESE")] + [InlineData(123.8, "SE")] + [InlineData(135, "SE")] + [InlineData(146.2, "SE")] + [InlineData(146.3, "SSE")] + [InlineData(157.5, "SSE")] + [InlineData(168.7, "SSE")] + [InlineData(168.8, "S")] + [InlineData(180, "S")] + [InlineData(191.2, "S")] + [InlineData(191.3, "SSW")] + [InlineData(202.5, "SSW")] + [InlineData(213.7, "SSW")] + [InlineData(213.8, "SW")] + [InlineData(225, "SW")] + [InlineData(236.2, "SW")] + [InlineData(236.3, "WSW")] + [InlineData(247.5, "WSW")] + [InlineData(258.7, "WSW")] + [InlineData(258.8, "W")] + [InlineData(270, "W")] + [InlineData(281.2, "W")] + [InlineData(281.3, "WNW")] + [InlineData(292.5, "WNW")] + [InlineData(303.7, "WNW")] + [InlineData(303.8, "NW")] + [InlineData(315, "NW")] + [InlineData(326.2, "NW")] + [InlineData(326.3, "NNW")] + [InlineData(337.5, "NNW")] + [InlineData(348.7, "NNW")] + [InlineData(348.8, "N")] + [InlineData(360, "N")] + [InlineData(720, "N")] + [Theory] + public void ToHeadingAbbreviated(double heading, string expected) => + Assert.Equal(expected, heading.ToHeading()); - [InlineData(0, "north")] - [InlineData(22.5, "north-northeast")] - [InlineData(45, "northeast")] - [InlineData(67.5, "east-northeast")] - [InlineData(90, "east")] - [InlineData(112.5, "east-southeast")] - [InlineData(135, "southeast")] - [InlineData(157.5, "south-southeast")] - [InlineData(180, "south")] - [InlineData(202.5, "south-southwest")] - [InlineData(225, "southwest")] - [InlineData(247.5, "west-southwest")] - [InlineData(270, "west")] - [InlineData(292.5, "west-northwest")] - [InlineData(315, "northwest")] - [InlineData(337.5, "north-northwest")] - [InlineData(360, "north")] - [InlineData(720, "north")] - [Theory] - public void ToHeading(double heading, string expected) => - Assert.Equal(expected, heading.ToHeading(HeadingStyle.Full)); + [InlineData(0, "north")] + [InlineData(22.5, "north-northeast")] + [InlineData(45, "northeast")] + [InlineData(67.5, "east-northeast")] + [InlineData(90, "east")] + [InlineData(112.5, "east-southeast")] + [InlineData(135, "southeast")] + [InlineData(157.5, "south-southeast")] + [InlineData(180, "south")] + [InlineData(202.5, "south-southwest")] + [InlineData(225, "southwest")] + [InlineData(247.5, "west-southwest")] + [InlineData(270, "west")] + [InlineData(292.5, "west-northwest")] + [InlineData(315, "northwest")] + [InlineData(337.5, "north-northwest")] + [InlineData(360, "north")] + [InlineData(720, "north")] + [Theory] + public void ToHeading(double heading, string expected) => + Assert.Equal(expected, heading.ToHeading(HeadingStyle.Full)); - [InlineData("N", 0)] - [InlineData("NNE", 22.5)] - [InlineData("NE", 45)] - [InlineData("ENE", 67.5)] - [InlineData("E", 90)] - [InlineData("ESE", 112.5)] - [InlineData("SE", 135)] - [InlineData("SSE", 157.5)] - [InlineData("S", 180)] - [InlineData("SSW", 202.5)] - [InlineData("SW", 225)] - [InlineData("WSW", 247.5)] - [InlineData("W", 270)] - [InlineData("WNW", 292.5)] - [InlineData("NW", 315)] - [InlineData("NNW", 337.5)] - [Theory] - public void FromShortHeading(string heading, double expected) => - Assert.Equal(expected, heading.FromAbbreviatedHeading()); + [InlineData("N", 0)] + [InlineData("NNE", 22.5)] + [InlineData("NE", 45)] + [InlineData("ENE", 67.5)] + [InlineData("E", 90)] + [InlineData("ESE", 112.5)] + [InlineData("SE", 135)] + [InlineData("SSE", 157.5)] + [InlineData("S", 180)] + [InlineData("SSW", 202.5)] + [InlineData("SW", 225)] + [InlineData("WSW", 247.5)] + [InlineData("W", 270)] + [InlineData("WNW", 292.5)] + [InlineData("NW", 315)] + [InlineData("NNW", 337.5)] + [Theory] + public void FromShortHeading(string heading, double expected) => + Assert.Equal(expected, heading.FromAbbreviatedHeading()); - [InlineData(0, '↑')] - [InlineData(11.2, '↑')] - [InlineData(11.3, '↑')] - [InlineData(22.5, '↗')] - [InlineData(33.7, '↗')] - [InlineData(33.8, '↗')] - [InlineData(45, '↗')] - [InlineData(56.2, '↗')] - [InlineData(56.3, '↗')] - [InlineData(67.5, '→')] - [InlineData(78.7, '→')] - [InlineData(78.8, '→')] - [InlineData(90, '→')] - [InlineData(101.2, '→')] - [InlineData(101.3, '→')] - [InlineData(112.5, '↘')] - [InlineData(123.7, '↘')] - [InlineData(123.8, '↘')] - [InlineData(135, '↘')] - [InlineData(146.2, '↘')] - [InlineData(146.3, '↘')] - [InlineData(157.5, '↓')] - [InlineData(168.7, '↓')] - [InlineData(168.8, '↓')] - [InlineData(180, '↓')] - [InlineData(191.2, '↓')] - [InlineData(191.3, '↓')] - [InlineData(202.5, '↙')] - [InlineData(213.7, '↙')] - [InlineData(213.8, '↙')] - [InlineData(225, '↙')] - [InlineData(236.2, '↙')] - [InlineData(236.3, '↙')] - [InlineData(247.5, '←')] - [InlineData(258.7, '←')] - [InlineData(258.8, '←')] - [InlineData(270, '←')] - [InlineData(281.2, '←')] - [InlineData(281.3, '←')] - [InlineData(292.5, '↖')] - [InlineData(303.7, '↖')] - [InlineData(303.8, '↖')] - [InlineData(315, '↖')] - [InlineData(326.2, '↖')] - [InlineData(326.3, '↖')] - [InlineData(337.5, '↑')] - [InlineData(348.7, '↑')] - [InlineData(348.8, '↑')] - [InlineData(360, '↑')] - [InlineData(720, '↑')] - [Theory] - public void ToHeadingArrow(double heading, char expected) => - Assert.Equal(expected, heading.ToHeadingArrow()); + [InlineData(0, '↑')] + [InlineData(11.2, '↑')] + [InlineData(11.3, '↑')] + [InlineData(22.5, '↗')] + [InlineData(33.7, '↗')] + [InlineData(33.8, '↗')] + [InlineData(45, '↗')] + [InlineData(56.2, '↗')] + [InlineData(56.3, '↗')] + [InlineData(67.5, '→')] + [InlineData(78.7, '→')] + [InlineData(78.8, '→')] + [InlineData(90, '→')] + [InlineData(101.2, '→')] + [InlineData(101.3, '→')] + [InlineData(112.5, '↘')] + [InlineData(123.7, '↘')] + [InlineData(123.8, '↘')] + [InlineData(135, '↘')] + [InlineData(146.2, '↘')] + [InlineData(146.3, '↘')] + [InlineData(157.5, '↓')] + [InlineData(168.7, '↓')] + [InlineData(168.8, '↓')] + [InlineData(180, '↓')] + [InlineData(191.2, '↓')] + [InlineData(191.3, '↓')] + [InlineData(202.5, '↙')] + [InlineData(213.7, '↙')] + [InlineData(213.8, '↙')] + [InlineData(225, '↙')] + [InlineData(236.2, '↙')] + [InlineData(236.3, '↙')] + [InlineData(247.5, '←')] + [InlineData(258.7, '←')] + [InlineData(258.8, '←')] + [InlineData(270, '←')] + [InlineData(281.2, '←')] + [InlineData(281.3, '←')] + [InlineData(292.5, '↖')] + [InlineData(303.7, '↖')] + [InlineData(303.8, '↖')] + [InlineData(315, '↖')] + [InlineData(326.2, '↖')] + [InlineData(326.3, '↖')] + [InlineData(337.5, '↑')] + [InlineData(348.7, '↑')] + [InlineData(348.8, '↑')] + [InlineData(360, '↑')] + [InlineData(720, '↑')] + [Theory] + public void ToHeadingArrow(double heading, char expected) => + Assert.Equal(expected, heading.ToHeadingArrow()); - [InlineData('↑', 0)] - [InlineData('↗', 45)] - [InlineData('→', 90)] - [InlineData('↘', 135)] - [InlineData('↓', 180)] - [InlineData('↙', 225)] - [InlineData('←', 270)] - [InlineData('↖', 315)] - [InlineData('\n', -1)] - [Theory] - public void FromHeadingArrow(char heading, double expected) => - Assert.Equal(expected, heading.FromHeadingArrow()); + [InlineData('↑', 0)] + [InlineData('↗', 45)] + [InlineData('→', 90)] + [InlineData('↘', 135)] + [InlineData('↓', 180)] + [InlineData('↙', 225)] + [InlineData('←', 270)] + [InlineData('↖', 315)] + [InlineData('\n', -1)] + [Theory] + public void FromHeadingArrow(char heading, double expected) => + Assert.Equal(expected, heading.FromHeadingArrow()); - [InlineData("↑", 0)] - [InlineData("↗", 45)] - [InlineData("→", 90)] - [InlineData("↘", 135)] - [InlineData("↓", 180)] - [InlineData("↙", 225)] - [InlineData("←", 270)] - [InlineData("↖", 315)] - [InlineData("", -1)] - [InlineData("xyz", -1)] - [Theory] - public void FromHeadingArrow_Also_Works_With_Strings(string heading, double expected) => - Assert.Equal(expected, heading.FromHeadingArrow()); + [InlineData("↑", 0)] + [InlineData("↗", 45)] + [InlineData("→", 90)] + [InlineData("↘", 135)] + [InlineData("↓", 180)] + [InlineData("↙", 225)] + [InlineData("←", 270)] + [InlineData("↖", 315)] + [InlineData("", -1)] + [InlineData("xyz", -1)] + [Theory] + public void FromHeadingArrow_Also_Works_With_Strings(string heading, double expected) => + Assert.Equal(expected, heading.FromHeadingArrow()); - [InlineData("NNW", "en-US", 337.5)] - [InlineData("ØNØ", "da", 67.5)] - [InlineData("O", "de-DE", 90.0)] - [Theory] - public void FromShortHeading_CanSpecifyCultureExplicitly(string heading, string culture, double expected) => - Assert.Equal(expected, heading.FromAbbreviatedHeading(new(culture))); - } -} + [InlineData("NNW", "en-US", 337.5)] + [InlineData("ØNØ", "da", 67.5)] + [InlineData("O", "de-DE", 90.0)] + [Theory] + public void FromShortHeading_CanSpecifyCultureExplicitly(string heading, string culture, double expected) => + Assert.Equal(expected, heading.FromAbbreviatedHeading(new(culture))); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/InflectorTests.cs b/src/Humanizer.Tests/InflectorTests.cs index 25a0f1352..6e3dc30b5 100644 --- a/src/Humanizer.Tests/InflectorTests.cs +++ b/src/Humanizer.Tests/InflectorTests.cs @@ -23,139 +23,139 @@ using System.Collections; -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class InflectorTests { - public class InflectorTests - { - public readonly IList PluralTestData = new List(); + public readonly IList PluralTestData = new List(); - [Theory] - [ClassData(typeof(PluralTestSource))] - public void Pluralize(string singular, string plural) => - Assert.Equal(plural, singular.Pluralize()); + [Theory] + [ClassData(typeof(PluralTestSource))] + public void Pluralize(string singular, string plural) => + Assert.Equal(plural, singular.Pluralize()); - [Theory] - [ClassData(typeof(PluralTestSource))] - public void PluralizeWordsWithUnknownPlurality(string singular, string plural) - { + [Theory] + [ClassData(typeof(PluralTestSource))] + public void PluralizeWordsWithUnknownPlurality(string singular, string plural) + { Assert.Equal(plural, plural.Pluralize(false)); Assert.Equal(plural, singular.Pluralize(false)); } - [Theory] - [ClassData(typeof(PluralTestSource))] - public void Singularize(string singular, string plural) => - Assert.Equal(singular, plural.Singularize()); + [Theory] + [ClassData(typeof(PluralTestSource))] + public void Singularize(string singular, string plural) => + Assert.Equal(singular, plural.Singularize()); - [Theory] - [ClassData(typeof(PluralTestSource))] - public void SingularizeWordsWithUnknownSingularity(string singular, string plural) - { + [Theory] + [ClassData(typeof(PluralTestSource))] + public void SingularizeWordsWithUnknownSingularity(string singular, string plural) + { Assert.Equal(singular, singular.Singularize(false)); Assert.Equal(singular, plural.Singularize(false)); } - [Theory] - [InlineData("tires", "tires")] - [InlineData("body", "bodies")] - [InlineData("traxxas", "traxxas")] - public void SingularizeSkipSimpleWords(string singular, string plural) => - Assert.Equal(singular, plural.Singularize(skipSimpleWords: true)); - - [Theory] - [InlineData("a")] - [InlineData("A")] - [InlineData("s")] - [InlineData("S")] - [InlineData("z")] - [InlineData("Z")] - [InlineData("1")] - public void SingularizeSingleLetter(string input) => - Assert.Equal(input, input.Singularize()); - - //Uppercases individual words and removes some characters - [Theory] - [InlineData("some title", "Some Title")] - [InlineData("some-title", "Some Title")] - [InlineData("sometitle", "Sometitle")] - [InlineData("some-title: The beginning", "Some Title: The Beginning")] - [InlineData("some_title:_the_beginning", "Some Title: the Beginning")] - [InlineData("some title: The_beginning", "Some Title: The Beginning")] - public void Titleize(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Titleize()); - - [InlineData("some_title", "some-title")] - [InlineData("some-title", "some-title")] - [InlineData("some_title_goes_here", "some-title-goes-here")] - [InlineData("some_title and_another", "some-title and-another")] - [Theory] - public void Dasherize(string input, string expectedOutput) => - Assert.Equal(input.Dasherize(), expectedOutput); - - [InlineData("some_title", "some-title")] - [InlineData("some-title", "some-title")] - [InlineData("some_title_goes_here", "some-title-goes-here")] - [InlineData("some_title and_another", "some-title and-another")] - [Theory] - public void Hyphenate(string input, string expectedOutput) => - Assert.Equal(input.Hyphenate(), expectedOutput); - - [Theory] - [InlineData("customer", "Customer")] - [InlineData("CUSTOMER", "CUSTOMER")] - [InlineData("CUStomer", "CUStomer")] - [InlineData("customer_name", "CustomerName")] - [InlineData("customer_first_name", "CustomerFirstName")] - [InlineData("customer_first_name goes here", "CustomerFirstNameGoesHere")] - [InlineData("customer name", "CustomerName")] - [InlineData("customer name", "CustomerName")] - [InlineData("customer-first-name", "CustomerFirstName")] - [InlineData("_customer-first-name", "CustomerFirstName")] - [InlineData(" customer__first--name", "CustomerFirstName")] - public void Pascalize(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Pascalize()); - - // Same as pascalize, except first char is lowercase - [Theory] - [InlineData("customer", "customer")] - [InlineData("CUSTOMER", "cUSTOMER")] - [InlineData("CUStomer", "cUStomer")] - [InlineData("customer_name", "customerName")] - [InlineData("customer_first_name", "customerFirstName")] - [InlineData("customer_first_name goes here", "customerFirstNameGoesHere")] - [InlineData("customer name", "customerName")] - [InlineData("customer name", "customerName")] - [InlineData("", "")] - public void Camelize(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Camelize()); - - //Makes an underscored lowercase string - [Theory] - [InlineData("SomeTitle", "some_title")] - [InlineData("someTitle", "some_title")] - [InlineData("some title", "some_title")] - [InlineData("some title that will be underscored", "some_title_that_will_be_underscored")] - [InlineData("SomeTitleThatWillBeUnderscored", "some_title_that_will_be_underscored")] - [InlineData("SomeForeignWordsLikeÄgyptenÑu", "some_foreign_words_like_ägypten_ñu")] - [InlineData("Some wordsTo be Underscored", "some_words_to_be_underscored")] - public void Underscore(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Underscore()); - - // transform words into lowercase and separate with a - - [Theory] - [InlineData("SomeWords", "some-words")] - [InlineData("SOME words TOGETHER", "some-words-together")] - [InlineData("A spanish word EL niño", "a-spanish-word-el-niño")] - [InlineData("SomeForeignWords ÆgÑuÄgypten", "some-foreign-words-æg-ñu-ägypten")] - [InlineData("A VeryShortSENTENCE", "a-very-short-sentence")] - public void Kebaberize(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Kebaberize()); - } - - class PluralTestSource : IEnumerable + [Theory] + [InlineData("tires", "tires")] + [InlineData("body", "bodies")] + [InlineData("traxxas", "traxxas")] + public void SingularizeSkipSimpleWords(string singular, string plural) => + Assert.Equal(singular, plural.Singularize(skipSimpleWords: true)); + + [Theory] + [InlineData("a")] + [InlineData("A")] + [InlineData("s")] + [InlineData("S")] + [InlineData("z")] + [InlineData("Z")] + [InlineData("1")] + public void SingularizeSingleLetter(string input) => + Assert.Equal(input, input.Singularize()); + + //Uppercases individual words and removes some characters + [Theory] + [InlineData("some title", "Some Title")] + [InlineData("some-title", "Some Title")] + [InlineData("sometitle", "Sometitle")] + [InlineData("some-title: The beginning", "Some Title: The Beginning")] + [InlineData("some_title:_the_beginning", "Some Title: the Beginning")] + [InlineData("some title: The_beginning", "Some Title: The Beginning")] + public void Titleize(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Titleize()); + + [InlineData("some_title", "some-title")] + [InlineData("some-title", "some-title")] + [InlineData("some_title_goes_here", "some-title-goes-here")] + [InlineData("some_title and_another", "some-title and-another")] + [Theory] + public void Dasherize(string input, string expectedOutput) => + Assert.Equal(input.Dasherize(), expectedOutput); + + [InlineData("some_title", "some-title")] + [InlineData("some-title", "some-title")] + [InlineData("some_title_goes_here", "some-title-goes-here")] + [InlineData("some_title and_another", "some-title and-another")] + [Theory] + public void Hyphenate(string input, string expectedOutput) => + Assert.Equal(input.Hyphenate(), expectedOutput); + + [Theory] + [InlineData("customer", "Customer")] + [InlineData("CUSTOMER", "CUSTOMER")] + [InlineData("CUStomer", "CUStomer")] + [InlineData("customer_name", "CustomerName")] + [InlineData("customer_first_name", "CustomerFirstName")] + [InlineData("customer_first_name goes here", "CustomerFirstNameGoesHere")] + [InlineData("customer name", "CustomerName")] + [InlineData("customer name", "CustomerName")] + [InlineData("customer-first-name", "CustomerFirstName")] + [InlineData("_customer-first-name", "CustomerFirstName")] + [InlineData(" customer__first--name", "CustomerFirstName")] + public void Pascalize(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Pascalize()); + + // Same as pascalize, except first char is lowercase + [Theory] + [InlineData("customer", "customer")] + [InlineData("CUSTOMER", "cUSTOMER")] + [InlineData("CUStomer", "cUStomer")] + [InlineData("customer_name", "customerName")] + [InlineData("customer_first_name", "customerFirstName")] + [InlineData("customer_first_name goes here", "customerFirstNameGoesHere")] + [InlineData("customer name", "customerName")] + [InlineData("customer name", "customerName")] + [InlineData("", "")] + public void Camelize(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Camelize()); + + //Makes an underscored lowercase string + [Theory] + [InlineData("SomeTitle", "some_title")] + [InlineData("someTitle", "some_title")] + [InlineData("some title", "some_title")] + [InlineData("some title that will be underscored", "some_title_that_will_be_underscored")] + [InlineData("SomeTitleThatWillBeUnderscored", "some_title_that_will_be_underscored")] + [InlineData("SomeForeignWordsLikeÄgyptenÑu", "some_foreign_words_like_ägypten_ñu")] + [InlineData("Some wordsTo be Underscored", "some_words_to_be_underscored")] + public void Underscore(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Underscore()); + + // transform words into lowercase and separate with a - + [Theory] + [InlineData("SomeWords", "some-words")] + [InlineData("SOME words TOGETHER", "some-words-together")] + [InlineData("A spanish word EL niño", "a-spanish-word-el-niño")] + [InlineData("SomeForeignWords ÆgÑuÄgypten", "some-foreign-words-æg-ñu-ägypten")] + [InlineData("A VeryShortSENTENCE", "a-very-short-sentence")] + public void Kebaberize(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Kebaberize()); +} + +class PluralTestSource : IEnumerable +{ + public IEnumerator GetEnumerator() { - public IEnumerator GetEnumerator() - { yield return ["search", "searches"]; yield return ["switch", "switches"]; yield return ["fix", "fixes"]; @@ -396,7 +396,6 @@ public IEnumerator GetEnumerator() yield return ["database", "databases"]; } - IEnumerator IEnumerable.GetEnumerator() => - GetEnumerator(); - } -} + IEnumerator IEnumerable.GetEnumerator() => + GetEnumerator(); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/DefaultFormatterTests.cs b/src/Humanizer.Tests/Localisation/DefaultFormatterTests.cs index 649286dc1..8e33ad41e 100644 --- a/src/Humanizer.Tests/Localisation/DefaultFormatterTests.cs +++ b/src/Humanizer.Tests/Localisation/DefaultFormatterTests.cs @@ -1,15 +1,14 @@ -namespace Humanizer.Tests.Localisation +namespace Humanizer.Tests.Localisation; + +public class DefaultFormatterTests { - public class DefaultFormatterTests + [Fact] + [UseCulture("iv")] + public void HandlesNotImplementedCollectionFormattersGracefully() { - [Fact] - [UseCulture("iv")] - public void HandlesNotImplementedCollectionFormattersGracefully() - { - var a = new[] { DateTime.UtcNow, DateTime.UtcNow.AddDays(10) }; - var b = a.Humanize(); + var a = new[] { DateTime.UtcNow, DateTime.UtcNow.AddDays(10) }; + var b = a.Humanize(); - Assert.Equal(a[0] + " & " + a[1], b); - } + Assert.Equal(a[0] + " & " + a[1], b); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ResourcesTests.cs b/src/Humanizer.Tests/Localisation/ResourcesTests.cs index c2d0e5885..7b0572ed3 100644 --- a/src/Humanizer.Tests/Localisation/ResourcesTests.cs +++ b/src/Humanizer.Tests/Localisation/ResourcesTests.cs @@ -1,20 +1,19 @@ -namespace Humanizer.Tests.Localisation +namespace Humanizer.Tests.Localisation; + +public class ResourcesTests { - public class ResourcesTests + [Fact] + [UseCulture("ro")] + public void CanGetCultureSpecificTranslationsWithImplicitCulture() { - [Fact] - [UseCulture("ro")] - public void CanGetCultureSpecificTranslationsWithImplicitCulture() - { - var format = Resources.GetResource("DateHumanize_MultipleYearsAgo"); - Assert.Equal("acum {0}{1} ani", format); - } + var format = Resources.GetResource("DateHumanize_MultipleYearsAgo"); + Assert.Equal("acum {0}{1} ani", format); + } - [Fact] - public void CanGetCultureSpecificTranslationsWithExplicitCulture() - { - var format = Resources.GetResource("DateHumanize_MultipleYearsAgo", new("ro")); - Assert.Equal("acum {0}{1} ani", format); - } + [Fact] + public void CanGetCultureSpecificTranslationsWithExplicitCulture() + { + var format = Resources.GetResource("DateHumanize_MultipleYearsAgo", new("ro")); + Assert.Equal("acum {0}{1} ani", format); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/af/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/af/DateHumanizeTests.cs index e0843405d..2ef96670b 100644 --- a/src/Humanizer.Tests/Localisation/af/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/af/DateHumanizeTests.cs @@ -1,85 +1,84 @@ -namespace Humanizer.Tests.Localisation.af +namespace Humanizer.Tests.Localisation.af; + +[UseCulture("af")] +public class DateHumanizeTests { - [UseCulture("af")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 dae gelede")] - [InlineData(1, "gister")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 dae gelede")] + [InlineData(1, "gister")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 ure gelede")] - [InlineData(1, "1 uur terug")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 ure gelede")] + [InlineData(1, "1 uur terug")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 minute terug")] - [InlineData(1, "1 minuut terug")] - [InlineData(60, "1 uur terug")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(2, "2 minute terug")] + [InlineData(1, "1 minuut terug")] + [InlineData(60, "1 uur terug")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 maande gelede")] - [InlineData(1, "1 maand gelede")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(2, "2 maande gelede")] + [InlineData(1, "1 maand gelede")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 sekondes terug")] - [InlineData(1, "1 sekonde terug")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(2, "2 sekondes terug")] + [InlineData(1, "1 sekonde terug")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 jaar gelede")] - [InlineData(1, "1 jaar gelede")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(2, "2 jaar gelede")] + [InlineData(1, "1 jaar gelede")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "oor 2 dae")] - [InlineData(1, "môre")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "oor 2 dae")] + [InlineData(1, "môre")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "oor 2 ure")] - [InlineData(1, "oor 1 uur")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "oor 2 ure")] + [InlineData(1, "oor 1 uur")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(2, "oor 2 minute")] - [InlineData(1, "oor 1 minuut")] - [InlineData(60, "oor 1 uur")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "oor 2 minute")] + [InlineData(1, "oor 1 minuut")] + [InlineData(60, "oor 1 uur")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(2, "oor 2 maande")] - [InlineData(1, "oor 1 maand")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "oor 2 maande")] + [InlineData(1, "oor 1 maand")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(2, "oor 2 sekondes")] - [InlineData(1, "oor 1 sekonde")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "oor 2 sekondes")] + [InlineData(1, "oor 1 sekonde")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(2, "oor 2 jaar")] - [InlineData(1, "oor 1 jaar")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(2, "oor 2 jaar")] + [InlineData(1, "oor 1 jaar")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "nou")] - public void RightNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - } -} + [Theory] + [InlineData(0, "nou")] + public void RightNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/af/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/af/NumberToWordsTests.cs index 5c9989f44..3e5d72a49 100644 --- a/src/Humanizer.Tests/Localisation/af/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/af/NumberToWordsTests.cs @@ -1,99 +1,98 @@ -namespace Humanizer.Tests.Localisation.af +namespace Humanizer.Tests.Localisation.af; + +[UseCulture("af")] +public class AfrikaansNumberToWordsTests { - [UseCulture("af")] - public class AfrikaansNumberToWordsTests - { - [InlineData(1, "een")] - [InlineData(10, "tien")] - [InlineData(11, "elf")] - [InlineData(20, "twintig")] - [InlineData(122, "een honderd twee en twintig")] - [InlineData(3501, "drie duisend vyf honderd en een")] - [InlineData(100, "een honderd")] - [InlineData(1000, "een duisend")] - [InlineData(100000, "een honderd duisend")] - [InlineData(1000000, "een miljoen")] - [InlineData(10000000, "tien miljoen")] - [InlineData(100000000, "een honderd miljoen")] - [InlineData(1000000000, "een miljard")] - [InlineData(111, "een honderd en elf")] - [InlineData(1111, "een duisend een honderd en elf")] - [InlineData(111111, "een honderd en elf duisend een honderd en elf")] - [InlineData(1111111, "een miljoen een honderd en elf duisend een honderd en elf")] - [InlineData(11111111, "elf miljoen een honderd en elf duisend een honderd en elf")] - [InlineData(111111111, "een honderd en elf miljoen een honderd en elf duisend een honderd en elf")] - [InlineData(1111111111, "een miljard een honderd en elf miljoen een honderd en elf duisend een honderd en elf")] - [InlineData(123, "een honderd drie en twintig")] - [InlineData(1234, "een duisend twee honderd vier en dertig")] - [InlineData(12345, "twaalf duisend drie honderd vyf en veertig")] - [InlineData(123456, "een honderd drie en twintig duisend vier honderd ses en vyftig")] - [InlineData(1234567, "een miljoen twee honderd vier en dertig duisend vyf honderd sewe en sestig")] - [InlineData(12345678, "twaalf miljoen drie honderd vyf en veertig duisend ses honderd agt en sewentig")] - [InlineData(123456789, "een honderd drie en twintig miljoen vier honderd ses en vyftig duisend sewe honderd nege en tagtig")] - [InlineData(1234567890, "een miljard twee honderd vier en dertig miljoen vyf honderd sewe en sestig duisend agt honderd en negentig")] - [Theory] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [InlineData(1, "een")] + [InlineData(10, "tien")] + [InlineData(11, "elf")] + [InlineData(20, "twintig")] + [InlineData(122, "een honderd twee en twintig")] + [InlineData(3501, "drie duisend vyf honderd en een")] + [InlineData(100, "een honderd")] + [InlineData(1000, "een duisend")] + [InlineData(100000, "een honderd duisend")] + [InlineData(1000000, "een miljoen")] + [InlineData(10000000, "tien miljoen")] + [InlineData(100000000, "een honderd miljoen")] + [InlineData(1000000000, "een miljard")] + [InlineData(111, "een honderd en elf")] + [InlineData(1111, "een duisend een honderd en elf")] + [InlineData(111111, "een honderd en elf duisend een honderd en elf")] + [InlineData(1111111, "een miljoen een honderd en elf duisend een honderd en elf")] + [InlineData(11111111, "elf miljoen een honderd en elf duisend een honderd en elf")] + [InlineData(111111111, "een honderd en elf miljoen een honderd en elf duisend een honderd en elf")] + [InlineData(1111111111, "een miljard een honderd en elf miljoen een honderd en elf duisend een honderd en elf")] + [InlineData(123, "een honderd drie en twintig")] + [InlineData(1234, "een duisend twee honderd vier en dertig")] + [InlineData(12345, "twaalf duisend drie honderd vyf en veertig")] + [InlineData(123456, "een honderd drie en twintig duisend vier honderd ses en vyftig")] + [InlineData(1234567, "een miljoen twee honderd vier en dertig duisend vyf honderd sewe en sestig")] + [InlineData(12345678, "twaalf miljoen drie honderd vyf en veertig duisend ses honderd agt en sewentig")] + [InlineData(123456789, "een honderd drie en twintig miljoen vier honderd ses en vyftig duisend sewe honderd nege en tagtig")] + [InlineData(1234567890, "een miljard twee honderd vier en dertig miljoen vyf honderd sewe en sestig duisend agt honderd en negentig")] + [Theory] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nulste")] - [InlineData(1, "eerste")] - [InlineData(2, "tweede")] - [InlineData(3, "derde")] - [InlineData(4, "vierde")] - [InlineData(5, "vyfde")] - [InlineData(6, "sesde")] - [InlineData(7, "sewende")] - [InlineData(8, "agste")] - [InlineData(9, "negende")] - [InlineData(10, "tiende")] - [InlineData(11, "elfde")] - [InlineData(12, "twaalfde")] - [InlineData(13, "dertiende")] - [InlineData(14, "veertiende")] - [InlineData(15, "vyftiende")] - [InlineData(16, "sestiende")] - [InlineData(17, "sewentiende")] - [InlineData(18, "agtiende")] - [InlineData(19, "negentiende")] - [InlineData(20, "twintigste")] - [InlineData(21, "een en twintigste")] - [InlineData(22, "twee en twintigste")] - [InlineData(30, "dertigste")] - [InlineData(40, "veertigste")] - [InlineData(50, "vyftigste")] - [InlineData(60, "sestigste")] - [InlineData(70, "sewentigste")] - [InlineData(80, "tagtigste")] - [InlineData(90, "negentigste")] - [InlineData(95, "vyf en negentigste")] - [InlineData(96, "ses en negentigste")] - [InlineData(100, "honderdste")] - [InlineData(112, "honderd en twaalfde")] - [InlineData(120, "honderd en twintigste")] - [InlineData(121, "honderd een en twintigste")] - [InlineData(1000, "duisendste")] - [InlineData(1001, "duisend en eerste")] - [InlineData(1021, "duisend een en twintigste")] - [InlineData(10000, "tien duisendste")] - [InlineData(10121, "tien duisend een honderd een en twintigste")] - [InlineData(100000, "honderd duisendste")] - [InlineData(1000000, "miljoenste")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "nulste")] + [InlineData(1, "eerste")] + [InlineData(2, "tweede")] + [InlineData(3, "derde")] + [InlineData(4, "vierde")] + [InlineData(5, "vyfde")] + [InlineData(6, "sesde")] + [InlineData(7, "sewende")] + [InlineData(8, "agste")] + [InlineData(9, "negende")] + [InlineData(10, "tiende")] + [InlineData(11, "elfde")] + [InlineData(12, "twaalfde")] + [InlineData(13, "dertiende")] + [InlineData(14, "veertiende")] + [InlineData(15, "vyftiende")] + [InlineData(16, "sestiende")] + [InlineData(17, "sewentiende")] + [InlineData(18, "agtiende")] + [InlineData(19, "negentiende")] + [InlineData(20, "twintigste")] + [InlineData(21, "een en twintigste")] + [InlineData(22, "twee en twintigste")] + [InlineData(30, "dertigste")] + [InlineData(40, "veertigste")] + [InlineData(50, "vyftigste")] + [InlineData(60, "sestigste")] + [InlineData(70, "sewentigste")] + [InlineData(80, "tagtigste")] + [InlineData(90, "negentigste")] + [InlineData(95, "vyf en negentigste")] + [InlineData(96, "ses en negentigste")] + [InlineData(100, "honderdste")] + [InlineData(112, "honderd en twaalfde")] + [InlineData(120, "honderd en twintigste")] + [InlineData(121, "honderd een en twintigste")] + [InlineData(1000, "duisendste")] + [InlineData(1001, "duisend en eerste")] + [InlineData(1021, "duisend een en twintigste")] + [InlineData(10000, "tien duisendste")] + [InlineData(10121, "tien duisend een honderd een en twintigste")] + [InlineData(100000, "honderd duisendste")] + [InlineData(1000000, "miljoenste")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); - [Theory] - [InlineData(11, "en-US", "eleven")] - [InlineData(22, "ar", "اثنان و عشرون")] - [InlineData(40, "ru", "сорок")] - public void ToWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => - Assert.Equal(expected, number.ToWords(new(culture))); + [Theory] + [InlineData(11, "en-US", "eleven")] + [InlineData(22, "ar", "اثنان و عشرون")] + [InlineData(40, "ru", "сорок")] + public void ToWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => + Assert.Equal(expected, number.ToWords(new(culture))); - [Theory] - [InlineData(1021, "en-US", "thousand and twenty-first")] - [InlineData(21, "ar", "الحادي و العشرون")] - [InlineData(1112, "ru", "одна тысяча сто двенадцатый")] - public void ToOrdinalWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(new(culture))); - } -} + [Theory] + [InlineData(1021, "en-US", "thousand and twenty-first")] + [InlineData(21, "ar", "الحادي و العشرون")] + [InlineData(1112, "ru", "одна тысяча сто двенадцатый")] + public void ToOrdinalWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(new(culture))); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/af/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/af/TimeSpanHumanizeTests.cs index e4fae2da4..6eed8abc8 100644 --- a/src/Humanizer.Tests/Localisation/af/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/af/TimeSpanHumanizeTests.cs @@ -1,84 +1,83 @@ -namespace Humanizer.Tests.Localisation.af +namespace Humanizer.Tests.Localisation.af; + +[UseCulture("af")] +public class TimeSpanHumanizeTests { - [UseCulture("af")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 jaar")] - [InlineData(731, "2 jaar")] - [InlineData(1096, "3 jaar")] - [InlineData(4018, "11 jaar")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 maand")] - [InlineData(61, "2 maande")] - [InlineData(92, "3 maande")] - [InlineData(335, "11 maande")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Fact] - public void TwoWeeks() => - Assert.Equal("2 weke", TimeSpan.FromDays(14).Humanize()); - - [Fact] - public void OneWeek() => - Assert.Equal("1 week", TimeSpan.FromDays(7).Humanize()); - - [Fact] - public void SixDays() => - Assert.Equal("6 dae", TimeSpan.FromDays(6).Humanize()); - - [Fact] - public void TwoDays() => - Assert.Equal("2 dae", TimeSpan.FromDays(2).Humanize()); - - [Fact] - public void OneDay() => - Assert.Equal("1 dag", TimeSpan.FromDays(1).Humanize()); - - [Fact] - public void TwoHours() => - Assert.Equal("2 ure", TimeSpan.FromHours(2).Humanize()); - - [Fact] - public void OneHour() => - Assert.Equal("1 uur", TimeSpan.FromHours(1).Humanize()); - - [Fact] - public void TwoMinutes() => - Assert.Equal("2 minute", TimeSpan.FromMinutes(2).Humanize()); - - [Fact] - public void OneMinute() => - Assert.Equal("1 minuut", TimeSpan.FromMinutes(1).Humanize()); - - [Fact] - public void TwoSeconds() => - Assert.Equal("2 sekondes", TimeSpan.FromSeconds(2).Humanize()); - - [Fact] - public void OneSecond() => - Assert.Equal("1 sekond", TimeSpan.FromSeconds(1).Humanize()); - - [Fact] - public void TwoMilliseconds() => - Assert.Equal("2 millisekondes", TimeSpan.FromMilliseconds(2).Humanize()); - - [Fact] - public void OneMillisecond() => - Assert.Equal("1 millisekond", TimeSpan.FromMilliseconds(1).Humanize()); - - [Fact] - public void NoTime() => - Assert.Equal("0 millisekondes", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - Assert.Equal("geen tyd", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 jaar")] + [InlineData(731, "2 jaar")] + [InlineData(1096, "3 jaar")] + [InlineData(4018, "11 jaar")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 maand")] + [InlineData(61, "2 maande")] + [InlineData(92, "3 maande")] + [InlineData(335, "11 maande")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Fact] + public void TwoWeeks() => + Assert.Equal("2 weke", TimeSpan.FromDays(14).Humanize()); + + [Fact] + public void OneWeek() => + Assert.Equal("1 week", TimeSpan.FromDays(7).Humanize()); + + [Fact] + public void SixDays() => + Assert.Equal("6 dae", TimeSpan.FromDays(6).Humanize()); + + [Fact] + public void TwoDays() => + Assert.Equal("2 dae", TimeSpan.FromDays(2).Humanize()); + + [Fact] + public void OneDay() => + Assert.Equal("1 dag", TimeSpan.FromDays(1).Humanize()); + + [Fact] + public void TwoHours() => + Assert.Equal("2 ure", TimeSpan.FromHours(2).Humanize()); + + [Fact] + public void OneHour() => + Assert.Equal("1 uur", TimeSpan.FromHours(1).Humanize()); + + [Fact] + public void TwoMinutes() => + Assert.Equal("2 minute", TimeSpan.FromMinutes(2).Humanize()); + + [Fact] + public void OneMinute() => + Assert.Equal("1 minuut", TimeSpan.FromMinutes(1).Humanize()); + + [Fact] + public void TwoSeconds() => + Assert.Equal("2 sekondes", TimeSpan.FromSeconds(2).Humanize()); + + [Fact] + public void OneSecond() => + Assert.Equal("1 sekond", TimeSpan.FromSeconds(1).Humanize()); + + [Fact] + public void TwoMilliseconds() => + Assert.Equal("2 millisekondes", TimeSpan.FromMilliseconds(2).Humanize()); + + [Fact] + public void OneMillisecond() => + Assert.Equal("1 millisekond", TimeSpan.FromMilliseconds(1).Humanize()); + + [Fact] + public void NoTime() => + Assert.Equal("0 millisekondes", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + Assert.Equal("geen tyd", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs index 68d88bed0..9bcb8ff63 100644 --- a/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs @@ -1,103 +1,102 @@ -namespace Humanizer.Tests.Localisation.ar +namespace Humanizer.Tests.Localisation.ar; + +[UseCulture("ar")] +public class DateHumanizeTests { - [UseCulture("ar")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-1, "أمس")] - [InlineData(-2, "منذ يومين")] - [InlineData(-3, "منذ 3 أيام")] - [InlineData(-11, "منذ 11 يوم")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-1, "أمس")] + [InlineData(-2, "منذ يومين")] + [InlineData(-3, "منذ 3 أيام")] + [InlineData(-11, "منذ 11 يوم")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "في غضون يوم واحد من الآن")] - [InlineData(2, "في غضون يومين من الآن")] - [InlineData(10, "في غضون 10 أيام من الآن")] - [InlineData(17, "في غضون 17 يوم من الآن")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "في غضون يوم واحد من الآن")] + [InlineData(2, "في غضون يومين من الآن")] + [InlineData(10, "في غضون 10 أيام من الآن")] + [InlineData(17, "في غضون 17 يوم من الآن")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-2, "منذ ساعتين")] - [InlineData(-1, "منذ ساعة واحدة")] - [InlineData(-3, "منذ 3 ساعات")] - [InlineData(-11, "منذ 11 ساعة")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "منذ ساعتين")] + [InlineData(-1, "منذ ساعة واحدة")] + [InlineData(-3, "منذ 3 ساعات")] + [InlineData(-11, "منذ 11 ساعة")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "في غضون ساعة واحدة من الآن")] - [InlineData(2, "في غضون ساعتين من الآن")] - [InlineData(10, "في غضون 10 ساعات من الآن")] - [InlineData(23, "في غضون 23 ساعة من الآن")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "في غضون ساعة واحدة من الآن")] + [InlineData(2, "في غضون ساعتين من الآن")] + [InlineData(10, "في غضون 10 ساعات من الآن")] + [InlineData(23, "في غضون 23 ساعة من الآن")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "منذ دقيقتين")] - [InlineData(-1, "منذ دقيقة واحدة")] - [InlineData(-3, "منذ 3 دقائق")] - [InlineData(-11, "منذ 11 دقيقة")] - [InlineData(60, "منذ ساعة واحدة")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "منذ دقيقتين")] + [InlineData(-1, "منذ دقيقة واحدة")] + [InlineData(-3, "منذ 3 دقائق")] + [InlineData(-11, "منذ 11 دقيقة")] + [InlineData(60, "منذ ساعة واحدة")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "في غضون دقيقة واحدة من الآن")] - [InlineData(2, "في غضون دقيقتين من الآن")] - [InlineData(10, "في غضون 10 دقائق من الآن")] - [InlineData(23, "في غضون 23 دقيقة من الآن")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "في غضون دقيقة واحدة من الآن")] + [InlineData(2, "في غضون دقيقتين من الآن")] + [InlineData(10, "في غضون 10 دقائق من الآن")] + [InlineData(23, "في غضون 23 دقيقة من الآن")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "منذ شهرين")] - [InlineData(-1, "منذ شهر واحد")] - [InlineData(-3, "منذ 3 أشهر")] - [InlineData(-11, "منذ 11 شهر")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "منذ شهرين")] + [InlineData(-1, "منذ شهر واحد")] + [InlineData(-3, "منذ 3 أشهر")] + [InlineData(-11, "منذ 11 شهر")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "في غضون شهر واحد من الآن")] - [InlineData(2, "في غضون شهرين من الآن")] - [InlineData(10, "في غضون 10 أشهر من الآن")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "في غضون شهر واحد من الآن")] + [InlineData(2, "في غضون شهرين من الآن")] + [InlineData(10, "في غضون 10 أشهر من الآن")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "منذ ثانيتين")] - [InlineData(-1, "منذ ثانية واحدة")] - [InlineData(-3, "منذ 3 ثوان")] - [InlineData(-11, "منذ 11 ثانية")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "منذ ثانيتين")] + [InlineData(-1, "منذ ثانية واحدة")] + [InlineData(-3, "منذ 3 ثوان")] + [InlineData(-11, "منذ 11 ثانية")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(0, "الآن")] - [InlineData(1, "في غضون ثانية واحدة من الآن")] - [InlineData(2, "في غضون ثانيتين من الآن")] - [InlineData(10, "في غضون 10 ثوان من الآن")] - [InlineData(24, "في غضون 24 ثانية من الآن")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(0, "الآن")] + [InlineData(1, "في غضون ثانية واحدة من الآن")] + [InlineData(2, "في غضون ثانيتين من الآن")] + [InlineData(10, "في غضون 10 ثوان من الآن")] + [InlineData(24, "في غضون 24 ثانية من الآن")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "منذ عامين")] - [InlineData(-1, "العام السابق")] - [InlineData(-3, "منذ 3 أعوام")] - [InlineData(-11, "منذ 11 عام")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "منذ عامين")] + [InlineData(-1, "العام السابق")] + [InlineData(-3, "منذ 3 أعوام")] + [InlineData(-11, "منذ 11 عام")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "في غضون سنة واحدة من الآن")] - [InlineData(2, "في غضون سنتين من الآن")] - [InlineData(7, "في غضون 7 سنوات من الآن")] - [InlineData(55, "في غضون 55 سنة من الآن")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "في غضون سنة واحدة من الآن")] + [InlineData(2, "في غضون سنتين من الآن")] + [InlineData(7, "في غضون 7 سنوات من الآن")] + [InlineData(55, "في غضون 55 سنة من الآن")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ar/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ar/NumberToWordsTests.cs index 894d41a76..cbc763a64 100644 --- a/src/Humanizer.Tests/Localisation/ar/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ar/NumberToWordsTests.cs @@ -1,182 +1,181 @@ -namespace Humanizer.Tests.Localisation.ar +namespace Humanizer.Tests.Localisation.ar; + +[UseCulture("ar")] +public class NumberToWordsTests { - [UseCulture("ar")] - public class NumberToWordsTests - { - [Theory] - [InlineData("صفر", 0)] - [InlineData("واحد", 1)] - [InlineData("اثنان", 2)] - [InlineData("اثنان و عشرون", 22)] - [InlineData("أحد عشر", 11)] - [InlineData("ثلاثة آلاف و خمس مئة و واحد", 3501)] - [InlineData("مليون و واحد", 1000001)] - public void ToWordsArabic(string expected, int number) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData("صفر", 0)] + [InlineData("واحد", 1)] + [InlineData("اثنان", 2)] + [InlineData("اثنان و عشرون", 22)] + [InlineData("أحد عشر", 11)] + [InlineData("ثلاثة آلاف و خمس مئة و واحد", 3501)] + [InlineData("مليون و واحد", 1000001)] + public void ToWordsArabic(string expected, int number) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData("ناقص واحد", -1)] - [InlineData("ناقص اثنان", -2)] - [InlineData("ناقص اثنان و عشرون", -22)] - [InlineData("ناقص أحد عشر", -11)] - [InlineData("ناقص ثلاثة آلاف و خمس مئة و واحد", -3501)] - [InlineData("ناقص مليون و واحد", -1000001)] - public void ToWordsArabicNegative(string expected, int number) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData("ناقص واحد", -1)] + [InlineData("ناقص اثنان", -2)] + [InlineData("ناقص اثنان و عشرون", -22)] + [InlineData("ناقص أحد عشر", -11)] + [InlineData("ناقص ثلاثة آلاف و خمس مئة و واحد", -3501)] + [InlineData("ناقص مليون و واحد", -1000001)] + public void ToWordsArabicNegative(string expected, int number) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1L, "واحد")] - [InlineData(11L, "أحد عشر")] - [InlineData(111L, "مئة و أحد عشر")] - [InlineData(1111L, "ألف و مئة و أحد عشر")] - [InlineData(11111L, "أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(111111L, "مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(1111111L, "مليون و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(11111111L, "أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(111111111L, "مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(1111111111L, "مليار و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(11111111111L, "أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(111111111111L, "مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(1111111111111L, "تريليون و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(11111111111111L, "أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(111111111111111L, "مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(1111111111111111L, "كوادريليون و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(11111111111111111L, "أحد عشر كوادريليوناً و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(111111111111111111L, "مئة و أحد عشر كوادريليوناً و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(1111111111111111111L, "كوينتليون و مئة و أحد عشر كوادريليوناً و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] - [InlineData(10000000001L, "عشرة مليارات و واحد")] - [InlineData(8750000500001L, "ثمانية تريليونات و سبع مئة و خمسون ملياراً و خمس مئة ألفاً و واحد")] - [InlineData(-10000000001L, "ناقص عشرة مليارات و واحد")] - [InlineData(-8750000500001L, "ناقص ثمانية تريليونات و سبع مئة و خمسون ملياراً و خمس مئة ألفاً و واحد")] - public void ToWordsArabicLong(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(1L, "واحد")] + [InlineData(11L, "أحد عشر")] + [InlineData(111L, "مئة و أحد عشر")] + [InlineData(1111L, "ألف و مئة و أحد عشر")] + [InlineData(11111L, "أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(111111L, "مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(1111111L, "مليون و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(11111111L, "أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(111111111L, "مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(1111111111L, "مليار و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(11111111111L, "أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(111111111111L, "مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(1111111111111L, "تريليون و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(11111111111111L, "أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(111111111111111L, "مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(1111111111111111L, "كوادريليون و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(11111111111111111L, "أحد عشر كوادريليوناً و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(111111111111111111L, "مئة و أحد عشر كوادريليوناً و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(1111111111111111111L, "كوينتليون و مئة و أحد عشر كوادريليوناً و مئة و أحد عشر تريليوناً و مئة و أحد عشر ملياراً و مئة و أحد عشر مليوناً و مئة و أحد عشر ألفاً و مئة و أحد عشر")] + [InlineData(10000000001L, "عشرة مليارات و واحد")] + [InlineData(8750000500001L, "ثمانية تريليونات و سبع مئة و خمسون ملياراً و خمس مئة ألفاً و واحد")] + [InlineData(-10000000001L, "ناقص عشرة مليارات و واحد")] + [InlineData(-8750000500001L, "ناقص ثمانية تريليونات و سبع مئة و خمسون ملياراً و خمس مئة ألفاً و واحد")] + public void ToWordsArabicLong(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData("صفر", 0)] - [InlineData("واحدة", 1)] - [InlineData("اثنتان", 2)] - [InlineData("اثنتان و عشرون", 22)] - [InlineData("إحدى عشرة", 11)] - [InlineData("ثلاثة آلاف و خمس مئة و واحدة", 3501)] - [InlineData("مليون و واحدة", 1000001)] - public void ToWordsArabicFeminine(string expected, long number) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData("صفر", 0)] + [InlineData("واحدة", 1)] + [InlineData("اثنتان", 2)] + [InlineData("اثنتان و عشرون", 22)] + [InlineData("إحدى عشرة", 11)] + [InlineData("ثلاثة آلاف و خمس مئة و واحدة", 3501)] + [InlineData("مليون و واحدة", 1000001)] + public void ToWordsArabicFeminine(string expected, long number) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData("عشرة مليارات و واحدة", 10000000001)] - [InlineData("ثمانية تريليونات و سبع مئة و خمسون ملياراً و خمس مئة ألفاً و واحدة", 8750000500001)] - public void ToWordsArabicLongFeminine(string expected, long number) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData("عشرة مليارات و واحدة", 10000000001)] + [InlineData("ثمانية تريليونات و سبع مئة و خمسون ملياراً و خمس مئة ألفاً و واحدة", 8750000500001)] + public void ToWordsArabicLongFeminine(string expected, long number) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(122, "مئة و اثنتان و عشرون", GrammaticalGender.Feminine)] - [InlineData(3501, "ثلاثة آلاف و خمس مئة و واحدة", GrammaticalGender.Feminine)] - [InlineData(3501, "ثلاثة آلاف و خمس مئة و واحد", GrammaticalGender.Neuter)] - public void ToWordsWithGender(long number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(122, "مئة و اثنتان و عشرون", GrammaticalGender.Feminine)] + [InlineData(3501, "ثلاثة آلاف و خمس مئة و واحدة", GrammaticalGender.Feminine)] + [InlineData(3501, "ثلاثة آلاف و خمس مئة و واحد", GrammaticalGender.Neuter)] + public void ToWordsWithGender(long number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(0, "الصفر")] - [InlineData(1, "الأول")] - [InlineData(2, "الثاني")] - [InlineData(3, "الثالث")] - [InlineData(4, "الرابع")] - [InlineData(5, "الخامس")] - [InlineData(6, "السادس")] - [InlineData(7, "السابع")] - [InlineData(8, "الثامن")] - [InlineData(9, "التاسع")] - [InlineData(10, "العاشر")] - [InlineData(11, "الحادي عشر")] - [InlineData(12, "الثاني عشر")] - [InlineData(13, "الثالث عشر")] - [InlineData(14, "الرابع عشر")] - [InlineData(15, "الخامس عشر")] - [InlineData(16, "السادس عشر")] - [InlineData(17, "السابع عشر")] - [InlineData(18, "الثامن عشر")] - [InlineData(19, "التاسع عشر")] - [InlineData(20, "العشرون")] - [InlineData(21, "الحادي و العشرون")] - [InlineData(22, "الثاني و العشرون")] - [InlineData(30, "الثلاثون")] - [InlineData(40, "الأربعون")] - [InlineData(50, "الخمسون")] - [InlineData(60, "الستون")] - [InlineData(70, "السبعون")] - [InlineData(80, "الثمانون")] - [InlineData(90, "التسعون")] - [InlineData(95, "الخامس و التسعون")] - [InlineData(96, "السادس و التسعون")] - [InlineData(100, "المئة")] - [InlineData(120, "العشرون بعد المئة")] - [InlineData(121, "الحادي و العشرون بعد المئة")] - [InlineData(200, "المئتان")] - [InlineData(221, "الحادي و العشرون بعد المئتان")] - [InlineData(300, "الثلاث مئة")] - [InlineData(321, "الحادي و العشرون بعد الثلاث مئة")] - [InlineData(327, "السابع و العشرون بعد الثلاث مئة")] - [InlineData(1000, "الألف")] - [InlineData(1001, "الأول بعد الألف")] - [InlineData(1021, "الحادي و العشرون بعد الألف")] - [InlineData(10000, "العشرة آلاف")] - [InlineData(10121, "الحادي و العشرون بعد العشرة آلاف و مئة")] - [InlineData(100000, "المئة ألف")] - [InlineData(1000000, "المليون")] - [InlineData(1020135, "الخامس و الثلاثون بعد المليون و عشرون ألفاً و مئة")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "الصفر")] + [InlineData(1, "الأول")] + [InlineData(2, "الثاني")] + [InlineData(3, "الثالث")] + [InlineData(4, "الرابع")] + [InlineData(5, "الخامس")] + [InlineData(6, "السادس")] + [InlineData(7, "السابع")] + [InlineData(8, "الثامن")] + [InlineData(9, "التاسع")] + [InlineData(10, "العاشر")] + [InlineData(11, "الحادي عشر")] + [InlineData(12, "الثاني عشر")] + [InlineData(13, "الثالث عشر")] + [InlineData(14, "الرابع عشر")] + [InlineData(15, "الخامس عشر")] + [InlineData(16, "السادس عشر")] + [InlineData(17, "السابع عشر")] + [InlineData(18, "الثامن عشر")] + [InlineData(19, "التاسع عشر")] + [InlineData(20, "العشرون")] + [InlineData(21, "الحادي و العشرون")] + [InlineData(22, "الثاني و العشرون")] + [InlineData(30, "الثلاثون")] + [InlineData(40, "الأربعون")] + [InlineData(50, "الخمسون")] + [InlineData(60, "الستون")] + [InlineData(70, "السبعون")] + [InlineData(80, "الثمانون")] + [InlineData(90, "التسعون")] + [InlineData(95, "الخامس و التسعون")] + [InlineData(96, "السادس و التسعون")] + [InlineData(100, "المئة")] + [InlineData(120, "العشرون بعد المئة")] + [InlineData(121, "الحادي و العشرون بعد المئة")] + [InlineData(200, "المئتان")] + [InlineData(221, "الحادي و العشرون بعد المئتان")] + [InlineData(300, "الثلاث مئة")] + [InlineData(321, "الحادي و العشرون بعد الثلاث مئة")] + [InlineData(327, "السابع و العشرون بعد الثلاث مئة")] + [InlineData(1000, "الألف")] + [InlineData(1001, "الأول بعد الألف")] + [InlineData(1021, "الحادي و العشرون بعد الألف")] + [InlineData(10000, "العشرة آلاف")] + [InlineData(10121, "الحادي و العشرون بعد العشرة آلاف و مئة")] + [InlineData(100000, "المئة ألف")] + [InlineData(1000000, "المليون")] + [InlineData(1020135, "الخامس و الثلاثون بعد المليون و عشرون ألفاً و مئة")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "الصفر")] - [InlineData(1, "الأولى")] - [InlineData(2, "الثانية")] - [InlineData(3, "الثالثة")] - [InlineData(4, "الرابعة")] - [InlineData(5, "الخامسة")] - [InlineData(6, "السادسة")] - [InlineData(7, "السابعة")] - [InlineData(8, "الثامنة")] - [InlineData(9, "التاسعة")] - [InlineData(10, "العاشرة")] - [InlineData(11, "الحادية عشرة")] - [InlineData(12, "الثانية عشرة")] - [InlineData(13, "الثالثة عشرة")] - [InlineData(14, "الرابعة عشرة")] - [InlineData(15, "الخامسة عشرة")] - [InlineData(16, "السادسة عشرة")] - [InlineData(17, "السابعة عشرة")] - [InlineData(18, "الثامنة عشرة")] - [InlineData(19, "التاسعة عشرة")] - [InlineData(20, "العشرون")] - [InlineData(21, "الحادية و العشرون")] - [InlineData(22, "الثانية و العشرون")] - [InlineData(30, "الثلاثون")] - [InlineData(40, "الأربعون")] - [InlineData(50, "الخمسون")] - [InlineData(60, "الستون")] - [InlineData(70, "السبعون")] - [InlineData(80, "الثمانون")] - [InlineData(90, "التسعون")] - [InlineData(95, "الخامسة و التسعون")] - [InlineData(96, "السادسة و التسعون")] - [InlineData(100, "المئة")] - [InlineData(120, "العشرون بعد المئة")] - [InlineData(121, "الحادية و العشرون بعد المئة")] - [InlineData(200, "المئتان")] - [InlineData(221, "الحادية و العشرون بعد المئتان")] - [InlineData(300, "الثلاث مئة")] - [InlineData(321, "الحادية و العشرون بعد الثلاث مئة")] - [InlineData(327, "السابعة و العشرون بعد الثلاث مئة")] - [InlineData(1000, "الألف")] - [InlineData(1001, "الأولى بعد الألف")] - [InlineData(1021, "الحادية و العشرون بعد الألف")] - [InlineData(10000, "العشرة آلاف")] - [InlineData(10121, "الحادية و العشرون بعد العشرة آلاف و مئة")] - [InlineData(100000, "المئة ألف")] - [InlineData(1000000, "المليون")] - [InlineData(1020135, "الخامسة و الثلاثون بعد المليون و عشرون ألفاً و مئة")] - public void ToOrdinalWordsWithFeminineGender(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(0, "الصفر")] + [InlineData(1, "الأولى")] + [InlineData(2, "الثانية")] + [InlineData(3, "الثالثة")] + [InlineData(4, "الرابعة")] + [InlineData(5, "الخامسة")] + [InlineData(6, "السادسة")] + [InlineData(7, "السابعة")] + [InlineData(8, "الثامنة")] + [InlineData(9, "التاسعة")] + [InlineData(10, "العاشرة")] + [InlineData(11, "الحادية عشرة")] + [InlineData(12, "الثانية عشرة")] + [InlineData(13, "الثالثة عشرة")] + [InlineData(14, "الرابعة عشرة")] + [InlineData(15, "الخامسة عشرة")] + [InlineData(16, "السادسة عشرة")] + [InlineData(17, "السابعة عشرة")] + [InlineData(18, "الثامنة عشرة")] + [InlineData(19, "التاسعة عشرة")] + [InlineData(20, "العشرون")] + [InlineData(21, "الحادية و العشرون")] + [InlineData(22, "الثانية و العشرون")] + [InlineData(30, "الثلاثون")] + [InlineData(40, "الأربعون")] + [InlineData(50, "الخمسون")] + [InlineData(60, "الستون")] + [InlineData(70, "السبعون")] + [InlineData(80, "الثمانون")] + [InlineData(90, "التسعون")] + [InlineData(95, "الخامسة و التسعون")] + [InlineData(96, "السادسة و التسعون")] + [InlineData(100, "المئة")] + [InlineData(120, "العشرون بعد المئة")] + [InlineData(121, "الحادية و العشرون بعد المئة")] + [InlineData(200, "المئتان")] + [InlineData(221, "الحادية و العشرون بعد المئتان")] + [InlineData(300, "الثلاث مئة")] + [InlineData(321, "الحادية و العشرون بعد الثلاث مئة")] + [InlineData(327, "السابعة و العشرون بعد الثلاث مئة")] + [InlineData(1000, "الألف")] + [InlineData(1001, "الأولى بعد الألف")] + [InlineData(1021, "الحادية و العشرون بعد الألف")] + [InlineData(10000, "العشرة آلاف")] + [InlineData(10121, "الحادية و العشرون بعد العشرة آلاف و مئة")] + [InlineData(100000, "المئة ألف")] + [InlineData(1000000, "المليون")] + [InlineData(1020135, "الخامسة و الثلاثون بعد المليون و عشرون ألفاً و مئة")] + public void ToOrdinalWordsWithFeminineGender(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ar/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ar/TimeSpanHumanizeTests.cs index f240d253c..65980d3ca 100644 --- a/src/Humanizer.Tests/Localisation/ar/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ar/TimeSpanHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.ar +namespace Humanizer.Tests.Localisation.ar; + +[UseCulture("ar")] +public class TimeSpanHumanizeTests { - [UseCulture("ar")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "السنة 1")] - [InlineData(731, "سنتين")] - [InlineData(1096, "3 سنة")] - [InlineData(4018, "11 سنة")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "السنة 1")] + [InlineData(731, "سنتين")] + [InlineData(1096, "3 سنة")] + [InlineData(4018, "11 سنة")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "شهر 1")] - [InlineData(61, "شهرين")] - [InlineData(92, "3 أشهر")] - [InlineData(335, "11 أشهر")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "شهر 1")] + [InlineData(61, "شهرين")] + [InlineData(92, "3 أشهر")] + [InlineData(335, "11 أشهر")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "أسبوع واحد")] - [InlineData(14, "أسبوعين")] - [InlineData(21, "3 أسابيع")] - [InlineData(77, "11 أسبوع")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "أسبوع واحد")] + [InlineData(14, "أسبوعين")] + [InlineData(21, "3 أسابيع")] + [InlineData(77, "11 أسبوع")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "يوم واحد")] - [InlineData(2, "يومين")] - [InlineData(3, "3 أيام")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "يوم واحد")] + [InlineData(2, "يومين")] + [InlineData(3, "3 أيام")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "ساعة واحدة")] - [InlineData(2, "ساعتين")] - [InlineData(3, "3 ساعات")] - [InlineData(11, "11 ساعة")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "ساعة واحدة")] + [InlineData(2, "ساعتين")] + [InlineData(3, "3 ساعات")] + [InlineData(11, "11 ساعة")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "دقيقة واحدة")] - [InlineData(2, "دقيقتين")] - [InlineData(3, "3 دقائق")] - [InlineData(11, "11 دقيقة")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "دقيقة واحدة")] + [InlineData(2, "دقيقتين")] + [InlineData(3, "3 دقائق")] + [InlineData(11, "11 دقيقة")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "ثانية واحدة")] - [InlineData(2, "ثانيتين")] - [InlineData(3, "3 ثوان")] - [InlineData(11, "11 ثانية")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "ثانية واحدة")] + [InlineData(2, "ثانيتين")] + [InlineData(3, "3 ثوان")] + [InlineData(11, "11 ثانية")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "جزء من الثانية")] - [InlineData(2, "جزئين من الثانية")] - [InlineData(3, "3 أجزاء من الثانية")] - [InlineData(11, "11 جزء من الثانية")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "جزء من الثانية")] + [InlineData(2, "جزئين من الثانية")] + [InlineData(3, "3 أجزاء من الثانية")] + [InlineData(11, "11 جزء من الثانية")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 جزء من الثانية", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 جزء من الثانية", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("حالاً", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("حالاً", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/az/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/az/DateHumanizeTests.cs index 4d230cf0e..7ba7ad431 100644 --- a/src/Humanizer.Tests/Localisation/az/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/az/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.az +namespace Humanizer.Tests.Localisation.az; + +[UseCulture("az")] +public class DateHumanizeTests { - [UseCulture("az")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "bir saniyə əvvəl")] - [InlineData(10, "10 saniyə əvvəl")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "bir saniyə əvvəl")] + [InlineData(10, "10 saniyə əvvəl")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "bir saniyə sonra")] - [InlineData(10, "10 saniyə sonra")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "bir saniyə sonra")] + [InlineData(10, "10 saniyə sonra")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "bir dəqiqə əvvəl")] - [InlineData(10, "10 dəqiqə əvvəl")] - [InlineData(60, "bir saat əvvəl")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "bir dəqiqə əvvəl")] + [InlineData(10, "10 dəqiqə əvvəl")] + [InlineData(60, "bir saat əvvəl")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "bir dəqiqə sonra")] - [InlineData(10, "10 dəqiqə sonra")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "bir dəqiqə sonra")] + [InlineData(10, "10 dəqiqə sonra")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "bir saat əvvəl")] - [InlineData(10, "10 saat əvvəl")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "bir saat əvvəl")] + [InlineData(10, "10 saat əvvəl")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "bir saat sonra")] - [InlineData(10, "10 saat sonra")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "bir saat sonra")] + [InlineData(10, "10 saat sonra")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "dünən")] - [InlineData(10, "10 gün əvvəl")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "dünən")] + [InlineData(10, "10 gün əvvəl")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "sabah")] - [InlineData(10, "10 gün sonra")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "sabah")] + [InlineData(10, "10 gün sonra")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "bir ay əvvəl")] - [InlineData(10, "10 ay əvvəl")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "bir ay əvvəl")] + [InlineData(10, "10 ay əvvəl")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "bir ay sonra")] - [InlineData(10, "10 ay sonra")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "bir ay sonra")] + [InlineData(10, "10 ay sonra")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "bir il əvvəl")] - [InlineData(2, "2 il əvvəl")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "bir il əvvəl")] + [InlineData(2, "2 il əvvəl")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "bir il sonra")] - [InlineData(2, "2 il sonra")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "bir il sonra")] + [InlineData(2, "2 il sonra")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("indi", 0, TimeUnit.Year, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("indi", 0, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/az/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/az/NumberToWordsTests.cs index 0975ec4fc..d4cdfb40b 100644 --- a/src/Humanizer.Tests/Localisation/az/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/az/NumberToWordsTests.cs @@ -1,67 +1,66 @@ -namespace Humanizer.Tests.Localisation.az +namespace Humanizer.Tests.Localisation.az; + +[UseCulture("az")] +public class NumberToWordsTests { - [UseCulture("az")] - public class NumberToWordsTests - { - [Theory] - [InlineData("sıfır", 0)] - [InlineData("bir", 1)] - [InlineData("iki", 2)] - [InlineData("on", 10)] - [InlineData("yüz on iki", 112)] - [InlineData("min dörd yüz qırx", 1440)] - [InlineData("iyirmi iki", 22)] - [InlineData("on bir", 11)] - [InlineData("üç min beş yüz bir", 3501)] - [InlineData("bir milyon bir", 1000001)] - [InlineData("mənfi bir milyon üç yüz qırx altı min yeddi yüz on bir", -1346711)] - public void ToWords(string expected, int number) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData("sıfır", 0)] + [InlineData("bir", 1)] + [InlineData("iki", 2)] + [InlineData("on", 10)] + [InlineData("yüz on iki", 112)] + [InlineData("min dörd yüz qırx", 1440)] + [InlineData("iyirmi iki", 22)] + [InlineData("on bir", 11)] + [InlineData("üç min beş yüz bir", 3501)] + [InlineData("bir milyon bir", 1000001)] + [InlineData("mənfi bir milyon üç yüz qırx altı min yeddi yüz on bir", -1346711)] + public void ToWords(string expected, int number) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "sıfırıncı")] - [InlineData(1, "birinci")] - [InlineData(2, "ikinci")] - [InlineData(3, "üçüncü")] - [InlineData(4, "dördüncü")] - [InlineData(5, "beşinci")] - [InlineData(6, "altıncı")] - [InlineData(7, "yeddinci")] - [InlineData(8, "səkkizinci")] - [InlineData(9, "doqquzuncu")] - [InlineData(10, "onuncu")] - [InlineData(11, "on birinci")] - [InlineData(12, "on ikinci")] - [InlineData(13, "on üçüncü")] - [InlineData(14, "on dördüncü")] - [InlineData(15, "on beşinci")] - [InlineData(16, "on altıncı")] - [InlineData(17, "on yeddinci")] - [InlineData(18, "on səkkizinci")] - [InlineData(19, "on doqquzuncu")] - [InlineData(20, "iyirminci")] - [InlineData(21, "iyirmi birinci")] - [InlineData(30, "otuzuncu")] - [InlineData(40, "qırxıncı")] - [InlineData(50, "əllinci")] - [InlineData(60, "altmışıncı")] - [InlineData(70, "yetmişinci")] - [InlineData(80, "səksəninci")] - [InlineData(90, "doxsanıncı")] - [InlineData(100, "yüzüncü")] - [InlineData(120, "yüz iyirminci")] - [InlineData(121, "yüz iyirmi birinci")] - [InlineData(200, "iki yüzüncü")] - [InlineData(221, "iki yüz iyirmi birinci")] - [InlineData(300, "üç yüzüncü")] - [InlineData(321, "üç yüz iyirmi birinci")] - [InlineData(1000, "mininci")] - [InlineData(1001, "min birinci")] - [InlineData(10000, "on mininci")] - [InlineData(100000, "yüz mininci")] - [InlineData(1000000, "bir milyonuncu")] - [InlineData(1022135, "bir milyon iyirmi iki min yüz otuz beşinci")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "sıfırıncı")] + [InlineData(1, "birinci")] + [InlineData(2, "ikinci")] + [InlineData(3, "üçüncü")] + [InlineData(4, "dördüncü")] + [InlineData(5, "beşinci")] + [InlineData(6, "altıncı")] + [InlineData(7, "yeddinci")] + [InlineData(8, "səkkizinci")] + [InlineData(9, "doqquzuncu")] + [InlineData(10, "onuncu")] + [InlineData(11, "on birinci")] + [InlineData(12, "on ikinci")] + [InlineData(13, "on üçüncü")] + [InlineData(14, "on dördüncü")] + [InlineData(15, "on beşinci")] + [InlineData(16, "on altıncı")] + [InlineData(17, "on yeddinci")] + [InlineData(18, "on səkkizinci")] + [InlineData(19, "on doqquzuncu")] + [InlineData(20, "iyirminci")] + [InlineData(21, "iyirmi birinci")] + [InlineData(30, "otuzuncu")] + [InlineData(40, "qırxıncı")] + [InlineData(50, "əllinci")] + [InlineData(60, "altmışıncı")] + [InlineData(70, "yetmişinci")] + [InlineData(80, "səksəninci")] + [InlineData(90, "doxsanıncı")] + [InlineData(100, "yüzüncü")] + [InlineData(120, "yüz iyirminci")] + [InlineData(121, "yüz iyirmi birinci")] + [InlineData(200, "iki yüzüncü")] + [InlineData(221, "iki yüz iyirmi birinci")] + [InlineData(300, "üç yüzüncü")] + [InlineData(321, "üç yüz iyirmi birinci")] + [InlineData(1000, "mininci")] + [InlineData(1001, "min birinci")] + [InlineData(10000, "on mininci")] + [InlineData(100000, "yüz mininci")] + [InlineData(1000000, "bir milyonuncu")] + [InlineData(1022135, "bir milyon iyirmi iki min yüz otuz beşinci")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/az/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/az/TimeSpanHumanizeTests.cs index fa9063712..1eec2c569 100644 --- a/src/Humanizer.Tests/Localisation/az/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/az/TimeSpanHumanizeTests.cs @@ -1,94 +1,93 @@ -namespace Humanizer.Tests.Localisation.az +namespace Humanizer.Tests.Localisation.az; + +[UseCulture("az")] +public class TimeSpanHumanizeTests { - [UseCulture("az")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 il")] - [InlineData(731, "2 il")] - [InlineData(1096, "3 il")] - [InlineData(4018, "11 il")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 il")] + [InlineData(731, "2 il")] + [InlineData(1096, "3 il")] + [InlineData(4018, "11 il")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 ay")] - [InlineData(61, "2 ay")] - [InlineData(92, "3 ay")] - [InlineData(335, "11 ay")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ay")] + [InlineData(61, "2 ay")] + [InlineData(92, "3 ay")] + [InlineData(335, "11 ay")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 həftə")] - [InlineData(7, "1 həftə")] - public void Weeks(int days, string expected) - { + [Theory] + [InlineData(14, "2 həftə")] + [InlineData(7, "1 həftə")] + public void Weeks(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(6, "6 gün")] - [InlineData(2, "2 gün")] - public void Days(int days, string expected) - { + [Theory] + [InlineData(6, "6 gün")] + [InlineData(2, "2 gün")] + public void Days(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 saat")] - [InlineData(1, "1 saat")] - public void Hours(int hours, string expected) - { + [Theory] + [InlineData(2, "2 saat")] + [InlineData(1, "1 saat")] + public void Hours(int hours, string expected) + { var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 dəqiqə")] - [InlineData(1, "1 dəqiqə")] - public void Minutes(int minutes, string expected) - { + [Theory] + [InlineData(2, "2 dəqiqə")] + [InlineData(1, "1 dəqiqə")] + public void Minutes(int minutes, string expected) + { var actual = TimeSpan.FromMinutes(minutes).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 saniyə")] - [InlineData(1, "1 saniyə")] - public void Seconds(int seconds, string expected) - { + [Theory] + [InlineData(2, "2 saniyə")] + [InlineData(1, "1 saniyə")] + public void Seconds(int seconds, string expected) + { var actual = TimeSpan.FromSeconds(seconds).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 millisaniyə")] - [InlineData(1, "1 millisaniyə")] - public void Milliseconds(int ms, string expected) - { + [Theory] + [InlineData(2, "2 millisaniyə")] + [InlineData(1, "1 millisaniyə")] + public void Milliseconds(int ms, string expected) + { var actual = TimeSpan.FromMilliseconds(ms).Humanize(); Assert.Equal(expected, actual); } - [Fact] - public void NoTime() - { + [Fact] + public void NoTime() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(); Assert.Equal("0 millisaniyə", actual); } - [Fact] - public void NoTimeToWords() - { + [Fact] + public void NoTimeToWords() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(toWords: true); Assert.Equal("zaman fərqi yoxdur", actual); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs index ec6fd9fcb..1ae38ec0d 100644 --- a/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.bg +namespace Humanizer.Tests.Localisation.bg; + +[UseCulture("bg-BG")] +public class DateHumanizeTests { - [UseCulture("bg-BG")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "преди секунда")] - [InlineData(2, "преди 2 секунди")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "преди секунда")] + [InlineData(2, "преди 2 секунди")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "след секунда")] - [InlineData(2, "след 2 секунди")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "след секунда")] + [InlineData(2, "след 2 секунди")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "преди минута")] - [InlineData(2, "преди 2 минути")] - [InlineData(60, "преди час")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "преди минута")] + [InlineData(2, "преди 2 минути")] + [InlineData(60, "преди час")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "след минута")] - [InlineData(2, "след 2 минути")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "след минута")] + [InlineData(2, "след 2 минути")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "преди час")] - [InlineData(2, "преди 2 часа")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "преди час")] + [InlineData(2, "преди 2 часа")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "след час")] - [InlineData(2, "след 2 часа")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "след час")] + [InlineData(2, "след 2 часа")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "вчера")] - [InlineData(2, "преди 2 дена")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "вчера")] + [InlineData(2, "преди 2 дена")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "утре")] - [InlineData(2, "след 2 дена")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "утре")] + [InlineData(2, "след 2 дена")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "преди месец")] - [InlineData(2, "преди 2 месеца")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "преди месец")] + [InlineData(2, "преди 2 месеца")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "след месец")] - [InlineData(2, "след 2 месеца")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "след месец")] + [InlineData(2, "след 2 месеца")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "преди година")] - [InlineData(2, "преди 2 години")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "преди година")] + [InlineData(2, "преди 2 години")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "след година")] - [InlineData(2, "след 2 години")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "след година")] + [InlineData(2, "след 2 години")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("сега", 0, TimeUnit.Day, Tense.Past); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("сега", 0, TimeUnit.Day, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bg/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/bg/NumberToWordsTests.cs index 44288d9d3..7fb1cc45a 100644 --- a/src/Humanizer.Tests/Localisation/bg/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/bg/NumberToWordsTests.cs @@ -1,151 +1,150 @@ -namespace Humanizer.Tests.Localisation.bg +namespace Humanizer.Tests.Localisation.bg; + +[UseCulture("bg")] +public class NumberToWordsTests { - [UseCulture("bg")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "нула")] - [InlineData(1, "едно")] - [InlineData(10, "десет")] - [InlineData(11, "единадесет")] - [InlineData(12, "дванадесет")] - [InlineData(13, "тринадесет")] - [InlineData(14, "четиринадесет")] - [InlineData(15, "петнадесет")] - [InlineData(16, "шестнадесет")] - [InlineData(17, "седемнадесет")] - [InlineData(18, "осемнадесет")] - [InlineData(19, "деветнадесет")] - [InlineData(20, "двадесет")] - [InlineData(30, "тридесет")] - [InlineData(40, "четиридесет")] - [InlineData(50, "петдесет")] - [InlineData(60, "шестдесет")] - [InlineData(70, "седемдесет")] - [InlineData(80, "осемдесет")] - [InlineData(90, "деветдесет")] - [InlineData(100, "сто")] - [InlineData(200, "двеста")] - [InlineData(300, "триста")] - [InlineData(400, "четиристотин")] - [InlineData(500, "петстотин")] - [InlineData(600, "шестстотин")] - [InlineData(700, "седемстотин")] - [InlineData(800, "осемстотин")] - [InlineData(900, "деветстотин")] - [InlineData(122, "сто двадесет и две")] - [InlineData(111, "сто и единадесет")] - [InlineData(55, "петдесет и пет")] - [InlineData(555, "петстотин петдесет и пет")] - [InlineData(4213, "четири хиляди двеста и тринадесет")] - [InlineData(5000, "пет хиляди")] - [InlineData(28205, "двадесет и осем хиляди двеста и пет")] - [InlineData(35000, "тридесет и пет хиляди")] - [InlineData(352192, "триста петдесет и две хиляди сто деветдесет и две")] - [InlineData(4000210, "четири милиона двеста и десет")] - [InlineData(5200, "пет хиляди и двеста")] - [InlineData(1125000, "един милион и сто двадесет и пет хиляди")] - [InlineData(1000000000, "един милиард")] - public void ToWordsBg(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "нула")] + [InlineData(1, "едно")] + [InlineData(10, "десет")] + [InlineData(11, "единадесет")] + [InlineData(12, "дванадесет")] + [InlineData(13, "тринадесет")] + [InlineData(14, "четиринадесет")] + [InlineData(15, "петнадесет")] + [InlineData(16, "шестнадесет")] + [InlineData(17, "седемнадесет")] + [InlineData(18, "осемнадесет")] + [InlineData(19, "деветнадесет")] + [InlineData(20, "двадесет")] + [InlineData(30, "тридесет")] + [InlineData(40, "четиридесет")] + [InlineData(50, "петдесет")] + [InlineData(60, "шестдесет")] + [InlineData(70, "седемдесет")] + [InlineData(80, "осемдесет")] + [InlineData(90, "деветдесет")] + [InlineData(100, "сто")] + [InlineData(200, "двеста")] + [InlineData(300, "триста")] + [InlineData(400, "четиристотин")] + [InlineData(500, "петстотин")] + [InlineData(600, "шестстотин")] + [InlineData(700, "седемстотин")] + [InlineData(800, "осемстотин")] + [InlineData(900, "деветстотин")] + [InlineData(122, "сто двадесет и две")] + [InlineData(111, "сто и единадесет")] + [InlineData(55, "петдесет и пет")] + [InlineData(555, "петстотин петдесет и пет")] + [InlineData(4213, "четири хиляди двеста и тринадесет")] + [InlineData(5000, "пет хиляди")] + [InlineData(28205, "двадесет и осем хиляди двеста и пет")] + [InlineData(35000, "тридесет и пет хиляди")] + [InlineData(352192, "триста петдесет и две хиляди сто деветдесет и две")] + [InlineData(4000210, "четири милиона двеста и десет")] + [InlineData(5200, "пет хиляди и двеста")] + [InlineData(1125000, "един милион и сто двадесет и пет хиляди")] + [InlineData(1000000000, "един милиард")] + public void ToWordsBg(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "нулев")] - [InlineData(1, "първи")] - [InlineData(2, "втори")] - [InlineData(3, "трети")] - [InlineData(4, "четвърти")] - [InlineData(5, "пети")] - [InlineData(6, "шести")] - [InlineData(7, "седми")] - [InlineData(8, "осми")] - [InlineData(11, "единадесети")] - [InlineData(12, "дванадесети")] - [InlineData(13, "тринадесети")] - [InlineData(14, "четиринадесети")] - [InlineData(15, "петнадесети")] - [InlineData(16, "шестнадесети")] - [InlineData(17, "седемнадесети")] - [InlineData(18, "осемнадесети")] - [InlineData(19, "деветнадесети")] - [InlineData(20, "двадесети")] - [InlineData(30, "тридесети")] - [InlineData(40, "четиридесети")] - [InlineData(50, "петдесети")] - [InlineData(60, "шестдесети")] - [InlineData(70, "седемдесети")] - [InlineData(80, "осемдесети")] - [InlineData(90, "деветдесети")] - [InlineData(21, "двадесет и първи")] - [InlineData(22, "двадесет и втори")] - [InlineData(35, "тридесет и пети")] - public void ToOrdinalWordsMasculine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "нулев")] + [InlineData(1, "първи")] + [InlineData(2, "втори")] + [InlineData(3, "трети")] + [InlineData(4, "четвърти")] + [InlineData(5, "пети")] + [InlineData(6, "шести")] + [InlineData(7, "седми")] + [InlineData(8, "осми")] + [InlineData(11, "единадесети")] + [InlineData(12, "дванадесети")] + [InlineData(13, "тринадесети")] + [InlineData(14, "четиринадесети")] + [InlineData(15, "петнадесети")] + [InlineData(16, "шестнадесети")] + [InlineData(17, "седемнадесети")] + [InlineData(18, "осемнадесети")] + [InlineData(19, "деветнадесети")] + [InlineData(20, "двадесети")] + [InlineData(30, "тридесети")] + [InlineData(40, "четиридесети")] + [InlineData(50, "петдесети")] + [InlineData(60, "шестдесети")] + [InlineData(70, "седемдесети")] + [InlineData(80, "осемдесети")] + [InlineData(90, "деветдесети")] + [InlineData(21, "двадесет и първи")] + [InlineData(22, "двадесет и втори")] + [InlineData(35, "тридесет и пети")] + public void ToOrdinalWordsMasculine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(0, "нулева")] - [InlineData(1, "първа")] - [InlineData(2, "втора")] - [InlineData(3, "трета")] - [InlineData(4, "четвърта")] - [InlineData(5, "пета")] - [InlineData(6, "шеста")] - [InlineData(7, "седма")] - [InlineData(8, "осма")] - [InlineData(11, "единадесета")] - [InlineData(12, "дванадесета")] - [InlineData(13, "тринадесета")] - [InlineData(14, "четиринадесета")] - [InlineData(15, "петнадесета")] - [InlineData(16, "шестнадесета")] - [InlineData(17, "седемнадесета")] - [InlineData(18, "осемнадесета")] - [InlineData(19, "деветнадесета")] - [InlineData(20, "двадесета")] - [InlineData(30, "тридесета")] - [InlineData(40, "четиридесета")] - [InlineData(50, "петдесета")] - [InlineData(60, "шестдесета")] - [InlineData(70, "седемдесета")] - [InlineData(80, "осемдесета")] - [InlineData(90, "деветдесета")] - [InlineData(21, "двадесет и първа")] - [InlineData(22, "двадесет и втора")] - [InlineData(35, "тридесет и пета")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "нулева")] + [InlineData(1, "първа")] + [InlineData(2, "втора")] + [InlineData(3, "трета")] + [InlineData(4, "четвърта")] + [InlineData(5, "пета")] + [InlineData(6, "шеста")] + [InlineData(7, "седма")] + [InlineData(8, "осма")] + [InlineData(11, "единадесета")] + [InlineData(12, "дванадесета")] + [InlineData(13, "тринадесета")] + [InlineData(14, "четиринадесета")] + [InlineData(15, "петнадесета")] + [InlineData(16, "шестнадесета")] + [InlineData(17, "седемнадесета")] + [InlineData(18, "осемнадесета")] + [InlineData(19, "деветнадесета")] + [InlineData(20, "двадесета")] + [InlineData(30, "тридесета")] + [InlineData(40, "четиридесета")] + [InlineData(50, "петдесета")] + [InlineData(60, "шестдесета")] + [InlineData(70, "седемдесета")] + [InlineData(80, "осемдесета")] + [InlineData(90, "деветдесета")] + [InlineData(21, "двадесет и първа")] + [InlineData(22, "двадесет и втора")] + [InlineData(35, "тридесет и пета")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "нулево")] - [InlineData(1, "първо")] - [InlineData(2, "второ")] - [InlineData(3, "трето")] - [InlineData(4, "четвърто")] - [InlineData(5, "пето")] - [InlineData(6, "шесто")] - [InlineData(7, "седмо")] - [InlineData(8, "осмо")] - [InlineData(11, "единадесето")] - [InlineData(12, "дванадесето")] - [InlineData(13, "тринадесето")] - [InlineData(14, "четиринадесето")] - [InlineData(15, "петнадесето")] - [InlineData(16, "шестнадесето")] - [InlineData(17, "седемнадесето")] - [InlineData(18, "осемнадесето")] - [InlineData(19, "деветнадесето")] - [InlineData(20, "двадесето")] - [InlineData(30, "тридесето")] - [InlineData(40, "четиридесето")] - [InlineData(50, "петдесето")] - [InlineData(60, "шестдесето")] - [InlineData(70, "седемдесето")] - [InlineData(80, "осемдесето")] - [InlineData(90, "деветдесето")] - [InlineData(21, "двадесет и първо")] - [InlineData(22, "двадесет и второ")] - [InlineData(35, "тридесет и пето")] - public void ToOrdinalWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(0, "нулево")] + [InlineData(1, "първо")] + [InlineData(2, "второ")] + [InlineData(3, "трето")] + [InlineData(4, "четвърто")] + [InlineData(5, "пето")] + [InlineData(6, "шесто")] + [InlineData(7, "седмо")] + [InlineData(8, "осмо")] + [InlineData(11, "единадесето")] + [InlineData(12, "дванадесето")] + [InlineData(13, "тринадесето")] + [InlineData(14, "четиринадесето")] + [InlineData(15, "петнадесето")] + [InlineData(16, "шестнадесето")] + [InlineData(17, "седемнадесето")] + [InlineData(18, "осемнадесето")] + [InlineData(19, "деветнадесето")] + [InlineData(20, "двадесето")] + [InlineData(30, "тридесето")] + [InlineData(40, "четиридесето")] + [InlineData(50, "петдесето")] + [InlineData(60, "шестдесето")] + [InlineData(70, "седемдесето")] + [InlineData(80, "осемдесето")] + [InlineData(90, "деветдесето")] + [InlineData(21, "двадесет и първо")] + [InlineData(22, "двадесет и второ")] + [InlineData(35, "тридесет и пето")] + public void ToOrdinalWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs index 13c3556b3..496ead316 100644 --- a/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs @@ -1,69 +1,68 @@ -namespace Humanizer.Tests.Localisation.bg +namespace Humanizer.Tests.Localisation.bg; + +[UseCulture("bg-BG")] +public class TimeSpanHumanizeTests { - [UseCulture("bg-BG")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "една година")] - [InlineData(731, "2 години")] - [InlineData(1096, "3 години")] - [InlineData(4018, "11 години")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "една година")] + [InlineData(731, "2 години")] + [InlineData(1096, "3 години")] + [InlineData(4018, "11 години")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "един месец")] - [InlineData(61, "2 месеца")] - [InlineData(92, "3 месеца")] - [InlineData(335, "11 месеца")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "един месец")] + [InlineData(61, "2 месеца")] + [InlineData(92, "3 месеца")] + [InlineData(335, "11 месеца")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "една седмица")] - [InlineData(14, "2 седмици")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "една седмица")] + [InlineData(14, "2 седмици")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "един ден")] - [InlineData(2, "2 дена")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "един ден")] + [InlineData(2, "2 дена")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "един час")] - [InlineData(2, "2 часа")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "един час")] + [InlineData(2, "2 часа")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "една минута")] - [InlineData(2, "2 минути")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "една минута")] + [InlineData(2, "2 минути")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "една секунда")] - [InlineData(2, "2 секунди")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "една секунда")] + [InlineData(2, "2 секунди")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "една милисекунда")] - [InlineData(2, "2 милисекунди")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "една милисекунда")] + [InlineData(2, "2 милисекунди")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("0 милисекунди", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("0 милисекунди", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("няма време", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("няма време", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bn-BD/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bn-BD/DateHumanizeTests.cs index 4d54e7bc4..91fb058c6 100644 --- a/src/Humanizer.Tests/Localisation/bn-BD/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/bn-BD/DateHumanizeTests.cs @@ -1,78 +1,77 @@ -namespace Humanizer.Tests.Localisation.bnBD +namespace Humanizer.Tests.Localisation.bnBD; + +[UseCulture("bn-BD")] +public class DateHumanizeTests { - [UseCulture("bn-BD")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "আগামিকাল")] - [InlineData(13, "13 দিন পর")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "আগামিকাল")] + [InlineData(13, "13 দিন পর")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-1, "গতকাল")] - [InlineData(-11, "11 দিন আগে")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-1, "গতকাল")] + [InlineData(-11, "11 দিন আগে")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "এক ঘণ্টা পর")] - [InlineData(11, "11 ঘণ্টা পর")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "এক ঘণ্টা পর")] + [InlineData(11, "11 ঘণ্টা পর")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-1, "এক ঘণ্টা আগে")] - [InlineData(-11, "11 ঘণ্টা আগে")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-1, "এক ঘণ্টা আগে")] + [InlineData(-11, "11 ঘণ্টা আগে")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "এক মিনিট পর")] - [InlineData(13, "13 মিনিট পর")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "এক মিনিট পর")] + [InlineData(13, "13 মিনিট পর")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-1, "এক মিনিট আগে")] - [InlineData(-13, "13 মিনিট আগে")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-1, "এক মিনিট আগে")] + [InlineData(-13, "13 মিনিট আগে")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "এক মাস পর")] - [InlineData(10, "10 মাস পর")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "এক মাস পর")] + [InlineData(10, "10 মাস পর")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-1, "এক মাস আগে")] - [InlineData(-10, "10 মাস আগে")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-1, "এক মাস আগে")] + [InlineData(-10, "10 মাস আগে")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "এক সেকেন্ড পর")] - [InlineData(11, "11 সেকেন্ড পর")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "এক সেকেন্ড পর")] + [InlineData(11, "11 সেকেন্ড পর")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-1, "এক সেকেন্ড আগে")] - [InlineData(-11, "11 সেকেন্ড আগে")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-1, "এক সেকেন্ড আগে")] + [InlineData(-11, "11 সেকেন্ড আগে")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "এক বছর পর")] - [InlineData(21, "21 বছর পর")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "এক বছর পর")] + [InlineData(21, "21 বছর পর")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(-1, "এক বছর আগে")] - [InlineData(-21, "21 বছর আগে")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - } -} + [Theory] + [InlineData(-1, "এক বছর আগে")] + [InlineData(-21, "21 বছর আগে")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bn-BD/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/bn-BD/NumberToWordsTests.cs index 916ada15f..b7df52bcb 100644 --- a/src/Humanizer.Tests/Localisation/bn-BD/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/bn-BD/NumberToWordsTests.cs @@ -1,77 +1,76 @@ -namespace Humanizer.Tests.Localisation.bnBD +namespace Humanizer.Tests.Localisation.bnBD; + +[UseCulture("bn-BD")] +public class NumberToWordsTests { - [UseCulture("bn-BD")] - public class NumberToWordsTests - { - [InlineData(0, "শূন্য")] - [InlineData(1, "এক")] - [InlineData(10, "দশ")] - [InlineData(11, "এগারো")] - [InlineData(20, "বিশ")] - [InlineData(122, "একশ বাইশ")] - [InlineData(3501, "তিন হাজার পাঁচশ এক")] - [InlineData(100, "একশ")] - [InlineData(1000, "এক হাজার")] - [InlineData(100000, "এক লক্ষ")] - [InlineData(1000000, "দশ লক্ষ")] - [InlineData(10000000, "এক কোটি")] - [InlineData(100000000, "দশ কোটি")] - [InlineData(1000000000, "একশ কোটি")] - [InlineData(111, "একশ এগারো")] - [InlineData(1111, "এক হাজার একশ এগারো")] - [InlineData(111111, "এক লক্ষ এগারো হাজার একশ এগারো")] - [InlineData(1111111, "এগারো লক্ষ এগারো হাজার একশ এগারো")] - [InlineData(11111111, "এক কোটি এগারো লক্ষ এগারো হাজার একশ এগারো")] - [InlineData(111111111, "এগারো কোটি এগারো লক্ষ এগারো হাজার একশ এগারো")] - [InlineData(1111111111, "একশ এগারো কোটি এগারো লক্ষ এগারো হাজার একশ এগারো")] - [InlineData(123, "একশ তেইশ")] - [InlineData(1234, "এক হাজার দুইশ চৌঁতিরিশ")] - [InlineData(12345, "বারো হাজার তিনশ পঁয়তাল্লিশ")] - [InlineData(123456, "এক লক্ষ তেইশ হাজার চারশ ছাপ্পান্ন")] - [InlineData(1234567, "বারো লক্ষ চৌঁতিরিশ হাজার পাঁচশ সাতষট্টি")] - [InlineData(12345678, "এক কোটি তেইশ লক্ষ পঁয়তাল্লিশ হাজার ছয়শ আটাত্তর")] - [InlineData(123456789, "বারো কোটি চৌঁতিরিশ লক্ষ ছাপ্পান্ন হাজার সাতশ উননব্বই")] - [InlineData(1234567890, "একশ তেইশ কোটি পঁয়তাল্লিশ লক্ষ সাতষট্টি হাজার আটশ নব্বই")] - [InlineData(-1234567890, "ঋণাত্মক একশ তেইশ কোটি পঁয়তাল্লিশ লক্ষ সাতষট্টি হাজার আটশ নব্বই")] - [Theory] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [InlineData(0, "শূন্য")] + [InlineData(1, "এক")] + [InlineData(10, "দশ")] + [InlineData(11, "এগারো")] + [InlineData(20, "বিশ")] + [InlineData(122, "একশ বাইশ")] + [InlineData(3501, "তিন হাজার পাঁচশ এক")] + [InlineData(100, "একশ")] + [InlineData(1000, "এক হাজার")] + [InlineData(100000, "এক লক্ষ")] + [InlineData(1000000, "দশ লক্ষ")] + [InlineData(10000000, "এক কোটি")] + [InlineData(100000000, "দশ কোটি")] + [InlineData(1000000000, "একশ কোটি")] + [InlineData(111, "একশ এগারো")] + [InlineData(1111, "এক হাজার একশ এগারো")] + [InlineData(111111, "এক লক্ষ এগারো হাজার একশ এগারো")] + [InlineData(1111111, "এগারো লক্ষ এগারো হাজার একশ এগারো")] + [InlineData(11111111, "এক কোটি এগারো লক্ষ এগারো হাজার একশ এগারো")] + [InlineData(111111111, "এগারো কোটি এগারো লক্ষ এগারো হাজার একশ এগারো")] + [InlineData(1111111111, "একশ এগারো কোটি এগারো লক্ষ এগারো হাজার একশ এগারো")] + [InlineData(123, "একশ তেইশ")] + [InlineData(1234, "এক হাজার দুইশ চৌঁতিরিশ")] + [InlineData(12345, "বারো হাজার তিনশ পঁয়তাল্লিশ")] + [InlineData(123456, "এক লক্ষ তেইশ হাজার চারশ ছাপ্পান্ন")] + [InlineData(1234567, "বারো লক্ষ চৌঁতিরিশ হাজার পাঁচশ সাতষট্টি")] + [InlineData(12345678, "এক কোটি তেইশ লক্ষ পঁয়তাল্লিশ হাজার ছয়শ আটাত্তর")] + [InlineData(123456789, "বারো কোটি চৌঁতিরিশ লক্ষ ছাপ্পান্ন হাজার সাতশ উননব্বই")] + [InlineData(1234567890, "একশ তেইশ কোটি পঁয়তাল্লিশ লক্ষ সাতষট্টি হাজার আটশ নব্বই")] + [InlineData(-1234567890, "ঋণাত্মক একশ তেইশ কোটি পঁয়তাল্লিশ লক্ষ সাতষট্টি হাজার আটশ নব্বই")] + [Theory] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "শূন্য তম")] - [InlineData(1, "প্রথম")] - [InlineData(2, "দ্বিতীয়")] - [InlineData(3, "তৃতীয়")] - [InlineData(4, "চতুর্থ")] - [InlineData(5, "পঞ্চম")] - [InlineData(6, "ষষ্ট")] - [InlineData(7, "সপ্তম")] - [InlineData(8, "অষ্টম")] - [InlineData(9, "নবম")] - [InlineData(10, "দশম")] - [InlineData(11, "একাদশ")] - [InlineData(12, "দ্বাদশ")] - [InlineData(13, "ত্রয়োদশ")] - [InlineData(14, "চতুর্দশ")] - [InlineData(15, "পঞ্চদশ")] - [InlineData(16, "ষোড়শ")] - [InlineData(17, "সপ্তদশ")] - [InlineData(18, "অষ্টাদশ")] - [InlineData(19, "উনিশ তম")] - [InlineData(20, "বিশ তম")] - [InlineData(21, "একুশ তম")] - [InlineData(100, "শত তম")] - [InlineData(112, "একশ বারো তম")] - [InlineData(118, "একশ আঠারো তম")] - [InlineData(1000, "হাজার তম")] - [InlineData(1001, "এক হাজার এক তম")] - [InlineData(1021, "এক হাজার একুশ তম")] - [InlineData(10000, "দশ হাজার তম")] - [InlineData(10121, "দশ হাজার একশ একুশ তম")] - [InlineData(100000, "লক্ষ তম")] - [InlineData(1000000, "দশ লক্ষ তম")] - [InlineData(10000000, "কোটি তম")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "শূন্য তম")] + [InlineData(1, "প্রথম")] + [InlineData(2, "দ্বিতীয়")] + [InlineData(3, "তৃতীয়")] + [InlineData(4, "চতুর্থ")] + [InlineData(5, "পঞ্চম")] + [InlineData(6, "ষষ্ট")] + [InlineData(7, "সপ্তম")] + [InlineData(8, "অষ্টম")] + [InlineData(9, "নবম")] + [InlineData(10, "দশম")] + [InlineData(11, "একাদশ")] + [InlineData(12, "দ্বাদশ")] + [InlineData(13, "ত্রয়োদশ")] + [InlineData(14, "চতুর্দশ")] + [InlineData(15, "পঞ্চদশ")] + [InlineData(16, "ষোড়শ")] + [InlineData(17, "সপ্তদশ")] + [InlineData(18, "অষ্টাদশ")] + [InlineData(19, "উনিশ তম")] + [InlineData(20, "বিশ তম")] + [InlineData(21, "একুশ তম")] + [InlineData(100, "শত তম")] + [InlineData(112, "একশ বারো তম")] + [InlineData(118, "একশ আঠারো তম")] + [InlineData(1000, "হাজার তম")] + [InlineData(1001, "এক হাজার এক তম")] + [InlineData(1021, "এক হাজার একুশ তম")] + [InlineData(10000, "দশ হাজার তম")] + [InlineData(10121, "দশ হাজার একশ একুশ তম")] + [InlineData(100000, "লক্ষ তম")] + [InlineData(1000000, "দশ লক্ষ তম")] + [InlineData(10000000, "কোটি তম")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bn-BD/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bn-BD/TimeSpanHumanizeTests.cs index 70018c51a..78a599733 100644 --- a/src/Humanizer.Tests/Localisation/bn-BD/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/bn-BD/TimeSpanHumanizeTests.cs @@ -1,69 +1,68 @@ -namespace Humanizer.Tests.Localisation.bnBD +namespace Humanizer.Tests.Localisation.bnBD; + +[UseCulture("bn-BD")] +public class TimeSpanHumanizeTests { - [UseCulture("bn-BD")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "এক বছর")] - [InlineData(731, "2 বছর")] - [InlineData(1096, "3 বছর")] - [InlineData(4018, "11 বছর")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "এক বছর")] + [InlineData(731, "2 বছর")] + [InlineData(1096, "3 বছর")] + [InlineData(4018, "11 বছর")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "এক মাসের")] - [InlineData(61, "2 মাস")] - [InlineData(92, "3 মাস")] - [InlineData(335, "11 মাস")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "এক মাসের")] + [InlineData(61, "2 মাস")] + [InlineData(92, "3 মাস")] + [InlineData(335, "11 মাস")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "এক সপ্তাহ")] - [InlineData(14, "2 সপ্তাহ")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "এক সপ্তাহ")] + [InlineData(14, "2 সপ্তাহ")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "এক দিন")] - [InlineData(2, "2 দিন")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "এক দিন")] + [InlineData(2, "2 দিন")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "এক ঘণ্টা")] - [InlineData(2, "2 ঘণ্টা")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "এক ঘণ্টা")] + [InlineData(2, "2 ঘণ্টা")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "এক মিনিট")] - [InlineData(2, "2 মিনিট")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "এক মিনিট")] + [InlineData(2, "2 মিনিট")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "এক সেকেন্ড")] - [InlineData(2, "2 সেকেন্ড")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "এক সেকেন্ড")] + [InlineData(2, "2 সেকেন্ড")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "এক মিলিসেকেন্ড")] - [InlineData(2, "2 মিলিসেকেন্ড")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "এক মিলিসেকেন্ড")] + [InlineData(2, "2 মিলিসেকেন্ড")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 মিলিসেকেন্ড", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 মিলিসেকেন্ড", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one really doesn't make a lot of sense but again... w/e - Assert.Equal("শূন্য সময়", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one really doesn't make a lot of sense but again... w/e + Assert.Equal("শূন্য সময়", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs index 81a5d32d6..85203f63b 100644 --- a/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs @@ -1,137 +1,136 @@ -namespace Humanizer.Tests.Localisation.cs +namespace Humanizer.Tests.Localisation.cs; + +[UseCulture("cs-CZ")] +public class DateHumanizeTests { - [UseCulture("cs-CZ")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "za sekundu")] - [InlineData(2, "za 2 sekundy")] - [InlineData(3, "za 3 sekundy")] - [InlineData(4, "za 4 sekundy")] - [InlineData(5, "za 5 sekund")] - [InlineData(6, "za 6 sekund")] - [InlineData(10, "za 10 sekund")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "za sekundu")] + [InlineData(2, "za 2 sekundy")] + [InlineData(3, "za 3 sekundy")] + [InlineData(4, "za 4 sekundy")] + [InlineData(5, "za 5 sekund")] + [InlineData(6, "za 6 sekund")] + [InlineData(10, "za 10 sekund")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "za minutu")] - [InlineData(2, "za 2 minuty")] - [InlineData(3, "za 3 minuty")] - [InlineData(4, "za 4 minuty")] - [InlineData(5, "za 5 minut")] - [InlineData(6, "za 6 minut")] - [InlineData(10, "za 10 minut")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "za minutu")] + [InlineData(2, "za 2 minuty")] + [InlineData(3, "za 3 minuty")] + [InlineData(4, "za 4 minuty")] + [InlineData(5, "za 5 minut")] + [InlineData(6, "za 6 minut")] + [InlineData(10, "za 10 minut")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "za hodinu")] - [InlineData(2, "za 2 hodiny")] - [InlineData(3, "za 3 hodiny")] - [InlineData(4, "za 4 hodiny")] - [InlineData(5, "za 5 hodin")] - [InlineData(6, "za 6 hodin")] - [InlineData(10, "za 10 hodin")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "za hodinu")] + [InlineData(2, "za 2 hodiny")] + [InlineData(3, "za 3 hodiny")] + [InlineData(4, "za 4 hodiny")] + [InlineData(5, "za 5 hodin")] + [InlineData(6, "za 6 hodin")] + [InlineData(10, "za 10 hodin")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "zítra")] - [InlineData(2, "za 2 dny")] - [InlineData(3, "za 3 dny")] - [InlineData(4, "za 4 dny")] - [InlineData(9, "za 9 dnů")] - [InlineData(10, "za 10 dnů")] - public void DayFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "zítra")] + [InlineData(2, "za 2 dny")] + [InlineData(3, "za 3 dny")] + [InlineData(4, "za 4 dny")] + [InlineData(9, "za 9 dnů")] + [InlineData(10, "za 10 dnů")] + public void DayFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "za měsíc")] - [InlineData(2, "za 2 měsíce")] - [InlineData(3, "za 3 měsíce")] - [InlineData(4, "za 4 měsíce")] - [InlineData(5, "za 5 měsíců")] - [InlineData(6, "za 6 měsíců")] - [InlineData(10, "za 10 měsíců")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "za měsíc")] + [InlineData(2, "za 2 měsíce")] + [InlineData(3, "za 3 měsíce")] + [InlineData(4, "za 4 měsíce")] + [InlineData(5, "za 5 měsíců")] + [InlineData(6, "za 6 měsíců")] + [InlineData(10, "za 10 měsíců")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "za rok")] - [InlineData(2, "za 2 roky")] - [InlineData(3, "za 3 roky")] - [InlineData(4, "za 4 roky")] - [InlineData(5, "za 5 let")] - [InlineData(6, "za 6 let")] - [InlineData(10, "za 10 let")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "za rok")] + [InlineData(2, "za 2 roky")] + [InlineData(3, "za 3 roky")] + [InlineData(4, "za 4 roky")] + [InlineData(5, "za 5 let")] + [InlineData(6, "za 6 let")] + [InlineData(10, "za 10 let")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(1, "před sekundou")] - [InlineData(2, "před 2 sekundami")] - [InlineData(3, "před 3 sekundami")] - [InlineData(4, "před 4 sekundami")] - [InlineData(5, "před 5 sekundami")] - [InlineData(6, "před 6 sekundami")] - [InlineData(10, "před 10 sekundami")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "před sekundou")] + [InlineData(2, "před 2 sekundami")] + [InlineData(3, "před 3 sekundami")] + [InlineData(4, "před 4 sekundami")] + [InlineData(5, "před 5 sekundami")] + [InlineData(6, "před 6 sekundami")] + [InlineData(10, "před 10 sekundami")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "před minutou")] - [InlineData(2, "před 2 minutami")] - [InlineData(3, "před 3 minutami")] - [InlineData(4, "před 4 minutami")] - [InlineData(5, "před 5 minutami")] - [InlineData(6, "před 6 minutami")] - [InlineData(10, "před 10 minutami")] - [InlineData(60, "před hodinou")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "před minutou")] + [InlineData(2, "před 2 minutami")] + [InlineData(3, "před 3 minutami")] + [InlineData(4, "před 4 minutami")] + [InlineData(5, "před 5 minutami")] + [InlineData(6, "před 6 minutami")] + [InlineData(10, "před 10 minutami")] + [InlineData(60, "před hodinou")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "před hodinou")] - [InlineData(2, "před 2 hodinami")] - [InlineData(3, "před 3 hodinami")] - [InlineData(4, "před 4 hodinami")] - [InlineData(5, "před 5 hodinami")] - [InlineData(6, "před 6 hodinami")] - [InlineData(10, "před 10 hodinami")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "před hodinou")] + [InlineData(2, "před 2 hodinami")] + [InlineData(3, "před 3 hodinami")] + [InlineData(4, "před 4 hodinami")] + [InlineData(5, "před 5 hodinami")] + [InlineData(6, "před 6 hodinami")] + [InlineData(10, "před 10 hodinami")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "včera")] - [InlineData(2, "před 2 dny")] - [InlineData(3, "před 3 dny")] - [InlineData(4, "před 4 dny")] - [InlineData(9, "před 9 dny")] - [InlineData(10, "před 10 dny")] - public void DayAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "včera")] + [InlineData(2, "před 2 dny")] + [InlineData(3, "před 3 dny")] + [InlineData(4, "před 4 dny")] + [InlineData(9, "před 9 dny")] + [InlineData(10, "před 10 dny")] + public void DayAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "před měsícem")] - [InlineData(2, "před 2 měsíci")] - [InlineData(3, "před 3 měsíci")] - [InlineData(4, "před 4 měsíci")] - [InlineData(5, "před 5 měsíci")] - [InlineData(6, "před 6 měsíci")] - [InlineData(10, "před 10 měsíci")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "před měsícem")] + [InlineData(2, "před 2 měsíci")] + [InlineData(3, "před 3 měsíci")] + [InlineData(4, "před 4 měsíci")] + [InlineData(5, "před 5 měsíci")] + [InlineData(6, "před 6 měsíci")] + [InlineData(10, "před 10 měsíci")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "před rokem")] - [InlineData(2, "před 2 lety")] - [InlineData(3, "před 3 lety")] - [InlineData(4, "před 4 lety")] - [InlineData(5, "před 5 lety")] - [InlineData(6, "před 6 lety")] - [InlineData(10, "před 10 lety")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - } -} + [Theory] + [InlineData(1, "před rokem")] + [InlineData(2, "před 2 lety")] + [InlineData(3, "před 3 lety")] + [InlineData(4, "před 4 lety")] + [InlineData(5, "před 5 lety")] + [InlineData(6, "před 6 lety")] + [InlineData(10, "před 10 lety")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/cs/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/cs/NumberToWordsTests.cs index d758bf1b1..b29bb6945 100644 --- a/src/Humanizer.Tests/Localisation/cs/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/cs/NumberToWordsTests.cs @@ -1,171 +1,170 @@ -namespace Humanizer.Tests.Localisation.cs +namespace Humanizer.Tests.Localisation.cs; + +[UseCulture("cs-CZ")] +public class NumberToWordsTests { - [UseCulture("cs-CZ")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "nula")] - [InlineData(1, "jeden")] - [InlineData(2, "dva")] - [InlineData(3, "tři")] - [InlineData(4, "čtyři")] - [InlineData(5, "pět")] - [InlineData(6, "šest")] - [InlineData(7, "sedm")] - [InlineData(8, "osm")] - [InlineData(9, "devět")] - [InlineData(10, "deset")] - [InlineData(11, "jedenáct")] - [InlineData(12, "dvanáct")] - [InlineData(13, "třináct")] - [InlineData(14, "čtrnáct")] - [InlineData(15, "patnáct")] - [InlineData(16, "šestnáct")] - [InlineData(17, "sedmnáct")] - [InlineData(18, "osmnáct")] - [InlineData(19, "devatenáct")] - [InlineData(20, "dvacet")] - [InlineData(22, "dvacet dva")] - [InlineData(30, "třicet")] - [InlineData(40, "čtyřicet")] - [InlineData(50, "padesát")] - [InlineData(60, "šedesát")] - [InlineData(70, "sedmdesát")] - [InlineData(80, "osmdesát")] - [InlineData(90, "devadesát")] - [InlineData(100, "sto")] - [InlineData(112, "sto dvanáct")] - [InlineData(128, "sto dvacet osm")] - [InlineData(1000, "jeden tisíc")] - [InlineData(2000, "dva tisíce")] - [InlineData(5000, "pět tisíc")] - [InlineData(10000, "deset tisíc")] - [InlineData(20000, "dvacet tisíc")] - [InlineData(21000, "dvacet jedna tisíc")] - [InlineData(22000, "dvacet dva tisíc")] - [InlineData(25000, "dvacet pět tisíc")] - [InlineData(100000, "sto tisíc")] - [InlineData(500000, "pět set tisíc")] - [InlineData(1000000, "jeden milion")] - [InlineData(2000000, "dva miliony")] - [InlineData(5000000, "pět milionů")] - [InlineData(1000000000, "jedna miliarda")] - [InlineData(1001001001, "jedna miliarda jeden milion jeden tisíc jeden")] - [InlineData(2000000000, "dvě miliardy")] - [InlineData(1501001892, "jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dva")] - [InlineData(2147483647, "dvě miliardy sto čtyřicet sedm milionů čtyři sta osmdesát tři tisíc šest set čtyřicet sedm")] - [InlineData(-1501001892, "mínus jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dva")] - public void ToWordsCzech(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "nula")] + [InlineData(1, "jeden")] + [InlineData(2, "dva")] + [InlineData(3, "tři")] + [InlineData(4, "čtyři")] + [InlineData(5, "pět")] + [InlineData(6, "šest")] + [InlineData(7, "sedm")] + [InlineData(8, "osm")] + [InlineData(9, "devět")] + [InlineData(10, "deset")] + [InlineData(11, "jedenáct")] + [InlineData(12, "dvanáct")] + [InlineData(13, "třináct")] + [InlineData(14, "čtrnáct")] + [InlineData(15, "patnáct")] + [InlineData(16, "šestnáct")] + [InlineData(17, "sedmnáct")] + [InlineData(18, "osmnáct")] + [InlineData(19, "devatenáct")] + [InlineData(20, "dvacet")] + [InlineData(22, "dvacet dva")] + [InlineData(30, "třicet")] + [InlineData(40, "čtyřicet")] + [InlineData(50, "padesát")] + [InlineData(60, "šedesát")] + [InlineData(70, "sedmdesát")] + [InlineData(80, "osmdesát")] + [InlineData(90, "devadesát")] + [InlineData(100, "sto")] + [InlineData(112, "sto dvanáct")] + [InlineData(128, "sto dvacet osm")] + [InlineData(1000, "jeden tisíc")] + [InlineData(2000, "dva tisíce")] + [InlineData(5000, "pět tisíc")] + [InlineData(10000, "deset tisíc")] + [InlineData(20000, "dvacet tisíc")] + [InlineData(21000, "dvacet jedna tisíc")] + [InlineData(22000, "dvacet dva tisíc")] + [InlineData(25000, "dvacet pět tisíc")] + [InlineData(100000, "sto tisíc")] + [InlineData(500000, "pět set tisíc")] + [InlineData(1000000, "jeden milion")] + [InlineData(2000000, "dva miliony")] + [InlineData(5000000, "pět milionů")] + [InlineData(1000000000, "jedna miliarda")] + [InlineData(1001001001, "jedna miliarda jeden milion jeden tisíc jeden")] + [InlineData(2000000000, "dvě miliardy")] + [InlineData(1501001892, "jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dva")] + [InlineData(2147483647, "dvě miliardy sto čtyřicet sedm milionů čtyři sta osmdesát tři tisíc šest set čtyřicet sedm")] + [InlineData(-1501001892, "mínus jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dva")] + public void ToWordsCzech(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nula")] - [InlineData(1, "jedna")] - [InlineData(2, "dvě")] - [InlineData(3, "tři")] - [InlineData(4, "čtyři")] - [InlineData(5, "pět")] - [InlineData(6, "šest")] - [InlineData(7, "sedm")] - [InlineData(8, "osm")] - [InlineData(9, "devět")] - [InlineData(10, "deset")] - [InlineData(11, "jedenáct")] - [InlineData(12, "dvanáct")] - [InlineData(13, "třináct")] - [InlineData(14, "čtrnáct")] - [InlineData(15, "patnáct")] - [InlineData(16, "šestnáct")] - [InlineData(17, "sedmnáct")] - [InlineData(18, "osmnáct")] - [InlineData(19, "devatenáct")] - [InlineData(20, "dvacet")] - [InlineData(22, "dvacet dvě")] - [InlineData(30, "třicet")] - [InlineData(40, "čtyřicet")] - [InlineData(50, "padesát")] - [InlineData(60, "šedesát")] - [InlineData(70, "sedmdesát")] - [InlineData(80, "osmdesát")] - [InlineData(90, "devadesát")] - [InlineData(100, "sto")] - [InlineData(112, "sto dvanáct")] - [InlineData(128, "sto dvacet osm")] - [InlineData(1000, "jeden tisíc")] - [InlineData(2000, "dva tisíce")] - [InlineData(5000, "pět tisíc")] - [InlineData(10000, "deset tisíc")] - [InlineData(20000, "dvacet tisíc")] - [InlineData(21000, "dvacet jedna tisíc")] - [InlineData(22000, "dvacet dva tisíc")] - [InlineData(25000, "dvacet pět tisíc")] - [InlineData(100000, "sto tisíc")] - [InlineData(500000, "pět set tisíc")] - [InlineData(1000000, "jeden milion")] - [InlineData(2000000, "dva miliony")] - [InlineData(5000000, "pět milionů")] - [InlineData(1000000000, "jedna miliarda")] - [InlineData(1001001001, "jedna miliarda jeden milion jeden tisíc jedna")] - [InlineData(2000000000, "dvě miliardy")] - [InlineData(1501001892, "jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] - [InlineData(2147483647, "dvě miliardy sto čtyřicet sedm milionů čtyři sta osmdesát tři tisíc šest set čtyřicet sedm")] - [InlineData(-1501001892, "mínus jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] - public void ToWordsCzechFeminine(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "nula")] + [InlineData(1, "jedna")] + [InlineData(2, "dvě")] + [InlineData(3, "tři")] + [InlineData(4, "čtyři")] + [InlineData(5, "pět")] + [InlineData(6, "šest")] + [InlineData(7, "sedm")] + [InlineData(8, "osm")] + [InlineData(9, "devět")] + [InlineData(10, "deset")] + [InlineData(11, "jedenáct")] + [InlineData(12, "dvanáct")] + [InlineData(13, "třináct")] + [InlineData(14, "čtrnáct")] + [InlineData(15, "patnáct")] + [InlineData(16, "šestnáct")] + [InlineData(17, "sedmnáct")] + [InlineData(18, "osmnáct")] + [InlineData(19, "devatenáct")] + [InlineData(20, "dvacet")] + [InlineData(22, "dvacet dvě")] + [InlineData(30, "třicet")] + [InlineData(40, "čtyřicet")] + [InlineData(50, "padesát")] + [InlineData(60, "šedesát")] + [InlineData(70, "sedmdesát")] + [InlineData(80, "osmdesát")] + [InlineData(90, "devadesát")] + [InlineData(100, "sto")] + [InlineData(112, "sto dvanáct")] + [InlineData(128, "sto dvacet osm")] + [InlineData(1000, "jeden tisíc")] + [InlineData(2000, "dva tisíce")] + [InlineData(5000, "pět tisíc")] + [InlineData(10000, "deset tisíc")] + [InlineData(20000, "dvacet tisíc")] + [InlineData(21000, "dvacet jedna tisíc")] + [InlineData(22000, "dvacet dva tisíc")] + [InlineData(25000, "dvacet pět tisíc")] + [InlineData(100000, "sto tisíc")] + [InlineData(500000, "pět set tisíc")] + [InlineData(1000000, "jeden milion")] + [InlineData(2000000, "dva miliony")] + [InlineData(5000000, "pět milionů")] + [InlineData(1000000000, "jedna miliarda")] + [InlineData(1001001001, "jedna miliarda jeden milion jeden tisíc jedna")] + [InlineData(2000000000, "dvě miliardy")] + [InlineData(1501001892, "jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] + [InlineData(2147483647, "dvě miliardy sto čtyřicet sedm milionů čtyři sta osmdesát tři tisíc šest set čtyřicet sedm")] + [InlineData(-1501001892, "mínus jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] + public void ToWordsCzechFeminine(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nula")] - [InlineData(1, "jedno")] - [InlineData(2, "dvě")] - [InlineData(3, "tři")] - [InlineData(4, "čtyři")] - [InlineData(5, "pět")] - [InlineData(6, "šest")] - [InlineData(7, "sedm")] - [InlineData(8, "osm")] - [InlineData(9, "devět")] - [InlineData(10, "deset")] - [InlineData(11, "jedenáct")] - [InlineData(12, "dvanáct")] - [InlineData(13, "třináct")] - [InlineData(14, "čtrnáct")] - [InlineData(15, "patnáct")] - [InlineData(16, "šestnáct")] - [InlineData(17, "sedmnáct")] - [InlineData(18, "osmnáct")] - [InlineData(19, "devatenáct")] - [InlineData(20, "dvacet")] - [InlineData(22, "dvacet dvě")] - [InlineData(30, "třicet")] - [InlineData(40, "čtyřicet")] - [InlineData(50, "padesát")] - [InlineData(60, "šedesát")] - [InlineData(70, "sedmdesát")] - [InlineData(80, "osmdesát")] - [InlineData(90, "devadesát")] - [InlineData(100, "sto")] - [InlineData(112, "sto dvanáct")] - [InlineData(128, "sto dvacet osm")] - [InlineData(1000, "jeden tisíc")] - [InlineData(2000, "dva tisíce")] - [InlineData(5000, "pět tisíc")] - [InlineData(10000, "deset tisíc")] - [InlineData(20000, "dvacet tisíc")] - [InlineData(21000, "dvacet jedna tisíc")] - [InlineData(22000, "dvacet dva tisíc")] - [InlineData(25000, "dvacet pět tisíc")] - [InlineData(100000, "sto tisíc")] - [InlineData(500000, "pět set tisíc")] - [InlineData(1000000, "jeden milion")] - [InlineData(2000000, "dva miliony")] - [InlineData(5000000, "pět milionů")] - [InlineData(1000000000, "jedna miliarda")] - [InlineData(1001001001, "jedna miliarda jeden milion jeden tisíc jedno")] - [InlineData(2000000000, "dvě miliardy")] - [InlineData(1501001892, "jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] - [InlineData(2147483647, "dvě miliardy sto čtyřicet sedm milionů čtyři sta osmdesát tři tisíc šest set čtyřicet sedm")] - [InlineData(-1501001892, "mínus jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] - public void ToWordsCzechNeuter(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(0, "nula")] + [InlineData(1, "jedno")] + [InlineData(2, "dvě")] + [InlineData(3, "tři")] + [InlineData(4, "čtyři")] + [InlineData(5, "pět")] + [InlineData(6, "šest")] + [InlineData(7, "sedm")] + [InlineData(8, "osm")] + [InlineData(9, "devět")] + [InlineData(10, "deset")] + [InlineData(11, "jedenáct")] + [InlineData(12, "dvanáct")] + [InlineData(13, "třináct")] + [InlineData(14, "čtrnáct")] + [InlineData(15, "patnáct")] + [InlineData(16, "šestnáct")] + [InlineData(17, "sedmnáct")] + [InlineData(18, "osmnáct")] + [InlineData(19, "devatenáct")] + [InlineData(20, "dvacet")] + [InlineData(22, "dvacet dvě")] + [InlineData(30, "třicet")] + [InlineData(40, "čtyřicet")] + [InlineData(50, "padesát")] + [InlineData(60, "šedesát")] + [InlineData(70, "sedmdesát")] + [InlineData(80, "osmdesát")] + [InlineData(90, "devadesát")] + [InlineData(100, "sto")] + [InlineData(112, "sto dvanáct")] + [InlineData(128, "sto dvacet osm")] + [InlineData(1000, "jeden tisíc")] + [InlineData(2000, "dva tisíce")] + [InlineData(5000, "pět tisíc")] + [InlineData(10000, "deset tisíc")] + [InlineData(20000, "dvacet tisíc")] + [InlineData(21000, "dvacet jedna tisíc")] + [InlineData(22000, "dvacet dva tisíc")] + [InlineData(25000, "dvacet pět tisíc")] + [InlineData(100000, "sto tisíc")] + [InlineData(500000, "pět set tisíc")] + [InlineData(1000000, "jeden milion")] + [InlineData(2000000, "dva miliony")] + [InlineData(5000000, "pět milionů")] + [InlineData(1000000000, "jedna miliarda")] + [InlineData(1001001001, "jedna miliarda jeden milion jeden tisíc jedno")] + [InlineData(2000000000, "dvě miliardy")] + [InlineData(1501001892, "jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] + [InlineData(2147483647, "dvě miliardy sto čtyřicet sedm milionů čtyři sta osmdesát tři tisíc šest set čtyřicet sedm")] + [InlineData(-1501001892, "mínus jedna miliarda pět set jedna milionů jeden tisíc osm set devadesát dvě")] + public void ToWordsCzechNeuter(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/cs/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/cs/TimeSpanHumanizeTests.cs index 17a20c723..e45e0dab1 100644 --- a/src/Humanizer.Tests/Localisation/cs/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/cs/TimeSpanHumanizeTests.cs @@ -1,88 +1,87 @@ -namespace Humanizer.Tests.Localisation.cs +namespace Humanizer.Tests.Localisation.cs; + +[UseCulture("cs-CZ")] +public class TimeSpanHumanizeTests { - [UseCulture("cs-CZ")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 rok")] - [InlineData(731, "2 roky")] - [InlineData(1096, "3 roky")] - [InlineData(4018, "11 let")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 rok")] + [InlineData(731, "2 roky")] + [InlineData(1096, "3 roky")] + [InlineData(4018, "11 let")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 měsíc")] - [InlineData(61, "2 měsíce")] - [InlineData(92, "3 měsíce")] - [InlineData(335, "11 měsíců")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 měsíc")] + [InlineData(61, "2 měsíce")] + [InlineData(92, "3 měsíce")] + [InlineData(335, "11 měsíců")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(1, "1 milisekunda")] - [InlineData(2, "2 milisekundy")] - [InlineData(3, "3 milisekundy")] - [InlineData(4, "4 milisekundy")] - [InlineData(5, "5 milisekund")] - [InlineData(6, "6 milisekund")] - [InlineData(10, "10 milisekund")] - public void Milliseconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); + [Theory] + [InlineData(1, "1 milisekunda")] + [InlineData(2, "2 milisekundy")] + [InlineData(3, "3 milisekundy")] + [InlineData(4, "4 milisekundy")] + [InlineData(5, "5 milisekund")] + [InlineData(6, "6 milisekund")] + [InlineData(10, "10 milisekund")] + public void Milliseconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); - [Theory] - [InlineData(1, "1 sekunda")] - [InlineData(2, "2 sekundy")] - [InlineData(3, "3 sekundy")] - [InlineData(4, "4 sekundy")] - [InlineData(5, "5 sekund")] - [InlineData(6, "6 sekund")] - [InlineData(10, "10 sekund")] - public void Seconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); + [Theory] + [InlineData(1, "1 sekunda")] + [InlineData(2, "2 sekundy")] + [InlineData(3, "3 sekundy")] + [InlineData(4, "4 sekundy")] + [InlineData(5, "5 sekund")] + [InlineData(6, "6 sekund")] + [InlineData(10, "10 sekund")] + public void Seconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); - [Theory] - [InlineData(1, "1 minuta")] - [InlineData(2, "2 minuty")] - [InlineData(3, "3 minuty")] - [InlineData(4, "4 minuty")] - [InlineData(5, "5 minut")] - [InlineData(6, "6 minut")] - [InlineData(10, "10 minut")] - public void Minutes(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); + [Theory] + [InlineData(1, "1 minuta")] + [InlineData(2, "2 minuty")] + [InlineData(3, "3 minuty")] + [InlineData(4, "4 minuty")] + [InlineData(5, "5 minut")] + [InlineData(6, "6 minut")] + [InlineData(10, "10 minut")] + public void Minutes(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); - [Theory] - [InlineData(1, "1 hodina")] - [InlineData(2, "2 hodiny")] - [InlineData(3, "3 hodiny")] - [InlineData(4, "4 hodiny")] - [InlineData(5, "5 hodin")] - [InlineData(6, "6 hodin")] - [InlineData(10, "10 hodin")] - public void Hours(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); + [Theory] + [InlineData(1, "1 hodina")] + [InlineData(2, "2 hodiny")] + [InlineData(3, "3 hodiny")] + [InlineData(4, "4 hodiny")] + [InlineData(5, "5 hodin")] + [InlineData(6, "6 hodin")] + [InlineData(10, "10 hodin")] + public void Hours(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); - [Theory] - [InlineData(1, "1 den")] - [InlineData(2, "2 dny")] - [InlineData(3, "3 dny")] - [InlineData(4, "4 dny")] - [InlineData(5, "5 dnů")] - [InlineData(6, "6 dnů")] - public void Days(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); + [Theory] + [InlineData(1, "1 den")] + [InlineData(2, "2 dny")] + [InlineData(3, "3 dny")] + [InlineData(4, "4 dny")] + [InlineData(5, "5 dnů")] + [InlineData(6, "6 dnů")] + public void Days(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); - [Theory] - [InlineData(1, "1 týden")] - [InlineData(2, "2 týdny")] - [InlineData(3, "3 týdny")] - [InlineData(4, "4 týdny")] - [InlineData(5, "5 týdnů")] - [InlineData(6, "6 týdnů")] - public void Weeks(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); - } -} + [Theory] + [InlineData(1, "1 týden")] + [InlineData(2, "2 týdny")] + [InlineData(3, "3 týdny")] + [InlineData(4, "4 týdny")] + [InlineData(5, "5 týdnů")] + [InlineData(6, "6 týdnů")] + public void Weeks(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs index be4c4c3b8..d8866fadc 100644 --- a/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/da/DateHumanizeTests.cs @@ -1,86 +1,85 @@ -namespace Humanizer.Tests.Localisation.da +namespace Humanizer.Tests.Localisation.da; + +[UseCulture("da-DK")] +public class DateHumanizeTests { - [UseCulture("da-DK")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "2 dage siden")] - [InlineData(-1, "i går")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "2 dage siden")] + [InlineData(-1, "i går")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "i morgen")] - [InlineData(10, "10 dage fra nu")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "i morgen")] + [InlineData(10, "10 dage fra nu")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "et sekund fra nu")] - [InlineData(10, "10 sekunder fra nu")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "et sekund fra nu")] + [InlineData(10, "10 sekunder fra nu")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 timer siden")] - [InlineData(-1, "en time siden")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "2 timer siden")] + [InlineData(-1, "en time siden")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "en time fra nu")] - [InlineData(10, "10 timer fra nu")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "en time fra nu")] + [InlineData(10, "10 timer fra nu")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 minutter siden")] - [InlineData(-1, "et minut siden")] - [InlineData(60, "en time siden")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 minutter siden")] + [InlineData(-1, "et minut siden")] + [InlineData(60, "en time siden")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "et minut fra nu")] - [InlineData(10, "10 minutter fra nu")] - [InlineData(59, "59 minutter fra nu")] - [InlineData(60, "en time fra nu")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "et minut fra nu")] + [InlineData(10, "10 minutter fra nu")] + [InlineData(59, "59 minutter fra nu")] + [InlineData(60, "en time fra nu")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 måneder siden")] - [InlineData(-1, "en måned siden")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 måneder siden")] + [InlineData(-1, "en måned siden")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "en måned fra nu")] - [InlineData(10, "10 måneder fra nu")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "en måned fra nu")] + [InlineData(10, "10 måneder fra nu")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 sekunder siden")] - [InlineData(-1, "et sekund siden")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 sekunder siden")] + [InlineData(-1, "et sekund siden")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(-2, "2 år siden")] - [InlineData(-1, "et år siden")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 år siden")] + [InlineData(-1, "et år siden")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "et år fra nu")] - [InlineData(2, "2 år fra nu")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "et år fra nu")] + [InlineData(2, "2 år fra nu")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "nu")] - public void Now(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(0, "nu")] + public void Now(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs index df6e13efa..52b4c4e55 100644 --- a/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/da/TimeSpanHumanizeTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.da +namespace Humanizer.Tests.Localisation.da; + +[UseCulture("da-DK")] +public class TimeSpanHumanizeTests { - [UseCulture("da-DK")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "et år")] - [InlineData(731, "2 år")] - [InlineData(1096, "3 år")] - [InlineData(4018, "11 år")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "et år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "en måned")] - [InlineData(61, "2 måneder")] - [InlineData(92, "3 måneder")] - [InlineData(335, "11 måneder")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "en måned")] + [InlineData(61, "2 måneder")] + [InlineData(92, "3 måneder")] + [InlineData(335, "11 måneder")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "en uge")] - [InlineData(14, "2 uger")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "en uge")] + [InlineData(14, "2 uger")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "en dag")] - [InlineData(2, "2 dage")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "en dag")] + [InlineData(2, "2 dage")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "en time")] - [InlineData(2, "2 timer")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "en time")] + [InlineData(2, "2 timer")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "et minut")] - [InlineData(2, "2 minutter")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "et minut")] + [InlineData(2, "2 minutter")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "et sekund")] - [InlineData(2, "2 sekunder")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "et sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "et millisekund")] - [InlineData(2, "2 millisekunder")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "et millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 millisekunder", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 millisekunder", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("ingen tid", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("ingen tid", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de-CH/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/de-CH/NumberToWordsTests.cs index 2f2315a57..9a376a8c5 100644 --- a/src/Humanizer.Tests/Localisation/de-CH/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/de-CH/NumberToWordsTests.cs @@ -1,151 +1,150 @@ -namespace Humanizer.Tests.Localisation.deCH +namespace Humanizer.Tests.Localisation.deCH; + +[UseCulture("de-CH")] +public class NumberToWordsTests { - [UseCulture("de-CH")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "null")] - [InlineData(1, "ein")] - [InlineData(2, "zwei")] - [InlineData(3, "drei")] - [InlineData(4, "vier")] - [InlineData(5, "fünf")] - [InlineData(6, "sechs")] - [InlineData(7, "sieben")] - [InlineData(8, "acht")] - [InlineData(9, "neun")] - [InlineData(10, "zehn")] - [InlineData(20, "zwanzig")] - [InlineData(30, "dreissig")] - [InlineData(40, "vierzig")] - [InlineData(50, "fünfzig")] - [InlineData(60, "sechzig")] - [InlineData(70, "siebzig")] - [InlineData(80, "achtzig")] - [InlineData(90, "neunzig")] - [InlineData(100, "einhundert")] - [InlineData(200, "zweihundert")] - [InlineData(1000, "eintausend")] - [InlineData(10000, "zehntausend")] - [InlineData(100000, "einhunderttausend")] - [InlineData(1000000, "eine Million")] - [InlineData(10000000, "zehn Millionen")] - [InlineData(100000000, "einhundert Millionen")] - [InlineData(1000000000, "eine Milliarde")] - [InlineData(2000000000, "zwei Milliarden")] - [InlineData(122, "einhundertzweiundzwanzig")] - [InlineData(3501, "dreitausendfünfhundertein")] - [InlineData(111, "einhundertelf")] - [InlineData(1112, "eintausendeinhundertzwölf")] - [InlineData(11213, "elftausendzweihundertdreizehn")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehn")] - [InlineData(2132415, "zwei Millionen einhundertzweiunddreissigtausendvierhundertfünfzehn")] - [InlineData(12345516, "zwölf Millionen dreihundertfünfundvierzigtausendfünfhundertsechzehn")] - [InlineData(751633617, "siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertsiebzehn")] - [InlineData(1111111118, "eine Milliarde einhundertelf Millionen einhundertelftausendeinhundertachtzehn")] - [InlineData(35484694489515, "fünfunddreissig Billionen vierhundertvierundachtzig Milliarden sechshundertvierundneunzig Millionen vierhundertneunundachtzigtausendfünfhundertfünfzehn")] - [InlineData(8183162164626926, "acht Billiarden einhundertdreiundachtzig Billionen einhundertzweiundsechzig Milliarden einhundertvierundsechzig Millionen sechshundertsechsundzwanzigtausendneunhundertsechsundzwanzig")] - [InlineData(4564121926659524672, "vier Trillionen fünfhundertvierundsechzig Billiarden einhunderteinundzwanzig Billionen neunhundertsechsundzwanzig Milliarden sechshundertneunundfünfzig Millionen fünfhundertvierundzwanzigtausendsechshundertzweiundsiebzig")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertneunzehn")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "null")] + [InlineData(1, "ein")] + [InlineData(2, "zwei")] + [InlineData(3, "drei")] + [InlineData(4, "vier")] + [InlineData(5, "fünf")] + [InlineData(6, "sechs")] + [InlineData(7, "sieben")] + [InlineData(8, "acht")] + [InlineData(9, "neun")] + [InlineData(10, "zehn")] + [InlineData(20, "zwanzig")] + [InlineData(30, "dreissig")] + [InlineData(40, "vierzig")] + [InlineData(50, "fünfzig")] + [InlineData(60, "sechzig")] + [InlineData(70, "siebzig")] + [InlineData(80, "achtzig")] + [InlineData(90, "neunzig")] + [InlineData(100, "einhundert")] + [InlineData(200, "zweihundert")] + [InlineData(1000, "eintausend")] + [InlineData(10000, "zehntausend")] + [InlineData(100000, "einhunderttausend")] + [InlineData(1000000, "eine Million")] + [InlineData(10000000, "zehn Millionen")] + [InlineData(100000000, "einhundert Millionen")] + [InlineData(1000000000, "eine Milliarde")] + [InlineData(2000000000, "zwei Milliarden")] + [InlineData(122, "einhundertzweiundzwanzig")] + [InlineData(3501, "dreitausendfünfhundertein")] + [InlineData(111, "einhundertelf")] + [InlineData(1112, "eintausendeinhundertzwölf")] + [InlineData(11213, "elftausendzweihundertdreizehn")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehn")] + [InlineData(2132415, "zwei Millionen einhundertzweiunddreissigtausendvierhundertfünfzehn")] + [InlineData(12345516, "zwölf Millionen dreihundertfünfundvierzigtausendfünfhundertsechzehn")] + [InlineData(751633617, "siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertsiebzehn")] + [InlineData(1111111118, "eine Milliarde einhundertelf Millionen einhundertelftausendeinhundertachtzehn")] + [InlineData(35484694489515, "fünfunddreissig Billionen vierhundertvierundachtzig Milliarden sechshundertvierundneunzig Millionen vierhundertneunundachtzigtausendfünfhundertfünfzehn")] + [InlineData(8183162164626926, "acht Billiarden einhundertdreiundachtzig Billionen einhundertzweiundsechzig Milliarden einhundertvierundsechzig Millionen sechshundertsechsundzwanzigtausendneunhundertsechsundzwanzig")] + [InlineData(4564121926659524672, "vier Trillionen fünfhundertvierundsechzig Billiarden einhunderteinundzwanzig Billionen neunhundertsechsundzwanzig Milliarden sechshundertneunundfünfzig Millionen fünfhundertvierundzwanzigtausendsechshundertzweiundsiebzig")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertneunzehn")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "eine")] - [InlineData(3501, "dreitausendfünfhunderteine")] - public void ToWordsFeminine(long number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(1, "eine")] + [InlineData(3501, "dreitausendfünfhunderteine")] + public void ToWordsFeminine(long number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nullter")] - [InlineData(1, "erster")] - [InlineData(2, "zweiter")] - [InlineData(3, "dritter")] - [InlineData(4, "vierter")] - [InlineData(5, "fünfter")] - [InlineData(6, "sechster")] - [InlineData(7, "siebter")] - [InlineData(8, "achter")] - [InlineData(9, "neunter")] - [InlineData(10, "zehnter")] - [InlineData(20, "zwanzigster")] - [InlineData(30, "dreissigster")] - [InlineData(40, "vierzigster")] - [InlineData(50, "fünfzigster")] - [InlineData(60, "sechzigster")] - [InlineData(70, "siebzigster")] - [InlineData(80, "achtzigster")] - [InlineData(90, "neunzigster")] - [InlineData(100, "einhundertster")] - [InlineData(200, "zweihundertster")] - [InlineData(1000, "eintausendster")] - [InlineData(10000, "zehntausendster")] - [InlineData(100000, "einhunderttausendster")] - [InlineData(1000000, "einmillionster")] - [InlineData(10000000, "zehnmillionster")] - [InlineData(100000000, "einhundertmillionster")] - [InlineData(1000000000, "einmilliardster")] - [InlineData(2000000000, "zweimilliardster")] - [InlineData(122, "einhundertzweiundzwanzigster")] - [InlineData(3501, "dreitausendfünfhunderterster")] - [InlineData(111, "einhundertelfter")] - [InlineData(1112, "eintausendeinhundertzwölfter")] - [InlineData(11213, "elftausendzweihundertdreizehnter")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnter")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnter")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnter")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnter")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnter")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnter")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "nullter")] + [InlineData(1, "erster")] + [InlineData(2, "zweiter")] + [InlineData(3, "dritter")] + [InlineData(4, "vierter")] + [InlineData(5, "fünfter")] + [InlineData(6, "sechster")] + [InlineData(7, "siebter")] + [InlineData(8, "achter")] + [InlineData(9, "neunter")] + [InlineData(10, "zehnter")] + [InlineData(20, "zwanzigster")] + [InlineData(30, "dreissigster")] + [InlineData(40, "vierzigster")] + [InlineData(50, "fünfzigster")] + [InlineData(60, "sechzigster")] + [InlineData(70, "siebzigster")] + [InlineData(80, "achtzigster")] + [InlineData(90, "neunzigster")] + [InlineData(100, "einhundertster")] + [InlineData(200, "zweihundertster")] + [InlineData(1000, "eintausendster")] + [InlineData(10000, "zehntausendster")] + [InlineData(100000, "einhunderttausendster")] + [InlineData(1000000, "einmillionster")] + [InlineData(10000000, "zehnmillionster")] + [InlineData(100000000, "einhundertmillionster")] + [InlineData(1000000000, "einmilliardster")] + [InlineData(2000000000, "zweimilliardster")] + [InlineData(122, "einhundertzweiundzwanzigster")] + [InlineData(3501, "dreitausendfünfhunderterster")] + [InlineData(111, "einhundertelfter")] + [InlineData(1112, "eintausendeinhundertzwölfter")] + [InlineData(11213, "elftausendzweihundertdreizehnter")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnter")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnter")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnter")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnter")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnter")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnter")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "nullte")] - [InlineData(1, "erste")] - [InlineData(2, "zweite")] - [InlineData(3, "dritte")] - [InlineData(4, "vierte")] - [InlineData(5, "fünfte")] - [InlineData(6, "sechste")] - [InlineData(7, "siebte")] - [InlineData(8, "achte")] - [InlineData(9, "neunte")] - [InlineData(10, "zehnte")] - [InlineData(111, "einhundertelfte")] - [InlineData(1112, "eintausendeinhundertzwölfte")] - [InlineData(11213, "elftausendzweihundertdreizehnte")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnte")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnte")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnte")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnte")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnte")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnte")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "nullte")] + [InlineData(1, "erste")] + [InlineData(2, "zweite")] + [InlineData(3, "dritte")] + [InlineData(4, "vierte")] + [InlineData(5, "fünfte")] + [InlineData(6, "sechste")] + [InlineData(7, "siebte")] + [InlineData(8, "achte")] + [InlineData(9, "neunte")] + [InlineData(10, "zehnte")] + [InlineData(111, "einhundertelfte")] + [InlineData(1112, "eintausendeinhundertzwölfte")] + [InlineData(11213, "elftausendzweihundertdreizehnte")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnte")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnte")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnte")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnte")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnte")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnte")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nulltes")] - [InlineData(1, "erstes")] - [InlineData(2, "zweites")] - [InlineData(3, "drittes")] - [InlineData(4, "viertes")] - [InlineData(5, "fünftes")] - [InlineData(6, "sechstes")] - [InlineData(7, "siebtes")] - [InlineData(8, "achtes")] - [InlineData(9, "neuntes")] - [InlineData(10, "zehntes")] - [InlineData(111, "einhundertelftes")] - [InlineData(1112, "eintausendeinhundertzwölftes")] - [InlineData(11213, "elftausendzweihundertdreizehntes")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehntes")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehntes")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehntes")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehntes")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehntes")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehntes")] - public void ToOrdinalWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(0, "nulltes")] + [InlineData(1, "erstes")] + [InlineData(2, "zweites")] + [InlineData(3, "drittes")] + [InlineData(4, "viertes")] + [InlineData(5, "fünftes")] + [InlineData(6, "sechstes")] + [InlineData(7, "siebtes")] + [InlineData(8, "achtes")] + [InlineData(9, "neuntes")] + [InlineData(10, "zehntes")] + [InlineData(111, "einhundertelftes")] + [InlineData(1112, "eintausendeinhundertzwölftes")] + [InlineData(11213, "elftausendzweihundertdreizehntes")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehntes")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehntes")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehntes")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehntes")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehntes")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehntes")] + public void ToOrdinalWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de-LI/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/de-LI/NumberToWordsTests.cs index 0a7cbc3c3..f4858efa3 100644 --- a/src/Humanizer.Tests/Localisation/de-LI/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/de-LI/NumberToWordsTests.cs @@ -1,151 +1,150 @@ -namespace Humanizer.Tests.Localisation.deLI +namespace Humanizer.Tests.Localisation.deLI; + +[UseCulture("de-LI")] +public class NumberToWordsTests { - [UseCulture("de-LI")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "null")] - [InlineData(1, "ein")] - [InlineData(2, "zwei")] - [InlineData(3, "drei")] - [InlineData(4, "vier")] - [InlineData(5, "fünf")] - [InlineData(6, "sechs")] - [InlineData(7, "sieben")] - [InlineData(8, "acht")] - [InlineData(9, "neun")] - [InlineData(10, "zehn")] - [InlineData(20, "zwanzig")] - [InlineData(30, "dreissig")] - [InlineData(40, "vierzig")] - [InlineData(50, "fünfzig")] - [InlineData(60, "sechzig")] - [InlineData(70, "siebzig")] - [InlineData(80, "achtzig")] - [InlineData(90, "neunzig")] - [InlineData(100, "einhundert")] - [InlineData(200, "zweihundert")] - [InlineData(1000, "eintausend")] - [InlineData(10000, "zehntausend")] - [InlineData(100000, "einhunderttausend")] - [InlineData(1000000, "eine Million")] - [InlineData(10000000, "zehn Millionen")] - [InlineData(100000000, "einhundert Millionen")] - [InlineData(1000000000, "eine Milliarde")] - [InlineData(2000000000, "zwei Milliarden")] - [InlineData(122, "einhundertzweiundzwanzig")] - [InlineData(3501, "dreitausendfünfhundertein")] - [InlineData(111, "einhundertelf")] - [InlineData(1112, "eintausendeinhundertzwölf")] - [InlineData(11213, "elftausendzweihundertdreizehn")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehn")] - [InlineData(2132415, "zwei Millionen einhundertzweiunddreissigtausendvierhundertfünfzehn")] - [InlineData(12345516, "zwölf Millionen dreihundertfünfundvierzigtausendfünfhundertsechzehn")] - [InlineData(751633617, "siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertsiebzehn")] - [InlineData(1111111118, "eine Milliarde einhundertelf Millionen einhundertelftausendeinhundertachtzehn")] - [InlineData(35484694489515, "fünfunddreissig Billionen vierhundertvierundachtzig Milliarden sechshundertvierundneunzig Millionen vierhundertneunundachtzigtausendfünfhundertfünfzehn")] - [InlineData(8183162164626926, "acht Billiarden einhundertdreiundachtzig Billionen einhundertzweiundsechzig Milliarden einhundertvierundsechzig Millionen sechshundertsechsundzwanzigtausendneunhundertsechsundzwanzig")] - [InlineData(4564121926659524672, "vier Trillionen fünfhundertvierundsechzig Billiarden einhunderteinundzwanzig Billionen neunhundertsechsundzwanzig Milliarden sechshundertneunundfünfzig Millionen fünfhundertvierundzwanzigtausendsechshundertzweiundsiebzig")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertneunzehn")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "null")] + [InlineData(1, "ein")] + [InlineData(2, "zwei")] + [InlineData(3, "drei")] + [InlineData(4, "vier")] + [InlineData(5, "fünf")] + [InlineData(6, "sechs")] + [InlineData(7, "sieben")] + [InlineData(8, "acht")] + [InlineData(9, "neun")] + [InlineData(10, "zehn")] + [InlineData(20, "zwanzig")] + [InlineData(30, "dreissig")] + [InlineData(40, "vierzig")] + [InlineData(50, "fünfzig")] + [InlineData(60, "sechzig")] + [InlineData(70, "siebzig")] + [InlineData(80, "achtzig")] + [InlineData(90, "neunzig")] + [InlineData(100, "einhundert")] + [InlineData(200, "zweihundert")] + [InlineData(1000, "eintausend")] + [InlineData(10000, "zehntausend")] + [InlineData(100000, "einhunderttausend")] + [InlineData(1000000, "eine Million")] + [InlineData(10000000, "zehn Millionen")] + [InlineData(100000000, "einhundert Millionen")] + [InlineData(1000000000, "eine Milliarde")] + [InlineData(2000000000, "zwei Milliarden")] + [InlineData(122, "einhundertzweiundzwanzig")] + [InlineData(3501, "dreitausendfünfhundertein")] + [InlineData(111, "einhundertelf")] + [InlineData(1112, "eintausendeinhundertzwölf")] + [InlineData(11213, "elftausendzweihundertdreizehn")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehn")] + [InlineData(2132415, "zwei Millionen einhundertzweiunddreissigtausendvierhundertfünfzehn")] + [InlineData(12345516, "zwölf Millionen dreihundertfünfundvierzigtausendfünfhundertsechzehn")] + [InlineData(751633617, "siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertsiebzehn")] + [InlineData(1111111118, "eine Milliarde einhundertelf Millionen einhundertelftausendeinhundertachtzehn")] + [InlineData(35484694489515, "fünfunddreissig Billionen vierhundertvierundachtzig Milliarden sechshundertvierundneunzig Millionen vierhundertneunundachtzigtausendfünfhundertfünfzehn")] + [InlineData(8183162164626926, "acht Billiarden einhundertdreiundachtzig Billionen einhundertzweiundsechzig Milliarden einhundertvierundsechzig Millionen sechshundertsechsundzwanzigtausendneunhundertsechsundzwanzig")] + [InlineData(4564121926659524672, "vier Trillionen fünfhundertvierundsechzig Billiarden einhunderteinundzwanzig Billionen neunhundertsechsundzwanzig Milliarden sechshundertneunundfünfzig Millionen fünfhundertvierundzwanzigtausendsechshundertzweiundsiebzig")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzig Millionen sechshundertdreiunddreissigtausendsechshundertneunzehn")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "eine")] - [InlineData(3501, "dreitausendfünfhunderteine")] - public void ToWordsFeminine(long number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(1, "eine")] + [InlineData(3501, "dreitausendfünfhunderteine")] + public void ToWordsFeminine(long number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nullter")] - [InlineData(1, "erster")] - [InlineData(2, "zweiter")] - [InlineData(3, "dritter")] - [InlineData(4, "vierter")] - [InlineData(5, "fünfter")] - [InlineData(6, "sechster")] - [InlineData(7, "siebter")] - [InlineData(8, "achter")] - [InlineData(9, "neunter")] - [InlineData(10, "zehnter")] - [InlineData(20, "zwanzigster")] - [InlineData(30, "dreissigster")] - [InlineData(40, "vierzigster")] - [InlineData(50, "fünfzigster")] - [InlineData(60, "sechzigster")] - [InlineData(70, "siebzigster")] - [InlineData(80, "achtzigster")] - [InlineData(90, "neunzigster")] - [InlineData(100, "einhundertster")] - [InlineData(200, "zweihundertster")] - [InlineData(1000, "eintausendster")] - [InlineData(10000, "zehntausendster")] - [InlineData(100000, "einhunderttausendster")] - [InlineData(1000000, "einmillionster")] - [InlineData(10000000, "zehnmillionster")] - [InlineData(100000000, "einhundertmillionster")] - [InlineData(1000000000, "einmilliardster")] - [InlineData(2000000000, "zweimilliardster")] - [InlineData(122, "einhundertzweiundzwanzigster")] - [InlineData(3501, "dreitausendfünfhunderterster")] - [InlineData(111, "einhundertelfter")] - [InlineData(1112, "eintausendeinhundertzwölfter")] - [InlineData(11213, "elftausendzweihundertdreizehnter")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnter")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnter")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnter")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnter")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnter")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnter")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "nullter")] + [InlineData(1, "erster")] + [InlineData(2, "zweiter")] + [InlineData(3, "dritter")] + [InlineData(4, "vierter")] + [InlineData(5, "fünfter")] + [InlineData(6, "sechster")] + [InlineData(7, "siebter")] + [InlineData(8, "achter")] + [InlineData(9, "neunter")] + [InlineData(10, "zehnter")] + [InlineData(20, "zwanzigster")] + [InlineData(30, "dreissigster")] + [InlineData(40, "vierzigster")] + [InlineData(50, "fünfzigster")] + [InlineData(60, "sechzigster")] + [InlineData(70, "siebzigster")] + [InlineData(80, "achtzigster")] + [InlineData(90, "neunzigster")] + [InlineData(100, "einhundertster")] + [InlineData(200, "zweihundertster")] + [InlineData(1000, "eintausendster")] + [InlineData(10000, "zehntausendster")] + [InlineData(100000, "einhunderttausendster")] + [InlineData(1000000, "einmillionster")] + [InlineData(10000000, "zehnmillionster")] + [InlineData(100000000, "einhundertmillionster")] + [InlineData(1000000000, "einmilliardster")] + [InlineData(2000000000, "zweimilliardster")] + [InlineData(122, "einhundertzweiundzwanzigster")] + [InlineData(3501, "dreitausendfünfhunderterster")] + [InlineData(111, "einhundertelfter")] + [InlineData(1112, "eintausendeinhundertzwölfter")] + [InlineData(11213, "elftausendzweihundertdreizehnter")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnter")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnter")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnter")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnter")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnter")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnter")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "nullte")] - [InlineData(1, "erste")] - [InlineData(2, "zweite")] - [InlineData(3, "dritte")] - [InlineData(4, "vierte")] - [InlineData(5, "fünfte")] - [InlineData(6, "sechste")] - [InlineData(7, "siebte")] - [InlineData(8, "achte")] - [InlineData(9, "neunte")] - [InlineData(10, "zehnte")] - [InlineData(111, "einhundertelfte")] - [InlineData(1112, "eintausendeinhundertzwölfte")] - [InlineData(11213, "elftausendzweihundertdreizehnte")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnte")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnte")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnte")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnte")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnte")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnte")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "nullte")] + [InlineData(1, "erste")] + [InlineData(2, "zweite")] + [InlineData(3, "dritte")] + [InlineData(4, "vierte")] + [InlineData(5, "fünfte")] + [InlineData(6, "sechste")] + [InlineData(7, "siebte")] + [InlineData(8, "achte")] + [InlineData(9, "neunte")] + [InlineData(10, "zehnte")] + [InlineData(111, "einhundertelfte")] + [InlineData(1112, "eintausendeinhundertzwölfte")] + [InlineData(11213, "elftausendzweihundertdreizehnte")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnte")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehnte")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnte")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehnte")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnte")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehnte")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nulltes")] - [InlineData(1, "erstes")] - [InlineData(2, "zweites")] - [InlineData(3, "drittes")] - [InlineData(4, "viertes")] - [InlineData(5, "fünftes")] - [InlineData(6, "sechstes")] - [InlineData(7, "siebtes")] - [InlineData(8, "achtes")] - [InlineData(9, "neuntes")] - [InlineData(10, "zehntes")] - [InlineData(111, "einhundertelftes")] - [InlineData(1112, "eintausendeinhundertzwölftes")] - [InlineData(11213, "elftausendzweihundertdreizehntes")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehntes")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehntes")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehntes")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehntes")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehntes")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehntes")] - public void ToOrdinalWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(0, "nulltes")] + [InlineData(1, "erstes")] + [InlineData(2, "zweites")] + [InlineData(3, "drittes")] + [InlineData(4, "viertes")] + [InlineData(5, "fünftes")] + [InlineData(6, "sechstes")] + [InlineData(7, "siebtes")] + [InlineData(8, "achtes")] + [InlineData(9, "neuntes")] + [InlineData(10, "zehntes")] + [InlineData(111, "einhundertelftes")] + [InlineData(1112, "eintausendeinhundertzwölftes")] + [InlineData(11213, "elftausendzweihundertdreizehntes")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehntes")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreissigtausendvierhundertfünfzehntes")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehntes")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertsiebzehntes")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehntes")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreissigtausendsechshundertneunzehntes")] + public void ToOrdinalWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/Bytes/ByteRateTests.cs b/src/Humanizer.Tests/Localisation/de/Bytes/ByteRateTests.cs index 3f10221fc..0dbe243a5 100644 --- a/src/Humanizer.Tests/Localisation/de/Bytes/ByteRateTests.cs +++ b/src/Humanizer.Tests/Localisation/de/Bytes/ByteRateTests.cs @@ -1,73 +1,72 @@ -namespace Humanizer.Tests.Localisation.de.Bytes +namespace Humanizer.Tests.Localisation.de.Bytes; + +[UseCulture("de-DE")] +public class ByteRateTests { - [UseCulture("de-DE")] - public class ByteRateTests + [Theory] + [InlineData(400, 1, "400 B/s")] + [InlineData(4 * 1024, 1, "4 kB/s")] + [InlineData(4 * 1024 * 1024, 1, "4 MB/s")] + [InlineData(4 * 2 * 1024 * 1024, 2, "4 MB/s")] + [InlineData(4 * 1024, 0.1, "40 kB/s")] + [InlineData(15 * 60 * 1024 * 1024, 60, "15 MB/s")] + public void HumanizesRates(long inputBytes, double perSeconds, string expectedValue) { - [Theory] - [InlineData(400, 1, "400 B/s")] - [InlineData(4 * 1024, 1, "4 kB/s")] - [InlineData(4 * 1024 * 1024, 1, "4 MB/s")] - [InlineData(4 * 2 * 1024 * 1024, 2, "4 MB/s")] - [InlineData(4 * 1024, 0.1, "40 kB/s")] - [InlineData(15 * 60 * 1024 * 1024, 60, "15 MB/s")] - public void HumanizesRates(long inputBytes, double perSeconds, string expectedValue) - { - var size = new ByteSize(inputBytes); - var interval = TimeSpan.FromSeconds(perSeconds); + var size = new ByteSize(inputBytes); + var interval = TimeSpan.FromSeconds(perSeconds); + + var rate = size.Per(interval).Humanize(); - var rate = size.Per(interval).Humanize(); + Assert.Equal(expectedValue, rate); + } - Assert.Equal(expectedValue, rate); - } + [Theory] + [InlineData(1, 1, TimeUnit.Second, "1 MB/s")] + [InlineData(1, 60, TimeUnit.Minute, "1 MB/min")] + [InlineData(1, 60 * 60, TimeUnit.Hour, "1 MB/h")] + [InlineData(10, 1, TimeUnit.Second, "10 MB/s")] + [InlineData(10, 60, TimeUnit.Minute, "10 MB/min")] + [InlineData(10, 60 * 60, TimeUnit.Hour, "10 MB/h")] + [InlineData(1, 10 * 1, TimeUnit.Second, "102,4 kB/s")] + [InlineData(1, 10 * 60, TimeUnit.Minute, "102,4 kB/min")] + [InlineData(1, 10 * 60 * 60, TimeUnit.Hour, "102,4 kB/h")] + public void TimeUnitTests(long megabytes, double measurementIntervalSeconds, TimeUnit displayInterval, string expectedValue) + { + var size = ByteSize.FromMegabytes(megabytes); + var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds); - [Theory] - [InlineData(1, 1, TimeUnit.Second, "1 MB/s")] - [InlineData(1, 60, TimeUnit.Minute, "1 MB/min")] - [InlineData(1, 60 * 60, TimeUnit.Hour, "1 MB/h")] - [InlineData(10, 1, TimeUnit.Second, "10 MB/s")] - [InlineData(10, 60, TimeUnit.Minute, "10 MB/min")] - [InlineData(10, 60 * 60, TimeUnit.Hour, "10 MB/h")] - [InlineData(1, 10 * 1, TimeUnit.Second, "102,4 kB/s")] - [InlineData(1, 10 * 60, TimeUnit.Minute, "102,4 kB/min")] - [InlineData(1, 10 * 60 * 60, TimeUnit.Hour, "102,4 kB/h")] - public void TimeUnitTests(long megabytes, double measurementIntervalSeconds, TimeUnit displayInterval, string expectedValue) - { - var size = ByteSize.FromMegabytes(megabytes); - var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds); + var rate = size.Per(measurementInterval); + var text = rate.Humanize(displayInterval); - var rate = size.Per(measurementInterval); - var text = rate.Humanize(displayInterval); + Assert.Equal(expectedValue, text); + } - Assert.Equal(expectedValue, text); - } + [Theory] + [InlineData(19854651984, 1, TimeUnit.Second, null, "18,49 GB/s")] + [InlineData(19854651984, 1, TimeUnit.Second, "#.##", "18,49 GB/s")] + public void FormattedTimeUnitTests(long bytes, int measurementIntervalSeconds, TimeUnit displayInterval, string? format, string expectedValue) + { + var size = ByteSize.FromBytes(bytes); + var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds); + var rate = size.Per(measurementInterval); + var text = rate.Humanize(format, displayInterval); - [Theory] - [InlineData(19854651984, 1, TimeUnit.Second, null, "18,49 GB/s")] - [InlineData(19854651984, 1, TimeUnit.Second, "#.##", "18,49 GB/s")] - public void FormattedTimeUnitTests(long bytes, int measurementIntervalSeconds, TimeUnit displayInterval, string? format, string expectedValue) - { - var size = ByteSize.FromBytes(bytes); - var measurementInterval = TimeSpan.FromSeconds(measurementIntervalSeconds); - var rate = size.Per(measurementInterval); - var text = rate.Humanize(format, displayInterval); + Assert.Equal(expectedValue, text); + } - Assert.Equal(expectedValue, text); - } + [Theory] + [InlineData(TimeUnit.Millisecond)] + [InlineData(TimeUnit.Day)] + [InlineData(TimeUnit.Month)] + [InlineData(TimeUnit.Week)] + [InlineData(TimeUnit.Year)] + public void ThrowsOnUnsupportedData(TimeUnit units) + { + var dummyRate = ByteSize.FromBits(1).Per(TimeSpan.FromSeconds(1)); - [Theory] - [InlineData(TimeUnit.Millisecond)] - [InlineData(TimeUnit.Day)] - [InlineData(TimeUnit.Month)] - [InlineData(TimeUnit.Week)] - [InlineData(TimeUnit.Year)] - public void ThrowsOnUnsupportedData(TimeUnit units) + Assert.Throws(() => { - var dummyRate = ByteSize.FromBits(1).Per(TimeSpan.FromSeconds(1)); - - Assert.Throws(() => - { - dummyRate.Humanize(units); - }); - } + dummyRate.Humanize(units); + }); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/Bytes/ByteSizeExtensionsTests.cs b/src/Humanizer.Tests/Localisation/de/Bytes/ByteSizeExtensionsTests.cs index 27dab2544..faff9daae 100644 --- a/src/Humanizer.Tests/Localisation/de/Bytes/ByteSizeExtensionsTests.cs +++ b/src/Humanizer.Tests/Localisation/de/Bytes/ByteSizeExtensionsTests.cs @@ -1,63 +1,62 @@ -namespace Humanizer.Tests.Localisation.de.Bytes +namespace Humanizer.Tests.Localisation.de.Bytes; + +[UseCulture("de-DE")] +public class ByteSizeExtensionsTests { - [UseCulture("de-DE")] - public class ByteSizeExtensionsTests - { - [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, 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(0, null, "0 bit")] - [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) => - Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); + [Theory] + [InlineData(0, null, "0 bit")] + [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) => + Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 bit")] - [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) => - Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); + [Theory] + [InlineData(0, null, "0 bit")] + [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) => + Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 bit")] - [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) => - Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); + [Theory] + [InlineData(0, null, "0 bit")] + [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) => + Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 bit")] - [InlineData(0, "#.##", "0 bit")] - [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) => - Assert.Equal(expectedValue, input.Bytes().Humanize(format)); + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "#.##", "0 bit")] + [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) => + Assert.Equal(expectedValue, input.Bytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 bit")] - [InlineData(0, "b", "0 bit")] - [InlineData(2, null, "2 bit")] - [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)); - } -} + [Theory] + [InlineData(0, null, "0 bit")] + [InlineData(0, "b", "0 bit")] + [InlineData(2, null, "2 bit")] + [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)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/Bytes/ToFullWordsTests.cs b/src/Humanizer.Tests/Localisation/de/Bytes/ToFullWordsTests.cs index 82dc74736..f95a00203 100644 --- a/src/Humanizer.Tests/Localisation/de/Bytes/ToFullWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/de/Bytes/ToFullWordsTests.cs @@ -1,60 +1,59 @@ -namespace Humanizer.Tests.Localisation.de.Bytes +namespace Humanizer.Tests.Localisation.de.Bytes; + +[UseCulture("de-DE")] +public class ToFullWordsTests { - [UseCulture("de-DE")] - public class ToFullWordsTests - { - [Fact] - public void ReturnsSingularBit() => - Assert.Equal("1 Bit", ByteSize.FromBits(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBits() => - Assert.Equal("2 Bit", ByteSize.FromBits(2).ToFullWords()); - - [Fact] - public void ReturnsSingularByte() => - Assert.Equal("1 Byte", ByteSize.FromBytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBytes() => - Assert.Equal("10 Byte", ByteSize.FromBytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularKiloByte() => - Assert.Equal("1 Kilobyte", ByteSize.FromKilobytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralKilobytes() => - Assert.Equal("10 Kilobyte", ByteSize.FromKilobytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularMegabyte() => - Assert.Equal("1 Megabyte", ByteSize.FromMegabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralMegabytes() => - Assert.Equal("10 Megabyte", ByteSize.FromMegabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularGigabyte() => - Assert.Equal("1 Gigabyte", ByteSize.FromGigabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralGigabytes() => - Assert.Equal("10 Gigabyte", ByteSize.FromGigabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularTerabyte() => - Assert.Equal("1 Terabyte", ByteSize.FromTerabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralTerabytes() => - Assert.Equal("10 Terabyte", ByteSize.FromTerabytes(10).ToFullWords()); - - [Theory] - [InlineData(229376, "B", "229376 Byte")] - [InlineData(229376, "# KB", "224 Kilobyte")] - public void ToFullWordsFormatted(double input, string format, string expectedValue) => - Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); - } -} + [Fact] + public void ReturnsSingularBit() => + Assert.Equal("1 Bit", ByteSize.FromBits(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBits() => + Assert.Equal("2 Bit", ByteSize.FromBits(2).ToFullWords()); + + [Fact] + public void ReturnsSingularByte() => + Assert.Equal("1 Byte", ByteSize.FromBytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBytes() => + Assert.Equal("10 Byte", ByteSize.FromBytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularKiloByte() => + Assert.Equal("1 Kilobyte", ByteSize.FromKilobytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralKilobytes() => + Assert.Equal("10 Kilobyte", ByteSize.FromKilobytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularMegabyte() => + Assert.Equal("1 Megabyte", ByteSize.FromMegabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralMegabytes() => + Assert.Equal("10 Megabyte", ByteSize.FromMegabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularGigabyte() => + Assert.Equal("1 Gigabyte", ByteSize.FromGigabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralGigabytes() => + Assert.Equal("10 Gigabyte", ByteSize.FromGigabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularTerabyte() => + Assert.Equal("1 Terabyte", ByteSize.FromTerabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralTerabytes() => + Assert.Equal("10 Terabyte", ByteSize.FromTerabytes(10).ToFullWords()); + + [Theory] + [InlineData(229376, "B", "229376 Byte")] + [InlineData(229376, "# KB", "224 Kilobyte")] + public void ToFullWordsFormatted(double input, string format, string expectedValue) => + Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/Bytes/ToStringTests.cs b/src/Humanizer.Tests/Localisation/de/Bytes/ToStringTests.cs index 95cefdd8f..9a7a70363 100644 --- a/src/Humanizer.Tests/Localisation/de/Bytes/ToStringTests.cs +++ b/src/Humanizer.Tests/Localisation/de/Bytes/ToStringTests.cs @@ -1,58 +1,57 @@ -namespace Humanizer.Tests.Localisation.de.Bytes +namespace Humanizer.Tests.Localisation.de.Bytes; + +[UseCulture("de-DE")] +public class ToStringTests { - [UseCulture("de-DE")] - public class ToStringTests - { - [Fact] - public void ReturnsLargestMetricSuffix() => - Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString()); - - [Fact] - public void ReturnsDefaultNumberFormat() => - Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString("KB")); - - [Fact] - public void ReturnsProvidedNumberFormat() => - Assert.Equal("10,1234 kB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); - - [Fact] - public void ReturnsBits() => - Assert.Equal("10 bit", ByteSize.FromBits(10).ToString("##.#### b")); - - [Fact] - public void ReturnsBytes() => - Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B")); - - [Fact] - public void ReturnsKilobytes() => - Assert.Equal("10 kB", ByteSize.FromKilobytes(10).ToString("##.#### KB")); - - [Fact] - public void ReturnsMegabytes() => - Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB")); - - [Fact] - public void ReturnsGigabytes() => - Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB")); - - [Fact] - public void ReturnsTerabytes() => - Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB")); - - [Fact] - public void ReturnsSelectedFormat() => - Assert.Equal("10,0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB")); - - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZero() => - Assert.Equal("512 kB", ByteSize.FromMegabytes(.5).ToString("#.#")); - - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => - Assert.Equal("-512 kB", ByteSize.FromMegabytes(-.5).ToString("#.#")); - - [Fact] - public void ReturnsBytesViaGeneralFormat() => - Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}"); - } -} + [Fact] + public void ReturnsLargestMetricSuffix() => + Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString()); + + [Fact] + public void ReturnsDefaultNumberFormat() => + Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString("KB")); + + [Fact] + public void ReturnsProvidedNumberFormat() => + Assert.Equal("10,1234 kB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); + + [Fact] + public void ReturnsBits() => + Assert.Equal("10 bit", ByteSize.FromBits(10).ToString("##.#### b")); + + [Fact] + public void ReturnsBytes() => + Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B")); + + [Fact] + public void ReturnsKilobytes() => + Assert.Equal("10 kB", ByteSize.FromKilobytes(10).ToString("##.#### KB")); + + [Fact] + public void ReturnsMegabytes() => + Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB")); + + [Fact] + public void ReturnsGigabytes() => + Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB")); + + [Fact] + public void ReturnsTerabytes() => + Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB")); + + [Fact] + public void ReturnsSelectedFormat() => + Assert.Equal("10,0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB")); + + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZero() => + Assert.Equal("512 kB", ByteSize.FromMegabytes(.5).ToString("#.#")); + + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => + Assert.Equal("-512 kB", ByteSize.FromMegabytes(-.5).ToString("#.#")); + + [Fact] + public void ReturnsBytesViaGeneralFormat() => + Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}"); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/CollectionFormatterTests.cs b/src/Humanizer.Tests/Localisation/de/CollectionFormatterTests.cs index 42faa8bc8..46ab1feec 100644 --- a/src/Humanizer.Tests/Localisation/de/CollectionFormatterTests.cs +++ b/src/Humanizer.Tests/Localisation/de/CollectionFormatterTests.cs @@ -1,30 +1,29 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de")] +public class CollectionFormatterTests { - [UseCulture("de")] - public class CollectionFormatterTests + [Fact] + public void OneItem() { - [Fact] - public void OneItem() - { - var collection = new List(new[] { 1 }); - var humanized = "1"; - Assert.Equal(humanized, collection.Humanize()); - } + var collection = new List(new[] { 1 }); + var humanized = "1"; + Assert.Equal(humanized, collection.Humanize()); + } - [Fact] - public void TwoItems() - { - var collection = new List(new[] { 1, 2 }); - var humanized = "1 und 2"; - Assert.Equal(humanized, collection.Humanize()); - } + [Fact] + public void TwoItems() + { + var collection = new List(new[] { 1, 2 }); + var humanized = "1 und 2"; + Assert.Equal(humanized, collection.Humanize()); + } - [Fact] - public void MoreThanTwoItems() - { - var collection = new List(new[] { 1, 2, 3 }); - var humanized = "1, 2 und 3"; - Assert.Equal(humanized, collection.Humanize()); - } + [Fact] + public void MoreThanTwoItems() + { + var collection = new List(new[] { 1, 2, 3 }); + var humanized = "1, 2 und 3"; + Assert.Equal(humanized, collection.Humanize()); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs index 75587e8d9..00e673c28 100644 --- a/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de-DE")] +public class DateHumanizeTests { - [UseCulture("de-DE")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "vor 2 Tagen")] - [InlineData(-1, "gestern")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "vor 2 Tagen")] + [InlineData(-1, "gestern")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "in 2 Tagen")] - [InlineData(1, "morgen")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "in 2 Tagen")] + [InlineData(1, "morgen")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-2, "vor 2 Stunden")] - [InlineData(-1, "vor einer Stunde")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "vor 2 Stunden")] + [InlineData(-1, "vor einer Stunde")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "in 2 Stunden")] - [InlineData(1, "in einer Stunde")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "in 2 Stunden")] + [InlineData(1, "in einer Stunde")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "vor 2 Minuten")] - [InlineData(-1, "vor einer Minute")] - [InlineData(60, "vor einer Stunde")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "vor 2 Minuten")] + [InlineData(-1, "vor einer Minute")] + [InlineData(60, "vor einer Stunde")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "in 2 Minuten")] - [InlineData(1, "in einer Minute")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "in 2 Minuten")] + [InlineData(1, "in einer Minute")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "vor 2 Monaten")] - [InlineData(-1, "vor einem Monat")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "vor 2 Monaten")] + [InlineData(-1, "vor einem Monat")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "in 2 Monaten")] - [InlineData(1, "in einem Monat")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "in 2 Monaten")] + [InlineData(1, "in einem Monat")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "vor 2 Sekunden")] - [InlineData(-1, "vor einer Sekunde")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "vor 2 Sekunden")] + [InlineData(-1, "vor einer Sekunde")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "in 2 Sekunden")] - [InlineData(1, "in einer Sekunde")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "in 2 Sekunden")] + [InlineData(1, "in einer Sekunde")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "vor 2 Jahren")] - [InlineData(-1, "vor einem Jahr")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "vor 2 Jahren")] + [InlineData(-1, "vor einem Jahr")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "in 2 Jahren")] - [InlineData(1, "in einem Jahr")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(2, "in 2 Jahren")] + [InlineData(1, "in einem Jahr")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/de/DateToOrdinalWordsTests.cs index e73360271..615ad5f35 100644 --- a/src/Humanizer.Tests/Localisation/de/DateToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/de/DateToOrdinalWordsTests.cs @@ -1,16 +1,15 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de")] +public class DateToOrdinalWordsTests { - [UseCulture("de")] - public class DateToOrdinalWordsTests - { - [Fact] - public void OrdinalizeString() => - Assert.Equal("1. Januar 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + [Fact] + public void OrdinalizeString() => + Assert.Equal("1. Januar 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); #if NET6_0_OR_GREATER [Fact] public void OrdinalizeDateOnlyString() => Assert.Equal("1. Januar 2015", new DateOnly(2015, 1, 1).ToOrdinalWords()); #endif - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/HeadingTests.cs b/src/Humanizer.Tests/Localisation/de/HeadingTests.cs index 00fac2baa..3938b3686 100644 --- a/src/Humanizer.Tests/Localisation/de/HeadingTests.cs +++ b/src/Humanizer.Tests/Localisation/de/HeadingTests.cs @@ -1,100 +1,99 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de-DE")] +public class HeadingTests { - [UseCulture("de-DE")] - public class HeadingTests - { - [InlineData(0, "N")] - [InlineData(11.2, "N")] - [InlineData(11.3, "NNO")] - [InlineData(22.5, "NNO")] - [InlineData(33.7, "NNO")] - [InlineData(33.8, "NO")] - [InlineData(45, "NO")] - [InlineData(56.2, "NO")] - [InlineData(56.3, "ONO")] - [InlineData(67.5, "ONO")] - [InlineData(78.7, "ONO")] - [InlineData(78.8, "O")] - [InlineData(90, "O")] - [InlineData(101.2, "O")] - [InlineData(101.3, "OSO")] - [InlineData(112.5, "OSO")] - [InlineData(123.7, "OSO")] - [InlineData(123.8, "SO")] - [InlineData(135, "SO")] - [InlineData(146.2, "SO")] - [InlineData(146.3, "SSO")] - [InlineData(157.5, "SSO")] - [InlineData(168.7, "SSO")] - [InlineData(168.8, "S")] - [InlineData(180, "S")] - [InlineData(191.2, "S")] - [InlineData(191.3, "SSW")] - [InlineData(202.5, "SSW")] - [InlineData(213.7, "SSW")] - [InlineData(213.8, "SW")] - [InlineData(225, "SW")] - [InlineData(236.2, "SW")] - [InlineData(236.3, "WSW")] - [InlineData(247.5, "WSW")] - [InlineData(258.7, "WSW")] - [InlineData(258.8, "W")] - [InlineData(270, "W")] - [InlineData(281.2, "W")] - [InlineData(281.3, "WNW")] - [InlineData(292.5, "WNW")] - [InlineData(303.7, "WNW")] - [InlineData(303.8, "NW")] - [InlineData(315, "NW")] - [InlineData(326.2, "NW")] - [InlineData(326.3, "NNW")] - [InlineData(337.5, "NNW")] - [InlineData(348.7, "NNW")] - [InlineData(348.8, "N")] - [InlineData(720, "N")] - [Theory] - public void ToHeadingAbbreviated(double heading, string expected) => - Assert.Equal(expected, heading.ToHeading()); + [InlineData(0, "N")] + [InlineData(11.2, "N")] + [InlineData(11.3, "NNO")] + [InlineData(22.5, "NNO")] + [InlineData(33.7, "NNO")] + [InlineData(33.8, "NO")] + [InlineData(45, "NO")] + [InlineData(56.2, "NO")] + [InlineData(56.3, "ONO")] + [InlineData(67.5, "ONO")] + [InlineData(78.7, "ONO")] + [InlineData(78.8, "O")] + [InlineData(90, "O")] + [InlineData(101.2, "O")] + [InlineData(101.3, "OSO")] + [InlineData(112.5, "OSO")] + [InlineData(123.7, "OSO")] + [InlineData(123.8, "SO")] + [InlineData(135, "SO")] + [InlineData(146.2, "SO")] + [InlineData(146.3, "SSO")] + [InlineData(157.5, "SSO")] + [InlineData(168.7, "SSO")] + [InlineData(168.8, "S")] + [InlineData(180, "S")] + [InlineData(191.2, "S")] + [InlineData(191.3, "SSW")] + [InlineData(202.5, "SSW")] + [InlineData(213.7, "SSW")] + [InlineData(213.8, "SW")] + [InlineData(225, "SW")] + [InlineData(236.2, "SW")] + [InlineData(236.3, "WSW")] + [InlineData(247.5, "WSW")] + [InlineData(258.7, "WSW")] + [InlineData(258.8, "W")] + [InlineData(270, "W")] + [InlineData(281.2, "W")] + [InlineData(281.3, "WNW")] + [InlineData(292.5, "WNW")] + [InlineData(303.7, "WNW")] + [InlineData(303.8, "NW")] + [InlineData(315, "NW")] + [InlineData(326.2, "NW")] + [InlineData(326.3, "NNW")] + [InlineData(337.5, "NNW")] + [InlineData(348.7, "NNW")] + [InlineData(348.8, "N")] + [InlineData(720, "N")] + [Theory] + public void ToHeadingAbbreviated(double heading, string expected) => + Assert.Equal(expected, heading.ToHeading()); - [InlineData(0, "Nord")] - [InlineData(22.5, "Nordnordost")] - [InlineData(45, "Nordost")] - [InlineData(67.5, "Ostnordost")] - [InlineData(90, "Ost")] - [InlineData(112.5, "Ostsüdost")] - [InlineData(135, "Südost")] - [InlineData(157.5, "Südsüdost")] - [InlineData(180, "Süd")] - [InlineData(202.5, "Südsüdwest")] - [InlineData(225, "Südwest")] - [InlineData(247.5, "Westsüdwest")] - [InlineData(270, "West")] - [InlineData(292.5, "Westnordwest")] - [InlineData(315, "Nordwest")] - [InlineData(337.5, "Nordnordwest")] - [InlineData(720, "Nord")] - [Theory] - public void ToHeading(double heading, string expected) => - Assert.Equal(expected, heading.ToHeading(HeadingStyle.Full)); + [InlineData(0, "Nord")] + [InlineData(22.5, "Nordnordost")] + [InlineData(45, "Nordost")] + [InlineData(67.5, "Ostnordost")] + [InlineData(90, "Ost")] + [InlineData(112.5, "Ostsüdost")] + [InlineData(135, "Südost")] + [InlineData(157.5, "Südsüdost")] + [InlineData(180, "Süd")] + [InlineData(202.5, "Südsüdwest")] + [InlineData(225, "Südwest")] + [InlineData(247.5, "Westsüdwest")] + [InlineData(270, "West")] + [InlineData(292.5, "Westnordwest")] + [InlineData(315, "Nordwest")] + [InlineData(337.5, "Nordnordwest")] + [InlineData(720, "Nord")] + [Theory] + public void ToHeading(double heading, string expected) => + Assert.Equal(expected, heading.ToHeading(HeadingStyle.Full)); - [InlineData("N", 0)] - [InlineData("NNO", 22.5)] - [InlineData("NO", 45)] - [InlineData("ONO", 67.5)] - [InlineData("O", 90)] - [InlineData("OSO", 112.5)] - [InlineData("SO", 135)] - [InlineData("SSO", 157.5)] - [InlineData("S", 180)] - [InlineData("SSW", 202.5)] - [InlineData("SW", 225)] - [InlineData("WSW", 247.5)] - [InlineData("W", 270)] - [InlineData("WNW", 292.5)] - [InlineData("NW", 315)] - [InlineData("NNW", 337.5)] - [Theory] - public void FromShortHeading(string heading, double expected) => - Assert.Equal(expected, heading.FromAbbreviatedHeading()); - } -} + [InlineData("N", 0)] + [InlineData("NNO", 22.5)] + [InlineData("NO", 45)] + [InlineData("ONO", 67.5)] + [InlineData("O", 90)] + [InlineData("OSO", 112.5)] + [InlineData("SO", 135)] + [InlineData("SSO", 157.5)] + [InlineData("S", 180)] + [InlineData("SSW", 202.5)] + [InlineData("SW", 225)] + [InlineData("WSW", 247.5)] + [InlineData("W", 270)] + [InlineData("WNW", 292.5)] + [InlineData("NW", 315)] + [InlineData("NNW", 337.5)] + [Theory] + public void FromShortHeading(string heading, double expected) => + Assert.Equal(expected, heading.FromAbbreviatedHeading()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/de/NumberToWordsTests.cs index 115914d78..50d548b5b 100644 --- a/src/Humanizer.Tests/Localisation/de/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/de/NumberToWordsTests.cs @@ -1,151 +1,150 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de-DE")] +public class NumberToWordsTests { - [UseCulture("de-DE")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "null")] - [InlineData(1, "ein")] - [InlineData(2, "zwei")] - [InlineData(3, "drei")] - [InlineData(4, "vier")] - [InlineData(5, "fünf")] - [InlineData(6, "sechs")] - [InlineData(7, "sieben")] - [InlineData(8, "acht")] - [InlineData(9, "neun")] - [InlineData(10, "zehn")] - [InlineData(20, "zwanzig")] - [InlineData(30, "dreißig")] - [InlineData(40, "vierzig")] - [InlineData(50, "fünfzig")] - [InlineData(60, "sechzig")] - [InlineData(70, "siebzig")] - [InlineData(80, "achtzig")] - [InlineData(90, "neunzig")] - [InlineData(100, "einhundert")] - [InlineData(200, "zweihundert")] - [InlineData(1000, "eintausend")] - [InlineData(10000, "zehntausend")] - [InlineData(100000, "einhunderttausend")] - [InlineData(1000000, "eine Million")] - [InlineData(10000000, "zehn Millionen")] - [InlineData(100000000, "einhundert Millionen")] - [InlineData(1000000000, "eine Milliarde")] - [InlineData(2000000000, "zwei Milliarden")] - [InlineData(122, "einhundertzweiundzwanzig")] - [InlineData(3501, "dreitausendfünfhundertein")] - [InlineData(111, "einhundertelf")] - [InlineData(1112, "eintausendeinhundertzwölf")] - [InlineData(11213, "elftausendzweihundertdreizehn")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehn")] - [InlineData(2132415, "zwei Millionen einhundertzweiunddreißigtausendvierhundertfünfzehn")] - [InlineData(12345516, "zwölf Millionen dreihundertfünfundvierzigtausendfünfhundertsechzehn")] - [InlineData(751633617, "siebenhunderteinundfünfzig Millionen sechshundertdreiunddreißigtausendsechshundertsiebzehn")] - [InlineData(1111111118, "eine Milliarde einhundertelf Millionen einhundertelftausendeinhundertachtzehn")] - [InlineData(35484694489515, "fünfunddreißig Billionen vierhundertvierundachtzig Milliarden sechshundertvierundneunzig Millionen vierhundertneunundachtzigtausendfünfhundertfünfzehn")] - [InlineData(8183162164626926, "acht Billiarden einhundertdreiundachtzig Billionen einhundertzweiundsechzig Milliarden einhundertvierundsechzig Millionen sechshundertsechsundzwanzigtausendneunhundertsechsundzwanzig")] - [InlineData(4564121926659524672, "vier Trillionen fünfhundertvierundsechzig Billiarden einhunderteinundzwanzig Billionen neunhundertsechsundzwanzig Milliarden sechshundertneunundfünfzig Millionen fünfhundertvierundzwanzigtausendsechshundertzweiundsiebzig")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzig Millionen sechshundertdreiunddreißigtausendsechshundertneunzehn")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "null")] + [InlineData(1, "ein")] + [InlineData(2, "zwei")] + [InlineData(3, "drei")] + [InlineData(4, "vier")] + [InlineData(5, "fünf")] + [InlineData(6, "sechs")] + [InlineData(7, "sieben")] + [InlineData(8, "acht")] + [InlineData(9, "neun")] + [InlineData(10, "zehn")] + [InlineData(20, "zwanzig")] + [InlineData(30, "dreißig")] + [InlineData(40, "vierzig")] + [InlineData(50, "fünfzig")] + [InlineData(60, "sechzig")] + [InlineData(70, "siebzig")] + [InlineData(80, "achtzig")] + [InlineData(90, "neunzig")] + [InlineData(100, "einhundert")] + [InlineData(200, "zweihundert")] + [InlineData(1000, "eintausend")] + [InlineData(10000, "zehntausend")] + [InlineData(100000, "einhunderttausend")] + [InlineData(1000000, "eine Million")] + [InlineData(10000000, "zehn Millionen")] + [InlineData(100000000, "einhundert Millionen")] + [InlineData(1000000000, "eine Milliarde")] + [InlineData(2000000000, "zwei Milliarden")] + [InlineData(122, "einhundertzweiundzwanzig")] + [InlineData(3501, "dreitausendfünfhundertein")] + [InlineData(111, "einhundertelf")] + [InlineData(1112, "eintausendeinhundertzwölf")] + [InlineData(11213, "elftausendzweihundertdreizehn")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehn")] + [InlineData(2132415, "zwei Millionen einhundertzweiunddreißigtausendvierhundertfünfzehn")] + [InlineData(12345516, "zwölf Millionen dreihundertfünfundvierzigtausendfünfhundertsechzehn")] + [InlineData(751633617, "siebenhunderteinundfünfzig Millionen sechshundertdreiunddreißigtausendsechshundertsiebzehn")] + [InlineData(1111111118, "eine Milliarde einhundertelf Millionen einhundertelftausendeinhundertachtzehn")] + [InlineData(35484694489515, "fünfunddreißig Billionen vierhundertvierundachtzig Milliarden sechshundertvierundneunzig Millionen vierhundertneunundachtzigtausendfünfhundertfünfzehn")] + [InlineData(8183162164626926, "acht Billiarden einhundertdreiundachtzig Billionen einhundertzweiundsechzig Milliarden einhundertvierundsechzig Millionen sechshundertsechsundzwanzigtausendneunhundertsechsundzwanzig")] + [InlineData(4564121926659524672, "vier Trillionen fünfhundertvierundsechzig Billiarden einhunderteinundzwanzig Billionen neunhundertsechsundzwanzig Milliarden sechshundertneunundfünfzig Millionen fünfhundertvierundzwanzigtausendsechshundertzweiundsiebzig")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzig Millionen sechshundertdreiunddreißigtausendsechshundertneunzehn")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "eine")] - [InlineData(3501, "dreitausendfünfhunderteine")] - public void ToWordsFeminine(long number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(1, "eine")] + [InlineData(3501, "dreitausendfünfhunderteine")] + public void ToWordsFeminine(long number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nullter")] - [InlineData(1, "erster")] - [InlineData(2, "zweiter")] - [InlineData(3, "dritter")] - [InlineData(4, "vierter")] - [InlineData(5, "fünfter")] - [InlineData(6, "sechster")] - [InlineData(7, "siebter")] - [InlineData(8, "achter")] - [InlineData(9, "neunter")] - [InlineData(10, "zehnter")] - [InlineData(20, "zwanzigster")] - [InlineData(30, "dreißigster")] - [InlineData(40, "vierzigster")] - [InlineData(50, "fünfzigster")] - [InlineData(60, "sechzigster")] - [InlineData(70, "siebzigster")] - [InlineData(80, "achtzigster")] - [InlineData(90, "neunzigster")] - [InlineData(100, "einhundertster")] - [InlineData(200, "zweihundertster")] - [InlineData(1000, "eintausendster")] - [InlineData(10000, "zehntausendster")] - [InlineData(100000, "einhunderttausendster")] - [InlineData(1000000, "einmillionster")] - [InlineData(10000000, "zehnmillionster")] - [InlineData(100000000, "einhundertmillionster")] - [InlineData(1000000000, "einmilliardster")] - [InlineData(2000000000, "zweimilliardster")] - [InlineData(122, "einhundertzweiundzwanzigster")] - [InlineData(3501, "dreitausendfünfhunderterster")] - [InlineData(111, "einhundertelfter")] - [InlineData(1112, "eintausendeinhundertzwölfter")] - [InlineData(11213, "elftausendzweihundertdreizehnter")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnter")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreißigtausendvierhundertfünfzehnter")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnter")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertsiebzehnter")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnter")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertneunzehnter")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "nullter")] + [InlineData(1, "erster")] + [InlineData(2, "zweiter")] + [InlineData(3, "dritter")] + [InlineData(4, "vierter")] + [InlineData(5, "fünfter")] + [InlineData(6, "sechster")] + [InlineData(7, "siebter")] + [InlineData(8, "achter")] + [InlineData(9, "neunter")] + [InlineData(10, "zehnter")] + [InlineData(20, "zwanzigster")] + [InlineData(30, "dreißigster")] + [InlineData(40, "vierzigster")] + [InlineData(50, "fünfzigster")] + [InlineData(60, "sechzigster")] + [InlineData(70, "siebzigster")] + [InlineData(80, "achtzigster")] + [InlineData(90, "neunzigster")] + [InlineData(100, "einhundertster")] + [InlineData(200, "zweihundertster")] + [InlineData(1000, "eintausendster")] + [InlineData(10000, "zehntausendster")] + [InlineData(100000, "einhunderttausendster")] + [InlineData(1000000, "einmillionster")] + [InlineData(10000000, "zehnmillionster")] + [InlineData(100000000, "einhundertmillionster")] + [InlineData(1000000000, "einmilliardster")] + [InlineData(2000000000, "zweimilliardster")] + [InlineData(122, "einhundertzweiundzwanzigster")] + [InlineData(3501, "dreitausendfünfhunderterster")] + [InlineData(111, "einhundertelfter")] + [InlineData(1112, "eintausendeinhundertzwölfter")] + [InlineData(11213, "elftausendzweihundertdreizehnter")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnter")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreißigtausendvierhundertfünfzehnter")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnter")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertsiebzehnter")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnter")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertneunzehnter")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "nullte")] - [InlineData(1, "erste")] - [InlineData(2, "zweite")] - [InlineData(3, "dritte")] - [InlineData(4, "vierte")] - [InlineData(5, "fünfte")] - [InlineData(6, "sechste")] - [InlineData(7, "siebte")] - [InlineData(8, "achte")] - [InlineData(9, "neunte")] - [InlineData(10, "zehnte")] - [InlineData(111, "einhundertelfte")] - [InlineData(1112, "eintausendeinhundertzwölfte")] - [InlineData(11213, "elftausendzweihundertdreizehnte")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnte")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreißigtausendvierhundertfünfzehnte")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnte")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertsiebzehnte")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnte")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertneunzehnte")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "nullte")] + [InlineData(1, "erste")] + [InlineData(2, "zweite")] + [InlineData(3, "dritte")] + [InlineData(4, "vierte")] + [InlineData(5, "fünfte")] + [InlineData(6, "sechste")] + [InlineData(7, "siebte")] + [InlineData(8, "achte")] + [InlineData(9, "neunte")] + [InlineData(10, "zehnte")] + [InlineData(111, "einhundertelfte")] + [InlineData(1112, "eintausendeinhundertzwölfte")] + [InlineData(11213, "elftausendzweihundertdreizehnte")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehnte")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreißigtausendvierhundertfünfzehnte")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehnte")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertsiebzehnte")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehnte")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertneunzehnte")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "nulltes")] - [InlineData(1, "erstes")] - [InlineData(2, "zweites")] - [InlineData(3, "drittes")] - [InlineData(4, "viertes")] - [InlineData(5, "fünftes")] - [InlineData(6, "sechstes")] - [InlineData(7, "siebtes")] - [InlineData(8, "achtes")] - [InlineData(9, "neuntes")] - [InlineData(10, "zehntes")] - [InlineData(111, "einhundertelftes")] - [InlineData(1112, "eintausendeinhundertzwölftes")] - [InlineData(11213, "elftausendzweihundertdreizehntes")] - [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehntes")] - [InlineData(2132415, "zweimillioneneinhundertzweiunddreißigtausendvierhundertfünfzehntes")] - [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehntes")] - [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertsiebzehntes")] - [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehntes")] - [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertneunzehntes")] - public void ToOrdinalWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(0, "nulltes")] + [InlineData(1, "erstes")] + [InlineData(2, "zweites")] + [InlineData(3, "drittes")] + [InlineData(4, "viertes")] + [InlineData(5, "fünftes")] + [InlineData(6, "sechstes")] + [InlineData(7, "siebtes")] + [InlineData(8, "achtes")] + [InlineData(9, "neuntes")] + [InlineData(10, "zehntes")] + [InlineData(111, "einhundertelftes")] + [InlineData(1112, "eintausendeinhundertzwölftes")] + [InlineData(11213, "elftausendzweihundertdreizehntes")] + [InlineData(121314, "einhunderteinundzwanzigtausenddreihundertvierzehntes")] + [InlineData(2132415, "zweimillioneneinhundertzweiunddreißigtausendvierhundertfünfzehntes")] + [InlineData(12345516, "zwölfmillionendreihundertfünfundvierzigtausendfünfhundertsechzehntes")] + [InlineData(751633617, "siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertsiebzehntes")] + [InlineData(1111111118, "einemilliardeeinhundertelfmillioneneinhundertelftausendeinhundertachtzehntes")] + [InlineData(-751633619, "minus siebenhunderteinundfünfzigmillionensechshundertdreiunddreißigtausendsechshundertneunzehntes")] + public void ToOrdinalWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/de/OrdinalizeTests.cs index 1d3440eb4..d1809fc9c 100644 --- a/src/Humanizer.Tests/Localisation/de/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/de/OrdinalizeTests.cs @@ -1,23 +1,22 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de-DE")] +public class OrdinalizeTests { - [UseCulture("de-DE")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0.")] - [InlineData("1", "1.")] - [InlineData("2", "2.")] - [InlineData("3", "3.")] - [InlineData("4", "4.")] - [InlineData("5", "5.")] - [InlineData("6", "6.")] - [InlineData("23", "23.")] - [InlineData("100", "100.")] - [InlineData("101", "101.")] - [InlineData("102", "102.")] - [InlineData("103", "103.")] - [InlineData("1001", "1001.")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(ordinalized, number.Ordinalize()); - } -} + [Theory] + [InlineData("0", "0.")] + [InlineData("1", "1.")] + [InlineData("2", "2.")] + [InlineData("3", "3.")] + [InlineData("4", "4.")] + [InlineData("5", "5.")] + [InlineData("6", "6.")] + [InlineData("23", "23.")] + [InlineData("100", "100.")] + [InlineData("101", "101.")] + [InlineData("102", "102.")] + [InlineData("103", "103.")] + [InlineData("1001", "1001.")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(ordinalized, number.Ordinalize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs index c8cc8bd86..4b1389488 100644 --- a/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/de/TimeSpanHumanizeTests.cs @@ -1,127 +1,126 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de-DE")] +public class TimeSpanHumanizeTests { - [UseCulture("de-DE")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 Jahr")] - [InlineData(731, "2 Jahre")] - [InlineData(1096, "3 Jahre")] - [InlineData(4018, "11 Jahre")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "ein Jahr")] - [InlineData(731, "zwei Jahre")] - [InlineData(1096, "drei Jahre")] - [InlineData(4018, "elf Jahre")] - public void YearsToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 Monat")] - [InlineData(61, "2 Monate")] - [InlineData(92, "3 Monate")] - [InlineData(335, "11 Monate")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "ein Monat")] - [InlineData(61, "zwei Monate")] - [InlineData(92, "drei Monate")] - [InlineData(335, "elf Monate")] - public void MonthsToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); - - [Theory] - [InlineData(7, "1 Woche")] - [InlineData(14, "2 Wochen")] - [InlineData(21, "3 Wochen")] - [InlineData(77, "11 Wochen")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - - [Theory] - [InlineData(7, "eine Woche")] - [InlineData(14, "zwei Wochen")] - [InlineData(21, "drei Wochen")] - [InlineData(77, "elf Wochen")] - public void WeeksToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "1 Tag")] - [InlineData(2, "2 Tage")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - - [Theory] - [InlineData(1, "ein Tag")] - [InlineData(2, "zwei Tage")] - public void DaysToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "1 Stunde")] - [InlineData(2, "2 Stunden")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - - [Theory] - [InlineData(1, "eine Stunde")] - [InlineData(2, "zwei Stunden")] - public void HoursToWords(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "1 Minute")] - [InlineData(2, "2 Minuten")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - - [Theory] - [InlineData(1, "eine Minute")] - [InlineData(2, "zwei Minuten")] - public void MinutesToWords(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "1 Sekunde")] - [InlineData(2, "2 Sekunden")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - - [Theory] - [InlineData(1, "eine Sekunde")] - [InlineData(2, "zwei Sekunden")] - public void SecondsToWords(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "1 Millisekunde")] - [InlineData(2, "2 Millisekunden")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - - [Theory] - [InlineData(1, "eine Millisekunde")] - [InlineData(2, "zwei Millisekunden")] - public void MillisecondsToWords(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: true)); - - [Fact] - public void NoTime() => - Assert.Equal("0 Millisekunden", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("Keine Zeit", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 Jahr")] + [InlineData(731, "2 Jahre")] + [InlineData(1096, "3 Jahre")] + [InlineData(4018, "11 Jahre")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "ein Jahr")] + [InlineData(731, "zwei Jahre")] + [InlineData(1096, "drei Jahre")] + [InlineData(4018, "elf Jahre")] + public void YearsToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 Monat")] + [InlineData(61, "2 Monate")] + [InlineData(92, "3 Monate")] + [InlineData(335, "11 Monate")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "ein Monat")] + [InlineData(61, "zwei Monate")] + [InlineData(92, "drei Monate")] + [InlineData(335, "elf Monate")] + public void MonthsToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); + + [Theory] + [InlineData(7, "1 Woche")] + [InlineData(14, "2 Wochen")] + [InlineData(21, "3 Wochen")] + [InlineData(77, "11 Wochen")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + + [Theory] + [InlineData(7, "eine Woche")] + [InlineData(14, "zwei Wochen")] + [InlineData(21, "drei Wochen")] + [InlineData(77, "elf Wochen")] + public void WeeksToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "1 Tag")] + [InlineData(2, "2 Tage")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + + [Theory] + [InlineData(1, "ein Tag")] + [InlineData(2, "zwei Tage")] + public void DaysToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "1 Stunde")] + [InlineData(2, "2 Stunden")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + + [Theory] + [InlineData(1, "eine Stunde")] + [InlineData(2, "zwei Stunden")] + public void HoursToWords(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "1 Minute")] + [InlineData(2, "2 Minuten")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + + [Theory] + [InlineData(1, "eine Minute")] + [InlineData(2, "zwei Minuten")] + public void MinutesToWords(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "1 Sekunde")] + [InlineData(2, "2 Sekunden")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + + [Theory] + [InlineData(1, "eine Sekunde")] + [InlineData(2, "zwei Sekunden")] + public void SecondsToWords(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "1 Millisekunde")] + [InlineData(2, "2 Millisekunden")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + + [Theory] + [InlineData(1, "eine Millisekunde")] + [InlineData(2, "zwei Millisekunden")] + public void MillisecondsToWords(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: true)); + + [Fact] + public void NoTime() => + Assert.Equal("0 Millisekunden", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("Keine Zeit", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/de/TimeUnitToSymbolTests.cs b/src/Humanizer.Tests/Localisation/de/TimeUnitToSymbolTests.cs index 264ee64ec..1c24443a0 100644 --- a/src/Humanizer.Tests/Localisation/de/TimeUnitToSymbolTests.cs +++ b/src/Humanizer.Tests/Localisation/de/TimeUnitToSymbolTests.cs @@ -1,19 +1,18 @@ -namespace Humanizer.Tests.Localisation.de +namespace Humanizer.Tests.Localisation.de; + +[UseCulture("de-DE")] +public class TimeUnitToSymbolTests { - [UseCulture("de-DE")] - public class TimeUnitToSymbolTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(TimeUnit.Millisecond, "ms")] - [InlineData(TimeUnit.Second, "s")] - [InlineData(TimeUnit.Minute, "min")] - [InlineData(TimeUnit.Hour, "h")] - [InlineData(TimeUnit.Day, "d")] - [InlineData(TimeUnit.Week, "Woche")] - [InlineData(TimeUnit.Month, "M")] - [InlineData(TimeUnit.Year, "a")] - public void ToSymbol(TimeUnit unit, string expected) => - Assert.Equal(expected, unit.ToSymbol()); - } -} + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(TimeUnit.Millisecond, "ms")] + [InlineData(TimeUnit.Second, "s")] + [InlineData(TimeUnit.Minute, "min")] + [InlineData(TimeUnit.Hour, "h")] + [InlineData(TimeUnit.Day, "d")] + [InlineData(TimeUnit.Week, "Woche")] + [InlineData(TimeUnit.Month, "M")] + [InlineData(TimeUnit.Year, "a")] + public void ToSymbol(TimeUnit unit, string expected) => + Assert.Equal(expected, unit.ToSymbol()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/el/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/el/DateHumanizeTests.cs index 5f0a0c0b3..62ce69dda 100644 --- a/src/Humanizer.Tests/Localisation/el/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/el/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.el +namespace Humanizer.Tests.Localisation.el; + +[UseCulture("el")] +public class DateHumanizeTests { - [UseCulture("el")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "πριν από 2 ημέρες")] - [InlineData(-1, "χθες")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "πριν από 2 ημέρες")] + [InlineData(-1, "χθες")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 ημέρες από τώρα")] - [InlineData(1, "αύριο")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "2 ημέρες από τώρα")] + [InlineData(1, "αύριο")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-2, "πριν από 2 ώρες")] - [InlineData(-1, "πριν από μία ώρα")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "πριν από 2 ώρες")] + [InlineData(-1, "πριν από μία ώρα")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 ώρες από τώρα")] - [InlineData(1, "πρίν από μία ώρα από τώρα")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "2 ώρες από τώρα")] + [InlineData(1, "πρίν από μία ώρα από τώρα")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "πριν από 2 λεπτά")] - [InlineData(-1, "πριν από ένα λεπτό")] - [InlineData(60, "πριν από μία ώρα")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "πριν από 2 λεπτά")] + [InlineData(-1, "πριν από ένα λεπτό")] + [InlineData(60, "πριν από μία ώρα")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 λεπτά από τώρα")] - [InlineData(1, "πρίν από ένα λεπτό από τώρα")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "2 λεπτά από τώρα")] + [InlineData(1, "πρίν από ένα λεπτό από τώρα")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "πριν από 2 μήνες")] - [InlineData(-1, "πριν από έναν μήνα")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "πριν από 2 μήνες")] + [InlineData(-1, "πριν από έναν μήνα")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 μήνες από τώρα")] - [InlineData(1, "πριν από έναν μήνα από τώρα")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "2 μήνες από τώρα")] + [InlineData(1, "πριν από έναν μήνα από τώρα")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "πριν από 2 δευτερόλεπτα")] - [InlineData(-1, "πριν από ένα δευτερόλεπτο")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "πριν από 2 δευτερόλεπτα")] + [InlineData(-1, "πριν από ένα δευτερόλεπτο")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 δευτερόλεπτα από τώρα")] - [InlineData(1, "πριν από ένα δευτερόλεπτο από τώρα")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "2 δευτερόλεπτα από τώρα")] + [InlineData(1, "πριν από ένα δευτερόλεπτο από τώρα")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "πριν από 2 χρόνια")] - [InlineData(-1, "πριν από έναν χρόνο")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "πριν από 2 χρόνια")] + [InlineData(-1, "πριν από έναν χρόνο")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "2 χρόνια από τώρα")] - [InlineData(1, "πριν από έναν χρόνο από τώρα")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(2, "2 χρόνια από τώρα")] + [InlineData(1, "πριν από έναν χρόνο από τώρα")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/el/NumberToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/el/NumberToOrdinalWordsTests.cs index d7bfaaf41..5444463d5 100644 --- a/src/Humanizer.Tests/Localisation/el/NumberToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/el/NumberToOrdinalWordsTests.cs @@ -1,31 +1,30 @@ -namespace Humanizer.Tests.Localisation.el +namespace Humanizer.Tests.Localisation.el; + +[UseCulture("el")] +public class NumberToOrdinalWordsTests { - [UseCulture("el")] - public class NumberToOrdinalWordsTests - { - [InlineData(-1, "")] - [InlineData(0, "")] - [InlineData(1, "πρώτος")] - [InlineData(10, "δέκατος")] - [InlineData(11, "ενδέκατος")] - [InlineData(12, "δωδέκατος")] - [InlineData(20, "εικοστός")] - [InlineData(31, "τριακοστός πρώτος")] - [InlineData(100, "εκατοστός")] - [InlineData(105, "εκατοστός πέμπτος")] - [InlineData(286, "διακοσιοστός ογδοηκοστός έκτος")] - [InlineData(530, "πεντακοσιοστός τριακοστός")] - [InlineData(912, "εννιακοσιοστός δωδέκατος")] - [InlineData(1203, "χιλιοστός διακοσιοστός τρίτος")] - [InlineData(1596, "χιλιοστός πεντακοσιοστός ενενηκοστός έκτος")] - [InlineData(1061, "χιλιοστός εξηκοστός πρώτος")] - [InlineData(1008, "χιλιοστός όγδοος")] - [InlineData(1211, "χιλιοστός διακοσιοστός ενδέκατος")] - [InlineData(1999, "χιλιοστός εννιακοσιοστός ενενηκοστός ένατος")] - [InlineData(2000, "")] + [InlineData(-1, "")] + [InlineData(0, "")] + [InlineData(1, "πρώτος")] + [InlineData(10, "δέκατος")] + [InlineData(11, "ενδέκατος")] + [InlineData(12, "δωδέκατος")] + [InlineData(20, "εικοστός")] + [InlineData(31, "τριακοστός πρώτος")] + [InlineData(100, "εκατοστός")] + [InlineData(105, "εκατοστός πέμπτος")] + [InlineData(286, "διακοσιοστός ογδοηκοστός έκτος")] + [InlineData(530, "πεντακοσιοστός τριακοστός")] + [InlineData(912, "εννιακοσιοστός δωδέκατος")] + [InlineData(1203, "χιλιοστός διακοσιοστός τρίτος")] + [InlineData(1596, "χιλιοστός πεντακοσιοστός ενενηκοστός έκτος")] + [InlineData(1061, "χιλιοστός εξηκοστός πρώτος")] + [InlineData(1008, "χιλιοστός όγδοος")] + [InlineData(1211, "χιλιοστός διακοσιοστός ενδέκατος")] + [InlineData(1999, "χιλιοστός εννιακοσιοστός ενενηκοστός ένατος")] + [InlineData(2000, "")] - [Theory] - public void ToOrdinalWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); - } -} + [Theory] + public void ToOrdinalWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/el/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/el/NumberToWordsTests.cs index 47c559e68..b3cb0828d 100644 --- a/src/Humanizer.Tests/Localisation/el/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/el/NumberToWordsTests.cs @@ -1,32 +1,31 @@ -namespace Humanizer.Tests.Localisation.el +namespace Humanizer.Tests.Localisation.el; + +[UseCulture("el")] +public class NumberToWordsTests { - [UseCulture("el")] - public class NumberToWordsTests - { - [InlineData(1, "ένα")] - [InlineData(10, "δέκα")] - [InlineData(11, "έντεκα")] - [InlineData(14, "δεκατέσσερα")] - [InlineData(20, "είκοσι")] - [InlineData(122, "εκατόν είκοσι δύο")] - [InlineData(3501, "τρείς χιλιάδες πεντακόσια ένα")] - [InlineData(100, "εκατό")] - [InlineData(1000, "χίλια")] - [InlineData(100000, "εκατό χιλιάδες")] - [InlineData(13448, "δεκατρείς χιλιάδες τετρακόσια σαράντα οκτώ")] - [InlineData(53, "πενήντα τρία")] - [InlineData(123647, "εκατόν είκοσι τρείς χιλιάδες εξακόσια σαράντα επτά")] - [InlineData(14000000, "δεκατέσσερα εκατομμύρια")] - [InlineData(578412, "πεντακόσιες εβδομήντα οκτώ χιλιάδες τετρακόσια δώδεκα")] - [InlineData(1000000000, "ένα δισεκατομμύριο")] - [InlineData(1000000001, "ένα δισεκατομμύριο ένα")] - [InlineData(1469, "χίλια τετρακόσια εξήντα εννέα")] - [InlineData(69, "εξήντα εννέα")] - [InlineData(619, "εξακόσια δεκαεννέα")] - [InlineData(1190, "χίλια εκατόν ενενήντα")] + [InlineData(1, "ένα")] + [InlineData(10, "δέκα")] + [InlineData(11, "έντεκα")] + [InlineData(14, "δεκατέσσερα")] + [InlineData(20, "είκοσι")] + [InlineData(122, "εκατόν είκοσι δύο")] + [InlineData(3501, "τρείς χιλιάδες πεντακόσια ένα")] + [InlineData(100, "εκατό")] + [InlineData(1000, "χίλια")] + [InlineData(100000, "εκατό χιλιάδες")] + [InlineData(13448, "δεκατρείς χιλιάδες τετρακόσια σαράντα οκτώ")] + [InlineData(53, "πενήντα τρία")] + [InlineData(123647, "εκατόν είκοσι τρείς χιλιάδες εξακόσια σαράντα επτά")] + [InlineData(14000000, "δεκατέσσερα εκατομμύρια")] + [InlineData(578412, "πεντακόσιες εβδομήντα οκτώ χιλιάδες τετρακόσια δώδεκα")] + [InlineData(1000000000, "ένα δισεκατομμύριο")] + [InlineData(1000000001, "ένα δισεκατομμύριο ένα")] + [InlineData(1469, "χίλια τετρακόσια εξήντα εννέα")] + [InlineData(69, "εξήντα εννέα")] + [InlineData(619, "εξακόσια δεκαεννέα")] + [InlineData(1190, "χίλια εκατόν ενενήντα")] - [Theory] - public void ToWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [Theory] + public void ToWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/el/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/el/TimeSpanHumanizeTests.cs index 2579e3fa9..a4e596985 100644 --- a/src/Humanizer.Tests/Localisation/el/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/el/TimeSpanHumanizeTests.cs @@ -1,70 +1,69 @@ -namespace Humanizer.Tests.Localisation.el +namespace Humanizer.Tests.Localisation.el; + +[UseCulture("el")] +public class TimeSpanHumanizeTests { - [UseCulture("el")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 χρόνο")] - [InlineData(731, "2 χρόνια")] - [InlineData(1096, "3 χρόνια")] - [InlineData(4018, "11 χρόνια")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 χρόνο")] + [InlineData(731, "2 χρόνια")] + [InlineData(1096, "3 χρόνια")] + [InlineData(4018, "11 χρόνια")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 μήνα")] - [InlineData(61, "2 μήνες")] - [InlineData(92, "3 μήνες")] - [InlineData(335, "11 μήνες")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 μήνα")] + [InlineData(61, "2 μήνες")] + [InlineData(92, "3 μήνες")] + [InlineData(335, "11 μήνες")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 βδομάδα")] - [InlineData(14, "2 βδομάδες")] - [InlineData(21, "3 βδομάδες")] - [InlineData(77, "11 βδομάδες")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 βδομάδα")] + [InlineData(14, "2 βδομάδες")] + [InlineData(21, "3 βδομάδες")] + [InlineData(77, "11 βδομάδες")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 μέρα")] - [InlineData(2, "2 μέρες")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 μέρα")] + [InlineData(2, "2 μέρες")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 ώρα")] - [InlineData(2, "2 ώρες")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 ώρα")] + [InlineData(2, "2 ώρες")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 λεπτό")] - [InlineData(2, "2 λεπτά")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 λεπτό")] + [InlineData(2, "2 λεπτά")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 δευτερόλεπτο")] - [InlineData(2, "2 δευτερόλεπτα")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 δευτερόλεπτο")] + [InlineData(2, "2 δευτερόλεπτα")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 χιλιοσtό του δευτερολέπτου")] - [InlineData(2, "2 χιλιοστά του δευτερολέπτου")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 χιλιοσtό του δευτερολέπτου")] + [InlineData(2, "2 χιλιοστά του δευτερολέπτου")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 χιλιοστά του δευτερολέπτου", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 χιλιοστά του δευτερολέπτου", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("μηδέν χρόνος", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("μηδέν χρόνος", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/en-IN/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/en-IN/NumberToWordsTests.cs index 24db6c3d9..4acb53748 100644 --- a/src/Humanizer.Tests/Localisation/en-IN/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/en-IN/NumberToWordsTests.cs @@ -1,57 +1,56 @@ -namespace Humanizer.Tests.Localisation.enIN +namespace Humanizer.Tests.Localisation.enIN; + +[UseCulture("en-IN")] +public class NumberToWordsTests { - [UseCulture("en-IN")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "")] - [InlineData(1, "one")] - [InlineData(10, "ten")] - [InlineData(11, "eleven")] - [InlineData(20, "twenty")] - [InlineData(122, "one hundred and twenty two")] - [InlineData(3501, "three thousand five hundred and one")] - [InlineData(100, "one hundred")] - [InlineData(1000, "one thousand")] - [InlineData(1001, "one thousand one")] - [InlineData(100000, "one lakh")] - [InlineData(1000000, "ten lakh")] - [InlineData(10000000, "one crore")] - [InlineData(100000000, "ten crore")] - [InlineData(1000000000, "one hundred crore")] - [InlineData(111, "one hundred and eleven")] - [InlineData(1111, "one thousand one hundred and eleven")] - [InlineData(111111, "one lakh eleven thousand one hundred and eleven")] - [InlineData(1111111, "eleven lakh eleven thousand one hundred and eleven")] - [InlineData(11111111, "one crore eleven lakh eleven thousand one hundred and eleven")] - [InlineData(111111111, "eleven crore eleven lakh eleven thousand one hundred and eleven")] - [InlineData(1111111111, "one hundred and eleven crore eleven lakh eleven thousand one hundred and eleven")] - [InlineData(101, "one hundred and one")] - [InlineData(1011, "one thousand eleven")] - [InlineData(100011, "one lakh eleven")] - [InlineData(1100001, "eleven lakh one")] - [InlineData(11000011, "one crore ten lakh eleven")] - [InlineData(110000011, "eleven crore eleven")] - [InlineData(1100000111, "one hundred and ten crore one hundred and eleven")] - [InlineData(123, "one hundred and twenty three")] - [InlineData(1234, "one thousand two hundred and thirty four")] - [InlineData(12345, "twelve thousand three hundred and forty five")] - [InlineData(123456, "one lakh twenty three thousand four hundred and fifty six")] - [InlineData(1234567, "twelve lakh thirty four thousand five hundred and sixty seven")] - [InlineData(12345678, "one crore twenty three lakh forty five thousand six hundred and seventy eight")] - [InlineData(123456789, "twelve crore thirty four lakh fifty six thousand seven hundred and eighty nine")] - [InlineData(1234567890, "one hundred and twenty three crore forty five lakh sixty seven thousand eight hundred and ninety")] - [InlineData(1000000000000, "one lakh crore")] - [InlineData(45678912345678, "forty five lakh sixty seven thousand eight hundred and ninety one crore twenty three lakh forty five thousand six hundred and seventy eight")] - [InlineData(-7516, "(Negative) seven thousand five hundred and sixteen")] + [Theory] + [InlineData(0, "")] + [InlineData(1, "one")] + [InlineData(10, "ten")] + [InlineData(11, "eleven")] + [InlineData(20, "twenty")] + [InlineData(122, "one hundred and twenty two")] + [InlineData(3501, "three thousand five hundred and one")] + [InlineData(100, "one hundred")] + [InlineData(1000, "one thousand")] + [InlineData(1001, "one thousand one")] + [InlineData(100000, "one lakh")] + [InlineData(1000000, "ten lakh")] + [InlineData(10000000, "one crore")] + [InlineData(100000000, "ten crore")] + [InlineData(1000000000, "one hundred crore")] + [InlineData(111, "one hundred and eleven")] + [InlineData(1111, "one thousand one hundred and eleven")] + [InlineData(111111, "one lakh eleven thousand one hundred and eleven")] + [InlineData(1111111, "eleven lakh eleven thousand one hundred and eleven")] + [InlineData(11111111, "one crore eleven lakh eleven thousand one hundred and eleven")] + [InlineData(111111111, "eleven crore eleven lakh eleven thousand one hundred and eleven")] + [InlineData(1111111111, "one hundred and eleven crore eleven lakh eleven thousand one hundred and eleven")] + [InlineData(101, "one hundred and one")] + [InlineData(1011, "one thousand eleven")] + [InlineData(100011, "one lakh eleven")] + [InlineData(1100001, "eleven lakh one")] + [InlineData(11000011, "one crore ten lakh eleven")] + [InlineData(110000011, "eleven crore eleven")] + [InlineData(1100000111, "one hundred and ten crore one hundred and eleven")] + [InlineData(123, "one hundred and twenty three")] + [InlineData(1234, "one thousand two hundred and thirty four")] + [InlineData(12345, "twelve thousand three hundred and forty five")] + [InlineData(123456, "one lakh twenty three thousand four hundred and fifty six")] + [InlineData(1234567, "twelve lakh thirty four thousand five hundred and sixty seven")] + [InlineData(12345678, "one crore twenty three lakh forty five thousand six hundred and seventy eight")] + [InlineData(123456789, "twelve crore thirty four lakh fifty six thousand seven hundred and eighty nine")] + [InlineData(1234567890, "one hundred and twenty three crore forty five lakh sixty seven thousand eight hundred and ninety")] + [InlineData(1000000000000, "one lakh crore")] + [InlineData(45678912345678, "forty five lakh sixty seven thousand eight hundred and ninety one crore twenty three lakh forty five thousand six hundred and seventy eight")] + [InlineData(-7516, "(Negative) seven thousand five hundred and sixteen")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "one")] - [InlineData(3501, "three thousand five hundred and one")] - public void ToWordsFeminine(long number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(1, "one")] + [InlineData(3501, "three thousand five hundred and one")] + public void ToWordsFeminine(long number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/en/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/en/DateToOrdinalWordsTests.cs index 0caaf59fd..43238e0ca 100644 --- a/src/Humanizer.Tests/Localisation/en/DateToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/en/DateToOrdinalWordsTests.cs @@ -1,16 +1,16 @@ -namespace Humanizer.Tests.Localisation.en +namespace Humanizer.Tests.Localisation.en; + +public class DateToOrdinalWordsTests { - public class DateToOrdinalWordsTests - { - [UseCulture("en-GB")] - [Fact] - public void OrdinalizeStringGb() => - Assert.Equal("1st January 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + [UseCulture("en-GB")] + [Fact] + public void OrdinalizeStringGb() => + Assert.Equal("1st January 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); - [UseCulture("en-US")] - [Fact] - public void OrdinalizeStringUs() => - Assert.Equal("January 1st, 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + [UseCulture("en-US")] + [Fact] + public void OrdinalizeStringUs() => + Assert.Equal("January 1st, 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); #if NET6_0_OR_GREATER [UseCulture("en-GB")] @@ -23,5 +23,4 @@ public void OrdinalizeDateOnlyStringGb() => public void OrdinalizeDateOnlyStringUs() => Assert.Equal("January 1st, 2015", new DateOnly(2015, 1, 1).ToOrdinalWords()); #endif - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/es/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/es/DateHumanizeTests.cs index e809f5692..7e611db1e 100644 --- a/src/Humanizer.Tests/Localisation/es/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/es/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.es +namespace Humanizer.Tests.Localisation.es; + +[UseCulture("es-ES")] +public class DateHumanizeTests { - [UseCulture("es-ES")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "hace un segundo")] - [InlineData(2, "hace 2 segundos")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "hace un segundo")] + [InlineData(2, "hace 2 segundos")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "en un segundo")] - [InlineData(2, "en 2 segundos")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "en un segundo")] + [InlineData(2, "en 2 segundos")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "hace un minuto")] - [InlineData(2, "hace 2 minutos")] - [InlineData(60, "hace una hora")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "hace un minuto")] + [InlineData(2, "hace 2 minutos")] + [InlineData(60, "hace una hora")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "en un minuto")] - [InlineData(2, "en 2 minutos")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "en un minuto")] + [InlineData(2, "en 2 minutos")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "hace una hora")] - [InlineData(2, "hace 2 horas")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "hace una hora")] + [InlineData(2, "hace 2 horas")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "en una hora")] - [InlineData(2, "en 2 horas")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "en una hora")] + [InlineData(2, "en 2 horas")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "ayer")] - [InlineData(2, "hace 2 días")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "ayer")] + [InlineData(2, "hace 2 días")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "mañana")] - [InlineData(2, "en 2 días")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "mañana")] + [InlineData(2, "en 2 días")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "hace un mes")] - [InlineData(2, "hace 2 meses")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "hace un mes")] + [InlineData(2, "hace 2 meses")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "en un mes")] - [InlineData(2, "en 2 meses")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "en un mes")] + [InlineData(2, "en 2 meses")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "hace un año")] - [InlineData(2, "hace 2 años")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "hace un año")] + [InlineData(2, "hace 2 años")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "en un año")] - [InlineData(2, "en 2 años")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "en un año")] + [InlineData(2, "en 2 años")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/es/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/es/DateToOrdinalWordsTests.cs index 7f6f5e631..f6818a8b6 100644 --- a/src/Humanizer.Tests/Localisation/es/DateToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/es/DateToOrdinalWordsTests.cs @@ -1,26 +1,25 @@ -namespace Humanizer.Tests.Localisation.es +namespace Humanizer.Tests.Localisation.es; + +[UseCulture("es-ES")] +public class DateToOrdinalWordsTests { - [UseCulture("es-ES")] - public class DateToOrdinalWordsTests + [Fact] + public void OrdinalizeString() { - [Fact] - public void OrdinalizeString() - { - Assert.Equal("25 de enero de 2022", new DateTime(2022, 1, 25).ToOrdinalWords()); - Assert.Equal("29 de febrero de 2020", new DateTime(2020, 2, 29).ToOrdinalWords()); - Assert.Equal("4 de septiembre de 2015", new DateTime(2015, 9, 4).ToOrdinalWords()); - Assert.Equal("7 de noviembre de 1979", new DateTime(1979, 11, 7).ToOrdinalWords()); - } + Assert.Equal("25 de enero de 2022", new DateTime(2022, 1, 25).ToOrdinalWords()); + Assert.Equal("29 de febrero de 2020", new DateTime(2020, 2, 29).ToOrdinalWords()); + Assert.Equal("4 de septiembre de 2015", new DateTime(2015, 9, 4).ToOrdinalWords()); + Assert.Equal("7 de noviembre de 1979", new DateTime(1979, 11, 7).ToOrdinalWords()); + } #if NET6_0_OR_GREATER - [Fact] - public void OrdinalizeDateOnlyString() - { - Assert.Equal("25 de enero de 2022", new DateOnly(2022, 1, 25).ToOrdinalWords()); - Assert.Equal("29 de febrero de 2020", new DateOnly(2020, 2, 29).ToOrdinalWords()); - Assert.Equal("4 de septiembre de 2015", new DateOnly(2015, 9, 4).ToOrdinalWords()); - Assert.Equal("7 de noviembre de 1979", new DateOnly(1979, 11, 7).ToOrdinalWords()); - } -#endif + [Fact] + public void OrdinalizeDateOnlyString() + { + Assert.Equal("25 de enero de 2022", new DateOnly(2022, 1, 25).ToOrdinalWords()); + Assert.Equal("29 de febrero de 2020", new DateOnly(2020, 2, 29).ToOrdinalWords()); + Assert.Equal("4 de septiembre de 2015", new DateOnly(2015, 9, 4).ToOrdinalWords()); + Assert.Equal("7 de noviembre de 1979", new DateOnly(1979, 11, 7).ToOrdinalWords()); } -} +#endif +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/es/NumberToWordsFeminineTest.cs b/src/Humanizer.Tests/Localisation/es/NumberToWordsFeminineTest.cs index a8f1c6b3c..1836ba6e5 100644 --- a/src/Humanizer.Tests/Localisation/es/NumberToWordsFeminineTest.cs +++ b/src/Humanizer.Tests/Localisation/es/NumberToWordsFeminineTest.cs @@ -1,20 +1,19 @@ -namespace Humanizer.Tests.Localisation.es +namespace Humanizer.Tests.Localisation.es; + +[UseCulture("es-ES")] +public class NumberToWordsFeminineTests { - [UseCulture("es-ES")] - public class NumberToWordsFeminineTests - { - [Theory] - [InlineData(1, "una")] - [InlineData(21, "veintiuna")] - [InlineData(31, "treinta y una")] - [InlineData(81, "ochenta y una")] - [InlineData(500, "quinientas")] - [InlineData(701, "setecientas una")] - [InlineData(3500, "tres mil quinientas")] - [InlineData(200121, "doscientas mil ciento veintiuna")] - [InlineData(200000121, "doscientos millones ciento veintiuna")] - [InlineData(1000001, "un millón una")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(1, "una")] + [InlineData(21, "veintiuna")] + [InlineData(31, "treinta y una")] + [InlineData(81, "ochenta y una")] + [InlineData(500, "quinientas")] + [InlineData(701, "setecientas una")] + [InlineData(3500, "tres mil quinientas")] + [InlineData(200121, "doscientas mil ciento veintiuna")] + [InlineData(200000121, "doscientos millones ciento veintiuna")] + [InlineData(1000001, "un millón una")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs index d953f77f1..d50f493ab 100644 --- a/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/es/NumberToWordsTests.cs @@ -1,381 +1,380 @@ -namespace Humanizer.Tests.Localisation.es -{ - [UseCulture("es-ES")] - public class NumberToWordsTests - { - [Theory] - [InlineData(-1, "primero", GrammaticalGender.Neuter)] - [InlineData(0, "cero", GrammaticalGender.Neuter)] - [InlineData(1, "primero", GrammaticalGender.Neuter)] - [InlineData(1, "primero", GrammaticalGender.Masculine)] - [InlineData(1, "primera", GrammaticalGender.Feminine)] - [InlineData(2, "segundo", GrammaticalGender.Masculine)] - [InlineData(2, "segunda", GrammaticalGender.Feminine)] - [InlineData(3, "tercero", GrammaticalGender.Neuter)] - [InlineData(3, "tercero", GrammaticalGender.Masculine)] - [InlineData(3, "tercera", GrammaticalGender.Feminine)] - [InlineData(4, "cuarto", GrammaticalGender.Masculine)] - [InlineData(4, "cuarta", GrammaticalGender.Feminine)] - [InlineData(5, "quinto", GrammaticalGender.Masculine)] - [InlineData(5, "quinta", GrammaticalGender.Feminine)] - [InlineData(6, "sexto", GrammaticalGender.Masculine)] - [InlineData(6, "sexta", GrammaticalGender.Feminine)] - [InlineData(7, "séptimo", GrammaticalGender.Masculine)] - [InlineData(7, "séptima", GrammaticalGender.Feminine)] - [InlineData(8, "octavo", GrammaticalGender.Masculine)] - [InlineData(8, "octava", GrammaticalGender.Feminine)] - [InlineData(9, "noveno", GrammaticalGender.Masculine)] - [InlineData(9, "novena", GrammaticalGender.Feminine)] - [InlineData(10, "décimo", GrammaticalGender.Masculine)] - [InlineData(10, "décima", GrammaticalGender.Feminine)] - [InlineData(11, "décimo primero", GrammaticalGender.Masculine)] - [InlineData(11, "décima primera", GrammaticalGender.Feminine)] - [InlineData(20, "vigésimo", GrammaticalGender.Masculine)] - [InlineData(20, "vigésima", GrammaticalGender.Feminine)] - [InlineData(22, "vigésimo segundo", GrammaticalGender.Masculine)] - [InlineData(22, "vigésima segunda", GrammaticalGender.Feminine)] - [InlineData(30, "trigésimo", GrammaticalGender.Masculine)] - [InlineData(30, "trigésima", GrammaticalGender.Feminine)] - [InlineData(34, "trigésimo cuarto", GrammaticalGender.Masculine)] - [InlineData(34, "trigésima cuarta", GrammaticalGender.Feminine)] - [InlineData(40, "cuadragésimo", GrammaticalGender.Masculine)] - [InlineData(40, "cuadragésima", GrammaticalGender.Feminine)] - [InlineData(46, "cuadragésimo sexto", GrammaticalGender.Masculine)] - [InlineData(46, "cuadragésima sexta", GrammaticalGender.Feminine)] - [InlineData(50, "quincuagésimo", GrammaticalGender.Masculine)] - [InlineData(50, "quincuagésima", GrammaticalGender.Feminine)] - [InlineData(57, "quincuagésimo séptimo", GrammaticalGender.Masculine)] - [InlineData(57, "quincuagésima séptima", GrammaticalGender.Feminine)] - [InlineData(60, "sexagésimo", GrammaticalGender.Masculine)] - [InlineData(60, "sexagésima", GrammaticalGender.Feminine)] - [InlineData(69, "sexagésimo noveno", GrammaticalGender.Masculine)] - [InlineData(69, "sexagésima novena", GrammaticalGender.Feminine)] - [InlineData(70, "septuagésimo", GrammaticalGender.Masculine)] - [InlineData(70, "septuagésima", GrammaticalGender.Feminine)] - [InlineData(74, "septuagésimo cuarto", GrammaticalGender.Masculine)] - [InlineData(74, "septuagésima cuarta", GrammaticalGender.Feminine)] - [InlineData(80, "octogésimo", GrammaticalGender.Masculine)] - [InlineData(80, "octogésima", GrammaticalGender.Feminine)] - [InlineData(85, "octogésimo quinto", GrammaticalGender.Masculine)] - [InlineData(85, "octogésima quinta", GrammaticalGender.Feminine)] - [InlineData(90, "nonagésimo", GrammaticalGender.Masculine)] - [InlineData(90, "nonagésima", GrammaticalGender.Feminine)] - [InlineData(99, "nonagésimo noveno", GrammaticalGender.Masculine)] - [InlineData(99, "nonagésima novena", GrammaticalGender.Feminine)] - [InlineData(100, "centésimo", GrammaticalGender.Masculine)] - [InlineData(100, "centésima", GrammaticalGender.Feminine)] - [InlineData(101, "centésimo primero", GrammaticalGender.Masculine)] - [InlineData(101, "centésima primera", GrammaticalGender.Feminine)] - [InlineData(131, "centésimo trigésimo primero", GrammaticalGender.Masculine)] - [InlineData(131, "centésima trigésima primera", GrammaticalGender.Feminine)] - [InlineData(156, "centésimo quincuagésimo sexto", GrammaticalGender.Masculine)] - [InlineData(156, "centésima quincuagésima sexta", GrammaticalGender.Feminine)] - [InlineData(214, "ducentésimo décimo cuarto", GrammaticalGender.Masculine)] - [InlineData(214, "ducentésima décima cuarta", GrammaticalGender.Feminine)] - [InlineData(330, "tricentésimo trigésimo", GrammaticalGender.Masculine)] - [InlineData(330, "tricentésima trigésima", GrammaticalGender.Feminine)] - [InlineData(334, "tricentésimo trigésimo cuarto", GrammaticalGender.Masculine)] - [InlineData(334, "tricentésima trigésima cuarta", GrammaticalGender.Feminine)] - [InlineData(400, "cuadringentésimo", GrammaticalGender.Masculine)] - [InlineData(400, "cuadringentésima", GrammaticalGender.Feminine)] - [InlineData(407, "cuadringentésimo séptimo", GrammaticalGender.Masculine)] - [InlineData(407, "cuadringentésima séptima", GrammaticalGender.Feminine)] - [InlineData(476, "cuadringentésimo septuagésimo sexto", GrammaticalGender.Masculine)] - [InlineData(476, "cuadringentésima septuagésima sexta", GrammaticalGender.Feminine)] - [InlineData(500, "quingentésimo", GrammaticalGender.Masculine)] - [InlineData(500, "quingentésima", GrammaticalGender.Feminine)] - [InlineData(509, "quingentésimo noveno", GrammaticalGender.Masculine)] - [InlineData(509, "quingentésima novena", GrammaticalGender.Feminine)] - [InlineData(549, "quingentésimo cuadragésimo noveno", GrammaticalGender.Masculine)] - [InlineData(549, "quingentésima cuadragésima novena", GrammaticalGender.Feminine)] - [InlineData(600, "sexcentésimo", GrammaticalGender.Masculine)] - [InlineData(600, "sexcentésima", GrammaticalGender.Feminine)] - [InlineData(605, "sexcentésimo quinto", GrammaticalGender.Masculine)] - [InlineData(605, "sexcentésima quinta", GrammaticalGender.Feminine)] - [InlineData(670, "sexcentésimo septuagésimo", GrammaticalGender.Masculine)] - [InlineData(670, "sexcentésima septuagésima", GrammaticalGender.Feminine)] - [InlineData(692, "sexcentésimo nonagésimo segundo", GrammaticalGender.Masculine)] - [InlineData(692, "sexcentésima nonagésima segunda", GrammaticalGender.Feminine)] - [InlineData(700, "septingentésimo", GrammaticalGender.Masculine)] - [InlineData(700, "septingentésima", GrammaticalGender.Feminine)] - [InlineData(771, "septingentésimo septuagésimo primero", GrammaticalGender.Masculine)] - [InlineData(771, "septingentésima septuagésima primera", GrammaticalGender.Feminine)] - [InlineData(800, "octingentésimo", GrammaticalGender.Masculine)] - [InlineData(800, "octingentésima", GrammaticalGender.Feminine)] - [InlineData(849, "octingentésimo cuadragésimo noveno", GrammaticalGender.Masculine)] - [InlineData(849, "octingentésima cuadragésima novena", GrammaticalGender.Feminine)] - [InlineData(900, "noningentésimo", GrammaticalGender.Masculine)] - [InlineData(900, "noningentésima", GrammaticalGender.Feminine)] - [InlineData(921, "noningentésimo vigésimo primero", GrammaticalGender.Masculine)] - [InlineData(921, "noningentésima vigésima primera", GrammaticalGender.Feminine)] - [InlineData(1000, "milésimo", GrammaticalGender.Masculine)] - [InlineData(1000, "milésima", GrammaticalGender.Feminine)] - [InlineData(1006, "milésimo sexto", GrammaticalGender.Masculine)] - [InlineData(1006, "milésima sexta", GrammaticalGender.Feminine)] - [InlineData(1108, "milésimo centésimo octavo", GrammaticalGender.Masculine)] - [InlineData(1108, "milésima centésima octava", GrammaticalGender.Feminine)] - [InlineData(1323, "milésimo tricentésimo vigésimo tercero", GrammaticalGender.Masculine)] - [InlineData(1323, "milésima tricentésima vigésima tercera", GrammaticalGender.Feminine)] - [InlineData(2000, "dosmilésimo", GrammaticalGender.Masculine)] - [InlineData(2000, "dosmilésima", GrammaticalGender.Feminine)] - [InlineData(2164, "dosmilésimo centésimo sexagésimo cuarto", GrammaticalGender.Masculine)] - [InlineData(2164, "dosmilésima centésima sexagésima cuarta", GrammaticalGender.Feminine)] - [InlineData(2915, "dosmilésimo noningentésimo décimo quinto", GrammaticalGender.Masculine)] - [InlineData(2915, "dosmilésima noningentésima décima quinta", GrammaticalGender.Feminine)] - [InlineData(3000, "tresmilésimo", GrammaticalGender.Masculine)] - [InlineData(3000, "tresmilésima", GrammaticalGender.Feminine)] - [InlineData(3456, "tresmilésimo cuadringentésimo quincuagésimo sexto", GrammaticalGender.Masculine)] - [InlineData(3456, "tresmilésima cuadringentésima quincuagésima sexta", GrammaticalGender.Feminine)] - [InlineData(4000, "cuatromilésimo", GrammaticalGender.Masculine)] - [InlineData(4000, "cuatromilésima", GrammaticalGender.Feminine)] - [InlineData(4354, "cuatromilésimo tricentésimo quincuagésimo cuarto", GrammaticalGender.Masculine)] - [InlineData(4354, "cuatromilésima tricentésima quincuagésima cuarta", GrammaticalGender.Feminine)] - [InlineData(5000, "cincomilésimo", GrammaticalGender.Masculine)] - [InlineData(5000, "cincomilésima", GrammaticalGender.Feminine)] - [InlineData(5695, "cincomilésimo sexcentésimo nonagésimo quinto", GrammaticalGender.Masculine)] - [InlineData(5695, "cincomilésima sexcentésima nonagésima quinta", GrammaticalGender.Feminine)] - [InlineData(6000, "seismilésimo", GrammaticalGender.Masculine)] - [InlineData(6000, "seismilésima", GrammaticalGender.Feminine)] - [InlineData(6642, "seismilésimo sexcentésimo cuadragésimo segundo", GrammaticalGender.Masculine)] - [InlineData(6642, "seismilésima sexcentésima cuadragésima segunda", GrammaticalGender.Feminine)] - [InlineData(7000, "sietemilésimo", GrammaticalGender.Masculine)] - [InlineData(7000, "sietemilésima", GrammaticalGender.Feminine)] - [InlineData(7676, "sietemilésimo sexcentésimo septuagésimo sexto", GrammaticalGender.Masculine)] - [InlineData(7676, "sietemilésima sexcentésima septuagésima sexta", GrammaticalGender.Feminine)] - [InlineData(8000, "ochomilésimo", GrammaticalGender.Masculine)] - [InlineData(8000, "ochomilésima", GrammaticalGender.Feminine)] - [InlineData(8431, "ochomilésimo cuadringentésimo trigésimo primero", GrammaticalGender.Masculine)] - [InlineData(8431, "ochomilésima cuadringentésima trigésima primera", GrammaticalGender.Feminine)] - [InlineData(9000, "nuevemilésimo", GrammaticalGender.Masculine)] - [InlineData(9000, "nuevemilésima", GrammaticalGender.Feminine)] - [InlineData(9620, "nuevemilésimo sexcentésimo vigésimo", GrammaticalGender.Masculine)] - [InlineData(9620, "nuevemilésima sexcentésima vigésima", GrammaticalGender.Feminine)] - [InlineData(9999, "nuevemilésimo noningentésimo nonagésimo noveno", GrammaticalGender.Masculine)] - [InlineData(9999, "nuevemilésima noningentésima nonagésima novena", GrammaticalGender.Feminine)] - [InlineData(10000, "diezmilésimo", GrammaticalGender.Masculine)] - [InlineData(10000, "diezmilésima", GrammaticalGender.Feminine)] - [InlineData(11000, "oncemilésimo", GrammaticalGender.Masculine)] - [InlineData(11000, "oncemilésima", GrammaticalGender.Feminine)] - [InlineData(20000, "veintemilésimo", GrammaticalGender.Masculine)] - [InlineData(21000, "veintiunmilésimo", GrammaticalGender.Masculine)] - [InlineData(21000, "veintiunmilésima", GrammaticalGender.Feminine)] - [InlineData(30000, "treintamilésimo", GrammaticalGender.Masculine)] - [InlineData(31000, "treinta y un milésimo", GrammaticalGender.Masculine)] - [InlineData(31000, "treinta y una milésima", GrammaticalGender.Feminine)] - [InlineData(84301, "ochenta y cuatro milésimo tricentésimo primero", GrammaticalGender.Masculine)] - [InlineData(84301, "ochenta y cuatro milésima tricentésima primera", GrammaticalGender.Feminine)] - [InlineData(99999, "noventa y nueve milésimo noningentésimo nonagésimo noveno", GrammaticalGender.Masculine)] - [InlineData(99999, "noventa y nueve milésima noningentésima nonagésima novena", GrammaticalGender.Feminine)] - [InlineData(100000, "cienmilésimo", GrammaticalGender.Masculine)] - [InlineData(100000, "cienmilésima", GrammaticalGender.Feminine)] - [InlineData(200000, "doscientosmilésimo", GrammaticalGender.Masculine)] - [InlineData(200000, "doscientasmilésima", GrammaticalGender.Feminine)] - [InlineData(380000, "trescientos ochenta milésimo", GrammaticalGender.Masculine)] - [InlineData(380000, "trescientas ochenta milésima", GrammaticalGender.Feminine)] - [InlineData(850000, "ochocientos cincuenta milésimo", GrammaticalGender.Masculine)] - [InlineData(850000, "ochocientas cincuenta milésima", GrammaticalGender.Feminine)] - [InlineData(214748, "doscientos catorce milésimo septingentésimo cuadragésimo octavo", GrammaticalGender.Masculine)] - [InlineData(214748, "doscientas catorce milésima septingentésima cuadragésima octava", GrammaticalGender.Feminine)] - [InlineData(221221, "doscientos veintiún milésimo ducentésimo vigésimo primero", GrammaticalGender.Masculine)] - [InlineData(221221, "doscientas veintiuna milésima ducentésima vigésima primera", GrammaticalGender.Feminine)] - [InlineData(1000000, "millonésimo", GrammaticalGender.Masculine)] - [InlineData(1000000, "millonésima", GrammaticalGender.Feminine)] - [InlineData(2000000, "dosmillonésimo", GrammaticalGender.Masculine)] - [InlineData(2000000, "dosmillonésima", GrammaticalGender.Feminine)] - [InlineData(1001000, "un millón milésimo", GrammaticalGender.Masculine)] - [InlineData(1221000, "un millón doscientos veintiún milésimo", GrammaticalGender.Masculine)] - [InlineData(1221000, "un millón doscientas veintiuna milésima", GrammaticalGender.Feminine)] - [InlineData(1500000, "un millón quinientos milésimo", GrammaticalGender.Masculine)] - [InlineData(1500000, "un millón quinientas milésima", GrammaticalGender.Feminine)] - [InlineData(10000000, "diezmillonésimo", GrammaticalGender.Masculine)] - [InlineData(10000000, "diezmillonésima", GrammaticalGender.Feminine)] - [InlineData(15000000, "quincemillonésimo", GrammaticalGender.Masculine)] - [InlineData(15000000, "quincemillonésima", GrammaticalGender.Feminine)] - [InlineData(21000000, "veintiunmillonésimo", GrammaticalGender.Masculine)] - [InlineData(21000000, "veintiunmillonésima", GrammaticalGender.Feminine)] - [InlineData(31000000, "treinta y un millonésimo", GrammaticalGender.Masculine)] - [InlineData(31000000, "treinta y una millonésima", GrammaticalGender.Feminine)] - [InlineData(50000000, "cincuentamillonésimo", GrammaticalGender.Masculine)] - [InlineData(50000000, "cincuentamillonésima", GrammaticalGender.Feminine)] - [InlineData(100000000, "cienmillonésimo", GrammaticalGender.Masculine)] - [InlineData(100000000, "cienmillonésima", GrammaticalGender.Feminine)] - [InlineData(150000000, "ciento cincuenta millonésimo", GrammaticalGender.Masculine)] - [InlineData(150000000, "ciento cincuenta millonésima", GrammaticalGender.Feminine)] - [InlineData(500000000, "quinientosmillonésimo", GrammaticalGender.Masculine)] - [InlineData(500000000, "quinientasmillonésima", GrammaticalGender.Feminine)] - [InlineData(1000000000, "milmillonésimo", GrammaticalGender.Masculine)] - [InlineData(1000000000, "milmillonésima", GrammaticalGender.Feminine)] - [InlineData(1001000000, "mil un millonésimo", GrammaticalGender.Masculine)] - [InlineData(1001000000, "mil una millonésima", GrammaticalGender.Feminine)] - [InlineData(1500000000, "mil quinientos millonésimo", GrammaticalGender.Masculine)] - [InlineData(1500000000, "mil quinientas millonésima", GrammaticalGender.Feminine)] - [InlineData(2000000000, "dos mil millonésimo", GrammaticalGender.Masculine)] - [InlineData(2000000000, "dos mil millonésima", GrammaticalGender.Feminine)] - [InlineData(2147483647, "dos mil ciento cuarenta y siete millones cuatrocientos ochenta y tres milésimo sexcentésimo cuadragésimo séptimo", GrammaticalGender.Masculine)] - [InlineData(2147483647, "dos mil ciento cuarenta y siete millones cuatrocientas ochenta y tres milésima sexcentésima cuadragésima séptima", GrammaticalGender.Feminine)] - public void ToOrdinalWords(int number, string words, GrammaticalGender gender) => - Assert.Equal(words, number.ToOrdinalWords(gender)); +namespace Humanizer.Tests.Localisation.es; - [Theory] - [InlineData(1, WordForm.Normal, "primero")] - [InlineData(1, WordForm.Abbreviation, "primer")] - [InlineData(2, WordForm.Normal, "segundo")] - [InlineData(2, WordForm.Abbreviation, "segundo")] - [InlineData(3, WordForm.Normal, "tercero")] - [InlineData(3, WordForm.Abbreviation, "tercer")] - [InlineData(21, WordForm.Normal, "vigésimo primero")] - [InlineData(21, WordForm.Abbreviation, "vigésimo primer")] - [InlineData(43, WordForm.Normal, "cuadragésimo tercero")] - [InlineData(43, WordForm.Abbreviation, "cuadragésimo tercer")] - public void ToOrdinalWordsWithWordForm(int number, WordForm wordForm, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(wordForm)); +[UseCulture("es-ES")] +public class NumberToWordsTests +{ + [Theory] + [InlineData(-1, "primero", GrammaticalGender.Neuter)] + [InlineData(0, "cero", GrammaticalGender.Neuter)] + [InlineData(1, "primero", GrammaticalGender.Neuter)] + [InlineData(1, "primero", GrammaticalGender.Masculine)] + [InlineData(1, "primera", GrammaticalGender.Feminine)] + [InlineData(2, "segundo", GrammaticalGender.Masculine)] + [InlineData(2, "segunda", GrammaticalGender.Feminine)] + [InlineData(3, "tercero", GrammaticalGender.Neuter)] + [InlineData(3, "tercero", GrammaticalGender.Masculine)] + [InlineData(3, "tercera", GrammaticalGender.Feminine)] + [InlineData(4, "cuarto", GrammaticalGender.Masculine)] + [InlineData(4, "cuarta", GrammaticalGender.Feminine)] + [InlineData(5, "quinto", GrammaticalGender.Masculine)] + [InlineData(5, "quinta", GrammaticalGender.Feminine)] + [InlineData(6, "sexto", GrammaticalGender.Masculine)] + [InlineData(6, "sexta", GrammaticalGender.Feminine)] + [InlineData(7, "séptimo", GrammaticalGender.Masculine)] + [InlineData(7, "séptima", GrammaticalGender.Feminine)] + [InlineData(8, "octavo", GrammaticalGender.Masculine)] + [InlineData(8, "octava", GrammaticalGender.Feminine)] + [InlineData(9, "noveno", GrammaticalGender.Masculine)] + [InlineData(9, "novena", GrammaticalGender.Feminine)] + [InlineData(10, "décimo", GrammaticalGender.Masculine)] + [InlineData(10, "décima", GrammaticalGender.Feminine)] + [InlineData(11, "décimo primero", GrammaticalGender.Masculine)] + [InlineData(11, "décima primera", GrammaticalGender.Feminine)] + [InlineData(20, "vigésimo", GrammaticalGender.Masculine)] + [InlineData(20, "vigésima", GrammaticalGender.Feminine)] + [InlineData(22, "vigésimo segundo", GrammaticalGender.Masculine)] + [InlineData(22, "vigésima segunda", GrammaticalGender.Feminine)] + [InlineData(30, "trigésimo", GrammaticalGender.Masculine)] + [InlineData(30, "trigésima", GrammaticalGender.Feminine)] + [InlineData(34, "trigésimo cuarto", GrammaticalGender.Masculine)] + [InlineData(34, "trigésima cuarta", GrammaticalGender.Feminine)] + [InlineData(40, "cuadragésimo", GrammaticalGender.Masculine)] + [InlineData(40, "cuadragésima", GrammaticalGender.Feminine)] + [InlineData(46, "cuadragésimo sexto", GrammaticalGender.Masculine)] + [InlineData(46, "cuadragésima sexta", GrammaticalGender.Feminine)] + [InlineData(50, "quincuagésimo", GrammaticalGender.Masculine)] + [InlineData(50, "quincuagésima", GrammaticalGender.Feminine)] + [InlineData(57, "quincuagésimo séptimo", GrammaticalGender.Masculine)] + [InlineData(57, "quincuagésima séptima", GrammaticalGender.Feminine)] + [InlineData(60, "sexagésimo", GrammaticalGender.Masculine)] + [InlineData(60, "sexagésima", GrammaticalGender.Feminine)] + [InlineData(69, "sexagésimo noveno", GrammaticalGender.Masculine)] + [InlineData(69, "sexagésima novena", GrammaticalGender.Feminine)] + [InlineData(70, "septuagésimo", GrammaticalGender.Masculine)] + [InlineData(70, "septuagésima", GrammaticalGender.Feminine)] + [InlineData(74, "septuagésimo cuarto", GrammaticalGender.Masculine)] + [InlineData(74, "septuagésima cuarta", GrammaticalGender.Feminine)] + [InlineData(80, "octogésimo", GrammaticalGender.Masculine)] + [InlineData(80, "octogésima", GrammaticalGender.Feminine)] + [InlineData(85, "octogésimo quinto", GrammaticalGender.Masculine)] + [InlineData(85, "octogésima quinta", GrammaticalGender.Feminine)] + [InlineData(90, "nonagésimo", GrammaticalGender.Masculine)] + [InlineData(90, "nonagésima", GrammaticalGender.Feminine)] + [InlineData(99, "nonagésimo noveno", GrammaticalGender.Masculine)] + [InlineData(99, "nonagésima novena", GrammaticalGender.Feminine)] + [InlineData(100, "centésimo", GrammaticalGender.Masculine)] + [InlineData(100, "centésima", GrammaticalGender.Feminine)] + [InlineData(101, "centésimo primero", GrammaticalGender.Masculine)] + [InlineData(101, "centésima primera", GrammaticalGender.Feminine)] + [InlineData(131, "centésimo trigésimo primero", GrammaticalGender.Masculine)] + [InlineData(131, "centésima trigésima primera", GrammaticalGender.Feminine)] + [InlineData(156, "centésimo quincuagésimo sexto", GrammaticalGender.Masculine)] + [InlineData(156, "centésima quincuagésima sexta", GrammaticalGender.Feminine)] + [InlineData(214, "ducentésimo décimo cuarto", GrammaticalGender.Masculine)] + [InlineData(214, "ducentésima décima cuarta", GrammaticalGender.Feminine)] + [InlineData(330, "tricentésimo trigésimo", GrammaticalGender.Masculine)] + [InlineData(330, "tricentésima trigésima", GrammaticalGender.Feminine)] + [InlineData(334, "tricentésimo trigésimo cuarto", GrammaticalGender.Masculine)] + [InlineData(334, "tricentésima trigésima cuarta", GrammaticalGender.Feminine)] + [InlineData(400, "cuadringentésimo", GrammaticalGender.Masculine)] + [InlineData(400, "cuadringentésima", GrammaticalGender.Feminine)] + [InlineData(407, "cuadringentésimo séptimo", GrammaticalGender.Masculine)] + [InlineData(407, "cuadringentésima séptima", GrammaticalGender.Feminine)] + [InlineData(476, "cuadringentésimo septuagésimo sexto", GrammaticalGender.Masculine)] + [InlineData(476, "cuadringentésima septuagésima sexta", GrammaticalGender.Feminine)] + [InlineData(500, "quingentésimo", GrammaticalGender.Masculine)] + [InlineData(500, "quingentésima", GrammaticalGender.Feminine)] + [InlineData(509, "quingentésimo noveno", GrammaticalGender.Masculine)] + [InlineData(509, "quingentésima novena", GrammaticalGender.Feminine)] + [InlineData(549, "quingentésimo cuadragésimo noveno", GrammaticalGender.Masculine)] + [InlineData(549, "quingentésima cuadragésima novena", GrammaticalGender.Feminine)] + [InlineData(600, "sexcentésimo", GrammaticalGender.Masculine)] + [InlineData(600, "sexcentésima", GrammaticalGender.Feminine)] + [InlineData(605, "sexcentésimo quinto", GrammaticalGender.Masculine)] + [InlineData(605, "sexcentésima quinta", GrammaticalGender.Feminine)] + [InlineData(670, "sexcentésimo septuagésimo", GrammaticalGender.Masculine)] + [InlineData(670, "sexcentésima septuagésima", GrammaticalGender.Feminine)] + [InlineData(692, "sexcentésimo nonagésimo segundo", GrammaticalGender.Masculine)] + [InlineData(692, "sexcentésima nonagésima segunda", GrammaticalGender.Feminine)] + [InlineData(700, "septingentésimo", GrammaticalGender.Masculine)] + [InlineData(700, "septingentésima", GrammaticalGender.Feminine)] + [InlineData(771, "septingentésimo septuagésimo primero", GrammaticalGender.Masculine)] + [InlineData(771, "septingentésima septuagésima primera", GrammaticalGender.Feminine)] + [InlineData(800, "octingentésimo", GrammaticalGender.Masculine)] + [InlineData(800, "octingentésima", GrammaticalGender.Feminine)] + [InlineData(849, "octingentésimo cuadragésimo noveno", GrammaticalGender.Masculine)] + [InlineData(849, "octingentésima cuadragésima novena", GrammaticalGender.Feminine)] + [InlineData(900, "noningentésimo", GrammaticalGender.Masculine)] + [InlineData(900, "noningentésima", GrammaticalGender.Feminine)] + [InlineData(921, "noningentésimo vigésimo primero", GrammaticalGender.Masculine)] + [InlineData(921, "noningentésima vigésima primera", GrammaticalGender.Feminine)] + [InlineData(1000, "milésimo", GrammaticalGender.Masculine)] + [InlineData(1000, "milésima", GrammaticalGender.Feminine)] + [InlineData(1006, "milésimo sexto", GrammaticalGender.Masculine)] + [InlineData(1006, "milésima sexta", GrammaticalGender.Feminine)] + [InlineData(1108, "milésimo centésimo octavo", GrammaticalGender.Masculine)] + [InlineData(1108, "milésima centésima octava", GrammaticalGender.Feminine)] + [InlineData(1323, "milésimo tricentésimo vigésimo tercero", GrammaticalGender.Masculine)] + [InlineData(1323, "milésima tricentésima vigésima tercera", GrammaticalGender.Feminine)] + [InlineData(2000, "dosmilésimo", GrammaticalGender.Masculine)] + [InlineData(2000, "dosmilésima", GrammaticalGender.Feminine)] + [InlineData(2164, "dosmilésimo centésimo sexagésimo cuarto", GrammaticalGender.Masculine)] + [InlineData(2164, "dosmilésima centésima sexagésima cuarta", GrammaticalGender.Feminine)] + [InlineData(2915, "dosmilésimo noningentésimo décimo quinto", GrammaticalGender.Masculine)] + [InlineData(2915, "dosmilésima noningentésima décima quinta", GrammaticalGender.Feminine)] + [InlineData(3000, "tresmilésimo", GrammaticalGender.Masculine)] + [InlineData(3000, "tresmilésima", GrammaticalGender.Feminine)] + [InlineData(3456, "tresmilésimo cuadringentésimo quincuagésimo sexto", GrammaticalGender.Masculine)] + [InlineData(3456, "tresmilésima cuadringentésima quincuagésima sexta", GrammaticalGender.Feminine)] + [InlineData(4000, "cuatromilésimo", GrammaticalGender.Masculine)] + [InlineData(4000, "cuatromilésima", GrammaticalGender.Feminine)] + [InlineData(4354, "cuatromilésimo tricentésimo quincuagésimo cuarto", GrammaticalGender.Masculine)] + [InlineData(4354, "cuatromilésima tricentésima quincuagésima cuarta", GrammaticalGender.Feminine)] + [InlineData(5000, "cincomilésimo", GrammaticalGender.Masculine)] + [InlineData(5000, "cincomilésima", GrammaticalGender.Feminine)] + [InlineData(5695, "cincomilésimo sexcentésimo nonagésimo quinto", GrammaticalGender.Masculine)] + [InlineData(5695, "cincomilésima sexcentésima nonagésima quinta", GrammaticalGender.Feminine)] + [InlineData(6000, "seismilésimo", GrammaticalGender.Masculine)] + [InlineData(6000, "seismilésima", GrammaticalGender.Feminine)] + [InlineData(6642, "seismilésimo sexcentésimo cuadragésimo segundo", GrammaticalGender.Masculine)] + [InlineData(6642, "seismilésima sexcentésima cuadragésima segunda", GrammaticalGender.Feminine)] + [InlineData(7000, "sietemilésimo", GrammaticalGender.Masculine)] + [InlineData(7000, "sietemilésima", GrammaticalGender.Feminine)] + [InlineData(7676, "sietemilésimo sexcentésimo septuagésimo sexto", GrammaticalGender.Masculine)] + [InlineData(7676, "sietemilésima sexcentésima septuagésima sexta", GrammaticalGender.Feminine)] + [InlineData(8000, "ochomilésimo", GrammaticalGender.Masculine)] + [InlineData(8000, "ochomilésima", GrammaticalGender.Feminine)] + [InlineData(8431, "ochomilésimo cuadringentésimo trigésimo primero", GrammaticalGender.Masculine)] + [InlineData(8431, "ochomilésima cuadringentésima trigésima primera", GrammaticalGender.Feminine)] + [InlineData(9000, "nuevemilésimo", GrammaticalGender.Masculine)] + [InlineData(9000, "nuevemilésima", GrammaticalGender.Feminine)] + [InlineData(9620, "nuevemilésimo sexcentésimo vigésimo", GrammaticalGender.Masculine)] + [InlineData(9620, "nuevemilésima sexcentésima vigésima", GrammaticalGender.Feminine)] + [InlineData(9999, "nuevemilésimo noningentésimo nonagésimo noveno", GrammaticalGender.Masculine)] + [InlineData(9999, "nuevemilésima noningentésima nonagésima novena", GrammaticalGender.Feminine)] + [InlineData(10000, "diezmilésimo", GrammaticalGender.Masculine)] + [InlineData(10000, "diezmilésima", GrammaticalGender.Feminine)] + [InlineData(11000, "oncemilésimo", GrammaticalGender.Masculine)] + [InlineData(11000, "oncemilésima", GrammaticalGender.Feminine)] + [InlineData(20000, "veintemilésimo", GrammaticalGender.Masculine)] + [InlineData(21000, "veintiunmilésimo", GrammaticalGender.Masculine)] + [InlineData(21000, "veintiunmilésima", GrammaticalGender.Feminine)] + [InlineData(30000, "treintamilésimo", GrammaticalGender.Masculine)] + [InlineData(31000, "treinta y un milésimo", GrammaticalGender.Masculine)] + [InlineData(31000, "treinta y una milésima", GrammaticalGender.Feminine)] + [InlineData(84301, "ochenta y cuatro milésimo tricentésimo primero", GrammaticalGender.Masculine)] + [InlineData(84301, "ochenta y cuatro milésima tricentésima primera", GrammaticalGender.Feminine)] + [InlineData(99999, "noventa y nueve milésimo noningentésimo nonagésimo noveno", GrammaticalGender.Masculine)] + [InlineData(99999, "noventa y nueve milésima noningentésima nonagésima novena", GrammaticalGender.Feminine)] + [InlineData(100000, "cienmilésimo", GrammaticalGender.Masculine)] + [InlineData(100000, "cienmilésima", GrammaticalGender.Feminine)] + [InlineData(200000, "doscientosmilésimo", GrammaticalGender.Masculine)] + [InlineData(200000, "doscientasmilésima", GrammaticalGender.Feminine)] + [InlineData(380000, "trescientos ochenta milésimo", GrammaticalGender.Masculine)] + [InlineData(380000, "trescientas ochenta milésima", GrammaticalGender.Feminine)] + [InlineData(850000, "ochocientos cincuenta milésimo", GrammaticalGender.Masculine)] + [InlineData(850000, "ochocientas cincuenta milésima", GrammaticalGender.Feminine)] + [InlineData(214748, "doscientos catorce milésimo septingentésimo cuadragésimo octavo", GrammaticalGender.Masculine)] + [InlineData(214748, "doscientas catorce milésima septingentésima cuadragésima octava", GrammaticalGender.Feminine)] + [InlineData(221221, "doscientos veintiún milésimo ducentésimo vigésimo primero", GrammaticalGender.Masculine)] + [InlineData(221221, "doscientas veintiuna milésima ducentésima vigésima primera", GrammaticalGender.Feminine)] + [InlineData(1000000, "millonésimo", GrammaticalGender.Masculine)] + [InlineData(1000000, "millonésima", GrammaticalGender.Feminine)] + [InlineData(2000000, "dosmillonésimo", GrammaticalGender.Masculine)] + [InlineData(2000000, "dosmillonésima", GrammaticalGender.Feminine)] + [InlineData(1001000, "un millón milésimo", GrammaticalGender.Masculine)] + [InlineData(1221000, "un millón doscientos veintiún milésimo", GrammaticalGender.Masculine)] + [InlineData(1221000, "un millón doscientas veintiuna milésima", GrammaticalGender.Feminine)] + [InlineData(1500000, "un millón quinientos milésimo", GrammaticalGender.Masculine)] + [InlineData(1500000, "un millón quinientas milésima", GrammaticalGender.Feminine)] + [InlineData(10000000, "diezmillonésimo", GrammaticalGender.Masculine)] + [InlineData(10000000, "diezmillonésima", GrammaticalGender.Feminine)] + [InlineData(15000000, "quincemillonésimo", GrammaticalGender.Masculine)] + [InlineData(15000000, "quincemillonésima", GrammaticalGender.Feminine)] + [InlineData(21000000, "veintiunmillonésimo", GrammaticalGender.Masculine)] + [InlineData(21000000, "veintiunmillonésima", GrammaticalGender.Feminine)] + [InlineData(31000000, "treinta y un millonésimo", GrammaticalGender.Masculine)] + [InlineData(31000000, "treinta y una millonésima", GrammaticalGender.Feminine)] + [InlineData(50000000, "cincuentamillonésimo", GrammaticalGender.Masculine)] + [InlineData(50000000, "cincuentamillonésima", GrammaticalGender.Feminine)] + [InlineData(100000000, "cienmillonésimo", GrammaticalGender.Masculine)] + [InlineData(100000000, "cienmillonésima", GrammaticalGender.Feminine)] + [InlineData(150000000, "ciento cincuenta millonésimo", GrammaticalGender.Masculine)] + [InlineData(150000000, "ciento cincuenta millonésima", GrammaticalGender.Feminine)] + [InlineData(500000000, "quinientosmillonésimo", GrammaticalGender.Masculine)] + [InlineData(500000000, "quinientasmillonésima", GrammaticalGender.Feminine)] + [InlineData(1000000000, "milmillonésimo", GrammaticalGender.Masculine)] + [InlineData(1000000000, "milmillonésima", GrammaticalGender.Feminine)] + [InlineData(1001000000, "mil un millonésimo", GrammaticalGender.Masculine)] + [InlineData(1001000000, "mil una millonésima", GrammaticalGender.Feminine)] + [InlineData(1500000000, "mil quinientos millonésimo", GrammaticalGender.Masculine)] + [InlineData(1500000000, "mil quinientas millonésima", GrammaticalGender.Feminine)] + [InlineData(2000000000, "dos mil millonésimo", GrammaticalGender.Masculine)] + [InlineData(2000000000, "dos mil millonésima", GrammaticalGender.Feminine)] + [InlineData(2147483647, "dos mil ciento cuarenta y siete millones cuatrocientos ochenta y tres milésimo sexcentésimo cuadragésimo séptimo", GrammaticalGender.Masculine)] + [InlineData(2147483647, "dos mil ciento cuarenta y siete millones cuatrocientas ochenta y tres milésima sexcentésima cuadragésima séptima", GrammaticalGender.Feminine)] + public void ToOrdinalWords(int number, string words, GrammaticalGender gender) => + Assert.Equal(words, number.ToOrdinalWords(gender)); - [Theory] - [InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "primero")] - [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "primer")] - [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "primera")] - [InlineData(2, WordForm.Normal, GrammaticalGender.Masculine, "segundo")] - [InlineData(2, WordForm.Abbreviation, GrammaticalGender.Masculine, "segundo")] - [InlineData(2, WordForm.Abbreviation, GrammaticalGender.Feminine, "segunda")] - [InlineData(3, WordForm.Normal, GrammaticalGender.Masculine, "tercero")] - [InlineData(3, WordForm.Abbreviation, GrammaticalGender.Masculine, "tercer")] - [InlineData(3, WordForm.Abbreviation, GrammaticalGender.Feminine, "tercera")] - [InlineData(21, WordForm.Normal, GrammaticalGender.Masculine, "vigésimo primero")] - [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Masculine, "vigésimo primer")] - [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Feminine, "vigésima primera")] - [InlineData(43, WordForm.Normal, GrammaticalGender.Masculine, "cuadragésimo tercero")] - [InlineData(43, WordForm.Abbreviation, GrammaticalGender.Masculine, "cuadragésimo tercer")] - [InlineData(43, WordForm.Abbreviation, GrammaticalGender.Feminine, "cuadragésima tercera")] - public void ToOrdinalWordsWithWordFormAndGender(int number, WordForm wordForm, GrammaticalGender gender, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(gender, wordForm)); + [Theory] + [InlineData(1, WordForm.Normal, "primero")] + [InlineData(1, WordForm.Abbreviation, "primer")] + [InlineData(2, WordForm.Normal, "segundo")] + [InlineData(2, WordForm.Abbreviation, "segundo")] + [InlineData(3, WordForm.Normal, "tercero")] + [InlineData(3, WordForm.Abbreviation, "tercer")] + [InlineData(21, WordForm.Normal, "vigésimo primero")] + [InlineData(21, WordForm.Abbreviation, "vigésimo primer")] + [InlineData(43, WordForm.Normal, "cuadragésimo tercero")] + [InlineData(43, WordForm.Abbreviation, "cuadragésimo tercer")] + public void ToOrdinalWordsWithWordForm(int number, WordForm wordForm, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(wordForm)); - [Theory] - [InlineData(0, "cero veces")] - [InlineData(2, "doble")] - [InlineData(100, "cien veces")] - public void ToTuple(int number, string expected) => - Assert.Equal(expected, number.ToTuple()); + [Theory] + [InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "primero")] + [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "primer")] + [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "primera")] + [InlineData(2, WordForm.Normal, GrammaticalGender.Masculine, "segundo")] + [InlineData(2, WordForm.Abbreviation, GrammaticalGender.Masculine, "segundo")] + [InlineData(2, WordForm.Abbreviation, GrammaticalGender.Feminine, "segunda")] + [InlineData(3, WordForm.Normal, GrammaticalGender.Masculine, "tercero")] + [InlineData(3, WordForm.Abbreviation, GrammaticalGender.Masculine, "tercer")] + [InlineData(3, WordForm.Abbreviation, GrammaticalGender.Feminine, "tercera")] + [InlineData(21, WordForm.Normal, GrammaticalGender.Masculine, "vigésimo primero")] + [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Masculine, "vigésimo primer")] + [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Feminine, "vigésima primera")] + [InlineData(43, WordForm.Normal, GrammaticalGender.Masculine, "cuadragésimo tercero")] + [InlineData(43, WordForm.Abbreviation, GrammaticalGender.Masculine, "cuadragésimo tercer")] + [InlineData(43, WordForm.Abbreviation, GrammaticalGender.Feminine, "cuadragésima tercera")] + public void ToOrdinalWordsWithWordFormAndGender(int number, WordForm wordForm, GrammaticalGender gender, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(gender, wordForm)); - [Theory] - [InlineData(0, "cero")] - [InlineData(1, "uno")] - [InlineData(1, "una", GrammaticalGender.Feminine)] - [InlineData(10, "diez")] - [InlineData(11, "once")] - [InlineData(15, "quince")] - [InlineData(16, "dieciséis")] - [InlineData(20, "veinte")] - [InlineData(21, "veintiuno")] - [InlineData(21, "veintiuna", GrammaticalGender.Feminine)] - [InlineData(22, "veintidós")] - [InlineData(25, "veinticinco")] - [InlineData(35, "treinta y cinco")] - [InlineData(122, "ciento veintidós")] - [InlineData(1999, "mil novecientos noventa y nueve")] - [InlineData(2014, "dos mil catorce")] - [InlineData(2048, "dos mil cuarenta y ocho")] - [InlineData(3501, "tres mil quinientos uno")] - [InlineData(21000, "veintiún mil")] - [InlineData(21000, "veintiuna mil", GrammaticalGender.Feminine)] - [InlineData(21501, "veintiún mil quinientos uno")] - [InlineData(21501, "veintiuna mil quinientas una", GrammaticalGender.Feminine)] - [InlineData(31000, "treinta y un mil")] - [InlineData(31000, "treinta y una mil", GrammaticalGender.Feminine)] - [InlineData(31501, "treinta y un mil quinientos uno")] - [InlineData(31501, "treinta y una mil quinientas una", GrammaticalGender.Feminine)] - [InlineData(101501, "ciento un mil quinientos uno")] - [InlineData(101501, "ciento una mil quinientas una", GrammaticalGender.Feminine)] - [InlineData(100, "cien")] - [InlineData(1000, "mil")] - [InlineData(100000, "cien mil")] - [InlineData(1000000, "un millón")] - [InlineData(10000000, "diez millones")] - [InlineData(100000000, "cien millones")] - [InlineData(1000000000, "mil millones")] - [InlineData(1000000000000, "un billón")] - [InlineData(1_000_000_000_000_000_000, "un trillón")] - [InlineData(111, "ciento once")] - [InlineData(1111, "mil ciento once")] - [InlineData(111111, "ciento once mil ciento once")] - [InlineData(1111111, "un millón ciento once mil ciento once")] - [InlineData(11111111, "once millones ciento once mil ciento once")] - [InlineData(111111111, "ciento once millones ciento once mil ciento once")] - [InlineData(1111111111, "mil ciento once millones ciento once mil ciento once")] - [InlineData(1111111111111, "un billón ciento once mil ciento once millones ciento once mil ciento once")] - [InlineData(1111111111111111, "mil ciento once billones ciento once mil ciento once millones ciento once mil ciento once")] - [InlineData(1111111111111111111, "un trillón ciento once mil ciento once billones ciento once mil ciento once millones ciento once mil ciento once")] - [InlineData(9223372036854775807, "nueve trillones doscientos veintitrés mil trescientos setenta y dos billones treinta y seis mil ochocientos cincuenta y cuatro millones setecientos setenta y cinco mil ochocientos siete")] - [InlineData(1001111111, "mil un millones ciento once mil ciento once")] - [InlineData(1001000001, "mil un millones uno")] - [InlineData(1002000001, "mil dos millones uno")] - [InlineData(2001000001, "dos mil un millones uno")] - [InlineData(1001000000001, "un billón mil millones uno")] - [InlineData(1001000000000001, "mil un billones uno")] - [InlineData(1002000000000001, "mil dos billones uno")] - [InlineData(2002000000000001, "dos mil dos billones uno")] - [InlineData(123, "ciento veintitrés")] - [InlineData(1234, "mil doscientos treinta y cuatro")] - [InlineData(12345, "doce mil trescientos cuarenta y cinco")] - [InlineData(123456, "ciento veintitrés mil cuatrocientos cincuenta y seis")] - [InlineData(1234567, "un millón doscientos treinta y cuatro mil quinientos sesenta y siete")] - [InlineData(12345678, "doce millones trescientos cuarenta y cinco mil seiscientos setenta y ocho")] - [InlineData(123456789, "ciento veintitrés millones cuatrocientos cincuenta y seis mil setecientos ochenta y nueve")] - [InlineData(1234567890, "mil doscientos treinta y cuatro millones quinientos sesenta y siete mil ochocientos noventa")] - [InlineData(-15, "menos quince")] - [InlineData(-123, "menos ciento veintitrés")] - [InlineData(-1234567890, "menos mil doscientos treinta y cuatro millones quinientos sesenta y siete mil ochocientos noventa")] - [InlineData(-9223372036854775808, "menos nueve trillones doscientos veintitrés mil trescientos setenta y dos billones treinta y seis mil ochocientos cincuenta y cuatro millones setecientos setenta y cinco mil ochocientos ocho")] - public void ToWords(long number, string expected, GrammaticalGender gender = GrammaticalGender.Masculine) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(0, "cero veces")] + [InlineData(2, "doble")] + [InlineData(100, "cien veces")] + public void ToTuple(int number, string expected) => + Assert.Equal(expected, number.ToTuple()); - [Theory] - [InlineData(1, WordForm.Abbreviation, "un")] - [InlineData(1, WordForm.Normal, "uno")] - [InlineData(21, WordForm.Abbreviation, "veintiún")] - [InlineData(21, WordForm.Normal, "veintiuno")] - [InlineData(21501, WordForm.Abbreviation, "veintiún mil quinientos un")] - [InlineData(21501, WordForm.Normal, "veintiún mil quinientos uno")] - public void ToWordsIntWithWordForm(int number, WordForm wordForm, string expected) - { - Assert.Equal(expected, number.ToWords(wordForm)); - Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: false)); - Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: true)); - } + [Theory] + [InlineData(0, "cero")] + [InlineData(1, "uno")] + [InlineData(1, "una", GrammaticalGender.Feminine)] + [InlineData(10, "diez")] + [InlineData(11, "once")] + [InlineData(15, "quince")] + [InlineData(16, "dieciséis")] + [InlineData(20, "veinte")] + [InlineData(21, "veintiuno")] + [InlineData(21, "veintiuna", GrammaticalGender.Feminine)] + [InlineData(22, "veintidós")] + [InlineData(25, "veinticinco")] + [InlineData(35, "treinta y cinco")] + [InlineData(122, "ciento veintidós")] + [InlineData(1999, "mil novecientos noventa y nueve")] + [InlineData(2014, "dos mil catorce")] + [InlineData(2048, "dos mil cuarenta y ocho")] + [InlineData(3501, "tres mil quinientos uno")] + [InlineData(21000, "veintiún mil")] + [InlineData(21000, "veintiuna mil", GrammaticalGender.Feminine)] + [InlineData(21501, "veintiún mil quinientos uno")] + [InlineData(21501, "veintiuna mil quinientas una", GrammaticalGender.Feminine)] + [InlineData(31000, "treinta y un mil")] + [InlineData(31000, "treinta y una mil", GrammaticalGender.Feminine)] + [InlineData(31501, "treinta y un mil quinientos uno")] + [InlineData(31501, "treinta y una mil quinientas una", GrammaticalGender.Feminine)] + [InlineData(101501, "ciento un mil quinientos uno")] + [InlineData(101501, "ciento una mil quinientas una", GrammaticalGender.Feminine)] + [InlineData(100, "cien")] + [InlineData(1000, "mil")] + [InlineData(100000, "cien mil")] + [InlineData(1000000, "un millón")] + [InlineData(10000000, "diez millones")] + [InlineData(100000000, "cien millones")] + [InlineData(1000000000, "mil millones")] + [InlineData(1000000000000, "un billón")] + [InlineData(1_000_000_000_000_000_000, "un trillón")] + [InlineData(111, "ciento once")] + [InlineData(1111, "mil ciento once")] + [InlineData(111111, "ciento once mil ciento once")] + [InlineData(1111111, "un millón ciento once mil ciento once")] + [InlineData(11111111, "once millones ciento once mil ciento once")] + [InlineData(111111111, "ciento once millones ciento once mil ciento once")] + [InlineData(1111111111, "mil ciento once millones ciento once mil ciento once")] + [InlineData(1111111111111, "un billón ciento once mil ciento once millones ciento once mil ciento once")] + [InlineData(1111111111111111, "mil ciento once billones ciento once mil ciento once millones ciento once mil ciento once")] + [InlineData(1111111111111111111, "un trillón ciento once mil ciento once billones ciento once mil ciento once millones ciento once mil ciento once")] + [InlineData(9223372036854775807, "nueve trillones doscientos veintitrés mil trescientos setenta y dos billones treinta y seis mil ochocientos cincuenta y cuatro millones setecientos setenta y cinco mil ochocientos siete")] + [InlineData(1001111111, "mil un millones ciento once mil ciento once")] + [InlineData(1001000001, "mil un millones uno")] + [InlineData(1002000001, "mil dos millones uno")] + [InlineData(2001000001, "dos mil un millones uno")] + [InlineData(1001000000001, "un billón mil millones uno")] + [InlineData(1001000000000001, "mil un billones uno")] + [InlineData(1002000000000001, "mil dos billones uno")] + [InlineData(2002000000000001, "dos mil dos billones uno")] + [InlineData(123, "ciento veintitrés")] + [InlineData(1234, "mil doscientos treinta y cuatro")] + [InlineData(12345, "doce mil trescientos cuarenta y cinco")] + [InlineData(123456, "ciento veintitrés mil cuatrocientos cincuenta y seis")] + [InlineData(1234567, "un millón doscientos treinta y cuatro mil quinientos sesenta y siete")] + [InlineData(12345678, "doce millones trescientos cuarenta y cinco mil seiscientos setenta y ocho")] + [InlineData(123456789, "ciento veintitrés millones cuatrocientos cincuenta y seis mil setecientos ochenta y nueve")] + [InlineData(1234567890, "mil doscientos treinta y cuatro millones quinientos sesenta y siete mil ochocientos noventa")] + [InlineData(-15, "menos quince")] + [InlineData(-123, "menos ciento veintitrés")] + [InlineData(-1234567890, "menos mil doscientos treinta y cuatro millones quinientos sesenta y siete mil ochocientos noventa")] + [InlineData(-9223372036854775808, "menos nueve trillones doscientos veintitrés mil trescientos setenta y dos billones treinta y seis mil ochocientos cincuenta y cuatro millones setecientos setenta y cinco mil ochocientos ocho")] + public void ToWords(long number, string expected, GrammaticalGender gender = GrammaticalGender.Masculine) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "un")] - [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "una")] - [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún")] - [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna")] - [InlineData(21501, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún mil quinientos un")] - [InlineData(21501, WordForm.Normal, GrammaticalGender.Masculine, "veintiún mil quinientos uno")] - [InlineData(21501, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna mil quinientas una")] - public void ToWordsIntWithWordFormAndGender(int number, WordForm wordForm, GrammaticalGender gender, string expected) => - Assert.Equal(expected, number.ToWords(wordForm, gender)); + [Theory] + [InlineData(1, WordForm.Abbreviation, "un")] + [InlineData(1, WordForm.Normal, "uno")] + [InlineData(21, WordForm.Abbreviation, "veintiún")] + [InlineData(21, WordForm.Normal, "veintiuno")] + [InlineData(21501, WordForm.Abbreviation, "veintiún mil quinientos un")] + [InlineData(21501, WordForm.Normal, "veintiún mil quinientos uno")] + public void ToWordsIntWithWordForm(int number, WordForm wordForm, string expected) + { + Assert.Equal(expected, number.ToWords(wordForm)); + Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: false)); + Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: true)); + } - [Theory] - [InlineData((long)1, WordForm.Abbreviation, "un")] - [InlineData((long)1, WordForm.Normal, "uno")] - [InlineData((long)21, WordForm.Abbreviation, "veintiún")] - [InlineData((long)21, WordForm.Normal, "veintiuno")] - [InlineData((long)21501, WordForm.Abbreviation, "veintiún mil quinientos un")] - [InlineData((long)21501, WordForm.Normal, "veintiún mil quinientos uno")] - public void ToWordsLongWithWordForm(long number, WordForm wordForm, string expected) - { - Assert.Equal(expected, number.ToWords(wordForm)); - Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: false)); - Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: true)); - } + [Theory] + [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "un")] + [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "una")] + [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún")] + [InlineData(21, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna")] + [InlineData(21501, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún mil quinientos un")] + [InlineData(21501, WordForm.Normal, GrammaticalGender.Masculine, "veintiún mil quinientos uno")] + [InlineData(21501, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna mil quinientas una")] + public void ToWordsIntWithWordFormAndGender(int number, WordForm wordForm, GrammaticalGender gender, string expected) => + Assert.Equal(expected, number.ToWords(wordForm, gender)); - [Theory] - [InlineData((long)1, WordForm.Abbreviation, GrammaticalGender.Masculine, "un")] - [InlineData((long)1, WordForm.Abbreviation, GrammaticalGender.Feminine, "una")] - [InlineData((long)21, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún")] - [InlineData((long)21, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna")] - [InlineData((long)21501, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún mil quinientos un")] - [InlineData((long)21501, WordForm.Normal, GrammaticalGender.Masculine, "veintiún mil quinientos uno")] - [InlineData((long)21501, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna mil quinientas una")] - public void ToWordsLongWithWordFormAndGender(long number, WordForm wordForm, GrammaticalGender gender, string expected) => - Assert.Equal(expected, number.ToWords(wordForm, gender)); + [Theory] + [InlineData((long)1, WordForm.Abbreviation, "un")] + [InlineData((long)1, WordForm.Normal, "uno")] + [InlineData((long)21, WordForm.Abbreviation, "veintiún")] + [InlineData((long)21, WordForm.Normal, "veintiuno")] + [InlineData((long)21501, WordForm.Abbreviation, "veintiún mil quinientos un")] + [InlineData((long)21501, WordForm.Normal, "veintiún mil quinientos uno")] + public void ToWordsLongWithWordForm(long number, WordForm wordForm, string expected) + { + Assert.Equal(expected, number.ToWords(wordForm)); + Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: false)); + Assert.Equal(expected, number.ToWords(wordForm: wordForm, addAnd: true)); } -} + + [Theory] + [InlineData((long)1, WordForm.Abbreviation, GrammaticalGender.Masculine, "un")] + [InlineData((long)1, WordForm.Abbreviation, GrammaticalGender.Feminine, "una")] + [InlineData((long)21, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún")] + [InlineData((long)21, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna")] + [InlineData((long)21501, WordForm.Abbreviation, GrammaticalGender.Masculine, "veintiún mil quinientos un")] + [InlineData((long)21501, WordForm.Normal, GrammaticalGender.Masculine, "veintiún mil quinientos uno")] + [InlineData((long)21501, WordForm.Abbreviation, GrammaticalGender.Feminine, "veintiuna mil quinientas una")] + public void ToWordsLongWithWordFormAndGender(long number, WordForm wordForm, GrammaticalGender gender, string expected) => + Assert.Equal(expected, number.ToWords(wordForm, gender)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs index 9ee613913..0412424dc 100644 --- a/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs @@ -1,115 +1,114 @@ -namespace Humanizer.Tests.Localisation.es +namespace Humanizer.Tests.Localisation.es; + +[UseCulture("es-ES")] +public class OrdinalizeTests { - [UseCulture("es-ES")] - public class OrdinalizeTests - { - [Theory] - [InlineData(1, "1.º")] - [InlineData(3, "3.º")] - public void OrdinalizeDefaultGender(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(), ordinalized); + [Theory] + [InlineData(1, "1.º")] + [InlineData(3, "3.º")] + public void OrdinalizeDefaultGender(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(), ordinalized); - [Theory] - [InlineData(-1, "1.º")] - [InlineData(int.MinValue, "0")] - public void OrdinalizeZeroOrNegativeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(), ordinalized); + [Theory] + [InlineData(-1, "1.º")] + [InlineData(int.MinValue, "0")] + public void OrdinalizeZeroOrNegativeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(), ordinalized); - [Theory] - [InlineData(1, WordForm.Abbreviation, "1.er")] - [InlineData(1, WordForm.Normal, "1.º")] - [InlineData(2, WordForm.Abbreviation, "2.º")] - [InlineData(2, WordForm.Normal, "2.º")] - [InlineData(3, WordForm.Abbreviation, "3.er")] - [InlineData(3, WordForm.Normal, "3.º")] - [InlineData(21, WordForm.Abbreviation, "21.er")] - [InlineData(21, WordForm.Normal, "21.º")] - public void OrdinalizeWithWordForm(int number, WordForm wordForm, string expected) - { + [Theory] + [InlineData(1, WordForm.Abbreviation, "1.er")] + [InlineData(1, WordForm.Normal, "1.º")] + [InlineData(2, WordForm.Abbreviation, "2.º")] + [InlineData(2, WordForm.Normal, "2.º")] + [InlineData(3, WordForm.Abbreviation, "3.er")] + [InlineData(3, WordForm.Normal, "3.º")] + [InlineData(21, WordForm.Abbreviation, "21.er")] + [InlineData(21, WordForm.Normal, "21.º")] + public void OrdinalizeWithWordForm(int number, WordForm wordForm, string expected) + { Assert.Equal(expected, number.Ordinalize(wordForm)); Assert.Equal(expected, number.ToString(CultureInfo.CurrentUICulture).Ordinalize(wordForm)); } - [Theory] - [InlineData(1, GrammaticalGender.Masculine, WordForm.Abbreviation, "1.er")] - [InlineData(1, GrammaticalGender.Masculine, WordForm.Normal, "1.º")] - [InlineData(1, GrammaticalGender.Feminine, WordForm.Abbreviation, "1.ª")] - [InlineData(1, GrammaticalGender.Feminine, WordForm.Normal, "1.ª")] - [InlineData(1, GrammaticalGender.Neuter, WordForm.Abbreviation, "1.er")] - [InlineData(1, GrammaticalGender.Neuter, WordForm.Normal, "1.º")] - public void OrdinalizeWithWordFormAndGender(int number, GrammaticalGender gender, WordForm wordForm, string expected) - { + [Theory] + [InlineData(1, GrammaticalGender.Masculine, WordForm.Abbreviation, "1.er")] + [InlineData(1, GrammaticalGender.Masculine, WordForm.Normal, "1.º")] + [InlineData(1, GrammaticalGender.Feminine, WordForm.Abbreviation, "1.ª")] + [InlineData(1, GrammaticalGender.Feminine, WordForm.Normal, "1.ª")] + [InlineData(1, GrammaticalGender.Neuter, WordForm.Abbreviation, "1.er")] + [InlineData(1, GrammaticalGender.Neuter, WordForm.Normal, "1.º")] + public void OrdinalizeWithWordFormAndGender(int number, GrammaticalGender gender, WordForm wordForm, string expected) + { Assert.Equal(expected, number.Ordinalize(gender, wordForm)); Assert.Equal(expected, number.ToString(CultureInfo.CurrentUICulture).Ordinalize(gender, wordForm)); } - [Theory] - [InlineData("1", "1.º")] - [InlineData("2", "2.º")] - [InlineData("3", "3.º")] - [InlineData("4", "4.º")] - [InlineData("5", "5.º")] - [InlineData("6", "6.º")] - [InlineData("23", "23.º")] - [InlineData("100", "100.º")] - [InlineData("101", "101.º")] - [InlineData("102", "102.º")] - [InlineData("103", "103.º")] - [InlineData("1001", "1001.º")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("1", "1.º")] + [InlineData("2", "2.º")] + [InlineData("3", "3.º")] + [InlineData("4", "4.º")] + [InlineData("5", "5.º")] + [InlineData("6", "6.º")] + [InlineData("23", "23.º")] + [InlineData("100", "100.º")] + [InlineData("101", "101.º")] + [InlineData("102", "102.º")] + [InlineData("103", "103.º")] + [InlineData("1001", "1001.º")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0")] - [InlineData("1", "1.ª")] - [InlineData("2", "2.ª")] - [InlineData("3", "3.ª")] - [InlineData("4", "4.ª")] - [InlineData("5", "5.ª")] - [InlineData("6", "6.ª")] - [InlineData("23", "23.ª")] - [InlineData("100", "100.ª")] - [InlineData("101", "101.ª")] - [InlineData("102", "102.ª")] - [InlineData("103", "103.ª")] - [InlineData("1001", "1001.ª")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1.ª")] + [InlineData("2", "2.ª")] + [InlineData("3", "3.ª")] + [InlineData("4", "4.ª")] + [InlineData("5", "5.ª")] + [InlineData("6", "6.ª")] + [InlineData("23", "23.ª")] + [InlineData("100", "100.ª")] + [InlineData("101", "101.ª")] + [InlineData("102", "102.ª")] + [InlineData("103", "103.ª")] + [InlineData("1001", "1001.ª")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "1.º")] - [InlineData(2, "2.º")] - [InlineData(3, "3.º")] - [InlineData(4, "4.º")] - [InlineData(5, "5.º")] - [InlineData(6, "6.º")] - [InlineData(10, "10.º")] - [InlineData(23, "23.º")] - [InlineData(100, "100.º")] - [InlineData(101, "101.º")] - [InlineData(102, "102.º")] - [InlineData(103, "103.º")] - [InlineData(1001, "1001.º")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1.º")] + [InlineData(2, "2.º")] + [InlineData(3, "3.º")] + [InlineData(4, "4.º")] + [InlineData(5, "5.º")] + [InlineData(6, "6.º")] + [InlineData(10, "10.º")] + [InlineData(23, "23.º")] + [InlineData(100, "100.º")] + [InlineData(101, "101.º")] + [InlineData(102, "102.º")] + [InlineData(103, "103.º")] + [InlineData(1001, "1001.º")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "1.ª")] - [InlineData(2, "2.ª")] - [InlineData(3, "3.ª")] - [InlineData(4, "4.ª")] - [InlineData(5, "5.ª")] - [InlineData(6, "6.ª")] - [InlineData(10, "10.ª")] - [InlineData(23, "23.ª")] - [InlineData(100, "100.ª")] - [InlineData(101, "101.ª")] - [InlineData(102, "102.ª")] - [InlineData(103, "103.ª")] - [InlineData(1001, "1001.ª")] - public void OrdinalizeNumberFeminine(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - } -} + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1.ª")] + [InlineData(2, "2.ª")] + [InlineData(3, "3.ª")] + [InlineData(4, "4.ª")] + [InlineData(5, "5.ª")] + [InlineData(6, "6.ª")] + [InlineData(10, "10.ª")] + [InlineData(23, "23.ª")] + [InlineData(100, "100.ª")] + [InlineData(101, "101.ª")] + [InlineData(102, "102.ª")] + [InlineData(103, "103.ª")] + [InlineData(1001, "1001.ª")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/es/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/es/TimeSpanHumanizeTests.cs index 0f6cdc745..c3849eadc 100644 --- a/src/Humanizer.Tests/Localisation/es/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/es/TimeSpanHumanizeTests.cs @@ -1,503 +1,502 @@ -namespace Humanizer.Tests.Localisation.es +namespace Humanizer.Tests.Localisation.es; + +[UseCulture("es-ES")] +public class TimeSpanHumanizeTests { - [UseCulture("es-ES")] - public class TimeSpanHumanizeTests + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 año")] + [InlineData(731, "2 años")] + [InlineData(1096, "3 años")] + [InlineData(4018, "11 años")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mes")] + [InlineData(61, "2 meses")] + [InlineData(92, "3 meses")] + [InlineData(335, "11 meses")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Fact] + public void TwoWeeks() => + Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); + + [Fact] + public void OneWeek() => + Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); + + [Fact] + public void SixDays() => + Assert.Equal("6 días", TimeSpan.FromDays(6).Humanize()); + + [Fact] + public void TwoDays() => + Assert.Equal("2 días", TimeSpan.FromDays(2).Humanize()); + + [Fact] + public void OneDay() => + Assert.Equal("1 día", TimeSpan.FromDays(1).Humanize()); + + [Fact] + public void TwoHours() => + Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); + + [Fact] + public void OneHour() => + Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); + + [Fact] + public void TwoMinutes() => + Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); + + [Fact] + public void OneMinute() => + Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); + + [Fact] + public void TwoSeconds() => + Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); + + [Fact] + public void OneSecond() => + Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); + + [Fact] + public void TwoMilliseconds() => + Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); + + [Fact] + public void OneMillisecond() => + Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); + + [Theory] + [InlineData(0, 0, 1, 1, 2, "un minuto, un segundo")] + [InlineData(0, 0, 2, 2, 2, "dos minutos, dos segundos")] + [InlineData(1, 2, 3, 4, 4, "un día, dos horas, tres minutos, cuatro segundos")] + public void ComplexTimeSpan(int days, int hours, int minutes, int seconds, int precision, string expected) + { + var timeSpan = new TimeSpan(days, hours, minutes, seconds); + Assert.Equal(expected, timeSpan.Humanize(precision, toWords: true)); + } + + [Fact] + public void NoTime() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("0 milisegundos", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("nada", TimeSpan.Zero.Humanize(toWords: true)); + + [Fact] + public void AllTimeSpansMustBeUniqueForASequenceOfDays() + { + var culture = new CultureInfo("es-ES"); + var qry = from i in Enumerable.Range(0, 100000) + let ts = TimeSpan.FromDays(i) + let text = ts.Humanize(precision: 3, culture: culture, maxUnit: TimeUnit.Year) + select text; + var grouping = from t in qry + group t by t into g + select new { g.Key, Count = g.Count() }; + var allUnique = grouping.All(g => g.Count == 1); + Assert.True(allUnique); + } + + [Theory] + [InlineData(365, "11 meses, 30 días")] + [InlineData(365 + 1, "1 año")] + [InlineData(365 + 365, "1 año, 11 meses, 29 días")] + [InlineData(365 + 365 + 1, "2 años")] + [InlineData(365 + 365 + 365, "2 años, 11 meses, 29 días")] + [InlineData(365 + 365 + 365 + 1, "3 años")] + [InlineData(365 + 365 + 365 + 365, "3 años, 11 meses, 29 días")] + [InlineData(365 + 365 + 365 + 365 + 1, "4 años")] + [InlineData(365 + 365 + 365 + 365 + 366, "4 años, 11 meses, 30 días")] + [InlineData(365 + 365 + 365 + 365 + 366 + 1, "5 años")] + public void Year(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(30, "4 semanas, 2 días")] + [InlineData(30 + 1, "1 mes")] + [InlineData(30 + 30, "1 mes, 29 días")] + [InlineData(30 + 30 + 1, "2 meses")] + [InlineData(30 + 30 + 31, "2 meses, 30 días")] + [InlineData(30 + 30 + 31 + 1, "3 meses")] + [InlineData(30 + 30 + 31 + 30, "3 meses, 29 días")] + [InlineData(30 + 30 + 31 + 30 + 1, "4 meses")] + [InlineData(30 + 30 + 31 + 30 + 31, "4 meses, 30 días")] + [InlineData(30 + 30 + 31 + 30 + 31 + 1, "5 meses")] + [InlineData(365, "11 meses, 30 días")] + [InlineData(366, "1 año")] + public void Month(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(14, "2 semanas")] + [InlineData(7, "1 semana")] + [InlineData(-14, "2 semanas")] + [InlineData(-7, "1 semana")] + [InlineData(730, "104 semanas")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(6, "6 días")] + [InlineData(2, "2 días")] + [InlineData(1, "1 día")] + [InlineData(-6, "6 días")] + [InlineData(-2, "2 días")] + [InlineData(-1, "1 día")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2, "2 horas")] + [InlineData(1, "1 hora")] + [InlineData(-2, "2 horas")] + [InlineData(-1, "1 hora")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2, "2 minutos")] + [InlineData(1, "1 minuto")] + [InlineData(-2, "2 minutos")] + [InlineData(-1, "1 minuto")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(135, "2 minutos")] + [InlineData(60, "1 minuto")] + [InlineData(2, "2 segundos")] + [InlineData(1, "1 segundo")] + [InlineData(-135, "2 minutos")] + [InlineData(-60, "1 minuto")] + [InlineData(-2, "2 segundos")] + [InlineData(-1, "1 segundo")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(2500, "2 segundos")] + [InlineData(1400, "1 segundo")] + [InlineData(2, "2 milisegundos")] + [InlineData(1, "1 milisegundo")] + [InlineData(-2500, "2 segundos")] + [InlineData(-1400, "1 segundo")] + [InlineData(-2, "2 milisegundos")] + [InlineData(-1, "1 milisegundo")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData((long)366 * 24 * 60 * 60 * 1000, "12 meses", TimeUnit.Month)] + [InlineData((long)6 * 7 * 24 * 60 * 60 * 1000, "6 semanas", TimeUnit.Week)] + [InlineData(7 * 24 * 60 * 60 * 1000, "7 días", TimeUnit.Day)] + [InlineData(24 * 60 * 60 * 1000, "24 horas", TimeUnit.Hour)] + [InlineData(60 * 60 * 1000, "60 minutos", TimeUnit.Minute)] + [InlineData(60 * 1000, "60 segundos", TimeUnit.Second)] + [InlineData(1000, "1000 milisegundos", TimeUnit.Millisecond)] + public void TimeSpanWithMaxTimeUnit(long ms, string expected, TimeUnit maxUnit) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(maxUnit: maxUnit); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(10, "10 milisegundos", TimeUnit.Millisecond)] + [InlineData(10, "nada", TimeUnit.Second, true)] + [InlineData(10, "nada", TimeUnit.Minute, true)] + [InlineData(10, "nada", TimeUnit.Hour, true)] + [InlineData(10, "nada", TimeUnit.Day, true)] + [InlineData(10, "nada", TimeUnit.Week, true)] + [InlineData(10, "0 segundos", TimeUnit.Second)] + [InlineData(10, "0 minutos", TimeUnit.Minute)] + [InlineData(10, "0 horas", TimeUnit.Hour)] + [InlineData(10, "0 días", TimeUnit.Day)] + [InlineData(10, "0 semanas", TimeUnit.Week)] + [InlineData(2500, "2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(2500, "2 segundos", TimeUnit.Second)] + [InlineData(2500, "nada", TimeUnit.Minute, true)] + [InlineData(2500, "nada", TimeUnit.Hour, true)] + [InlineData(2500, "nada", TimeUnit.Day, true)] + [InlineData(2500, "nada", TimeUnit.Week, true)] + [InlineData(2500, "0 minutos", TimeUnit.Minute)] + [InlineData(2500, "0 horas", TimeUnit.Hour)] + [InlineData(2500, "0 días", TimeUnit.Day)] + [InlineData(2500, "0 semanas", TimeUnit.Week)] + [InlineData(122500, "2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(122500, "2 minutos, 2 segundos", TimeUnit.Second)] + [InlineData(122500, "2 minutos", TimeUnit.Minute)] + [InlineData(122500, "nada", TimeUnit.Hour, true)] + [InlineData(122500, "nada", TimeUnit.Day, true)] + [InlineData(122500, "nada", TimeUnit.Week, true)] + [InlineData(122500, "0 horas", TimeUnit.Hour)] + [InlineData(122500, "0 días", TimeUnit.Day)] + [InlineData(122500, "0 semanas", TimeUnit.Week)] + [InlineData(3722500, "1 hora, 2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(3722500, "1 hora, 2 minutos, 2 segundos", TimeUnit.Second)] + [InlineData(3722500, "1 hora, 2 minutos", TimeUnit.Minute)] + [InlineData(3722500, "1 hora", TimeUnit.Hour)] + [InlineData(3722500, "nada", TimeUnit.Day, true)] + [InlineData(3722500, "nada", TimeUnit.Week, true)] + [InlineData(3722500, "0 días", TimeUnit.Day)] + [InlineData(3722500, "0 semanas", TimeUnit.Week)] + [InlineData(90122500, "1 día, 1 hora, 2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(90122500, "1 día, 1 hora, 2 minutos, 2 segundos", TimeUnit.Second)] + [InlineData(90122500, "1 día, 1 hora, 2 minutos", TimeUnit.Minute)] + [InlineData(90122500, "1 día, 1 hora", TimeUnit.Hour)] + [InlineData(90122500, "1 día", TimeUnit.Day)] + [InlineData(90122500, "nada", TimeUnit.Week, true)] + [InlineData(90122500, "0 semanas", TimeUnit.Week)] + [InlineData(694922500, "1 semana, 1 día, 1 hora, 2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(694922500, "1 semana, 1 día, 1 hora, 2 minutos, 2 segundos", TimeUnit.Second)] + [InlineData(694922500, "1 semana, 1 día, 1 hora, 2 minutos", TimeUnit.Minute)] + [InlineData(694922500, "1 semana, 1 día, 1 hora", TimeUnit.Hour)] + [InlineData(694922500, "1 semana, 1 día", TimeUnit.Day)] + [InlineData(694922500, "1 semana", TimeUnit.Week)] + [InlineData(2768462500, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(2768462500, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos", TimeUnit.Second)] + [InlineData(2768462500, "1 mes, 1 día, 1 hora, 1 minuto", TimeUnit.Minute)] + [InlineData(2768462500, "1 mes, 1 día, 1 hora", TimeUnit.Hour)] + [InlineData(2768462500, "1 mes, 1 día", TimeUnit.Day)] + [InlineData(2768462500, "1 mes", TimeUnit.Week)] + [InlineData(2768462500, "1 mes", TimeUnit.Month)] + [InlineData(2768462500, "nada", TimeUnit.Year, true)] + [InlineData(2768462500, "0 años", TimeUnit.Year)] + [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] + [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos", TimeUnit.Second)] + [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora, 1 minuto", TimeUnit.Minute)] + [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora", TimeUnit.Hour)] + [InlineData(34390862500, "1 año, 1 mes, 2 días", TimeUnit.Day)] + [InlineData(34390862500, "1 año, 1 mes", TimeUnit.Week)] + [InlineData(34390862500, "1 año, 1 mes", TimeUnit.Month)] + [InlineData(34390862500, "1 año", TimeUnit.Year)] + public void TimeSpanWithMinTimeUnit(long ms, string expected, TimeUnit minUnit, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(minUnit: minUnit, precision: 7, maxUnit: TimeUnit.Year, toWords: toWords); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(0, 3, "nada", true)] + [InlineData(0, 2, "nada", true)] + [InlineData(0, 3, "0 milisegundos")] + [InlineData(0, 2, "0 milisegundos")] + [InlineData(10, 2, "10 milisegundos")] + [InlineData(1400, 2, "1 segundo, 400 milisegundos")] + [InlineData(2500, 2, "2 segundos, 500 milisegundos")] + [InlineData(120000, 2, "2 minutos")] + [InlineData(62000, 2, "1 minuto, 2 segundos")] + [InlineData(62020, 2, "1 minuto, 2 segundos")] + [InlineData(62020, 3, "1 minuto, 2 segundos, 20 milisegundos")] + [InlineData(3600020, 4, "1 hora, 20 milisegundos")] + [InlineData(3600020, 3, "1 hora, 20 milisegundos")] + [InlineData(3600020, 2, "1 hora, 20 milisegundos")] + [InlineData(3600020, 1, "1 hora")] + [InlineData(3603001, 2, "1 hora, 3 segundos")] + [InlineData(3603001, 3, "1 hora, 3 segundos, 1 milisegundo")] + [InlineData(86400000, 3, "1 día")] + [InlineData(86400000, 2, "1 día")] + [InlineData(86400000, 1, "1 día")] + [InlineData(86401000, 1, "1 día")] + [InlineData(86401000, 2, "1 día, 1 segundo")] + [InlineData(86401200, 2, "1 día, 1 segundo")] + [InlineData(86401200, 3, "1 día, 1 segundo, 200 milisegundos")] + [InlineData(1296000000, 1, "2 semanas")] + [InlineData(1296000000, 2, "2 semanas, 1 día")] + [InlineData(1299600000, 2, "2 semanas, 1 día")] + [InlineData(1299600000, 3, "2 semanas, 1 día, 1 hora")] + [InlineData(1299630020, 3, "2 semanas, 1 día, 1 hora")] + [InlineData(1299630020, 4, "2 semanas, 1 día, 1 hora, 30 segundos")] + [InlineData(1299630020, 5, "2 semanas, 1 día, 1 hora, 30 segundos, 20 milisegundos")] + [InlineData(2768462500, 6, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos, 500 milisegundos")] + [InlineData(2768462500, 5, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos")] + [InlineData(2768462500, 4, "1 mes, 1 día, 1 hora, 1 minuto")] + [InlineData(2768462500, 3, "1 mes, 1 día, 1 hora")] + [InlineData(2768462500, 2, "1 mes, 1 día")] + [InlineData(2768462500, 1, "1 mes")] + [InlineData(34390862500, 7, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos, 500 milisegundos")] + [InlineData(34390862500, 6, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos")] + [InlineData(34390862500, 5, "1 año, 1 mes, 2 días, 1 hora, 1 minuto")] + [InlineData(34390862500, 4, "1 año, 1 mes, 2 días, 1 hora")] + [InlineData(34390862500, 3, "1 año, 1 mes, 2 días")] + [InlineData(34390862500, 2, "1 año, 1 mes")] + [InlineData(34390862500, 1, "1 año")] + public void TimeSpanWithPrecision(long milliseconds, int precision, string expected, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, maxUnit: TimeUnit.Year, toWords: toWords); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(3 * 7 + 4, 2, "3 semanas, 4 días")] + [InlineData(6 * 7 + 3, 2, "6 semanas, 3 días")] + [InlineData(72 * 7 + 6, 2, "72 semanas, 6 días")] + public void DaysWithPrecision(int days, int precision, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(precision: precision); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(50)] + [InlineData(52)] + public void TimeSpanWithMinAndMaxUnits_DoesNotReportExcessiveTime(int minutes) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(2, null, TimeUnit.Hour, TimeUnit.Minute); + var expected = TimeSpan.FromMinutes(minutes).Humanize(2); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(0, 3, "nada", true)] + [InlineData(0, 2, "nada", true)] + [InlineData(0, 3, "0 milisegundos")] + [InlineData(0, 2, "0 milisegundos")] + [InlineData(10, 2, "10 milisegundos")] + [InlineData(1400, 2, "1 segundo, 400 milisegundos")] + [InlineData(2500, 2, "2 segundos, 500 milisegundos")] + [InlineData(60001, 1, "1 minuto")] + [InlineData(60001, 2, "1 minuto")] + [InlineData(60001, 3, "1 minuto, 1 milisegundo")] + [InlineData(120000, 2, "2 minutos")] + [InlineData(62000, 2, "1 minuto, 2 segundos")] + [InlineData(62020, 2, "1 minuto, 2 segundos")] + [InlineData(62020, 3, "1 minuto, 2 segundos, 20 milisegundos")] + [InlineData(3600020, 4, "1 hora, 20 milisegundos")] + [InlineData(3600020, 3, "1 hora")] + [InlineData(3600020, 2, "1 hora")] + [InlineData(3600020, 1, "1 hora")] + [InlineData(3603001, 2, "1 hora")] + [InlineData(3603001, 3, "1 hora, 3 segundos")] + [InlineData(86400000, 3, "1 día")] + [InlineData(86400000, 2, "1 día")] + [InlineData(86400000, 1, "1 día")] + [InlineData(86401000, 1, "1 día")] + [InlineData(86401000, 2, "1 día")] + [InlineData(86401000, 3, "1 día")] + [InlineData(86401000, 4, "1 día, 1 segundo")] + [InlineData(86401200, 4, "1 día, 1 segundo")] + [InlineData(86401200, 5, "1 día, 1 segundo, 200 milisegundos")] + [InlineData(1296000000, 1, "2 semanas")] + [InlineData(1296000000, 2, "2 semanas, 1 día")] + [InlineData(1299600000, 2, "2 semanas, 1 día")] + [InlineData(1299600000, 3, "2 semanas, 1 día, 1 hora")] + [InlineData(1299630020, 3, "2 semanas, 1 día, 1 hora")] + [InlineData(1299630020, 4, "2 semanas, 1 día, 1 hora")] + [InlineData(1299630020, 5, "2 semanas, 1 día, 1 hora, 30 segundos")] + [InlineData(1299630020, 6, "2 semanas, 1 día, 1 hora, 30 segundos, 20 milisegundos")] + public void TimeSpanWithPrecisionAndCountingEmptyUnits(int milliseconds, int precision, string expected, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision: precision, countEmptyUnits: true, toWords: toWords); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(0, 3, "nada", true)] + [InlineData(0, 2, "nada", true)] + [InlineData(0, 3, "0 milisegundos")] + [InlineData(0, 2, "0 milisegundos")] + [InlineData(10, 2, "10 milisegundos")] + [InlineData(1400, 2, "1 segundo y 400 milisegundos")] + [InlineData(2500, 2, "2 segundos y 500 milisegundos")] + [InlineData(120000, 2, "2 minutos")] + [InlineData(62000, 2, "1 minuto y 2 segundos")] + [InlineData(62020, 2, "1 minuto y 2 segundos")] + [InlineData(62020, 3, "1 minuto, 2 segundos y 20 milisegundos")] + [InlineData(3600020, 4, "1 hora y 20 milisegundos")] + [InlineData(3600020, 3, "1 hora y 20 milisegundos")] + [InlineData(3600020, 2, "1 hora y 20 milisegundos")] + [InlineData(3600020, 1, "1 hora")] + [InlineData(3603001, 2, "1 hora y 3 segundos")] + [InlineData(3603001, 3, "1 hora, 3 segundos y 1 milisegundo")] + [InlineData(86400000, 3, "1 día")] + [InlineData(86400000, 2, "1 día")] + [InlineData(86400000, 1, "1 día")] + [InlineData(86401000, 1, "1 día")] + [InlineData(86401000, 2, "1 día y 1 segundo")] + [InlineData(86401200, 2, "1 día y 1 segundo")] + [InlineData(86401200, 3, "1 día, 1 segundo y 200 milisegundos")] + [InlineData(1296000000, 1, "2 semanas")] + [InlineData(1296000000, 2, "2 semanas y 1 día")] + [InlineData(1299600000, 2, "2 semanas y 1 día")] + [InlineData(1299600000, 3, "2 semanas, 1 día y 1 hora")] + [InlineData(1299630020, 3, "2 semanas, 1 día y 1 hora")] + [InlineData(1299630020, 4, "2 semanas, 1 día, 1 hora y 30 segundos")] + [InlineData(1299630020, 5, "2 semanas, 1 día, 1 hora, 30 segundos y 20 milisegundos")] + public void TimeSpanWithPrecisionAndAlternativeCollectionFormatter(int milliseconds, int precision, + string expected, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, collectionSeparator: null, toWords: toWords); + Assert.Equal(expected, actual); + } + + [Theory] + [InlineData(0, 3, "nada")] + [InlineData(0, 2, "nada")] + [InlineData(10, 2, "diez milisegundos")] + [InlineData(1400, 2, "un segundo, cuatrocientos milisegundos")] + [InlineData(2500, 2, "dos segundos, quinientos milisegundos")] + [InlineData(120000, 2, "dos minutos")] + [InlineData(62000, 2, "un minuto, dos segundos")] + [InlineData(62020, 2, "un minuto, dos segundos")] + [InlineData(62020, 3, "un minuto, dos segundos, veinte milisegundos")] + [InlineData(3600020, 4, "una hora, veinte milisegundos")] + [InlineData(3600020, 3, "una hora, veinte milisegundos")] + [InlineData(3600020, 2, "una hora, veinte milisegundos")] + [InlineData(3600020, 1, "una hora")] + [InlineData(3603001, 2, "una hora, tres segundos")] + [InlineData(3603001, 3, "una hora, tres segundos, un milisegundo")] + [InlineData(86400000, 3, "un día")] + [InlineData(86400000, 2, "un día")] + [InlineData(86400000, 1, "un día")] + [InlineData(86401000, 1, "un día")] + [InlineData(86401000, 2, "un día, un segundo")] + [InlineData(86401200, 2, "un día, un segundo")] + [InlineData(86401200, 3, "un día, un segundo, doscientos milisegundos")] + [InlineData(1296000000, 1, "dos semanas")] + [InlineData(1296000000, 2, "dos semanas, un día")] + [InlineData(1299600000, 2, "dos semanas, un día")] + [InlineData(1299600000, 3, "dos semanas, un día, una hora")] + [InlineData(1299630020, 3, "dos semanas, un día, una hora")] + [InlineData(1299630020, 4, "dos semanas, un día, una hora, treinta segundos")] + [InlineData(1299630020, 5, "dos semanas, un día, una hora, treinta segundos, veinte milisegundos")] + public void TimeSpanWithNumbersConvertedToWords(int milliseconds, int precision, string expected) { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 año")] - [InlineData(731, "2 años")] - [InlineData(1096, "3 años")] - [InlineData(4018, "11 años")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mes")] - [InlineData(61, "2 meses")] - [InlineData(92, "3 meses")] - [InlineData(335, "11 meses")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Fact] - public void TwoWeeks() => - Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); - - [Fact] - public void OneWeek() => - Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); - - [Fact] - public void SixDays() => - Assert.Equal("6 días", TimeSpan.FromDays(6).Humanize()); - - [Fact] - public void TwoDays() => - Assert.Equal("2 días", TimeSpan.FromDays(2).Humanize()); - - [Fact] - public void OneDay() => - Assert.Equal("1 día", TimeSpan.FromDays(1).Humanize()); - - [Fact] - public void TwoHours() => - Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); - - [Fact] - public void OneHour() => - Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); - - [Fact] - public void TwoMinutes() => - Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); - - [Fact] - public void OneMinute() => - Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); - - [Fact] - public void TwoSeconds() => - Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); - - [Fact] - public void OneSecond() => - Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); - - [Fact] - public void TwoMilliseconds() => - Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); - - [Fact] - public void OneMillisecond() => - Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); - - [Theory] - [InlineData(0, 0, 1, 1, 2, "un minuto, un segundo")] - [InlineData(0, 0, 2, 2, 2, "dos minutos, dos segundos")] - [InlineData(1, 2, 3, 4, 4, "un día, dos horas, tres minutos, cuatro segundos")] - public void ComplexTimeSpan(int days, int hours, int minutes, int seconds, int precision, string expected) - { - var timeSpan = new TimeSpan(days, hours, minutes, seconds); - Assert.Equal(expected, timeSpan.Humanize(precision, toWords: true)); - } - - [Fact] - public void NoTime() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("0 milisegundos", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("nada", TimeSpan.Zero.Humanize(toWords: true)); - - [Fact] - public void AllTimeSpansMustBeUniqueForASequenceOfDays() - { - var culture = new CultureInfo("es-ES"); - var qry = from i in Enumerable.Range(0, 100000) - let ts = TimeSpan.FromDays(i) - let text = ts.Humanize(precision: 3, culture: culture, maxUnit: TimeUnit.Year) - select text; - var grouping = from t in qry - group t by t into g - select new { g.Key, Count = g.Count() }; - var allUnique = grouping.All(g => g.Count == 1); - Assert.True(allUnique); - } - - [Theory] - [InlineData(365, "11 meses, 30 días")] - [InlineData(365 + 1, "1 año")] - [InlineData(365 + 365, "1 año, 11 meses, 29 días")] - [InlineData(365 + 365 + 1, "2 años")] - [InlineData(365 + 365 + 365, "2 años, 11 meses, 29 días")] - [InlineData(365 + 365 + 365 + 1, "3 años")] - [InlineData(365 + 365 + 365 + 365, "3 años, 11 meses, 29 días")] - [InlineData(365 + 365 + 365 + 365 + 1, "4 años")] - [InlineData(365 + 365 + 365 + 365 + 366, "4 años, 11 meses, 30 días")] - [InlineData(365 + 365 + 365 + 365 + 366 + 1, "5 años")] - public void Year(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(30, "4 semanas, 2 días")] - [InlineData(30 + 1, "1 mes")] - [InlineData(30 + 30, "1 mes, 29 días")] - [InlineData(30 + 30 + 1, "2 meses")] - [InlineData(30 + 30 + 31, "2 meses, 30 días")] - [InlineData(30 + 30 + 31 + 1, "3 meses")] - [InlineData(30 + 30 + 31 + 30, "3 meses, 29 días")] - [InlineData(30 + 30 + 31 + 30 + 1, "4 meses")] - [InlineData(30 + 30 + 31 + 30 + 31, "4 meses, 30 días")] - [InlineData(30 + 30 + 31 + 30 + 31 + 1, "5 meses")] - [InlineData(365, "11 meses, 30 días")] - [InlineData(366, "1 año")] - public void Month(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(14, "2 semanas")] - [InlineData(7, "1 semana")] - [InlineData(-14, "2 semanas")] - [InlineData(-7, "1 semana")] - [InlineData(730, "104 semanas")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(6, "6 días")] - [InlineData(2, "2 días")] - [InlineData(1, "1 día")] - [InlineData(-6, "6 días")] - [InlineData(-2, "2 días")] - [InlineData(-1, "1 día")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(2, "2 horas")] - [InlineData(1, "1 hora")] - [InlineData(-2, "2 horas")] - [InlineData(-1, "1 hora")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(2, "2 minutos")] - [InlineData(1, "1 minuto")] - [InlineData(-2, "2 minutos")] - [InlineData(-1, "1 minuto")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(135, "2 minutos")] - [InlineData(60, "1 minuto")] - [InlineData(2, "2 segundos")] - [InlineData(1, "1 segundo")] - [InlineData(-135, "2 minutos")] - [InlineData(-60, "1 minuto")] - [InlineData(-2, "2 segundos")] - [InlineData(-1, "1 segundo")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(2500, "2 segundos")] - [InlineData(1400, "1 segundo")] - [InlineData(2, "2 milisegundos")] - [InlineData(1, "1 milisegundo")] - [InlineData(-2500, "2 segundos")] - [InlineData(-1400, "1 segundo")] - [InlineData(-2, "2 milisegundos")] - [InlineData(-1, "1 milisegundo")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData((long)366 * 24 * 60 * 60 * 1000, "12 meses", TimeUnit.Month)] - [InlineData((long)6 * 7 * 24 * 60 * 60 * 1000, "6 semanas", TimeUnit.Week)] - [InlineData(7 * 24 * 60 * 60 * 1000, "7 días", TimeUnit.Day)] - [InlineData(24 * 60 * 60 * 1000, "24 horas", TimeUnit.Hour)] - [InlineData(60 * 60 * 1000, "60 minutos", TimeUnit.Minute)] - [InlineData(60 * 1000, "60 segundos", TimeUnit.Second)] - [InlineData(1000, "1000 milisegundos", TimeUnit.Millisecond)] - public void TimeSpanWithMaxTimeUnit(long ms, string expected, TimeUnit maxUnit) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(maxUnit: maxUnit); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(10, "10 milisegundos", TimeUnit.Millisecond)] - [InlineData(10, "nada", TimeUnit.Second, true)] - [InlineData(10, "nada", TimeUnit.Minute, true)] - [InlineData(10, "nada", TimeUnit.Hour, true)] - [InlineData(10, "nada", TimeUnit.Day, true)] - [InlineData(10, "nada", TimeUnit.Week, true)] - [InlineData(10, "0 segundos", TimeUnit.Second)] - [InlineData(10, "0 minutos", TimeUnit.Minute)] - [InlineData(10, "0 horas", TimeUnit.Hour)] - [InlineData(10, "0 días", TimeUnit.Day)] - [InlineData(10, "0 semanas", TimeUnit.Week)] - [InlineData(2500, "2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(2500, "2 segundos", TimeUnit.Second)] - [InlineData(2500, "nada", TimeUnit.Minute, true)] - [InlineData(2500, "nada", TimeUnit.Hour, true)] - [InlineData(2500, "nada", TimeUnit.Day, true)] - [InlineData(2500, "nada", TimeUnit.Week, true)] - [InlineData(2500, "0 minutos", TimeUnit.Minute)] - [InlineData(2500, "0 horas", TimeUnit.Hour)] - [InlineData(2500, "0 días", TimeUnit.Day)] - [InlineData(2500, "0 semanas", TimeUnit.Week)] - [InlineData(122500, "2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(122500, "2 minutos, 2 segundos", TimeUnit.Second)] - [InlineData(122500, "2 minutos", TimeUnit.Minute)] - [InlineData(122500, "nada", TimeUnit.Hour, true)] - [InlineData(122500, "nada", TimeUnit.Day, true)] - [InlineData(122500, "nada", TimeUnit.Week, true)] - [InlineData(122500, "0 horas", TimeUnit.Hour)] - [InlineData(122500, "0 días", TimeUnit.Day)] - [InlineData(122500, "0 semanas", TimeUnit.Week)] - [InlineData(3722500, "1 hora, 2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(3722500, "1 hora, 2 minutos, 2 segundos", TimeUnit.Second)] - [InlineData(3722500, "1 hora, 2 minutos", TimeUnit.Minute)] - [InlineData(3722500, "1 hora", TimeUnit.Hour)] - [InlineData(3722500, "nada", TimeUnit.Day, true)] - [InlineData(3722500, "nada", TimeUnit.Week, true)] - [InlineData(3722500, "0 días", TimeUnit.Day)] - [InlineData(3722500, "0 semanas", TimeUnit.Week)] - [InlineData(90122500, "1 día, 1 hora, 2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(90122500, "1 día, 1 hora, 2 minutos, 2 segundos", TimeUnit.Second)] - [InlineData(90122500, "1 día, 1 hora, 2 minutos", TimeUnit.Minute)] - [InlineData(90122500, "1 día, 1 hora", TimeUnit.Hour)] - [InlineData(90122500, "1 día", TimeUnit.Day)] - [InlineData(90122500, "nada", TimeUnit.Week, true)] - [InlineData(90122500, "0 semanas", TimeUnit.Week)] - [InlineData(694922500, "1 semana, 1 día, 1 hora, 2 minutos, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(694922500, "1 semana, 1 día, 1 hora, 2 minutos, 2 segundos", TimeUnit.Second)] - [InlineData(694922500, "1 semana, 1 día, 1 hora, 2 minutos", TimeUnit.Minute)] - [InlineData(694922500, "1 semana, 1 día, 1 hora", TimeUnit.Hour)] - [InlineData(694922500, "1 semana, 1 día", TimeUnit.Day)] - [InlineData(694922500, "1 semana", TimeUnit.Week)] - [InlineData(2768462500, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(2768462500, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos", TimeUnit.Second)] - [InlineData(2768462500, "1 mes, 1 día, 1 hora, 1 minuto", TimeUnit.Minute)] - [InlineData(2768462500, "1 mes, 1 día, 1 hora", TimeUnit.Hour)] - [InlineData(2768462500, "1 mes, 1 día", TimeUnit.Day)] - [InlineData(2768462500, "1 mes", TimeUnit.Week)] - [InlineData(2768462500, "1 mes", TimeUnit.Month)] - [InlineData(2768462500, "nada", TimeUnit.Year, true)] - [InlineData(2768462500, "0 años", TimeUnit.Year)] - [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos, 500 milisegundos", TimeUnit.Millisecond)] - [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos", TimeUnit.Second)] - [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora, 1 minuto", TimeUnit.Minute)] - [InlineData(34390862500, "1 año, 1 mes, 2 días, 1 hora", TimeUnit.Hour)] - [InlineData(34390862500, "1 año, 1 mes, 2 días", TimeUnit.Day)] - [InlineData(34390862500, "1 año, 1 mes", TimeUnit.Week)] - [InlineData(34390862500, "1 año, 1 mes", TimeUnit.Month)] - [InlineData(34390862500, "1 año", TimeUnit.Year)] - public void TimeSpanWithMinTimeUnit(long ms, string expected, TimeUnit minUnit, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(minUnit: minUnit, precision: 7, maxUnit: TimeUnit.Year, toWords: toWords); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 3, "nada", true)] - [InlineData(0, 2, "nada", true)] - [InlineData(0, 3, "0 milisegundos")] - [InlineData(0, 2, "0 milisegundos")] - [InlineData(10, 2, "10 milisegundos")] - [InlineData(1400, 2, "1 segundo, 400 milisegundos")] - [InlineData(2500, 2, "2 segundos, 500 milisegundos")] - [InlineData(120000, 2, "2 minutos")] - [InlineData(62000, 2, "1 minuto, 2 segundos")] - [InlineData(62020, 2, "1 minuto, 2 segundos")] - [InlineData(62020, 3, "1 minuto, 2 segundos, 20 milisegundos")] - [InlineData(3600020, 4, "1 hora, 20 milisegundos")] - [InlineData(3600020, 3, "1 hora, 20 milisegundos")] - [InlineData(3600020, 2, "1 hora, 20 milisegundos")] - [InlineData(3600020, 1, "1 hora")] - [InlineData(3603001, 2, "1 hora, 3 segundos")] - [InlineData(3603001, 3, "1 hora, 3 segundos, 1 milisegundo")] - [InlineData(86400000, 3, "1 día")] - [InlineData(86400000, 2, "1 día")] - [InlineData(86400000, 1, "1 día")] - [InlineData(86401000, 1, "1 día")] - [InlineData(86401000, 2, "1 día, 1 segundo")] - [InlineData(86401200, 2, "1 día, 1 segundo")] - [InlineData(86401200, 3, "1 día, 1 segundo, 200 milisegundos")] - [InlineData(1296000000, 1, "2 semanas")] - [InlineData(1296000000, 2, "2 semanas, 1 día")] - [InlineData(1299600000, 2, "2 semanas, 1 día")] - [InlineData(1299600000, 3, "2 semanas, 1 día, 1 hora")] - [InlineData(1299630020, 3, "2 semanas, 1 día, 1 hora")] - [InlineData(1299630020, 4, "2 semanas, 1 día, 1 hora, 30 segundos")] - [InlineData(1299630020, 5, "2 semanas, 1 día, 1 hora, 30 segundos, 20 milisegundos")] - [InlineData(2768462500, 6, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos, 500 milisegundos")] - [InlineData(2768462500, 5, "1 mes, 1 día, 1 hora, 1 minuto, 2 segundos")] - [InlineData(2768462500, 4, "1 mes, 1 día, 1 hora, 1 minuto")] - [InlineData(2768462500, 3, "1 mes, 1 día, 1 hora")] - [InlineData(2768462500, 2, "1 mes, 1 día")] - [InlineData(2768462500, 1, "1 mes")] - [InlineData(34390862500, 7, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos, 500 milisegundos")] - [InlineData(34390862500, 6, "1 año, 1 mes, 2 días, 1 hora, 1 minuto, 2 segundos")] - [InlineData(34390862500, 5, "1 año, 1 mes, 2 días, 1 hora, 1 minuto")] - [InlineData(34390862500, 4, "1 año, 1 mes, 2 días, 1 hora")] - [InlineData(34390862500, 3, "1 año, 1 mes, 2 días")] - [InlineData(34390862500, 2, "1 año, 1 mes")] - [InlineData(34390862500, 1, "1 año")] - public void TimeSpanWithPrecision(long milliseconds, int precision, string expected, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, maxUnit: TimeUnit.Year, toWords: toWords); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(3 * 7 + 4, 2, "3 semanas, 4 días")] - [InlineData(6 * 7 + 3, 2, "6 semanas, 3 días")] - [InlineData(72 * 7 + 6, 2, "72 semanas, 6 días")] - public void DaysWithPrecision(int days, int precision, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(precision: precision); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(50)] - [InlineData(52)] - public void TimeSpanWithMinAndMaxUnits_DoesNotReportExcessiveTime(int minutes) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(2, null, TimeUnit.Hour, TimeUnit.Minute); - var expected = TimeSpan.FromMinutes(minutes).Humanize(2); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 3, "nada", true)] - [InlineData(0, 2, "nada", true)] - [InlineData(0, 3, "0 milisegundos")] - [InlineData(0, 2, "0 milisegundos")] - [InlineData(10, 2, "10 milisegundos")] - [InlineData(1400, 2, "1 segundo, 400 milisegundos")] - [InlineData(2500, 2, "2 segundos, 500 milisegundos")] - [InlineData(60001, 1, "1 minuto")] - [InlineData(60001, 2, "1 minuto")] - [InlineData(60001, 3, "1 minuto, 1 milisegundo")] - [InlineData(120000, 2, "2 minutos")] - [InlineData(62000, 2, "1 minuto, 2 segundos")] - [InlineData(62020, 2, "1 minuto, 2 segundos")] - [InlineData(62020, 3, "1 minuto, 2 segundos, 20 milisegundos")] - [InlineData(3600020, 4, "1 hora, 20 milisegundos")] - [InlineData(3600020, 3, "1 hora")] - [InlineData(3600020, 2, "1 hora")] - [InlineData(3600020, 1, "1 hora")] - [InlineData(3603001, 2, "1 hora")] - [InlineData(3603001, 3, "1 hora, 3 segundos")] - [InlineData(86400000, 3, "1 día")] - [InlineData(86400000, 2, "1 día")] - [InlineData(86400000, 1, "1 día")] - [InlineData(86401000, 1, "1 día")] - [InlineData(86401000, 2, "1 día")] - [InlineData(86401000, 3, "1 día")] - [InlineData(86401000, 4, "1 día, 1 segundo")] - [InlineData(86401200, 4, "1 día, 1 segundo")] - [InlineData(86401200, 5, "1 día, 1 segundo, 200 milisegundos")] - [InlineData(1296000000, 1, "2 semanas")] - [InlineData(1296000000, 2, "2 semanas, 1 día")] - [InlineData(1299600000, 2, "2 semanas, 1 día")] - [InlineData(1299600000, 3, "2 semanas, 1 día, 1 hora")] - [InlineData(1299630020, 3, "2 semanas, 1 día, 1 hora")] - [InlineData(1299630020, 4, "2 semanas, 1 día, 1 hora")] - [InlineData(1299630020, 5, "2 semanas, 1 día, 1 hora, 30 segundos")] - [InlineData(1299630020, 6, "2 semanas, 1 día, 1 hora, 30 segundos, 20 milisegundos")] - public void TimeSpanWithPrecisionAndCountingEmptyUnits(int milliseconds, int precision, string expected, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision: precision, countEmptyUnits: true, toWords: toWords); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 3, "nada", true)] - [InlineData(0, 2, "nada", true)] - [InlineData(0, 3, "0 milisegundos")] - [InlineData(0, 2, "0 milisegundos")] - [InlineData(10, 2, "10 milisegundos")] - [InlineData(1400, 2, "1 segundo y 400 milisegundos")] - [InlineData(2500, 2, "2 segundos y 500 milisegundos")] - [InlineData(120000, 2, "2 minutos")] - [InlineData(62000, 2, "1 minuto y 2 segundos")] - [InlineData(62020, 2, "1 minuto y 2 segundos")] - [InlineData(62020, 3, "1 minuto, 2 segundos y 20 milisegundos")] - [InlineData(3600020, 4, "1 hora y 20 milisegundos")] - [InlineData(3600020, 3, "1 hora y 20 milisegundos")] - [InlineData(3600020, 2, "1 hora y 20 milisegundos")] - [InlineData(3600020, 1, "1 hora")] - [InlineData(3603001, 2, "1 hora y 3 segundos")] - [InlineData(3603001, 3, "1 hora, 3 segundos y 1 milisegundo")] - [InlineData(86400000, 3, "1 día")] - [InlineData(86400000, 2, "1 día")] - [InlineData(86400000, 1, "1 día")] - [InlineData(86401000, 1, "1 día")] - [InlineData(86401000, 2, "1 día y 1 segundo")] - [InlineData(86401200, 2, "1 día y 1 segundo")] - [InlineData(86401200, 3, "1 día, 1 segundo y 200 milisegundos")] - [InlineData(1296000000, 1, "2 semanas")] - [InlineData(1296000000, 2, "2 semanas y 1 día")] - [InlineData(1299600000, 2, "2 semanas y 1 día")] - [InlineData(1299600000, 3, "2 semanas, 1 día y 1 hora")] - [InlineData(1299630020, 3, "2 semanas, 1 día y 1 hora")] - [InlineData(1299630020, 4, "2 semanas, 1 día, 1 hora y 30 segundos")] - [InlineData(1299630020, 5, "2 semanas, 1 día, 1 hora, 30 segundos y 20 milisegundos")] - public void TimeSpanWithPrecisionAndAlternativeCollectionFormatter(int milliseconds, int precision, - string expected, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, collectionSeparator: null, toWords: toWords); - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 3, "nada")] - [InlineData(0, 2, "nada")] - [InlineData(10, 2, "diez milisegundos")] - [InlineData(1400, 2, "un segundo, cuatrocientos milisegundos")] - [InlineData(2500, 2, "dos segundos, quinientos milisegundos")] - [InlineData(120000, 2, "dos minutos")] - [InlineData(62000, 2, "un minuto, dos segundos")] - [InlineData(62020, 2, "un minuto, dos segundos")] - [InlineData(62020, 3, "un minuto, dos segundos, veinte milisegundos")] - [InlineData(3600020, 4, "una hora, veinte milisegundos")] - [InlineData(3600020, 3, "una hora, veinte milisegundos")] - [InlineData(3600020, 2, "una hora, veinte milisegundos")] - [InlineData(3600020, 1, "una hora")] - [InlineData(3603001, 2, "una hora, tres segundos")] - [InlineData(3603001, 3, "una hora, tres segundos, un milisegundo")] - [InlineData(86400000, 3, "un día")] - [InlineData(86400000, 2, "un día")] - [InlineData(86400000, 1, "un día")] - [InlineData(86401000, 1, "un día")] - [InlineData(86401000, 2, "un día, un segundo")] - [InlineData(86401200, 2, "un día, un segundo")] - [InlineData(86401200, 3, "un día, un segundo, doscientos milisegundos")] - [InlineData(1296000000, 1, "dos semanas")] - [InlineData(1296000000, 2, "dos semanas, un día")] - [InlineData(1299600000, 2, "dos semanas, un día")] - [InlineData(1299600000, 3, "dos semanas, un día, una hora")] - [InlineData(1299630020, 3, "dos semanas, un día, una hora")] - [InlineData(1299630020, 4, "dos semanas, un día, una hora, treinta segundos")] - [InlineData(1299630020, 5, "dos semanas, un día, una hora, treinta segundos, veinte milisegundos")] - public void TimeSpanWithNumbersConvertedToWords(int milliseconds, int precision, string expected) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, toWords: true); - Assert.Equal(expected, actual); - } + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, toWords: true); + Assert.Equal(expected, actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fa/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fa/DateHumanizeTests.cs index 502ac8758..1e3166eea 100644 --- a/src/Humanizer.Tests/Localisation/fa/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fa/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.fa +namespace Humanizer.Tests.Localisation.fa; + +[UseCulture("fa")] +public class DateHumanizeTests { - [UseCulture("fa")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "فردا")] - [InlineData(13, "13 روز بعد")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "فردا")] + [InlineData(13, "13 روز بعد")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-1, "دیروز")] - [InlineData(-11, "11 روز پیش")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-1, "دیروز")] + [InlineData(-11, "11 روز پیش")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "یک ساعت بعد")] - [InlineData(11, "11 ساعت بعد")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "یک ساعت بعد")] + [InlineData(11, "11 ساعت بعد")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-1, "یک ساعت پیش")] - [InlineData(-11, "11 ساعت پیش")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-1, "یک ساعت پیش")] + [InlineData(-11, "11 ساعت پیش")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "یک دقیقه بعد")] - [InlineData(13, "13 دقیقه بعد")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "یک دقیقه بعد")] + [InlineData(13, "13 دقیقه بعد")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-1, "یک دقیقه پیش")] - [InlineData(-13, "13 دقیقه پیش")] - [InlineData(60, "یک ساعت پیش")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-1, "یک دقیقه پیش")] + [InlineData(-13, "13 دقیقه پیش")] + [InlineData(60, "یک ساعت پیش")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "یک ماه بعد")] - [InlineData(10, "10 ماه بعد")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "یک ماه بعد")] + [InlineData(10, "10 ماه بعد")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-1, "یک ماه پیش")] - [InlineData(-10, "10 ماه پیش")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-1, "یک ماه پیش")] + [InlineData(-10, "10 ماه پیش")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "یک ثانیه بعد")] - [InlineData(11, "11 ثانیه بعد")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "یک ثانیه بعد")] + [InlineData(11, "11 ثانیه بعد")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-1, "یک ثانیه پیش")] - [InlineData(-11, "11 ثانیه پیش")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-1, "یک ثانیه پیش")] + [InlineData(-11, "11 ثانیه پیش")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "یک سال بعد")] - [InlineData(21, "21 سال بعد")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "یک سال بعد")] + [InlineData(21, "21 سال بعد")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(-1, "یک سال پیش")] - [InlineData(-21, "21 سال پیش")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - } -} + [Theory] + [InlineData(-1, "یک سال پیش")] + [InlineData(-21, "21 سال پیش")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fa/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/fa/NumberToWordsTests.cs index 168b779d6..5cad3f710 100644 --- a/src/Humanizer.Tests/Localisation/fa/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fa/NumberToWordsTests.cs @@ -1,76 +1,75 @@ -namespace Humanizer.Tests.Localisation.fa +namespace Humanizer.Tests.Localisation.fa; + +[UseCulture("fa")] +public class NumberToWordsTests { - [UseCulture("fa")] - public class NumberToWordsTests - { - [Theory] - [InlineData(1, "یک")] - [InlineData(10, "ده")] - [InlineData(11, "یازده")] - [InlineData(122, "صد و بیست و دو")] - [InlineData(3501, "سه هزار و پانصد و یک")] - [InlineData(100, "صد")] - [InlineData(1000, "یک هزار")] - [InlineData(100000, "صد هزار")] - [InlineData(1000000, "یک میلیون")] - [InlineData(10000000, "ده میلیون")] - [InlineData(100000000, "صد میلیون")] - [InlineData(1000000000, "یک میلیارد")] - [InlineData(1000000000000, "یک بیلیون")] - [InlineData(1000000000000000, "یک بیلیارد")] - [InlineData(1000000000000000000, "یک تریلیون")] - [InlineData(111, "صد و یازده")] - [InlineData(1111, "یک هزار و صد و یازده")] - [InlineData(111111, "صد و یازده هزار و صد و یازده")] - [InlineData(1111111, "یک میلیون و صد و یازده هزار و صد و یازده")] - [InlineData(11111111, "یازده میلیون و صد و یازده هزار و صد و یازده")] - [InlineData(111111111, "صد و یازده میلیون و صد و یازده هزار و صد و یازده")] - [InlineData(1111111111, "یک میلیارد و صد و یازده میلیون و صد و یازده هزار و صد و یازده")] - [InlineData(123, "صد و بیست و سه")] - [InlineData(1234, "یک هزار و دویست و سی و چهار")] - [InlineData(12345, "دوازده هزار و سیصد و چهل و پنج")] - [InlineData(123456, "صد و بیست و سه هزار و چهارصد و پنجاه و شش")] - [InlineData(1234567, "یک میلیون و دویست و سی و چهار هزار و پانصد و شصت و هفت")] - [InlineData(12345678, "دوازده میلیون و سیصد و چهل و پنج هزار و ششصد و هفتاد و هشت")] - [InlineData(123456789, "صد و بیست و سه میلیون و چهارصد و پنجاه و شش هزار و هفتصد و هشتاد و نه")] - [InlineData(1234567890, "یک میلیارد و دویست و سی و چهار میلیون و پانصد و شصت و هفت هزار و هشتصد و نود")] - [InlineData(long.MaxValue, "نه تریلیون و دویست و بیست و سه بیلیارد و سیصد و هفتاد و دو بیلیون و سی و شش میلیارد و هشتصد و پنجاه و چهار میلیون و هفتصد و هفتاد و پنج هزار و هشتصد و هفت")] - public void ToWordsFarsi(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(1, "یک")] + [InlineData(10, "ده")] + [InlineData(11, "یازده")] + [InlineData(122, "صد و بیست و دو")] + [InlineData(3501, "سه هزار و پانصد و یک")] + [InlineData(100, "صد")] + [InlineData(1000, "یک هزار")] + [InlineData(100000, "صد هزار")] + [InlineData(1000000, "یک میلیون")] + [InlineData(10000000, "ده میلیون")] + [InlineData(100000000, "صد میلیون")] + [InlineData(1000000000, "یک میلیارد")] + [InlineData(1000000000000, "یک بیلیون")] + [InlineData(1000000000000000, "یک بیلیارد")] + [InlineData(1000000000000000000, "یک تریلیون")] + [InlineData(111, "صد و یازده")] + [InlineData(1111, "یک هزار و صد و یازده")] + [InlineData(111111, "صد و یازده هزار و صد و یازده")] + [InlineData(1111111, "یک میلیون و صد و یازده هزار و صد و یازده")] + [InlineData(11111111, "یازده میلیون و صد و یازده هزار و صد و یازده")] + [InlineData(111111111, "صد و یازده میلیون و صد و یازده هزار و صد و یازده")] + [InlineData(1111111111, "یک میلیارد و صد و یازده میلیون و صد و یازده هزار و صد و یازده")] + [InlineData(123, "صد و بیست و سه")] + [InlineData(1234, "یک هزار و دویست و سی و چهار")] + [InlineData(12345, "دوازده هزار و سیصد و چهل و پنج")] + [InlineData(123456, "صد و بیست و سه هزار و چهارصد و پنجاه و شش")] + [InlineData(1234567, "یک میلیون و دویست و سی و چهار هزار و پانصد و شصت و هفت")] + [InlineData(12345678, "دوازده میلیون و سیصد و چهل و پنج هزار و ششصد و هفتاد و هشت")] + [InlineData(123456789, "صد و بیست و سه میلیون و چهارصد و پنجاه و شش هزار و هفتصد و هشتاد و نه")] + [InlineData(1234567890, "یک میلیارد و دویست و سی و چهار میلیون و پانصد و شصت و هفت هزار و هشتصد و نود")] + [InlineData(long.MaxValue, "نه تریلیون و دویست و بیست و سه بیلیارد و سیصد و هفتاد و دو بیلیون و سی و شش میلیارد و هشتصد و پنجاه و چهار میلیون و هفتصد و هفتاد و پنج هزار و هشتصد و هفت")] + public void ToWordsFarsi(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "صفرم")] - [InlineData(1, "اول")] - [InlineData(2, "دوم")] - [InlineData(3, "سوم")] - [InlineData(4, "چهارم")] - [InlineData(5, "پنجم")] - [InlineData(6, "ششم")] - [InlineData(7, "هفتم")] - [InlineData(8, "هشتم")] - [InlineData(9, "نهم")] - [InlineData(10, "دهم")] - [InlineData(11, "یازدهم")] - [InlineData(12, "دوازدهم")] - [InlineData(13, "سیزدهم")] - [InlineData(21, "بیست و یکم")] - [InlineData(22, "بیست و دوم")] - [InlineData(23, "بیست و سوم")] - [InlineData(24, "بیست و چهارم")] - [InlineData(25, "بیست و پنجم")] - [InlineData(30, "سی ام")] - [InlineData(40, "چهلم")] - [InlineData(50, "پنجاهم")] - [InlineData(60, "شصتم")] - [InlineData(70, "هفتادم")] - [InlineData(80, "هشتادم")] - [InlineData(90, "نودم")] - [InlineData(100, "صدم")] - [InlineData(200, "دویستم")] - [InlineData(1000, "یک هزارم")] - [InlineData(1333, "یک هزار و سیصد و سی و سوم")] - [InlineData(1000000, "یک میلیونم")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "صفرم")] + [InlineData(1, "اول")] + [InlineData(2, "دوم")] + [InlineData(3, "سوم")] + [InlineData(4, "چهارم")] + [InlineData(5, "پنجم")] + [InlineData(6, "ششم")] + [InlineData(7, "هفتم")] + [InlineData(8, "هشتم")] + [InlineData(9, "نهم")] + [InlineData(10, "دهم")] + [InlineData(11, "یازدهم")] + [InlineData(12, "دوازدهم")] + [InlineData(13, "سیزدهم")] + [InlineData(21, "بیست و یکم")] + [InlineData(22, "بیست و دوم")] + [InlineData(23, "بیست و سوم")] + [InlineData(24, "بیست و چهارم")] + [InlineData(25, "بیست و پنجم")] + [InlineData(30, "سی ام")] + [InlineData(40, "چهلم")] + [InlineData(50, "پنجاهم")] + [InlineData(60, "شصتم")] + [InlineData(70, "هفتادم")] + [InlineData(80, "هشتادم")] + [InlineData(90, "نودم")] + [InlineData(100, "صدم")] + [InlineData(200, "دویستم")] + [InlineData(1000, "یک هزارم")] + [InlineData(1333, "یک هزار و سیصد و سی و سوم")] + [InlineData(1000000, "یک میلیونم")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fa/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fa/TimeSpanHumanizeTests.cs index 3081b3249..55658be6c 100644 --- a/src/Humanizer.Tests/Localisation/fa/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fa/TimeSpanHumanizeTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.fa +namespace Humanizer.Tests.Localisation.fa; + +[UseCulture("fa")] +public class TimeSpanHumanizeTests { - [UseCulture("fa")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "یک سال")] - [InlineData(731, "2 سال")] - [InlineData(1096, "3 سال")] - [InlineData(4018, "11 سال")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "یک سال")] + [InlineData(731, "2 سال")] + [InlineData(1096, "3 سال")] + [InlineData(4018, "11 سال")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "یک ماه")] - [InlineData(61, "2 ماه")] - [InlineData(92, "3 ماه")] - [InlineData(335, "11 ماه")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "یک ماه")] + [InlineData(61, "2 ماه")] + [InlineData(92, "3 ماه")] + [InlineData(335, "11 ماه")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "یک هفته")] - [InlineData(77, "11 هفته")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "یک هفته")] + [InlineData(77, "11 هفته")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "یک روز")] - [InlineData(3, "3 روز")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "یک روز")] + [InlineData(3, "3 روز")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "یک ساعت")] - [InlineData(11, "11 ساعت")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "یک ساعت")] + [InlineData(11, "11 ساعت")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "یک دقیقه")] - [InlineData(11, "11 دقیقه")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "یک دقیقه")] + [InlineData(11, "11 دقیقه")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "یک ثانیه")] - [InlineData(11, "11 ثانیه")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "یک ثانیه")] + [InlineData(11, "11 ثانیه")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "یک میلی ثانیه")] - [InlineData(11, "11 میلی ثانیه")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "یک میلی ثانیه")] + [InlineData(11, "11 میلی ثانیه")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 میلی ثانیه", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 میلی ثانیه", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("الآن", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("الآن", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs index 82a1052a1..a4ff2df36 100644 --- a/src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs @@ -1,43 +1,42 @@ -namespace Humanizer.Tests.Localisation.fiFI +namespace Humanizer.Tests.Localisation.fiFI; + +[UseCulture("fi-FI")] +public class DateHumanizeTests { - [UseCulture("fi-FI")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 päivää sitten")] - [InlineData(1, "eilen")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 päivää sitten")] + [InlineData(1, "eilen")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 tuntia sitten")] - [InlineData(1, "tunti sitten")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 tuntia sitten")] + [InlineData(1, "tunti sitten")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 minuuttia sitten")] - [InlineData(1, "minuutti sitten")] - [InlineData(60, "tunti sitten")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(2, "2 minuuttia sitten")] + [InlineData(1, "minuutti sitten")] + [InlineData(60, "tunti sitten")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 kuukautta sitten")] - [InlineData(1, "kuukausi sitten")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(2, "2 kuukautta sitten")] + [InlineData(1, "kuukausi sitten")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 sekuntia sitten")] - [InlineData(1, "sekuntti sitten")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(2, "2 sekuntia sitten")] + [InlineData(1, "sekuntti sitten")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 vuotta sitten")] - [InlineData(1, "vuosi sitten")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - } -} + [Theory] + [InlineData(2, "2 vuotta sitten")] + [InlineData(1, "vuosi sitten")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fi-FI/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/fi-FI/NumberToWordsTests.cs index bfab77651..fb9156800 100644 --- a/src/Humanizer.Tests/Localisation/fi-FI/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fi-FI/NumberToWordsTests.cs @@ -1,64 +1,63 @@ -namespace Humanizer.Tests.Localisation.fiFI +namespace Humanizer.Tests.Localisation.fiFI; + +[UseCulture("fi-FI")] +public class NumberToWordsTests { - [UseCulture("fi-FI")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "nolla")] - [InlineData(1, "yksi")] - [InlineData(11, "yksitoista")] - [InlineData(15, "viisitoista")] - [InlineData(19, "yhdeksäntoista")] - [InlineData(20, "kaksikymmentä")] - [InlineData(25, "kaksikymmentäviisi")] - [InlineData(50, "viisikymmentä")] - [InlineData(90, "yhdeksänkymmentä")] - [InlineData(100, "sata")] - [InlineData(101, "satayksi")] - [InlineData(345, "kolmesataaneljäkymmentäviisi")] - [InlineData(678, "kuusisataaseitsemänkymmentäkahdeksan")] - [InlineData(1000, "tuhat")] - [InlineData(1001, "tuhat yksi")] - [InlineData(1234, "tuhat kaksisataakolmekymmentäneljä")] - [InlineData(4567, "neljätuhatta viisisataakuusikymmentäseitsemän")] - [InlineData(10000, "kymmenentuhatta")] - [InlineData(100000, "satatuhatta")] - [InlineData(1000000, "miljoona")] - [InlineData(10000000, "kymmenenmiljoonaa")] - [InlineData(100000000, "satamiljoonaa")] - [InlineData(1000000000, "miljardi")] - [InlineData(2147483647, "kaksimiljardia sataneljäkymmentäseitsemänmiljoonaa neljäsataakahdeksankymmentäkolmetuhatta kuusisataaneljäkymmentäseitsemän")] // int.MaxValue - [InlineData(-2147483647, "miinus kaksimiljardia sataneljäkymmentäseitsemänmiljoonaa neljäsataakahdeksankymmentäkolmetuhatta kuusisataaneljäkymmentäseitsemän")] // int.MinValue + 1 - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "nolla")] + [InlineData(1, "yksi")] + [InlineData(11, "yksitoista")] + [InlineData(15, "viisitoista")] + [InlineData(19, "yhdeksäntoista")] + [InlineData(20, "kaksikymmentä")] + [InlineData(25, "kaksikymmentäviisi")] + [InlineData(50, "viisikymmentä")] + [InlineData(90, "yhdeksänkymmentä")] + [InlineData(100, "sata")] + [InlineData(101, "satayksi")] + [InlineData(345, "kolmesataaneljäkymmentäviisi")] + [InlineData(678, "kuusisataaseitsemänkymmentäkahdeksan")] + [InlineData(1000, "tuhat")] + [InlineData(1001, "tuhat yksi")] + [InlineData(1234, "tuhat kaksisataakolmekymmentäneljä")] + [InlineData(4567, "neljätuhatta viisisataakuusikymmentäseitsemän")] + [InlineData(10000, "kymmenentuhatta")] + [InlineData(100000, "satatuhatta")] + [InlineData(1000000, "miljoona")] + [InlineData(10000000, "kymmenenmiljoonaa")] + [InlineData(100000000, "satamiljoonaa")] + [InlineData(1000000000, "miljardi")] + [InlineData(2147483647, "kaksimiljardia sataneljäkymmentäseitsemänmiljoonaa neljäsataakahdeksankymmentäkolmetuhatta kuusisataaneljäkymmentäseitsemän")] // int.MaxValue + [InlineData(-2147483647, "miinus kaksimiljardia sataneljäkymmentäseitsemänmiljoonaa neljäsataakahdeksankymmentäkolmetuhatta kuusisataaneljäkymmentäseitsemän")] // int.MinValue + 1 + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nollas")] - [InlineData(1, "ensimmäinen")] - [InlineData(2, "toinen")] - [InlineData(10, "kymmenes")] - [InlineData(11, "yhdestoista")] - [InlineData(12, "kahdestoista")] - [InlineData(19, "yhdeksästoista")] - [InlineData(20, "kahdeskymmenes")] - [InlineData(21, "kahdeskymmenesensimmäinen")] - [InlineData(22, "kahdeskymmenestoinen")] - [InlineData(28, "kahdeskymmeneskahdeksas")] - [InlineData(75, "seitsemäskymmenesviides")] - [InlineData(100, "sadas")] - [InlineData(101, "sadasensimmäinen")] - [InlineData(111, "sadasyhdestoista")] - [InlineData(1000, "tuhannes")] - [InlineData(1101, "tuhannessadasensimmäinen")] - [InlineData(10000, "kymmenestuhannes")] - [InlineData(100000, "sadastuhannes")] - [InlineData(1000000, "miljoonas")] - [InlineData(10000000, "kymmenesmiljoonas")] - [InlineData(100000000, "sadasmiljoonas")] - [InlineData(1000000000, "miljardis")] - [InlineData(1000000001, "miljardisensimmäinen")] - [InlineData(2147483647, "kahdesmiljardissadasneljäskymmenesseitsemäsmiljoonasneljässadaskahdeksaskymmeneskolmastuhanneskuudessadasneljäskymmenesseitsemäs")] // int.MaxValue - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "nollas")] + [InlineData(1, "ensimmäinen")] + [InlineData(2, "toinen")] + [InlineData(10, "kymmenes")] + [InlineData(11, "yhdestoista")] + [InlineData(12, "kahdestoista")] + [InlineData(19, "yhdeksästoista")] + [InlineData(20, "kahdeskymmenes")] + [InlineData(21, "kahdeskymmenesensimmäinen")] + [InlineData(22, "kahdeskymmenestoinen")] + [InlineData(28, "kahdeskymmeneskahdeksas")] + [InlineData(75, "seitsemäskymmenesviides")] + [InlineData(100, "sadas")] + [InlineData(101, "sadasensimmäinen")] + [InlineData(111, "sadasyhdestoista")] + [InlineData(1000, "tuhannes")] + [InlineData(1101, "tuhannessadasensimmäinen")] + [InlineData(10000, "kymmenestuhannes")] + [InlineData(100000, "sadastuhannes")] + [InlineData(1000000, "miljoonas")] + [InlineData(10000000, "kymmenesmiljoonas")] + [InlineData(100000000, "sadasmiljoonas")] + [InlineData(1000000000, "miljardis")] + [InlineData(1000000001, "miljardisensimmäinen")] + [InlineData(2147483647, "kahdesmiljardissadasneljäskymmenesseitsemäsmiljoonasneljässadaskahdeksaskymmeneskolmastuhanneskuudessadasneljäskymmenesseitsemäs")] // int.MaxValue + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fil-PH/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fil-PH/TimeSpanHumanizeTests.cs index 596f219dc..e1a2738c2 100644 --- a/src/Humanizer.Tests/Localisation/fil-PH/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fil-PH/TimeSpanHumanizeTests.cs @@ -1,76 +1,75 @@ -namespace Humanizer.Tests.Localisation.filPH +namespace Humanizer.Tests.Localisation.filPH; + +[UseCulture("fil-PH")] +public class TimeSpanHumanizeTests { - [UseCulture("fil-PH")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(366, "1 taon")] - [InlineData(731, "2 taon")] - [InlineData(1096, "3 taon")] - [InlineData(4018, "11 taon")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(366, "1 taon")] + [InlineData(731, "2 taon")] + [InlineData(1096, "3 taon")] + [InlineData(4018, "11 taon")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(31, "1 buwan")] - [InlineData(61, "2 buwan")] - [InlineData(92, "3 buwan")] - [InlineData(335, "11 buwan")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(31, "1 buwan")] + [InlineData(61, "2 buwan")] + [InlineData(92, "3 buwan")] + [InlineData(335, "11 buwan")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(7, "1 linggo")] - [InlineData(14, "2 linggo")] - [InlineData(21, "3 linggo")] - [InlineData(77, "11 linggo")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(7, "1 linggo")] + [InlineData(14, "2 linggo")] + [InlineData(21, "3 linggo")] + [InlineData(77, "11 linggo")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(1, "1 araw")] - [InlineData(2, "2 araw")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(1, "1 araw")] + [InlineData(2, "2 araw")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(1, "1 oras")] - [InlineData(2, "2 oras")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(1, "1 oras")] + [InlineData(2, "2 oras")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(1, "1 minuto")] - [InlineData(2, "2 minuto")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(1, "1 minuto")] + [InlineData(2, "2 minuto")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(1, "1 segundo")] - [InlineData(2, "2 segundo")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(1, "1 segundo")] + [InlineData(2, "2 segundo")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [Trait("Translation", "Google Translate")] - [InlineData(1, "1 millisecond")] - [InlineData(2, "2 milliseconds")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [Trait("Translation", "Google Translate")] + [InlineData(1, "1 millisecond")] + [InlineData(2, "2 milliseconds")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 milliseconds", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 milliseconds", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("walang oras", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("walang oras", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr-BE/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fr-BE/DateHumanizeTests.cs index fb88ec484..8d8cb5cfc 100644 --- a/src/Humanizer.Tests/Localisation/fr-BE/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fr-BE/DateHumanizeTests.cs @@ -1,89 +1,88 @@ -namespace Humanizer.Tests.Localisation.frBE +namespace Humanizer.Tests.Localisation.frBE; + +[UseCulture("fr-BE")] +public class DateHumanizeTests { - [UseCulture("fr-BE")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "il y a une seconde")] - [InlineData(2, "il y a 2 secondes")] - [InlineData(10, "il y a 10 secondes")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "il y a une seconde")] + [InlineData(2, "il y a 2 secondes")] + [InlineData(10, "il y a 10 secondes")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "dans une seconde")] - [InlineData(2, "dans 2 secondes")] - [InlineData(10, "dans 10 secondes")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "dans une seconde")] + [InlineData(2, "dans 2 secondes")] + [InlineData(10, "dans 10 secondes")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "il y a une minute")] - [InlineData(2, "il y a 2 minutes")] - [InlineData(10, "il y a 10 minutes")] - [InlineData(60, "il y a une heure")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "il y a une minute")] + [InlineData(2, "il y a 2 minutes")] + [InlineData(10, "il y a 10 minutes")] + [InlineData(60, "il y a une heure")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "dans une minute")] - [InlineData(2, "dans 2 minutes")] - [InlineData(10, "dans 10 minutes")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "dans une minute")] + [InlineData(2, "dans 2 minutes")] + [InlineData(10, "dans 10 minutes")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "il y a une heure")] - [InlineData(2, "il y a 2 heures")] - [InlineData(10, "il y a 10 heures")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "il y a une heure")] + [InlineData(2, "il y a 2 heures")] + [InlineData(10, "il y a 10 heures")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "dans une heure")] - [InlineData(2, "dans 2 heures")] - [InlineData(10, "dans 10 heures")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "dans une heure")] + [InlineData(2, "dans 2 heures")] + [InlineData(10, "dans 10 heures")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "hier")] - [InlineData(2, "avant-hier")] - [InlineData(10, "il y a 10 jours")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "hier")] + [InlineData(2, "avant-hier")] + [InlineData(10, "il y a 10 jours")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "demain")] - [InlineData(2, "après-demain")] - [InlineData(10, "dans 10 jours")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "demain")] + [InlineData(2, "après-demain")] + [InlineData(10, "dans 10 jours")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "il y a un mois")] - [InlineData(2, "il y a 2 mois")] - [InlineData(10, "il y a 10 mois")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "il y a un mois")] + [InlineData(2, "il y a 2 mois")] + [InlineData(10, "il y a 10 mois")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "dans un mois")] - [InlineData(2, "dans 2 mois")] - [InlineData(10, "dans 10 mois")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "dans un mois")] + [InlineData(2, "dans 2 mois")] + [InlineData(10, "dans 10 mois")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "il y a un an")] - [InlineData(2, "il y a 2 ans")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "il y a un an")] + [InlineData(2, "il y a 2 ans")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "dans un an")] - [InlineData(2, "dans 2 ans")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "dans un an")] + [InlineData(2, "dans 2 ans")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr-BE/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/fr-BE/NumberToWordsTests.cs index fe77c87d6..b5e6d78d5 100644 --- a/src/Humanizer.Tests/Localisation/fr-BE/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fr-BE/NumberToWordsTests.cs @@ -1,156 +1,155 @@ -namespace Humanizer.Tests.Localisation.frBE +namespace Humanizer.Tests.Localisation.frBE; + +[UseCulture("fr-BE")] +public class NumberToWordsTests { - [UseCulture("fr-BE")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "zéro")] - [InlineData(1, "un")] - [InlineData(10, "dix")] - [InlineData(11, "onze")] - [InlineData(15, "quinze")] - [InlineData(17, "dix-sept")] - [InlineData(25, "vingt-cinq")] - [InlineData(31, "trente et un")] - [InlineData(71, "septante et un")] - [InlineData(80, "quatre-vingts")] - [InlineData(81, "quatre-vingt-un")] - [InlineData(122, "cent vingt-deux")] - [InlineData(3501, "trois mille cinq cent un")] - [InlineData(100, "cent")] - [InlineData(1000, "mille")] - [InlineData(100000, "cent mille")] - [InlineData(1000000, "un million")] - [InlineData(10000000, "dix millions")] - [InlineData(100000000, "cent millions")] - [InlineData(200000000, "deux cents millions")] - [InlineData(1000000000, "un milliard")] - [InlineData(111, "cent onze")] - [InlineData(1111, "mille cent onze")] - [InlineData(111111, "cent onze mille cent onze")] - [InlineData(1111111, "un million cent onze mille cent onze")] - [InlineData(11111111, "onze millions cent onze mille cent onze")] - [InlineData(111111111, "cent onze millions cent onze mille cent onze")] - [InlineData(1111111111, "un milliard cent onze millions cent onze mille cent onze")] - [InlineData(123, "cent vingt-trois")] - [InlineData(1234, "mille deux cent trente-quatre")] - [InlineData(12345, "douze mille trois cent quarante-cinq")] - [InlineData(123456, "cent vingt-trois mille quatre cent cinquante-six")] - [InlineData(1234567, "un million deux cent trente-quatre mille cinq cent soixante-sept")] - [InlineData(12345678, "douze millions trois cent quarante-cinq mille six cent septante-huit")] - [InlineData(123456789, "cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] - [InlineData(1234567890, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante")] - [InlineData(1234567899, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante-neuf")] - [InlineData(223, "deux cent vingt-trois")] - [InlineData(2234, "deux mille deux cent trente-quatre")] - [InlineData(22345, "vingt-deux mille trois cent quarante-cinq")] - [InlineData(200456, "deux cent mille quatre cent cinquante-six")] - [InlineData(223456, "deux cent vingt-trois mille quatre cent cinquante-six")] - [InlineData(2234567, "deux millions deux cent trente-quatre mille cinq cent soixante-sept")] - [InlineData(22345678, "vingt-deux millions trois cent quarante-cinq mille six cent septante-huit")] - [InlineData(223456789, "deux cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] - [InlineData(2147483646, "deux milliards cent quarante-sept millions quatre cent quatre-vingt-trois mille six cent quarante-six")] - [InlineData(1999, "mille neuf cent nonante-neuf")] - [InlineData(2014, "deux mille quatorze")] - [InlineData(2048, "deux mille quarante-huit")] - [InlineData(400, "quatre cents")] - [InlineData(401, "quatre cent un")] - [InlineData(480, "quatre cent quatre-vingts")] - [InlineData(80000, "quatre-vingt mille")] - [InlineData(80000000, "quatre-vingts millions")] - [InlineData(80080080, "quatre-vingts millions quatre-vingt mille quatre-vingts")] - [InlineData(200200200, "deux cents millions deux cent mille deux cents")] - [InlineData(200200202, "deux cents millions deux cent mille deux cent deux")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "zéro")] + [InlineData(1, "un")] + [InlineData(10, "dix")] + [InlineData(11, "onze")] + [InlineData(15, "quinze")] + [InlineData(17, "dix-sept")] + [InlineData(25, "vingt-cinq")] + [InlineData(31, "trente et un")] + [InlineData(71, "septante et un")] + [InlineData(80, "quatre-vingts")] + [InlineData(81, "quatre-vingt-un")] + [InlineData(122, "cent vingt-deux")] + [InlineData(3501, "trois mille cinq cent un")] + [InlineData(100, "cent")] + [InlineData(1000, "mille")] + [InlineData(100000, "cent mille")] + [InlineData(1000000, "un million")] + [InlineData(10000000, "dix millions")] + [InlineData(100000000, "cent millions")] + [InlineData(200000000, "deux cents millions")] + [InlineData(1000000000, "un milliard")] + [InlineData(111, "cent onze")] + [InlineData(1111, "mille cent onze")] + [InlineData(111111, "cent onze mille cent onze")] + [InlineData(1111111, "un million cent onze mille cent onze")] + [InlineData(11111111, "onze millions cent onze mille cent onze")] + [InlineData(111111111, "cent onze millions cent onze mille cent onze")] + [InlineData(1111111111, "un milliard cent onze millions cent onze mille cent onze")] + [InlineData(123, "cent vingt-trois")] + [InlineData(1234, "mille deux cent trente-quatre")] + [InlineData(12345, "douze mille trois cent quarante-cinq")] + [InlineData(123456, "cent vingt-trois mille quatre cent cinquante-six")] + [InlineData(1234567, "un million deux cent trente-quatre mille cinq cent soixante-sept")] + [InlineData(12345678, "douze millions trois cent quarante-cinq mille six cent septante-huit")] + [InlineData(123456789, "cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] + [InlineData(1234567890, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante")] + [InlineData(1234567899, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante-neuf")] + [InlineData(223, "deux cent vingt-trois")] + [InlineData(2234, "deux mille deux cent trente-quatre")] + [InlineData(22345, "vingt-deux mille trois cent quarante-cinq")] + [InlineData(200456, "deux cent mille quatre cent cinquante-six")] + [InlineData(223456, "deux cent vingt-trois mille quatre cent cinquante-six")] + [InlineData(2234567, "deux millions deux cent trente-quatre mille cinq cent soixante-sept")] + [InlineData(22345678, "vingt-deux millions trois cent quarante-cinq mille six cent septante-huit")] + [InlineData(223456789, "deux cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] + [InlineData(2147483646, "deux milliards cent quarante-sept millions quatre cent quatre-vingt-trois mille six cent quarante-six")] + [InlineData(1999, "mille neuf cent nonante-neuf")] + [InlineData(2014, "deux mille quatorze")] + [InlineData(2048, "deux mille quarante-huit")] + [InlineData(400, "quatre cents")] + [InlineData(401, "quatre cent un")] + [InlineData(480, "quatre cent quatre-vingts")] + [InlineData(80000, "quatre-vingt mille")] + [InlineData(80000000, "quatre-vingts millions")] + [InlineData(80080080, "quatre-vingts millions quatre-vingt mille quatre-vingts")] + [InlineData(200200200, "deux cents millions deux cent mille deux cents")] + [InlineData(200200202, "deux cents millions deux cent mille deux cent deux")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "une", GrammaticalGender.Feminine)] - [InlineData(1, "un", GrammaticalGender.Masculine)] - [InlineData(2, "deux", GrammaticalGender.Feminine)] - [InlineData(2, "deux", GrammaticalGender.Masculine)] - [InlineData(11, "onze", GrammaticalGender.Feminine)] - [InlineData(11, "onze", GrammaticalGender.Masculine)] - [InlineData(21, "vingt et une", GrammaticalGender.Feminine)] - [InlineData(21, "vingt et un", GrammaticalGender.Masculine)] - [InlineData(31, "trente et une", GrammaticalGender.Feminine)] - [InlineData(31, "trente et un", GrammaticalGender.Masculine)] - [InlineData(41, "quarante et une", GrammaticalGender.Feminine)] - [InlineData(41, "quarante et un", GrammaticalGender.Masculine)] - [InlineData(51, "cinquante et une", GrammaticalGender.Feminine)] - [InlineData(51, "cinquante et un", GrammaticalGender.Masculine)] - [InlineData(61, "soixante et une", GrammaticalGender.Feminine)] - [InlineData(61, "soixante et un", GrammaticalGender.Masculine)] - [InlineData(71, "septante et une", GrammaticalGender.Feminine)] - [InlineData(71, "septante et un", GrammaticalGender.Masculine)] - [InlineData(81, "quatre-vingt-une", GrammaticalGender.Feminine)] - [InlineData(81, "quatre-vingt-un", GrammaticalGender.Masculine)] - [InlineData(91, "nonante et une", GrammaticalGender.Feminine)] - [InlineData(91, "nonante et un", GrammaticalGender.Masculine)] - [InlineData(121, "cent vingt et une", GrammaticalGender.Feminine)] - [InlineData(121, "cent vingt et un", GrammaticalGender.Masculine)] - [InlineData(10121, "dix mille cent vingt et une", GrammaticalGender.Feminine)] - [InlineData(10121, "dix mille cent vingt et un", GrammaticalGender.Masculine)] - public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(1, "une", GrammaticalGender.Feminine)] + [InlineData(1, "un", GrammaticalGender.Masculine)] + [InlineData(2, "deux", GrammaticalGender.Feminine)] + [InlineData(2, "deux", GrammaticalGender.Masculine)] + [InlineData(11, "onze", GrammaticalGender.Feminine)] + [InlineData(11, "onze", GrammaticalGender.Masculine)] + [InlineData(21, "vingt et une", GrammaticalGender.Feminine)] + [InlineData(21, "vingt et un", GrammaticalGender.Masculine)] + [InlineData(31, "trente et une", GrammaticalGender.Feminine)] + [InlineData(31, "trente et un", GrammaticalGender.Masculine)] + [InlineData(41, "quarante et une", GrammaticalGender.Feminine)] + [InlineData(41, "quarante et un", GrammaticalGender.Masculine)] + [InlineData(51, "cinquante et une", GrammaticalGender.Feminine)] + [InlineData(51, "cinquante et un", GrammaticalGender.Masculine)] + [InlineData(61, "soixante et une", GrammaticalGender.Feminine)] + [InlineData(61, "soixante et un", GrammaticalGender.Masculine)] + [InlineData(71, "septante et une", GrammaticalGender.Feminine)] + [InlineData(71, "septante et un", GrammaticalGender.Masculine)] + [InlineData(81, "quatre-vingt-une", GrammaticalGender.Feminine)] + [InlineData(81, "quatre-vingt-un", GrammaticalGender.Masculine)] + [InlineData(91, "nonante et une", GrammaticalGender.Feminine)] + [InlineData(91, "nonante et un", GrammaticalGender.Masculine)] + [InlineData(121, "cent vingt et une", GrammaticalGender.Feminine)] + [InlineData(121, "cent vingt et un", GrammaticalGender.Masculine)] + [InlineData(10121, "dix mille cent vingt et une", GrammaticalGender.Feminine)] + [InlineData(10121, "dix mille cent vingt et un", GrammaticalGender.Masculine)] + public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(0, "zérotième")] - [InlineData(1, "premier")] - [InlineData(2, "deuxième")] - [InlineData(3, "troisième")] - [InlineData(4, "quatrième")] - [InlineData(5, "cinquième")] - [InlineData(6, "sixième")] - [InlineData(7, "septième")] - [InlineData(8, "huitième")] - [InlineData(9, "neuvième")] - [InlineData(10, "dixième")] - [InlineData(11, "onzième")] - [InlineData(12, "douzième")] - [InlineData(13, "treizième")] - [InlineData(14, "quatorzième")] - [InlineData(15, "quinzième")] - [InlineData(16, "seizième")] - [InlineData(17, "dix-septième")] - [InlineData(18, "dix-huitième")] - [InlineData(19, "dix-neuvième")] - [InlineData(20, "vingtième")] - [InlineData(21, "vingt et unième")] - [InlineData(22, "vingt-deuxième")] - [InlineData(30, "trentième")] - [InlineData(40, "quarantième")] - [InlineData(50, "cinquantième")] - [InlineData(60, "soixantième")] - [InlineData(70, "septantième")] - [InlineData(80, "quatre-vingtième")] - [InlineData(90, "nonantième")] - [InlineData(95, "nonante-cinquième")] - [InlineData(96, "nonante-sixième")] - [InlineData(100, "centième")] - [InlineData(120, "cent vingtième")] - [InlineData(121, "cent vingt et unième")] - [InlineData(1000, "millième")] - [InlineData(1001, "mille unième")] - [InlineData(1021, "mille vingt et unième")] - [InlineData(10000, "dix millième")] - [InlineData(10121, "dix mille cent vingt et unième")] - [InlineData(100000, "cent millième")] - [InlineData(1000000, "millionième")] - [InlineData(1000000000, "milliardième")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zérotième")] + [InlineData(1, "premier")] + [InlineData(2, "deuxième")] + [InlineData(3, "troisième")] + [InlineData(4, "quatrième")] + [InlineData(5, "cinquième")] + [InlineData(6, "sixième")] + [InlineData(7, "septième")] + [InlineData(8, "huitième")] + [InlineData(9, "neuvième")] + [InlineData(10, "dixième")] + [InlineData(11, "onzième")] + [InlineData(12, "douzième")] + [InlineData(13, "treizième")] + [InlineData(14, "quatorzième")] + [InlineData(15, "quinzième")] + [InlineData(16, "seizième")] + [InlineData(17, "dix-septième")] + [InlineData(18, "dix-huitième")] + [InlineData(19, "dix-neuvième")] + [InlineData(20, "vingtième")] + [InlineData(21, "vingt et unième")] + [InlineData(22, "vingt-deuxième")] + [InlineData(30, "trentième")] + [InlineData(40, "quarantième")] + [InlineData(50, "cinquantième")] + [InlineData(60, "soixantième")] + [InlineData(70, "septantième")] + [InlineData(80, "quatre-vingtième")] + [InlineData(90, "nonantième")] + [InlineData(95, "nonante-cinquième")] + [InlineData(96, "nonante-sixième")] + [InlineData(100, "centième")] + [InlineData(120, "cent vingtième")] + [InlineData(121, "cent vingt et unième")] + [InlineData(1000, "millième")] + [InlineData(1001, "mille unième")] + [InlineData(1021, "mille vingt et unième")] + [InlineData(10000, "dix millième")] + [InlineData(10121, "dix mille cent vingt et unième")] + [InlineData(100000, "cent millième")] + [InlineData(1000000, "millionième")] + [InlineData(1000000000, "milliardième")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); - [Theory] - [InlineData(1, "première", GrammaticalGender.Feminine)] - [InlineData(1, "premier", GrammaticalGender.Masculine)] - [InlineData(2, "deuxième", GrammaticalGender.Feminine)] - [InlineData(2, "deuxième", GrammaticalGender.Masculine)] - [InlineData(121, "cent vingt et unième", GrammaticalGender.Feminine)] - [InlineData(121, "cent vingt et unième", GrammaticalGender.Masculine)] - [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Feminine)] - [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Masculine)] - public void ToOrdinalWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToOrdinalWords(gender)); - } -} + [Theory] + [InlineData(1, "première", GrammaticalGender.Feminine)] + [InlineData(1, "premier", GrammaticalGender.Masculine)] + [InlineData(2, "deuxième", GrammaticalGender.Feminine)] + [InlineData(2, "deuxième", GrammaticalGender.Masculine)] + [InlineData(121, "cent vingt et unième", GrammaticalGender.Feminine)] + [InlineData(121, "cent vingt et unième", GrammaticalGender.Masculine)] + [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Feminine)] + [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Masculine)] + public void ToOrdinalWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToOrdinalWords(gender)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr-BE/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fr-BE/TimeSpanHumanizeTests.cs index 54969f0c9..26b794bc3 100644 --- a/src/Humanizer.Tests/Localisation/fr-BE/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fr-BE/TimeSpanHumanizeTests.cs @@ -1,102 +1,101 @@ -namespace Humanizer.Tests.Localisation.frBE +namespace Humanizer.Tests.Localisation.frBE; + +[UseCulture("fr-BE")] +public class TimeSpanHumanizeTests { - [UseCulture("fr-BE")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 an")] - [InlineData(731, "2 ans")] - [InlineData(1096, "3 ans")] - [InlineData(4018, "11 ans")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 an")] + [InlineData(731, "2 ans")] + [InlineData(1096, "3 ans")] + [InlineData(4018, "11 ans")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mois")] - [InlineData(61, "2 mois")] - [InlineData(92, "3 mois")] - [InlineData(335, "11 mois")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mois")] + [InlineData(61, "2 mois")] + [InlineData(92, "3 mois")] + [InlineData(335, "11 mois")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 semaines")] - [InlineData(7, "1 semaine")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(14, "2 semaines")] + [InlineData(7, "1 semaine")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(6, "6 jours")] - [InlineData(1, "1 jour")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(6, "6 jours")] + [InlineData(1, "1 jour")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 heures")] - [InlineData(1, "1 heure")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 heures")] + [InlineData(1, "1 heure")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 minutes")] - [InlineData(1, "1 minute")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 minutes")] + [InlineData(1, "1 minute")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 secondes")] - [InlineData(1, "1 seconde")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 secondes")] + [InlineData(1, "1 seconde")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 millisecondes")] - [InlineData(1, "1 milliseconde")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 millisecondes")] + [InlineData(1, "1 milliseconde")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(TimeUnit.Year, "0 an")] - [InlineData(TimeUnit.Month, "0 mois")] - [InlineData(TimeUnit.Week, "0 semaine")] - [InlineData(TimeUnit.Day, "0 jour")] - [InlineData(TimeUnit.Hour, "0 heure")] - [InlineData(TimeUnit.Minute, "0 minute")] - [InlineData(TimeUnit.Second, "0 seconde")] - [InlineData(TimeUnit.Millisecond, "0 milliseconde")] - public void NoTime(TimeUnit minUnit, string expected) - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(minUnit: minUnit); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(TimeUnit.Year, "0 an")] + [InlineData(TimeUnit.Month, "0 mois")] + [InlineData(TimeUnit.Week, "0 semaine")] + [InlineData(TimeUnit.Day, "0 jour")] + [InlineData(TimeUnit.Hour, "0 heure")] + [InlineData(TimeUnit.Minute, "0 minute")] + [InlineData(TimeUnit.Second, "0 seconde")] + [InlineData(TimeUnit.Millisecond, "0 milliseconde")] + public void NoTime(TimeUnit minUnit, string expected) + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(minUnit: minUnit); + Assert.Equal(expected, actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("temps nul", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("temps nul", actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr-CH/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/fr-CH/NumberToWordsTests.cs index a577b0041..e07121b69 100644 --- a/src/Humanizer.Tests/Localisation/fr-CH/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fr-CH/NumberToWordsTests.cs @@ -1,156 +1,155 @@ -namespace Humanizer.Tests.Localisation.frCH +namespace Humanizer.Tests.Localisation.frCH; + +[UseCulture("fr-CH")] +public class NumberToWordsTests { - [UseCulture("fr-CH")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "zéro")] - [InlineData(1, "un")] - [InlineData(10, "dix")] - [InlineData(11, "onze")] - [InlineData(15, "quinze")] - [InlineData(17, "dix-sept")] - [InlineData(25, "vingt-cinq")] - [InlineData(31, "trente et un")] - [InlineData(71, "septante et un")] - [InlineData(80, "octante")] - [InlineData(81, "octante et un")] - [InlineData(122, "cent vingt-deux")] - [InlineData(3501, "trois mille cinq cent un")] - [InlineData(100, "cent")] - [InlineData(1000, "mille")] - [InlineData(100000, "cent mille")] - [InlineData(1000000, "un million")] - [InlineData(10000000, "dix millions")] - [InlineData(100000000, "cent millions")] - [InlineData(200000000, "deux cents millions")] - [InlineData(1000000000, "un milliard")] - [InlineData(111, "cent onze")] - [InlineData(1111, "mille cent onze")] - [InlineData(111111, "cent onze mille cent onze")] - [InlineData(1111111, "un million cent onze mille cent onze")] - [InlineData(11111111, "onze millions cent onze mille cent onze")] - [InlineData(111111111, "cent onze millions cent onze mille cent onze")] - [InlineData(1111111111, "un milliard cent onze millions cent onze mille cent onze")] - [InlineData(123, "cent vingt-trois")] - [InlineData(1234, "mille deux cent trente-quatre")] - [InlineData(12345, "douze mille trois cent quarante-cinq")] - [InlineData(123456, "cent vingt-trois mille quatre cent cinquante-six")] - [InlineData(1234567, "un million deux cent trente-quatre mille cinq cent soixante-sept")] - [InlineData(12345678, "douze millions trois cent quarante-cinq mille six cent septante-huit")] - [InlineData(123456789, "cent vingt-trois millions quatre cent cinquante-six mille sept cent octante-neuf")] - [InlineData(1234567890, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante")] - [InlineData(1234567899, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante-neuf")] - [InlineData(223, "deux cent vingt-trois")] - [InlineData(2234, "deux mille deux cent trente-quatre")] - [InlineData(22345, "vingt-deux mille trois cent quarante-cinq")] - [InlineData(200456, "deux cent mille quatre cent cinquante-six")] - [InlineData(223456, "deux cent vingt-trois mille quatre cent cinquante-six")] - [InlineData(2234567, "deux millions deux cent trente-quatre mille cinq cent soixante-sept")] - [InlineData(22345678, "vingt-deux millions trois cent quarante-cinq mille six cent septante-huit")] - [InlineData(223456789, "deux cent vingt-trois millions quatre cent cinquante-six mille sept cent octante-neuf")] - [InlineData(2147483646, "deux milliards cent quarante-sept millions quatre cent octante-trois mille six cent quarante-six")] - [InlineData(1999, "mille neuf cent nonante-neuf")] - [InlineData(2014, "deux mille quatorze")] - [InlineData(2048, "deux mille quarante-huit")] - [InlineData(400, "quatre cents")] - [InlineData(401, "quatre cent un")] - [InlineData(480, "quatre cent octante")] - [InlineData(80000, "octante mille")] - [InlineData(80000000, "octante millions")] - [InlineData(80080080, "octante millions octante mille octante")] - [InlineData(200200200, "deux cents millions deux cent mille deux cents")] - [InlineData(200200202, "deux cents millions deux cent mille deux cent deux")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "zéro")] + [InlineData(1, "un")] + [InlineData(10, "dix")] + [InlineData(11, "onze")] + [InlineData(15, "quinze")] + [InlineData(17, "dix-sept")] + [InlineData(25, "vingt-cinq")] + [InlineData(31, "trente et un")] + [InlineData(71, "septante et un")] + [InlineData(80, "octante")] + [InlineData(81, "octante et un")] + [InlineData(122, "cent vingt-deux")] + [InlineData(3501, "trois mille cinq cent un")] + [InlineData(100, "cent")] + [InlineData(1000, "mille")] + [InlineData(100000, "cent mille")] + [InlineData(1000000, "un million")] + [InlineData(10000000, "dix millions")] + [InlineData(100000000, "cent millions")] + [InlineData(200000000, "deux cents millions")] + [InlineData(1000000000, "un milliard")] + [InlineData(111, "cent onze")] + [InlineData(1111, "mille cent onze")] + [InlineData(111111, "cent onze mille cent onze")] + [InlineData(1111111, "un million cent onze mille cent onze")] + [InlineData(11111111, "onze millions cent onze mille cent onze")] + [InlineData(111111111, "cent onze millions cent onze mille cent onze")] + [InlineData(1111111111, "un milliard cent onze millions cent onze mille cent onze")] + [InlineData(123, "cent vingt-trois")] + [InlineData(1234, "mille deux cent trente-quatre")] + [InlineData(12345, "douze mille trois cent quarante-cinq")] + [InlineData(123456, "cent vingt-trois mille quatre cent cinquante-six")] + [InlineData(1234567, "un million deux cent trente-quatre mille cinq cent soixante-sept")] + [InlineData(12345678, "douze millions trois cent quarante-cinq mille six cent septante-huit")] + [InlineData(123456789, "cent vingt-trois millions quatre cent cinquante-six mille sept cent octante-neuf")] + [InlineData(1234567890, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante")] + [InlineData(1234567899, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent nonante-neuf")] + [InlineData(223, "deux cent vingt-trois")] + [InlineData(2234, "deux mille deux cent trente-quatre")] + [InlineData(22345, "vingt-deux mille trois cent quarante-cinq")] + [InlineData(200456, "deux cent mille quatre cent cinquante-six")] + [InlineData(223456, "deux cent vingt-trois mille quatre cent cinquante-six")] + [InlineData(2234567, "deux millions deux cent trente-quatre mille cinq cent soixante-sept")] + [InlineData(22345678, "vingt-deux millions trois cent quarante-cinq mille six cent septante-huit")] + [InlineData(223456789, "deux cent vingt-trois millions quatre cent cinquante-six mille sept cent octante-neuf")] + [InlineData(2147483646, "deux milliards cent quarante-sept millions quatre cent octante-trois mille six cent quarante-six")] + [InlineData(1999, "mille neuf cent nonante-neuf")] + [InlineData(2014, "deux mille quatorze")] + [InlineData(2048, "deux mille quarante-huit")] + [InlineData(400, "quatre cents")] + [InlineData(401, "quatre cent un")] + [InlineData(480, "quatre cent octante")] + [InlineData(80000, "octante mille")] + [InlineData(80000000, "octante millions")] + [InlineData(80080080, "octante millions octante mille octante")] + [InlineData(200200200, "deux cents millions deux cent mille deux cents")] + [InlineData(200200202, "deux cents millions deux cent mille deux cent deux")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "une", GrammaticalGender.Feminine)] - [InlineData(1, "un", GrammaticalGender.Masculine)] - [InlineData(2, "deux", GrammaticalGender.Feminine)] - [InlineData(2, "deux", GrammaticalGender.Masculine)] - [InlineData(11, "onze", GrammaticalGender.Feminine)] - [InlineData(11, "onze", GrammaticalGender.Masculine)] - [InlineData(21, "vingt et une", GrammaticalGender.Feminine)] - [InlineData(21, "vingt et un", GrammaticalGender.Masculine)] - [InlineData(31, "trente et une", GrammaticalGender.Feminine)] - [InlineData(31, "trente et un", GrammaticalGender.Masculine)] - [InlineData(41, "quarante et une", GrammaticalGender.Feminine)] - [InlineData(41, "quarante et un", GrammaticalGender.Masculine)] - [InlineData(51, "cinquante et une", GrammaticalGender.Feminine)] - [InlineData(51, "cinquante et un", GrammaticalGender.Masculine)] - [InlineData(61, "soixante et une", GrammaticalGender.Feminine)] - [InlineData(61, "soixante et un", GrammaticalGender.Masculine)] - [InlineData(71, "septante et une", GrammaticalGender.Feminine)] - [InlineData(71, "septante et un", GrammaticalGender.Masculine)] - [InlineData(81, "octante et une", GrammaticalGender.Feminine)] - [InlineData(81, "octante et un", GrammaticalGender.Masculine)] - [InlineData(91, "nonante et une", GrammaticalGender.Feminine)] - [InlineData(91, "nonante et un", GrammaticalGender.Masculine)] - [InlineData(121, "cent vingt et une", GrammaticalGender.Feminine)] - [InlineData(121, "cent vingt et un", GrammaticalGender.Masculine)] - [InlineData(10121, "dix mille cent vingt et une", GrammaticalGender.Feminine)] - [InlineData(10121, "dix mille cent vingt et un", GrammaticalGender.Masculine)] - public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(1, "une", GrammaticalGender.Feminine)] + [InlineData(1, "un", GrammaticalGender.Masculine)] + [InlineData(2, "deux", GrammaticalGender.Feminine)] + [InlineData(2, "deux", GrammaticalGender.Masculine)] + [InlineData(11, "onze", GrammaticalGender.Feminine)] + [InlineData(11, "onze", GrammaticalGender.Masculine)] + [InlineData(21, "vingt et une", GrammaticalGender.Feminine)] + [InlineData(21, "vingt et un", GrammaticalGender.Masculine)] + [InlineData(31, "trente et une", GrammaticalGender.Feminine)] + [InlineData(31, "trente et un", GrammaticalGender.Masculine)] + [InlineData(41, "quarante et une", GrammaticalGender.Feminine)] + [InlineData(41, "quarante et un", GrammaticalGender.Masculine)] + [InlineData(51, "cinquante et une", GrammaticalGender.Feminine)] + [InlineData(51, "cinquante et un", GrammaticalGender.Masculine)] + [InlineData(61, "soixante et une", GrammaticalGender.Feminine)] + [InlineData(61, "soixante et un", GrammaticalGender.Masculine)] + [InlineData(71, "septante et une", GrammaticalGender.Feminine)] + [InlineData(71, "septante et un", GrammaticalGender.Masculine)] + [InlineData(81, "octante et une", GrammaticalGender.Feminine)] + [InlineData(81, "octante et un", GrammaticalGender.Masculine)] + [InlineData(91, "nonante et une", GrammaticalGender.Feminine)] + [InlineData(91, "nonante et un", GrammaticalGender.Masculine)] + [InlineData(121, "cent vingt et une", GrammaticalGender.Feminine)] + [InlineData(121, "cent vingt et un", GrammaticalGender.Masculine)] + [InlineData(10121, "dix mille cent vingt et une", GrammaticalGender.Feminine)] + [InlineData(10121, "dix mille cent vingt et un", GrammaticalGender.Masculine)] + public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(0, "zérotième")] - [InlineData(1, "premier")] - [InlineData(2, "deuxième")] - [InlineData(3, "troisième")] - [InlineData(4, "quatrième")] - [InlineData(5, "cinquième")] - [InlineData(6, "sixième")] - [InlineData(7, "septième")] - [InlineData(8, "huitième")] - [InlineData(9, "neuvième")] - [InlineData(10, "dixième")] - [InlineData(11, "onzième")] - [InlineData(12, "douzième")] - [InlineData(13, "treizième")] - [InlineData(14, "quatorzième")] - [InlineData(15, "quinzième")] - [InlineData(16, "seizième")] - [InlineData(17, "dix-septième")] - [InlineData(18, "dix-huitième")] - [InlineData(19, "dix-neuvième")] - [InlineData(20, "vingtième")] - [InlineData(21, "vingt et unième")] - [InlineData(22, "vingt-deuxième")] - [InlineData(30, "trentième")] - [InlineData(40, "quarantième")] - [InlineData(50, "cinquantième")] - [InlineData(60, "soixantième")] - [InlineData(70, "septantième")] - [InlineData(80, "octantième")] - [InlineData(90, "nonantième")] - [InlineData(95, "nonante-cinquième")] - [InlineData(96, "nonante-sixième")] - [InlineData(100, "centième")] - [InlineData(120, "cent vingtième")] - [InlineData(121, "cent vingt et unième")] - [InlineData(1000, "millième")] - [InlineData(1001, "mille unième")] - [InlineData(1021, "mille vingt et unième")] - [InlineData(10000, "dix millième")] - [InlineData(10121, "dix mille cent vingt et unième")] - [InlineData(100000, "cent millième")] - [InlineData(1000000, "millionième")] - [InlineData(1000000000, "milliardième")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zérotième")] + [InlineData(1, "premier")] + [InlineData(2, "deuxième")] + [InlineData(3, "troisième")] + [InlineData(4, "quatrième")] + [InlineData(5, "cinquième")] + [InlineData(6, "sixième")] + [InlineData(7, "septième")] + [InlineData(8, "huitième")] + [InlineData(9, "neuvième")] + [InlineData(10, "dixième")] + [InlineData(11, "onzième")] + [InlineData(12, "douzième")] + [InlineData(13, "treizième")] + [InlineData(14, "quatorzième")] + [InlineData(15, "quinzième")] + [InlineData(16, "seizième")] + [InlineData(17, "dix-septième")] + [InlineData(18, "dix-huitième")] + [InlineData(19, "dix-neuvième")] + [InlineData(20, "vingtième")] + [InlineData(21, "vingt et unième")] + [InlineData(22, "vingt-deuxième")] + [InlineData(30, "trentième")] + [InlineData(40, "quarantième")] + [InlineData(50, "cinquantième")] + [InlineData(60, "soixantième")] + [InlineData(70, "septantième")] + [InlineData(80, "octantième")] + [InlineData(90, "nonantième")] + [InlineData(95, "nonante-cinquième")] + [InlineData(96, "nonante-sixième")] + [InlineData(100, "centième")] + [InlineData(120, "cent vingtième")] + [InlineData(121, "cent vingt et unième")] + [InlineData(1000, "millième")] + [InlineData(1001, "mille unième")] + [InlineData(1021, "mille vingt et unième")] + [InlineData(10000, "dix millième")] + [InlineData(10121, "dix mille cent vingt et unième")] + [InlineData(100000, "cent millième")] + [InlineData(1000000, "millionième")] + [InlineData(1000000000, "milliardième")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); - [Theory] - [InlineData(1, "première", GrammaticalGender.Feminine)] - [InlineData(1, "premier", GrammaticalGender.Masculine)] - [InlineData(2, "deuxième", GrammaticalGender.Feminine)] - [InlineData(2, "deuxième", GrammaticalGender.Masculine)] - [InlineData(121, "cent vingt et unième", GrammaticalGender.Feminine)] - [InlineData(121, "cent vingt et unième", GrammaticalGender.Masculine)] - [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Feminine)] - [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Masculine)] - public void ToOrdinalWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToOrdinalWords(gender)); - } -} + [Theory] + [InlineData(1, "première", GrammaticalGender.Feminine)] + [InlineData(1, "premier", GrammaticalGender.Masculine)] + [InlineData(2, "deuxième", GrammaticalGender.Feminine)] + [InlineData(2, "deuxième", GrammaticalGender.Masculine)] + [InlineData(121, "cent vingt et unième", GrammaticalGender.Feminine)] + [InlineData(121, "cent vingt et unième", GrammaticalGender.Masculine)] + [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Feminine)] + [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Masculine)] + public void ToOrdinalWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToOrdinalWords(gender)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/Bytes/ByteSizeExtensionsTests.cs b/src/Humanizer.Tests/Localisation/fr/Bytes/ByteSizeExtensionsTests.cs index 63b21db1b..c82626227 100644 --- a/src/Humanizer.Tests/Localisation/fr/Bytes/ByteSizeExtensionsTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/Bytes/ByteSizeExtensionsTests.cs @@ -1,70 +1,69 @@ -namespace Humanizer.Tests.Localisation.fr.Bytes -{ - [UseCulture("fr-FR")] - public class ByteSizeExtensionsTests - { - [Theory] - [InlineData(2, null, "2 To")] - [InlineData(2, "GB", "2048 Go")] - [InlineData(2.123, "#.#", "2,1 To")] - public void HumanizesTerabytes(double input, string? format, string expectedValue) => - Assert.Equal(expectedValue, input.Terabytes().Humanize(format)); +namespace Humanizer.Tests.Localisation.fr.Bytes; - [Theory] - [InlineData(0, null, "0 b")] - [InlineData(0, "GB", "0 Go")] - [InlineData(2, null, "2 Go")] - [InlineData(2, "MB", "2048 Mo")] - [InlineData(2.123, "#.##", "2,12 Go")] - public void HumanizesGigabytes(double input, string? format, string expectedValue) => - Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); +[UseCulture("fr-FR")] +public class ByteSizeExtensionsTests +{ + [Theory] + [InlineData(2, null, "2 To")] + [InlineData(2, "GB", "2048 Go")] + [InlineData(2.123, "#.#", "2,1 To")] + public void HumanizesTerabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Terabytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 b")] - [InlineData(0, "MB", "0 Mo")] - [InlineData(2, null, "2 Mo")] - [InlineData(2, "KB", "2048 Ko")] - [InlineData(2.123, "#", "2 Mo")] - public void HumanizesMegabytes(double input, string? format, string expectedValue) => - Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); + [Theory] + [InlineData(0, null, "0 b")] + [InlineData(0, "GB", "0 Go")] + [InlineData(2, null, "2 Go")] + [InlineData(2, "MB", "2048 Mo")] + [InlineData(2.123, "#.##", "2,12 Go")] + public void HumanizesGigabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 b")] - [InlineData(0, "KB", "0 Ko")] - [InlineData(2, null, "2 Ko")] - [InlineData(2, "B", "2048 o")] - [InlineData(2.123, "#.####", "2,123 Ko")] - public void HumanizesKilobytes(double input, string? format, string expectedValue) => - Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); + [Theory] + [InlineData(0, null, "0 b")] + [InlineData(0, "MB", "0 Mo")] + [InlineData(2, null, "2 Mo")] + [InlineData(2, "KB", "2048 Ko")] + [InlineData(2.123, "#", "2 Mo")] + public void HumanizesMegabytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 b")] - [InlineData(0, "#.##", "0 b")] - [InlineData(0, "#.## B", "0 o")] - [InlineData(0, "B", "0 o")] - [InlineData(2, null, "2 o")] - [InlineData(2000, "KB", "1,95 Ko")] - [InlineData(2123, "#.##", "2,07 Ko")] - [InlineData(10000000, "KB", "9765,63 Ko")] - [InlineData(10000000, "#,##0 KB", "9 766 Ko")] - [InlineData(10000000, "#,##0.# KB", "9 765,6 Ko")] - public void HumanizesBytes(double input, string? format, string expectedValue) - { - expectedValue = expectedValue.Replace(" ", NumberFormatInfo.CurrentInfo.NumberGroupSeparator); - Assert.Equal( - expectedValue, - input - .Bytes() - .Humanize(format)); - } + [Theory] + [InlineData(0, null, "0 b")] + [InlineData(0, "KB", "0 Ko")] + [InlineData(2, null, "2 Ko")] + [InlineData(2, "B", "2048 o")] + [InlineData(2.123, "#.####", "2,123 Ko")] + public void HumanizesKilobytes(double input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); - [Theory] - [InlineData(0, null, "0 b")] - [InlineData(0, "b", "0 b")] - [InlineData(2, null, "2 b")] - [InlineData(12, "B", "1,5 o")] - [InlineData(10000, "#.# KB", "1,2 Ko")] - public void HumanizesBits(long input, string? format, string expectedValue) => - Assert.Equal(expectedValue, input.Bits().Humanize(format)); + [Theory] + [InlineData(0, null, "0 b")] + [InlineData(0, "#.##", "0 b")] + [InlineData(0, "#.## B", "0 o")] + [InlineData(0, "B", "0 o")] + [InlineData(2, null, "2 o")] + [InlineData(2000, "KB", "1,95 Ko")] + [InlineData(2123, "#.##", "2,07 Ko")] + [InlineData(10000000, "KB", "9765,63 Ko")] + [InlineData(10000000, "#,##0 KB", "9 766 Ko")] + [InlineData(10000000, "#,##0.# KB", "9 765,6 Ko")] + public void HumanizesBytes(double input, string? format, string expectedValue) + { + expectedValue = expectedValue.Replace(" ", NumberFormatInfo.CurrentInfo.NumberGroupSeparator); + Assert.Equal( + expectedValue, + input + .Bytes() + .Humanize(format)); } -} + + [Theory] + [InlineData(0, null, "0 b")] + [InlineData(0, "b", "0 b")] + [InlineData(2, null, "2 b")] + [InlineData(12, "B", "1,5 o")] + [InlineData(10000, "#.# KB", "1,2 Ko")] + public void HumanizesBits(long input, string? format, string expectedValue) => + Assert.Equal(expectedValue, input.Bits().Humanize(format)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/Bytes/ToFullWordsTests.cs b/src/Humanizer.Tests/Localisation/fr/Bytes/ToFullWordsTests.cs index 6842b133d..78f5de97f 100644 --- a/src/Humanizer.Tests/Localisation/fr/Bytes/ToFullWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/Bytes/ToFullWordsTests.cs @@ -1,60 +1,59 @@ -namespace Humanizer.Tests.Localisation.fr.Bytes +namespace Humanizer.Tests.Localisation.fr.Bytes; + +[UseCulture("fr-FR")] +public class ToFullWordsTests { - [UseCulture("fr-FR")] - public class ToFullWordsTests - { - [Fact] - public void ReturnsSingularBit() => - Assert.Equal("1 bit", ByteSize.FromBits(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBits() => - Assert.Equal("2 bits", ByteSize.FromBits(2).ToFullWords()); - - [Fact] - public void ReturnsSingularByte() => - Assert.Equal("1 octet", ByteSize.FromBytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBytes() => - Assert.Equal("10 octets", ByteSize.FromBytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularKiloByte() => - Assert.Equal("1 kilooctet", ByteSize.FromKilobytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralKilobytes() => - Assert.Equal("10 kilooctets", ByteSize.FromKilobytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularMegabyte() => - Assert.Equal("1 mégaoctet", ByteSize.FromMegabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralMegabytes() => - Assert.Equal("10 mégaoctets", ByteSize.FromMegabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularGigabyte() => - Assert.Equal("1 gigaoctet", ByteSize.FromGigabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralGigabytes() => - Assert.Equal("10 gigaoctets", ByteSize.FromGigabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularTerabyte() => - Assert.Equal("1 téraoctet", ByteSize.FromTerabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralTerabytes() => - Assert.Equal("10 téraoctets", ByteSize.FromTerabytes(10).ToFullWords()); - - [Theory] - [InlineData(229376, "B", "229376 octets")] - [InlineData(229376, "# KB", "224 kilooctets")] - public void ToFullWordsFormatted(double input, string format, string expectedValue) => - Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); - } -} + [Fact] + public void ReturnsSingularBit() => + Assert.Equal("1 bit", ByteSize.FromBits(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBits() => + Assert.Equal("2 bits", ByteSize.FromBits(2).ToFullWords()); + + [Fact] + public void ReturnsSingularByte() => + Assert.Equal("1 octet", ByteSize.FromBytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBytes() => + Assert.Equal("10 octets", ByteSize.FromBytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularKiloByte() => + Assert.Equal("1 kilooctet", ByteSize.FromKilobytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralKilobytes() => + Assert.Equal("10 kilooctets", ByteSize.FromKilobytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularMegabyte() => + Assert.Equal("1 mégaoctet", ByteSize.FromMegabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralMegabytes() => + Assert.Equal("10 mégaoctets", ByteSize.FromMegabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularGigabyte() => + Assert.Equal("1 gigaoctet", ByteSize.FromGigabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralGigabytes() => + Assert.Equal("10 gigaoctets", ByteSize.FromGigabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularTerabyte() => + Assert.Equal("1 téraoctet", ByteSize.FromTerabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralTerabytes() => + Assert.Equal("10 téraoctets", ByteSize.FromTerabytes(10).ToFullWords()); + + [Theory] + [InlineData(229376, "B", "229376 octets")] + [InlineData(229376, "# KB", "224 kilooctets")] + public void ToFullWordsFormatted(double input, string format, string expectedValue) => + Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/Bytes/ToStringTests.cs b/src/Humanizer.Tests/Localisation/fr/Bytes/ToStringTests.cs index 9ba85307f..fdbeb5cb6 100644 --- a/src/Humanizer.Tests/Localisation/fr/Bytes/ToStringTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/Bytes/ToStringTests.cs @@ -1,58 +1,57 @@ -namespace Humanizer.Tests.Localisation.fr.Bytes +namespace Humanizer.Tests.Localisation.fr.Bytes; + +[UseCulture("fr-FR")] +public class ToStringTests { - [UseCulture("fr-FR")] - public class ToStringTests - { - [Fact] - public void ReturnsLargestMetricSuffix() => - Assert.Equal("10,5 Ko", ByteSize.FromKilobytes(10.5).ToString()); - - [Fact] - public void ReturnsDefaultNumberFormat() => - Assert.Equal("10,5 Ko", ByteSize.FromKilobytes(10.5).ToString("KB")); - - [Fact] - public void ReturnsProvidedNumberFormat() => - Assert.Equal("10,1234 Ko", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); - - [Fact] - public void ReturnsBits() => - Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); - - [Fact] - public void ReturnsBytes() => - Assert.Equal("10 o", ByteSize.FromBytes(10).ToString("##.#### B")); - - [Fact] - public void ReturnsKilobytes() => - Assert.Equal("10 Ko", ByteSize.FromKilobytes(10).ToString("##.#### KB")); - - [Fact] - public void ReturnsMegabytes() => - Assert.Equal("10 Mo", ByteSize.FromMegabytes(10).ToString("##.#### MB")); - - [Fact] - public void ReturnsGigabytes() => - Assert.Equal("10 Go", ByteSize.FromGigabytes(10).ToString("##.#### GB")); - - [Fact] - public void ReturnsTerabytes() => - Assert.Equal("10 To", ByteSize.FromTerabytes(10).ToString("##.#### TB")); - - [Fact] - public void ReturnsSelectedFormat() => - Assert.Equal("10,0 To", ByteSize.FromTerabytes(10).ToString("0.0 TB")); - - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZero() => - Assert.Equal("512 Ko", ByteSize.FromMegabytes(.5).ToString("#.#")); - - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => - Assert.Equal("-512 Ko", ByteSize.FromMegabytes(-.5).ToString("#.#")); - - [Fact] - public void ReturnsBytesViaGeneralFormat() => - Assert.Equal("10 o", $"{ByteSize.FromBytes(10)}"); - } -} + [Fact] + public void ReturnsLargestMetricSuffix() => + Assert.Equal("10,5 Ko", ByteSize.FromKilobytes(10.5).ToString()); + + [Fact] + public void ReturnsDefaultNumberFormat() => + Assert.Equal("10,5 Ko", ByteSize.FromKilobytes(10.5).ToString("KB")); + + [Fact] + public void ReturnsProvidedNumberFormat() => + Assert.Equal("10,1234 Ko", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); + + [Fact] + public void ReturnsBits() => + Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); + + [Fact] + public void ReturnsBytes() => + Assert.Equal("10 o", ByteSize.FromBytes(10).ToString("##.#### B")); + + [Fact] + public void ReturnsKilobytes() => + Assert.Equal("10 Ko", ByteSize.FromKilobytes(10).ToString("##.#### KB")); + + [Fact] + public void ReturnsMegabytes() => + Assert.Equal("10 Mo", ByteSize.FromMegabytes(10).ToString("##.#### MB")); + + [Fact] + public void ReturnsGigabytes() => + Assert.Equal("10 Go", ByteSize.FromGigabytes(10).ToString("##.#### GB")); + + [Fact] + public void ReturnsTerabytes() => + Assert.Equal("10 To", ByteSize.FromTerabytes(10).ToString("##.#### TB")); + + [Fact] + public void ReturnsSelectedFormat() => + Assert.Equal("10,0 To", ByteSize.FromTerabytes(10).ToString("0.0 TB")); + + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZero() => + Assert.Equal("512 Ko", ByteSize.FromMegabytes(.5).ToString("#.#")); + + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => + Assert.Equal("-512 Ko", ByteSize.FromMegabytes(-.5).ToString("#.#")); + + [Fact] + public void ReturnsBytesViaGeneralFormat() => + Assert.Equal("10 o", $"{ByteSize.FromBytes(10)}"); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fr/DateHumanizeTests.cs index 607b338bc..6709740fb 100644 --- a/src/Humanizer.Tests/Localisation/fr/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/DateHumanizeTests.cs @@ -1,89 +1,88 @@ -namespace Humanizer.Tests.Localisation.fr +namespace Humanizer.Tests.Localisation.fr; + +[UseCulture("fr")] +public class DateHumanizeTests { - [UseCulture("fr")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "il y a une seconde")] - [InlineData(2, "il y a 2 secondes")] - [InlineData(10, "il y a 10 secondes")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "il y a une seconde")] + [InlineData(2, "il y a 2 secondes")] + [InlineData(10, "il y a 10 secondes")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "dans une seconde")] - [InlineData(2, "dans 2 secondes")] - [InlineData(10, "dans 10 secondes")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "dans une seconde")] + [InlineData(2, "dans 2 secondes")] + [InlineData(10, "dans 10 secondes")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "il y a une minute")] - [InlineData(2, "il y a 2 minutes")] - [InlineData(10, "il y a 10 minutes")] - [InlineData(60, "il y a une heure")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "il y a une minute")] + [InlineData(2, "il y a 2 minutes")] + [InlineData(10, "il y a 10 minutes")] + [InlineData(60, "il y a une heure")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "dans une minute")] - [InlineData(2, "dans 2 minutes")] - [InlineData(10, "dans 10 minutes")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "dans une minute")] + [InlineData(2, "dans 2 minutes")] + [InlineData(10, "dans 10 minutes")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "il y a une heure")] - [InlineData(2, "il y a 2 heures")] - [InlineData(10, "il y a 10 heures")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "il y a une heure")] + [InlineData(2, "il y a 2 heures")] + [InlineData(10, "il y a 10 heures")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "dans une heure")] - [InlineData(2, "dans 2 heures")] - [InlineData(10, "dans 10 heures")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "dans une heure")] + [InlineData(2, "dans 2 heures")] + [InlineData(10, "dans 10 heures")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "hier")] - [InlineData(2, "avant-hier")] - [InlineData(10, "il y a 10 jours")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "hier")] + [InlineData(2, "avant-hier")] + [InlineData(10, "il y a 10 jours")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "demain")] - [InlineData(2, "après-demain")] - [InlineData(10, "dans 10 jours")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "demain")] + [InlineData(2, "après-demain")] + [InlineData(10, "dans 10 jours")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "il y a un mois")] - [InlineData(2, "il y a 2 mois")] - [InlineData(10, "il y a 10 mois")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "il y a un mois")] + [InlineData(2, "il y a 2 mois")] + [InlineData(10, "il y a 10 mois")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "dans un mois")] - [InlineData(2, "dans 2 mois")] - [InlineData(10, "dans 10 mois")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "dans un mois")] + [InlineData(2, "dans 2 mois")] + [InlineData(10, "dans 10 mois")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "il y a un an")] - [InlineData(2, "il y a 2 ans")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "il y a un an")] + [InlineData(2, "il y a 2 ans")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "dans un an")] - [InlineData(2, "dans 2 ans")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "dans un an")] + [InlineData(2, "dans 2 ans")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/fr/DateToOrdinalWordsTests.cs index 95c5845f7..f7eb1c7f9 100644 --- a/src/Humanizer.Tests/Localisation/fr/DateToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/DateToOrdinalWordsTests.cs @@ -1,15 +1,15 @@ -namespace Humanizer.Tests.Localisation.fr +namespace Humanizer.Tests.Localisation.fr; + +[UseCulture("fr")] +public class DateToOrdinalWordsTests { - [UseCulture("fr")] - public class DateToOrdinalWordsTests + [Fact] + public void OrdinalizeString() { - [Fact] - public void OrdinalizeString() - { - Assert.Equal("1er janvier 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); - Assert.Equal("2 mars 2020", new DateTime(2020, 3, 2).ToOrdinalWords()); - Assert.Equal("31 octobre 2021", new DateTime(2021, 10, 31).ToOrdinalWords()); - } + Assert.Equal("1er janvier 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); + Assert.Equal("2 mars 2020", new DateTime(2020, 3, 2).ToOrdinalWords()); + Assert.Equal("31 octobre 2021", new DateTime(2021, 10, 31).ToOrdinalWords()); + } #if NET6_0_OR_GREATER [Fact] @@ -20,5 +20,4 @@ public void OrdinalizeDateOnlyString() Assert.Equal("31 octobre 2021", new DateOnly(2021, 10, 31).ToOrdinalWords()); } #endif - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/fr/NumberToWordsTests.cs index 164198796..879b7cb27 100644 --- a/src/Humanizer.Tests/Localisation/fr/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/NumberToWordsTests.cs @@ -1,182 +1,181 @@ -namespace Humanizer.Tests.Localisation.fr +namespace Humanizer.Tests.Localisation.fr; + +[UseCulture("fr-FR")] +public class NumberToWordsTests { - [UseCulture("fr-FR")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "zéro")] - [InlineData(1, "un")] - [InlineData(10, "dix")] - [InlineData(11, "onze")] - [InlineData(15, "quinze")] - [InlineData(17, "dix-sept")] - [InlineData(25, "vingt-cinq")] - [InlineData(31, "trente et un")] - [InlineData(70, "soixante-dix")] - [InlineData(71, "soixante et onze")] - [InlineData(80, "quatre-vingts")] - [InlineData(81, "quatre-vingt-un")] - [InlineData(90, "quatre-vingt-dix")] - [InlineData(91, "quatre-vingt-onze")] - [InlineData(122, "cent vingt-deux")] - [InlineData(3501, "trois mille cinq cent un")] - [InlineData(100, "cent")] - [InlineData(1000, "mille")] - [InlineData(100000, "cent mille")] - [InlineData(1000000, "un million")] - [InlineData(10000000, "dix millions")] - [InlineData(100000000, "cent millions")] - [InlineData(1000000000, "un milliard")] - [InlineData(111, "cent onze")] - [InlineData(1111, "mille cent onze")] - [InlineData(111111, "cent onze mille cent onze")] - [InlineData(1111111, "un million cent onze mille cent onze")] - [InlineData(11111111, "onze millions cent onze mille cent onze")] - [InlineData(111111111, "cent onze millions cent onze mille cent onze")] - [InlineData(1111111111, "un milliard cent onze millions cent onze mille cent onze")] - [InlineData(123, "cent vingt-trois")] - [InlineData(1234, "mille deux cent trente-quatre")] - [InlineData(12345, "douze mille trois cent quarante-cinq")] - [InlineData(123456, "cent vingt-trois mille quatre cent cinquante-six")] - [InlineData(1234567, "un million deux cent trente-quatre mille cinq cent soixante-sept")] - [InlineData(12345678, "douze millions trois cent quarante-cinq mille six cent soixante-dix-huit")] - [InlineData(123456789, "cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] - [InlineData(1234567890, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent quatre-vingt-dix")] - [InlineData(1234567899, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent quatre-vingt-dix-neuf")] - [InlineData(223, "deux cent vingt-trois")] - [InlineData(2234, "deux mille deux cent trente-quatre")] - [InlineData(22345, "vingt-deux mille trois cent quarante-cinq")] - [InlineData(223456, "deux cent vingt-trois mille quatre cent cinquante-six")] - [InlineData(2234567, "deux millions deux cent trente-quatre mille cinq cent soixante-sept")] - [InlineData(22345678, "vingt-deux millions trois cent quarante-cinq mille six cent soixante-dix-huit")] - [InlineData(223456789, "deux cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] - [InlineData(2147483646, "deux milliards cent quarante-sept millions quatre cent quatre-vingt-trois mille six cent quarante-six")] - [InlineData(1999, "mille neuf cent quatre-vingt-dix-neuf")] - [InlineData(2014, "deux mille quatorze")] - [InlineData(2048, "deux mille quarante-huit")] - [InlineData(400, "quatre cents")] - [InlineData(401, "quatre cent un")] - [InlineData(480, "quatre cent quatre-vingts")] - [InlineData(80000, "quatre-vingt mille")] - [InlineData(80000000, "quatre-vingts millions")] - [InlineData(80080080, "quatre-vingts millions quatre-vingt mille quatre-vingts")] - [InlineData(200200200, "deux cents millions deux cent mille deux cents")] - [InlineData(200200202, "deux cents millions deux cent mille deux cent deux")] - public void ToWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "zéro")] + [InlineData(1, "un")] + [InlineData(10, "dix")] + [InlineData(11, "onze")] + [InlineData(15, "quinze")] + [InlineData(17, "dix-sept")] + [InlineData(25, "vingt-cinq")] + [InlineData(31, "trente et un")] + [InlineData(70, "soixante-dix")] + [InlineData(71, "soixante et onze")] + [InlineData(80, "quatre-vingts")] + [InlineData(81, "quatre-vingt-un")] + [InlineData(90, "quatre-vingt-dix")] + [InlineData(91, "quatre-vingt-onze")] + [InlineData(122, "cent vingt-deux")] + [InlineData(3501, "trois mille cinq cent un")] + [InlineData(100, "cent")] + [InlineData(1000, "mille")] + [InlineData(100000, "cent mille")] + [InlineData(1000000, "un million")] + [InlineData(10000000, "dix millions")] + [InlineData(100000000, "cent millions")] + [InlineData(1000000000, "un milliard")] + [InlineData(111, "cent onze")] + [InlineData(1111, "mille cent onze")] + [InlineData(111111, "cent onze mille cent onze")] + [InlineData(1111111, "un million cent onze mille cent onze")] + [InlineData(11111111, "onze millions cent onze mille cent onze")] + [InlineData(111111111, "cent onze millions cent onze mille cent onze")] + [InlineData(1111111111, "un milliard cent onze millions cent onze mille cent onze")] + [InlineData(123, "cent vingt-trois")] + [InlineData(1234, "mille deux cent trente-quatre")] + [InlineData(12345, "douze mille trois cent quarante-cinq")] + [InlineData(123456, "cent vingt-trois mille quatre cent cinquante-six")] + [InlineData(1234567, "un million deux cent trente-quatre mille cinq cent soixante-sept")] + [InlineData(12345678, "douze millions trois cent quarante-cinq mille six cent soixante-dix-huit")] + [InlineData(123456789, "cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] + [InlineData(1234567890, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent quatre-vingt-dix")] + [InlineData(1234567899, "un milliard deux cent trente-quatre millions cinq cent soixante-sept mille huit cent quatre-vingt-dix-neuf")] + [InlineData(223, "deux cent vingt-trois")] + [InlineData(2234, "deux mille deux cent trente-quatre")] + [InlineData(22345, "vingt-deux mille trois cent quarante-cinq")] + [InlineData(223456, "deux cent vingt-trois mille quatre cent cinquante-six")] + [InlineData(2234567, "deux millions deux cent trente-quatre mille cinq cent soixante-sept")] + [InlineData(22345678, "vingt-deux millions trois cent quarante-cinq mille six cent soixante-dix-huit")] + [InlineData(223456789, "deux cent vingt-trois millions quatre cent cinquante-six mille sept cent quatre-vingt-neuf")] + [InlineData(2147483646, "deux milliards cent quarante-sept millions quatre cent quatre-vingt-trois mille six cent quarante-six")] + [InlineData(1999, "mille neuf cent quatre-vingt-dix-neuf")] + [InlineData(2014, "deux mille quatorze")] + [InlineData(2048, "deux mille quarante-huit")] + [InlineData(400, "quatre cents")] + [InlineData(401, "quatre cent un")] + [InlineData(480, "quatre cent quatre-vingts")] + [InlineData(80000, "quatre-vingt mille")] + [InlineData(80000000, "quatre-vingts millions")] + [InlineData(80080080, "quatre-vingts millions quatre-vingt mille quatre-vingts")] + [InlineData(200200200, "deux cents millions deux cent mille deux cents")] + [InlineData(200200202, "deux cents millions deux cent mille deux cent deux")] + public void ToWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "une", GrammaticalGender.Feminine)] - [InlineData(1, "un", GrammaticalGender.Masculine)] - [InlineData(2, "deux", GrammaticalGender.Feminine)] - [InlineData(2, "deux", GrammaticalGender.Masculine)] - [InlineData(11, "onze", GrammaticalGender.Feminine)] - [InlineData(11, "onze", GrammaticalGender.Masculine)] - [InlineData(21, "vingt et une", GrammaticalGender.Feminine)] - [InlineData(21, "vingt et un", GrammaticalGender.Masculine)] - [InlineData(31, "trente et une", GrammaticalGender.Feminine)] - [InlineData(31, "trente et un", GrammaticalGender.Masculine)] - [InlineData(41, "quarante et une", GrammaticalGender.Feminine)] - [InlineData(41, "quarante et un", GrammaticalGender.Masculine)] - [InlineData(51, "cinquante et une", GrammaticalGender.Feminine)] - [InlineData(51, "cinquante et un", GrammaticalGender.Masculine)] - [InlineData(61, "soixante et une", GrammaticalGender.Feminine)] - [InlineData(61, "soixante et un", GrammaticalGender.Masculine)] - [InlineData(71, "soixante et onze", GrammaticalGender.Feminine)] - [InlineData(71, "soixante et onze", GrammaticalGender.Masculine)] - [InlineData(81, "quatre-vingt-une", GrammaticalGender.Feminine)] - [InlineData(81, "quatre-vingt-un", GrammaticalGender.Masculine)] - [InlineData(91, "quatre-vingt-onze", GrammaticalGender.Feminine)] - [InlineData(91, "quatre-vingt-onze", GrammaticalGender.Masculine)] - [InlineData(121, "cent vingt et une", GrammaticalGender.Feminine)] - [InlineData(121, "cent vingt et un", GrammaticalGender.Masculine)] - [InlineData(10121, "dix mille cent vingt et une", GrammaticalGender.Feminine)] - [InlineData(10121, "dix mille cent vingt et un", GrammaticalGender.Masculine)] - [InlineData(81000, "quatre-vingt-un mille", GrammaticalGender.Feminine)] - [InlineData(81000, "quatre-vingt-un mille", GrammaticalGender.Masculine)] - public void ToWordsIntWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(1, "une", GrammaticalGender.Feminine)] + [InlineData(1, "un", GrammaticalGender.Masculine)] + [InlineData(2, "deux", GrammaticalGender.Feminine)] + [InlineData(2, "deux", GrammaticalGender.Masculine)] + [InlineData(11, "onze", GrammaticalGender.Feminine)] + [InlineData(11, "onze", GrammaticalGender.Masculine)] + [InlineData(21, "vingt et une", GrammaticalGender.Feminine)] + [InlineData(21, "vingt et un", GrammaticalGender.Masculine)] + [InlineData(31, "trente et une", GrammaticalGender.Feminine)] + [InlineData(31, "trente et un", GrammaticalGender.Masculine)] + [InlineData(41, "quarante et une", GrammaticalGender.Feminine)] + [InlineData(41, "quarante et un", GrammaticalGender.Masculine)] + [InlineData(51, "cinquante et une", GrammaticalGender.Feminine)] + [InlineData(51, "cinquante et un", GrammaticalGender.Masculine)] + [InlineData(61, "soixante et une", GrammaticalGender.Feminine)] + [InlineData(61, "soixante et un", GrammaticalGender.Masculine)] + [InlineData(71, "soixante et onze", GrammaticalGender.Feminine)] + [InlineData(71, "soixante et onze", GrammaticalGender.Masculine)] + [InlineData(81, "quatre-vingt-une", GrammaticalGender.Feminine)] + [InlineData(81, "quatre-vingt-un", GrammaticalGender.Masculine)] + [InlineData(91, "quatre-vingt-onze", GrammaticalGender.Feminine)] + [InlineData(91, "quatre-vingt-onze", GrammaticalGender.Masculine)] + [InlineData(121, "cent vingt et une", GrammaticalGender.Feminine)] + [InlineData(121, "cent vingt et un", GrammaticalGender.Masculine)] + [InlineData(10121, "dix mille cent vingt et une", GrammaticalGender.Feminine)] + [InlineData(10121, "dix mille cent vingt et un", GrammaticalGender.Masculine)] + [InlineData(81000, "quatre-vingt-un mille", GrammaticalGender.Feminine)] + [InlineData(81000, "quatre-vingt-un mille", GrammaticalGender.Masculine)] + public void ToWordsIntWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(1L, "un")] - [InlineData(11L, "onze")] - [InlineData(111L, "cent onze")] - [InlineData(1111L, "mille cent onze")] - [InlineData(11111L, "onze mille cent onze")] - [InlineData(111111L, "cent onze mille cent onze")] - [InlineData(1111111L, "un million cent onze mille cent onze")] - [InlineData(11111111L, "onze millions cent onze mille cent onze")] - [InlineData(111111111L, "cent onze millions cent onze mille cent onze")] - [InlineData(1111111111L, "un milliard cent onze millions cent onze mille cent onze")] - [InlineData(11111111111L, "onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(111111111111L, "cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(1111111111111L, "un billion cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(11111111111111L, "onze billions cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(111111111111111L, "cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(1111111111111111L, "un billiard cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(11111111111111111L, "onze billiards cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(111111111111111111L, "cent onze billiards cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] - [InlineData(1111111111111111111L, "un trillion cent onze billiards cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] - public void ToWordsLong(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(1L, "un")] + [InlineData(11L, "onze")] + [InlineData(111L, "cent onze")] + [InlineData(1111L, "mille cent onze")] + [InlineData(11111L, "onze mille cent onze")] + [InlineData(111111L, "cent onze mille cent onze")] + [InlineData(1111111L, "un million cent onze mille cent onze")] + [InlineData(11111111L, "onze millions cent onze mille cent onze")] + [InlineData(111111111L, "cent onze millions cent onze mille cent onze")] + [InlineData(1111111111L, "un milliard cent onze millions cent onze mille cent onze")] + [InlineData(11111111111L, "onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(111111111111L, "cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(1111111111111L, "un billion cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(11111111111111L, "onze billions cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(111111111111111L, "cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(1111111111111111L, "un billiard cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(11111111111111111L, "onze billiards cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(111111111111111111L, "cent onze billiards cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] + [InlineData(1111111111111111111L, "un trillion cent onze billiards cent onze billions cent onze milliards cent onze millions cent onze mille cent onze")] + public void ToWordsLong(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "zérotième")] - [InlineData(1, "premier")] - [InlineData(2, "deuxième")] - [InlineData(3, "troisième")] - [InlineData(4, "quatrième")] - [InlineData(5, "cinquième")] - [InlineData(6, "sixième")] - [InlineData(7, "septième")] - [InlineData(8, "huitième")] - [InlineData(9, "neuvième")] - [InlineData(10, "dixième")] - [InlineData(11, "onzième")] - [InlineData(12, "douzième")] - [InlineData(13, "treizième")] - [InlineData(14, "quatorzième")] - [InlineData(15, "quinzième")] - [InlineData(16, "seizième")] - [InlineData(17, "dix-septième")] - [InlineData(18, "dix-huitième")] - [InlineData(19, "dix-neuvième")] - [InlineData(20, "vingtième")] - [InlineData(21, "vingt et unième")] - [InlineData(22, "vingt-deuxième")] - [InlineData(30, "trentième")] - [InlineData(40, "quarantième")] - [InlineData(50, "cinquantième")] - [InlineData(60, "soixantième")] - [InlineData(70, "soixante-dixième")] - [InlineData(80, "quatre-vingtième")] - [InlineData(90, "quatre-vingt-dixième")] - [InlineData(95, "quatre-vingt-quinzième")] - [InlineData(96, "quatre-vingt-seizième")] - [InlineData(100, "centième")] - [InlineData(120, "cent vingtième")] - [InlineData(121, "cent vingt et unième")] - [InlineData(1000, "millième")] - [InlineData(1001, "mille unième")] - [InlineData(1021, "mille vingt et unième")] - [InlineData(10000, "dix millième")] - [InlineData(10121, "dix mille cent vingt et unième")] - [InlineData(100000, "cent millième")] - [InlineData(1000000, "millionième")] - [InlineData(1000000000, "milliardième")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zérotième")] + [InlineData(1, "premier")] + [InlineData(2, "deuxième")] + [InlineData(3, "troisième")] + [InlineData(4, "quatrième")] + [InlineData(5, "cinquième")] + [InlineData(6, "sixième")] + [InlineData(7, "septième")] + [InlineData(8, "huitième")] + [InlineData(9, "neuvième")] + [InlineData(10, "dixième")] + [InlineData(11, "onzième")] + [InlineData(12, "douzième")] + [InlineData(13, "treizième")] + [InlineData(14, "quatorzième")] + [InlineData(15, "quinzième")] + [InlineData(16, "seizième")] + [InlineData(17, "dix-septième")] + [InlineData(18, "dix-huitième")] + [InlineData(19, "dix-neuvième")] + [InlineData(20, "vingtième")] + [InlineData(21, "vingt et unième")] + [InlineData(22, "vingt-deuxième")] + [InlineData(30, "trentième")] + [InlineData(40, "quarantième")] + [InlineData(50, "cinquantième")] + [InlineData(60, "soixantième")] + [InlineData(70, "soixante-dixième")] + [InlineData(80, "quatre-vingtième")] + [InlineData(90, "quatre-vingt-dixième")] + [InlineData(95, "quatre-vingt-quinzième")] + [InlineData(96, "quatre-vingt-seizième")] + [InlineData(100, "centième")] + [InlineData(120, "cent vingtième")] + [InlineData(121, "cent vingt et unième")] + [InlineData(1000, "millième")] + [InlineData(1001, "mille unième")] + [InlineData(1021, "mille vingt et unième")] + [InlineData(10000, "dix millième")] + [InlineData(10121, "dix mille cent vingt et unième")] + [InlineData(100000, "cent millième")] + [InlineData(1000000, "millionième")] + [InlineData(1000000000, "milliardième")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); - [Theory] - [InlineData(1, "première", GrammaticalGender.Feminine)] - [InlineData(1, "premier", GrammaticalGender.Masculine)] - [InlineData(2, "deuxième", GrammaticalGender.Feminine)] - [InlineData(2, "deuxième", GrammaticalGender.Masculine)] - [InlineData(121, "cent vingt et unième", GrammaticalGender.Feminine)] - [InlineData(121, "cent vingt et unième", GrammaticalGender.Masculine)] - [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Feminine)] - [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Masculine)] - public void ToOrdinalWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToOrdinalWords(gender)); - } -} + [Theory] + [InlineData(1, "première", GrammaticalGender.Feminine)] + [InlineData(1, "premier", GrammaticalGender.Masculine)] + [InlineData(2, "deuxième", GrammaticalGender.Feminine)] + [InlineData(2, "deuxième", GrammaticalGender.Masculine)] + [InlineData(121, "cent vingt et unième", GrammaticalGender.Feminine)] + [InlineData(121, "cent vingt et unième", GrammaticalGender.Masculine)] + [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Feminine)] + [InlineData(10121, "dix mille cent vingt et unième", GrammaticalGender.Masculine)] + public void ToOrdinalWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToOrdinalWords(gender)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/fr/OrdinalizeTests.cs index 883547add..04668b3f1 100644 --- a/src/Humanizer.Tests/Localisation/fr/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/OrdinalizeTests.cs @@ -1,111 +1,110 @@ -namespace Humanizer.Tests.Localisation.fr +namespace Humanizer.Tests.Localisation.fr; + +[UseCulture("fr")] +public class OrdinalizeTests { - [UseCulture("fr")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0ème")] - [InlineData("1", "1er")] - [InlineData("2", "2ème")] - [InlineData("3", "3ème")] - [InlineData("4", "4ème")] - [InlineData("5", "5ème")] - [InlineData("6", "6ème")] - [InlineData("23", "23ème")] - [InlineData("100", "100ème")] - [InlineData("101", "101ème")] - [InlineData("102", "102ème")] - [InlineData("103", "103ème")] - [InlineData("1001", "1001ème")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("0", "0ème")] + [InlineData("1", "1er")] + [InlineData("2", "2ème")] + [InlineData("3", "3ème")] + [InlineData("4", "4ème")] + [InlineData("5", "5ème")] + [InlineData("6", "6ème")] + [InlineData("23", "23ème")] + [InlineData("100", "100ème")] + [InlineData("101", "101ème")] + [InlineData("102", "102ème")] + [InlineData("103", "103ème")] + [InlineData("1001", "1001ème")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0ème")] - [InlineData("1", "1ère")] - [InlineData("2", "2ème")] - [InlineData("3", "3ème")] - [InlineData("4", "4ème")] - [InlineData("5", "5ème")] - [InlineData("6", "6ème")] - [InlineData("23", "23ème")] - [InlineData("100", "100ème")] - [InlineData("101", "101ème")] - [InlineData("102", "102ème")] - [InlineData("103", "103ème")] - [InlineData("1001", "1001ème")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0ème")] + [InlineData("1", "1ère")] + [InlineData("2", "2ème")] + [InlineData("3", "3ème")] + [InlineData("4", "4ème")] + [InlineData("5", "5ème")] + [InlineData("6", "6ème")] + [InlineData("23", "23ème")] + [InlineData("100", "100ème")] + [InlineData("101", "101ème")] + [InlineData("102", "102ème")] + [InlineData("103", "103ème")] + [InlineData("1001", "1001ème")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData("0", "0ème")] - [InlineData("1", "1er")] - [InlineData("2", "2ème")] - [InlineData("3", "3ème")] - [InlineData("4", "4ème")] - [InlineData("5", "5ème")] - [InlineData("6", "6ème")] - [InlineData("23", "23ème")] - [InlineData("100", "100ème")] - [InlineData("101", "101ème")] - [InlineData("102", "102ème")] - [InlineData("103", "103ème")] - [InlineData("1001", "1001ème")] - public void OrdinalizeStringNeuter(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); + [Theory] + [InlineData("0", "0ème")] + [InlineData("1", "1er")] + [InlineData("2", "2ème")] + [InlineData("3", "3ème")] + [InlineData("4", "4ème")] + [InlineData("5", "5ème")] + [InlineData("6", "6ème")] + [InlineData("23", "23ème")] + [InlineData("100", "100ème")] + [InlineData("101", "101ème")] + [InlineData("102", "102ème")] + [InlineData("103", "103ème")] + [InlineData("1001", "1001ème")] + public void OrdinalizeStringNeuter(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - [Theory] - [InlineData(0, "0ème")] - [InlineData(1, "1er")] - [InlineData(2, "2ème")] - [InlineData(3, "3ème")] - [InlineData(4, "4ème")] - [InlineData(5, "5ème")] - [InlineData(6, "6ème")] - [InlineData(10, "10ème")] - [InlineData(23, "23ème")] - [InlineData(100, "100ème")] - [InlineData(101, "101ème")] - [InlineData(102, "102ème")] - [InlineData(103, "103ème")] - [InlineData(1001, "1001ème")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData(0, "0ème")] + [InlineData(1, "1er")] + [InlineData(2, "2ème")] + [InlineData(3, "3ème")] + [InlineData(4, "4ème")] + [InlineData(5, "5ème")] + [InlineData(6, "6ème")] + [InlineData(10, "10ème")] + [InlineData(23, "23ème")] + [InlineData(100, "100ème")] + [InlineData(101, "101ème")] + [InlineData(102, "102ème")] + [InlineData(103, "103ème")] + [InlineData(1001, "1001ème")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData(0, "0ème")] - [InlineData(1, "1ère")] - [InlineData(2, "2ème")] - [InlineData(3, "3ème")] - [InlineData(4, "4ème")] - [InlineData(5, "5ème")] - [InlineData(6, "6ème")] - [InlineData(10, "10ème")] - [InlineData(23, "23ème")] - [InlineData(100, "100ème")] - [InlineData(101, "101ème")] - [InlineData(102, "102ème")] - [InlineData(103, "103ème")] - [InlineData(1001, "1001ème")] - public void OrdinalizeNumberFeminine(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData(0, "0ème")] + [InlineData(1, "1ère")] + [InlineData(2, "2ème")] + [InlineData(3, "3ème")] + [InlineData(4, "4ème")] + [InlineData(5, "5ème")] + [InlineData(6, "6ème")] + [InlineData(10, "10ème")] + [InlineData(23, "23ème")] + [InlineData(100, "100ème")] + [InlineData(101, "101ème")] + [InlineData(102, "102ème")] + [InlineData(103, "103ème")] + [InlineData(1001, "1001ème")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData(0, "0ème")] - [InlineData(1, "1er")] - [InlineData(2, "2ème")] - [InlineData(3, "3ème")] - [InlineData(4, "4ème")] - [InlineData(5, "5ème")] - [InlineData(6, "6ème")] - [InlineData(10, "10ème")] - [InlineData(23, "23ème")] - [InlineData(100, "100ème")] - [InlineData(101, "101ème")] - [InlineData(102, "102ème")] - [InlineData(103, "103ème")] - [InlineData(1001, "1001ème")] - public void OrdinalizeNumberNeuter(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - } -} + [Theory] + [InlineData(0, "0ème")] + [InlineData(1, "1er")] + [InlineData(2, "2ème")] + [InlineData(3, "3ème")] + [InlineData(4, "4ème")] + [InlineData(5, "5ème")] + [InlineData(6, "6ème")] + [InlineData(10, "10ème")] + [InlineData(23, "23ème")] + [InlineData(100, "100ème")] + [InlineData(101, "101ème")] + [InlineData(102, "102ème")] + [InlineData(103, "103ème")] + [InlineData(1001, "1001ème")] + public void OrdinalizeNumberNeuter(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/fr/TimeSpanHumanizeTests.cs index 87661a7c3..5aa55eb72 100644 --- a/src/Humanizer.Tests/Localisation/fr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/TimeSpanHumanizeTests.cs @@ -1,182 +1,181 @@ -namespace Humanizer.Tests.Localisation.fr +namespace Humanizer.Tests.Localisation.fr; + +[UseCulture("fr")] +public class TimeSpanHumanizeTests { - [UseCulture("fr")] - public class TimeSpanHumanizeTests + [Theory] + [InlineData(366, "1 an")] + [InlineData(731, "2 ans")] + [InlineData(1096, "3 ans")] + [InlineData(4018, "11 ans")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [InlineData(366, "un an")] + [InlineData(731, "deux ans")] + [InlineData(1096, "trois ans")] + [InlineData(4018, "onze ans")] + public void YearsToWord(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: true)); + + [Theory] + [InlineData(31, "1 mois")] + [InlineData(61, "2 mois")] + [InlineData(92, "3 mois")] + [InlineData(335, "11 mois")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [InlineData(31, "un mois")] + [InlineData(61, "deux mois")] + [InlineData(92, "trois mois")] + [InlineData(335, "onze mois")] + public void MonthsToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: true)); + + [Theory] + [InlineData(14, "2 semaines")] + [InlineData(7, "1 semaine")] + public void Weeks(int days, string expected) { - [Theory] - [InlineData(366, "1 an")] - [InlineData(731, "2 ans")] - [InlineData(1096, "3 ans")] - [InlineData(4018, "11 ans")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [InlineData(366, "un an")] - [InlineData(731, "deux ans")] - [InlineData(1096, "trois ans")] - [InlineData(4018, "onze ans")] - public void YearsToWord(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: true)); - - [Theory] - [InlineData(31, "1 mois")] - [InlineData(61, "2 mois")] - [InlineData(92, "3 mois")] - [InlineData(335, "11 mois")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [InlineData(31, "un mois")] - [InlineData(61, "deux mois")] - [InlineData(92, "trois mois")] - [InlineData(335, "onze mois")] - public void MonthsToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: true)); - - [Theory] - [InlineData(14, "2 semaines")] - [InlineData(7, "1 semaine")] - public void Weeks(int days, string expected) - { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(14, "deux semaines")] - [InlineData(7, "une semaine")] - public void WeeksToWords(int days, string expected) - { + [Theory] + [InlineData(14, "deux semaines")] + [InlineData(7, "une semaine")] + public void WeeksToWords(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(toWords: true); Assert.Equal(expected, actual); } - [Theory] - [InlineData(6, "6 jours")] - [InlineData(1, "1 jour")] - public void Days(int days, string expected) - { + [Theory] + [InlineData(6, "6 jours")] + [InlineData(1, "1 jour")] + public void Days(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(6, "six jours")] - [InlineData(1, "un jour")] - public void DaysToWords(int days, string expected) - { + [Theory] + [InlineData(6, "six jours")] + [InlineData(1, "un jour")] + public void DaysToWords(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(toWords: true); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 heures")] - [InlineData(1, "1 heure")] - public void Hours(int hours, string expected) - { + [Theory] + [InlineData(2, "2 heures")] + [InlineData(1, "1 heure")] + public void Hours(int hours, string expected) + { var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "deux heures")] - [InlineData(1, "une heure")] - public void HoursToWords(int hours, string expected) - { + [Theory] + [InlineData(2, "deux heures")] + [InlineData(1, "une heure")] + public void HoursToWords(int hours, string expected) + { var actual = TimeSpan.FromHours(hours).Humanize(toWords: true); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 minutes")] - [InlineData(1, "1 minute")] - public void Minutes(int minutes, string expected) - { + [Theory] + [InlineData(2, "2 minutes")] + [InlineData(1, "1 minute")] + public void Minutes(int minutes, string expected) + { var actual = TimeSpan.FromMinutes(minutes).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "deux minutes")] - [InlineData(1, "une minute")] - public void MinutesToWords(int minutes, string expected) - { + [Theory] + [InlineData(2, "deux minutes")] + [InlineData(1, "une minute")] + public void MinutesToWords(int minutes, string expected) + { var actual = TimeSpan.FromMinutes(minutes).Humanize(toWords: true); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 secondes")] - [InlineData(1, "1 seconde")] - public void Seconds(int seconds, string expected) - { + [Theory] + [InlineData(2, "2 secondes")] + [InlineData(1, "1 seconde")] + public void Seconds(int seconds, string expected) + { var actual = TimeSpan.FromSeconds(seconds).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "deux secondes")] - [InlineData(1, "une seconde")] - public void SecondsToWords(int seconds, string expected) - { + [Theory] + [InlineData(2, "deux secondes")] + [InlineData(1, "une seconde")] + public void SecondsToWords(int seconds, string expected) + { var actual = TimeSpan.FromSeconds(seconds).Humanize(toWords: true); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 millisecondes")] - [InlineData(1, "1 milliseconde")] - public void Milliseconds(int ms, string expected) - { + [Theory] + [InlineData(2, "2 millisecondes")] + [InlineData(1, "1 milliseconde")] + public void Milliseconds(int ms, string expected) + { var actual = TimeSpan.FromMilliseconds(ms).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "deux millisecondes")] - [InlineData(1, "une milliseconde")] - public void MillisecondsToWords(int ms, string expected) - { + [Theory] + [InlineData(2, "deux millisecondes")] + [InlineData(1, "une milliseconde")] + public void MillisecondsToWords(int ms, string expected) + { var actual = TimeSpan.FromMilliseconds(ms).Humanize(toWords: true); Assert.Equal(expected, actual); } - [Theory] - [InlineData(4, false, "4 jours")] - [InlineData(23, false, "3 semaines")] - [InlineData(64, false, "2 mois")] - [InlineData(367, true, "un an")] - [InlineData(750, true, "deux ans")] - public void Age(int days, bool toWords, string expected) - { + [Theory] + [InlineData(4, false, "4 jours")] + [InlineData(23, false, "3 semaines")] + [InlineData(64, false, "2 mois")] + [InlineData(367, true, "un an")] + [InlineData(750, true, "deux ans")] + public void Age(int days, bool toWords, string expected) + { var actual = TimeSpan.FromDays(days).ToAge(toWords: toWords); Assert.Equal(expected, actual); } - [Theory] - [InlineData(TimeUnit.Year, "0 an")] - [InlineData(TimeUnit.Month, "0 mois")] - [InlineData(TimeUnit.Week, "0 semaine")] - [InlineData(TimeUnit.Day, "0 jour")] - [InlineData(TimeUnit.Hour, "0 heure")] - [InlineData(TimeUnit.Minute, "0 minute")] - [InlineData(TimeUnit.Second, "0 seconde")] - [InlineData(TimeUnit.Millisecond, "0 milliseconde")] - public void NoTime(TimeUnit minUnit, string expected) - { + [Theory] + [InlineData(TimeUnit.Year, "0 an")] + [InlineData(TimeUnit.Month, "0 mois")] + [InlineData(TimeUnit.Week, "0 semaine")] + [InlineData(TimeUnit.Day, "0 jour")] + [InlineData(TimeUnit.Hour, "0 heure")] + [InlineData(TimeUnit.Minute, "0 minute")] + [InlineData(TimeUnit.Second, "0 seconde")] + [InlineData(TimeUnit.Millisecond, "0 milliseconde")] + public void NoTime(TimeUnit minUnit, string expected) + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(minUnit: minUnit); Assert.Equal(expected, actual); } - [Fact] - public void NoTimeToWords() - { + [Fact] + public void NoTimeToWords() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(toWords: true); Assert.Equal("temps nul", actual); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/fr/TimeUnitToSymbolTests.cs b/src/Humanizer.Tests/Localisation/fr/TimeUnitToSymbolTests.cs index ceff87e3b..d6b73eae7 100644 --- a/src/Humanizer.Tests/Localisation/fr/TimeUnitToSymbolTests.cs +++ b/src/Humanizer.Tests/Localisation/fr/TimeUnitToSymbolTests.cs @@ -1,19 +1,18 @@ -namespace Humanizer.Tests.Localisation.fr +namespace Humanizer.Tests.Localisation.fr; + +[UseCulture("fr")] +public class TimeUnitToSymbolTests { - [UseCulture("fr")] - public class TimeUnitToSymbolTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(TimeUnit.Millisecond, "ms")] - [InlineData(TimeUnit.Second, "s")] - [InlineData(TimeUnit.Minute, "min")] - [InlineData(TimeUnit.Hour, "h")] - [InlineData(TimeUnit.Day, "j")] - [InlineData(TimeUnit.Week, "semaine")] - [InlineData(TimeUnit.Month, "mois")] - [InlineData(TimeUnit.Year, "a")] - public void ToSymbol(TimeUnit unit, string expected) => - Assert.Equal(expected, unit.ToSymbol()); - } -} + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(TimeUnit.Millisecond, "ms")] + [InlineData(TimeUnit.Second, "s")] + [InlineData(TimeUnit.Minute, "min")] + [InlineData(TimeUnit.Hour, "h")] + [InlineData(TimeUnit.Day, "j")] + [InlineData(TimeUnit.Week, "semaine")] + [InlineData(TimeUnit.Month, "mois")] + [InlineData(TimeUnit.Year, "a")] + public void ToSymbol(TimeUnit unit, string expected) => + Assert.Equal(expected, unit.ToSymbol()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/he/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/he/DateHumanizeTests.cs index b33d99553..14c8d5a10 100644 --- a/src/Humanizer.Tests/Localisation/he/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/he/DateHumanizeTests.cs @@ -1,103 +1,102 @@ -namespace Humanizer.Tests.Localisation.he +namespace Humanizer.Tests.Localisation.he; + +[UseCulture("he")] +public class DateHumanizeTests { - [UseCulture("he")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "אתמול")] - [InlineData(2, "לפני יומיים")] - [InlineData(3, "לפני 3 ימים")] - [InlineData(11, "לפני 11 יום")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "אתמול")] + [InlineData(2, "לפני יומיים")] + [InlineData(3, "לפני 3 ימים")] + [InlineData(11, "לפני 11 יום")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "לפני שעתיים")] - [InlineData(1, "לפני שעה")] - [InlineData(3, "לפני 3 שעות")] - [InlineData(11, "לפני 11 שעות")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "לפני שעתיים")] + [InlineData(1, "לפני שעה")] + [InlineData(3, "לפני 3 שעות")] + [InlineData(11, "לפני 11 שעות")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "לפני 2 דקות")] - [InlineData(1, "לפני דקה")] - [InlineData(3, "לפני 3 דקות")] - [InlineData(11, "לפני 11 דקות")] - [InlineData(60, "לפני שעה")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(2, "לפני 2 דקות")] + [InlineData(1, "לפני דקה")] + [InlineData(3, "לפני 3 דקות")] + [InlineData(11, "לפני 11 דקות")] + [InlineData(60, "לפני שעה")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "לפני חודשיים")] - [InlineData(1, "לפני חודש")] - [InlineData(3, "לפני 3 חודשים")] - [InlineData(11, "לפני 11 חודשים")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(2, "לפני חודשיים")] + [InlineData(1, "לפני חודש")] + [InlineData(3, "לפני 3 חודשים")] + [InlineData(11, "לפני 11 חודשים")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "לפני 2 שניות")] - [InlineData(1, "לפני שנייה")] - [InlineData(3, "לפני 3 שניות")] - [InlineData(11, "לפני 11 שניות")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(2, "לפני 2 שניות")] + [InlineData(1, "לפני שנייה")] + [InlineData(3, "לפני 3 שניות")] + [InlineData(11, "לפני 11 שניות")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "לפני שנתיים")] - [InlineData(1, "לפני שנה")] - [InlineData(3, "לפני 3 שנים")] - [InlineData(11, "לפני 11 שנה")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(2, "לפני שנתיים")] + [InlineData(1, "לפני שנה")] + [InlineData(3, "לפני 3 שנים")] + [InlineData(11, "לפני 11 שנה")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "בעוד יומיים")] - [InlineData(1, "מחר")] - [InlineData(3, "בעוד 3 ימים")] - [InlineData(11, "בעוד 11 יום")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "בעוד יומיים")] + [InlineData(1, "מחר")] + [InlineData(3, "בעוד 3 ימים")] + [InlineData(11, "בעוד 11 יום")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "בעוד חודשיים")] - [InlineData(1, "בעוד חודש")] - [InlineData(10, "בעוד 10 חודשים")] - [InlineData(11, "בעוד 11 חודשים")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "בעוד חודשיים")] + [InlineData(1, "בעוד חודש")] + [InlineData(10, "בעוד 10 חודשים")] + [InlineData(11, "בעוד 11 חודשים")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(2, "בעוד שנתיים")] - [InlineData(1, "בעוד שנה")] - [InlineData(3, "בעוד 3 שנים")] - [InlineData(11, "בעוד 11 שנה")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(2, "בעוד שנתיים")] + [InlineData(1, "בעוד שנה")] + [InlineData(3, "בעוד 3 שנים")] + [InlineData(11, "בעוד 11 שנה")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(2, "בעוד שעתיים")] - [InlineData(1, "בעוד שעה")] - [InlineData(3, "בעוד 3 שעות")] - [InlineData(11, "בעוד 11 שעות")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "בעוד שעתיים")] + [InlineData(1, "בעוד שעה")] + [InlineData(3, "בעוד 3 שעות")] + [InlineData(11, "בעוד 11 שעות")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(2, "בעוד 2 דקות")] - [InlineData(1, "בעוד דקה")] - [InlineData(3, "בעוד 3 דקות")] - [InlineData(11, "בעוד 11 דקות")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "בעוד 2 דקות")] + [InlineData(1, "בעוד דקה")] + [InlineData(3, "בעוד 3 דקות")] + [InlineData(11, "בעוד 11 דקות")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(2, "בעוד 2 שניות")] - [InlineData(1, "בעוד שנייה")] - [InlineData(3, "בעוד 3 שניות")] - [InlineData(11, "בעוד 11 שניות")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - } -} + [Theory] + [InlineData(2, "בעוד 2 שניות")] + [InlineData(1, "בעוד שנייה")] + [InlineData(3, "בעוד 3 שניות")] + [InlineData(11, "בעוד 11 שניות")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/he/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/he/NumberToWordsTests.cs index 1b5fa9d94..adfda6f05 100644 --- a/src/Humanizer.Tests/Localisation/he/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/he/NumberToWordsTests.cs @@ -1,105 +1,104 @@ -namespace Humanizer.Tests.Localisation.he +namespace Humanizer.Tests.Localisation.he; + +[UseCulture("he")] +public class NumberToWordsTests { - [UseCulture("he")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "אפס")] - [InlineData(1, "אחת")] - [InlineData(2, "שתיים")] - [InlineData(3, "שלוש")] - [InlineData(4, "ארבע")] - [InlineData(5, "חמש")] - [InlineData(6, "שש")] - [InlineData(7, "שבע")] - [InlineData(8, "שמונה")] - [InlineData(9, "תשע")] - [InlineData(10, "עשר")] - [InlineData(11, "אחת עשרה")] - [InlineData(12, "שתים עשרה")] - [InlineData(19, "תשע עשרה")] - [InlineData(20, "עשרים")] - [InlineData(22, "עשרים ושתיים")] - [InlineData(50, "חמישים")] - [InlineData(99, "תשעים ותשע")] - [InlineData(100, "מאה")] - [InlineData(101, "מאה ואחת")] - [InlineData(111, "מאה ואחת עשרה")] - [InlineData(200, "מאתיים")] - [InlineData(241, "מאתיים ארבעים ואחת")] - [InlineData(500, "חמש מאות")] - [InlineData(505, "חמש מאות וחמש")] - [InlineData(725, "שבע מאות עשרים וחמש")] - [InlineData(1000, "אלף")] - [InlineData(1009, "אלף ותשע")] - [InlineData(1011, "אלף ואחת עשרה")] - [InlineData(1024, "אלף עשרים וארבע")] - [InlineData(1040, "אלף ארבעים")] - [InlineData(2000, "אלפיים")] - [InlineData(7021, "שבעת אלפים עשרים ואחת")] - [InlineData(20000, "עשרים אלף")] - [InlineData(28123, "עשרים ושמונה אלף מאה עשרים ושלוש")] - [InlineData(500000, "חמש מאות אלף")] - [InlineData(500001, "חמש מאות אלף ואחת")] - [InlineData(1000000, "מיליון")] - [InlineData(1000001, "מיליון ואחת")] - [InlineData(2000408, "שני מיליון ארבע מאות ושמונה")] - [InlineData(1000000000, "מיליארד")] - [InlineData(1000000001, "מיליארד ואחת")] - [InlineData(int.MaxValue /* 2147483647 */, "שני מיליארד מאה ארבעים ושבעה מיליון ארבע מאות שמונים ושלוש אלף שש מאות ארבעים ושבע")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "אפס")] + [InlineData(1, "אחת")] + [InlineData(2, "שתיים")] + [InlineData(3, "שלוש")] + [InlineData(4, "ארבע")] + [InlineData(5, "חמש")] + [InlineData(6, "שש")] + [InlineData(7, "שבע")] + [InlineData(8, "שמונה")] + [InlineData(9, "תשע")] + [InlineData(10, "עשר")] + [InlineData(11, "אחת עשרה")] + [InlineData(12, "שתים עשרה")] + [InlineData(19, "תשע עשרה")] + [InlineData(20, "עשרים")] + [InlineData(22, "עשרים ושתיים")] + [InlineData(50, "חמישים")] + [InlineData(99, "תשעים ותשע")] + [InlineData(100, "מאה")] + [InlineData(101, "מאה ואחת")] + [InlineData(111, "מאה ואחת עשרה")] + [InlineData(200, "מאתיים")] + [InlineData(241, "מאתיים ארבעים ואחת")] + [InlineData(500, "חמש מאות")] + [InlineData(505, "חמש מאות וחמש")] + [InlineData(725, "שבע מאות עשרים וחמש")] + [InlineData(1000, "אלף")] + [InlineData(1009, "אלף ותשע")] + [InlineData(1011, "אלף ואחת עשרה")] + [InlineData(1024, "אלף עשרים וארבע")] + [InlineData(1040, "אלף ארבעים")] + [InlineData(2000, "אלפיים")] + [InlineData(7021, "שבעת אלפים עשרים ואחת")] + [InlineData(20000, "עשרים אלף")] + [InlineData(28123, "עשרים ושמונה אלף מאה עשרים ושלוש")] + [InlineData(500000, "חמש מאות אלף")] + [InlineData(500001, "חמש מאות אלף ואחת")] + [InlineData(1000000, "מיליון")] + [InlineData(1000001, "מיליון ואחת")] + [InlineData(2000408, "שני מיליון ארבע מאות ושמונה")] + [InlineData(1000000000, "מיליארד")] + [InlineData(1000000001, "מיליארד ואחת")] + [InlineData(int.MaxValue /* 2147483647 */, "שני מיליארד מאה ארבעים ושבעה מיליון ארבע מאות שמונים ושלוש אלף שש מאות ארבעים ושבע")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "אפס")] - [InlineData(1, "אחד")] - [InlineData(2, "שניים")] - [InlineData(3, "שלושה")] - [InlineData(4, "ארבעה")] - [InlineData(5, "חמישה")] - [InlineData(6, "שישה")] - [InlineData(7, "שבעה")] - [InlineData(8, "שמונה")] - [InlineData(9, "תשעה")] - [InlineData(10, "עשרה")] - [InlineData(11, "אחד עשר")] - [InlineData(12, "שנים עשר")] - [InlineData(19, "תשעה עשר")] - [InlineData(20, "עשרים")] - [InlineData(22, "עשרים ושניים")] - [InlineData(50, "חמישים")] - [InlineData(99, "תשעים ותשעה")] - [InlineData(100, "מאה")] - [InlineData(101, "מאה ואחד")] - [InlineData(111, "מאה ואחד עשר")] - [InlineData(200, "מאתיים")] - [InlineData(241, "מאתיים ארבעים ואחד")] - [InlineData(500, "חמש מאות")] - [InlineData(505, "חמש מאות וחמישה")] - [InlineData(725, "שבע מאות עשרים וחמישה")] - [InlineData(1000, "אלף")] - [InlineData(1009, "אלף ותשעה")] - [InlineData(1011, "אלף ואחד עשר")] - [InlineData(1024, "אלף עשרים וארבעה")] - [InlineData(1040, "אלף ארבעים")] - [InlineData(2000, "אלפיים")] - [InlineData(7021, "שבעת אלפים עשרים ואחד")] - [InlineData(20000, "עשרים אלף")] - [InlineData(28123, "עשרים ושמונה אלף מאה עשרים ושלושה")] - [InlineData(500000, "חמש מאות אלף")] - [InlineData(500001, "חמש מאות אלף ואחד")] - [InlineData(1000000, "מיליון")] - [InlineData(1000001, "מיליון ואחד")] - [InlineData(2000408, "שני מיליון ארבע מאות ושמונה")] - [InlineData(1000000000, "מיליארד")] - [InlineData(1000000001, "מיליארד ואחד")] - [InlineData(int.MaxValue /* 2147483647 */, "שני מיליארד מאה ארבעים ושבעה מיליון ארבע מאות שמונים ושלוש אלף שש מאות ארבעים ושבעה")] - public void ToWordsMasculine(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "אפס")] + [InlineData(1, "אחד")] + [InlineData(2, "שניים")] + [InlineData(3, "שלושה")] + [InlineData(4, "ארבעה")] + [InlineData(5, "חמישה")] + [InlineData(6, "שישה")] + [InlineData(7, "שבעה")] + [InlineData(8, "שמונה")] + [InlineData(9, "תשעה")] + [InlineData(10, "עשרה")] + [InlineData(11, "אחד עשר")] + [InlineData(12, "שנים עשר")] + [InlineData(19, "תשעה עשר")] + [InlineData(20, "עשרים")] + [InlineData(22, "עשרים ושניים")] + [InlineData(50, "חמישים")] + [InlineData(99, "תשעים ותשעה")] + [InlineData(100, "מאה")] + [InlineData(101, "מאה ואחד")] + [InlineData(111, "מאה ואחד עשר")] + [InlineData(200, "מאתיים")] + [InlineData(241, "מאתיים ארבעים ואחד")] + [InlineData(500, "חמש מאות")] + [InlineData(505, "חמש מאות וחמישה")] + [InlineData(725, "שבע מאות עשרים וחמישה")] + [InlineData(1000, "אלף")] + [InlineData(1009, "אלף ותשעה")] + [InlineData(1011, "אלף ואחד עשר")] + [InlineData(1024, "אלף עשרים וארבעה")] + [InlineData(1040, "אלף ארבעים")] + [InlineData(2000, "אלפיים")] + [InlineData(7021, "שבעת אלפים עשרים ואחד")] + [InlineData(20000, "עשרים אלף")] + [InlineData(28123, "עשרים ושמונה אלף מאה עשרים ושלושה")] + [InlineData(500000, "חמש מאות אלף")] + [InlineData(500001, "חמש מאות אלף ואחד")] + [InlineData(1000000, "מיליון")] + [InlineData(1000001, "מיליון ואחד")] + [InlineData(2000408, "שני מיליון ארבע מאות ושמונה")] + [InlineData(1000000000, "מיליארד")] + [InlineData(1000000001, "מיליארד ואחד")] + [InlineData(int.MaxValue /* 2147483647 */, "שני מיליארד מאה ארבעים ושבעה מיליון ארבע מאות שמונים ושלוש אלף שש מאות ארבעים ושבעה")] + public void ToWordsMasculine(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(-2, "מינוס שתיים")] - public void NegativeToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [Theory] + [InlineData(-2, "מינוס שתיים")] + public void NegativeToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/he/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/he/TimeSpanHumanizeTests.cs index a412de584..a8e7a7328 100644 --- a/src/Humanizer.Tests/Localisation/he/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/he/TimeSpanHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.he +namespace Humanizer.Tests.Localisation.he; + +[UseCulture("he")] +public class TimeSpanHumanizeTests { - [UseCulture("he")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "שנה")] - [InlineData(731, "שנתיים")] - [InlineData(1096, "3 שנים")] - [InlineData(4018, "11 שנים")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "שנה")] + [InlineData(731, "שנתיים")] + [InlineData(1096, "3 שנים")] + [InlineData(4018, "11 שנים")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "חודש")] - [InlineData(61, "חודשיים")] - [InlineData(92, "3 חודשים")] - [InlineData(335, "11 חודשים")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "חודש")] + [InlineData(61, "חודשיים")] + [InlineData(92, "3 חודשים")] + [InlineData(335, "11 חודשים")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "שבוע")] - [InlineData(14, "שבועיים")] - [InlineData(21, "3 שבועות")] - [InlineData(77, "11 שבועות")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "שבוע")] + [InlineData(14, "שבועיים")] + [InlineData(21, "3 שבועות")] + [InlineData(77, "11 שבועות")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "יום")] - [InlineData(2, "יומיים")] - [InlineData(3, "3 ימים")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "יום")] + [InlineData(2, "יומיים")] + [InlineData(3, "3 ימים")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "שעה")] - [InlineData(2, "שעתיים")] - [InlineData(3, "3 שעות")] - [InlineData(11, "11 שעות")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "שעה")] + [InlineData(2, "שעתיים")] + [InlineData(3, "3 שעות")] + [InlineData(11, "11 שעות")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "דקה")] - [InlineData(2, "שתי דקות")] - [InlineData(3, "3 דקות")] - [InlineData(11, "11 דקות")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "דקה")] + [InlineData(2, "שתי דקות")] + [InlineData(3, "3 דקות")] + [InlineData(11, "11 דקות")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "שנייה")] - [InlineData(2, "שתי שניות")] - [InlineData(3, "3 שניות")] - [InlineData(11, "11 שניות")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "שנייה")] + [InlineData(2, "שתי שניות")] + [InlineData(3, "3 שניות")] + [InlineData(11, "11 שניות")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "אלפית שנייה")] - [InlineData(2, "שתי אלפיות שנייה")] - [InlineData(3, "3 אלפיות שנייה")] - [InlineData(11, "11 אלפיות שנייה")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "אלפית שנייה")] + [InlineData(2, "שתי אלפיות שנייה")] + [InlineData(3, "3 אלפיות שנייה")] + [InlineData(11, "11 אלפיות שנייה")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 אלפיות שנייה", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 אלפיות שנייה", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("אין זמן", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("אין זמן", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hr/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hr/DateHumanizeTests.cs index 3f15a3d00..cafbba8ab 100644 --- a/src/Humanizer.Tests/Localisation/hr/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hr/DateHumanizeTests.cs @@ -1,119 +1,118 @@ -namespace Humanizer.Tests.Localisation.hr +namespace Humanizer.Tests.Localisation.hr; + +[UseCulture("hr-HR")] +public class DateHumanizeTests { - [UseCulture("hr-HR")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-22, "prije 22 godine")] - [InlineData(-5, "prije 5 godina")] - [InlineData(-4, "prije 4 godine")] - [InlineData(-2, "prije 2 godine")] - [InlineData(-1, "prije godinu dana")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-22, "prije 22 godine")] + [InlineData(-5, "prije 5 godina")] + [InlineData(-4, "prije 4 godine")] + [InlineData(-2, "prije 2 godine")] + [InlineData(-1, "prije godinu dana")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(5, "za 5 godina")] - [InlineData(4, "za 4 godine")] - [InlineData(3, "za 3 godine")] - [InlineData(2, "za 2 godine")] - [InlineData(1, "za godinu dana")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(5, "za 5 godina")] + [InlineData(4, "za 4 godine")] + [InlineData(3, "za 3 godine")] + [InlineData(2, "za 2 godine")] + [InlineData(1, "za godinu dana")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(-8, "prije 8 mjeseci")] - [InlineData(-5, "prije 5 mjeseci")] - [InlineData(-4, "prije 4 mjeseca")] - [InlineData(-3, "prije 3 mjeseca")] - [InlineData(-2, "prije 2 mjeseca")] - [InlineData(-1, "prije mjesec dana")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-8, "prije 8 mjeseci")] + [InlineData(-5, "prije 5 mjeseci")] + [InlineData(-4, "prije 4 mjeseca")] + [InlineData(-3, "prije 3 mjeseca")] + [InlineData(-2, "prije 2 mjeseca")] + [InlineData(-1, "prije mjesec dana")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(5, "za 5 mjeseci")] - [InlineData(4, "za 4 mjeseca")] - [InlineData(2, "za 2 mjeseca")] - [InlineData(1, "za mjesec dana")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(5, "za 5 mjeseci")] + [InlineData(4, "za 4 mjeseca")] + [InlineData(2, "za 2 mjeseca")] + [InlineData(1, "za mjesec dana")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-24, "prije 24 dana")] - [InlineData(-22, "prije 22 dana")] - [InlineData(-10, "prije 10 dana")] - [InlineData(-5, "prije 5 dana")] - [InlineData(-4, "prije 4 dana")] - [InlineData(-3, "prije 3 dana")] - [InlineData(-2, "prije 2 dana")] - [InlineData(-1, "jučer")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-24, "prije 24 dana")] + [InlineData(-22, "prije 22 dana")] + [InlineData(-10, "prije 10 dana")] + [InlineData(-5, "prije 5 dana")] + [InlineData(-4, "prije 4 dana")] + [InlineData(-3, "prije 3 dana")] + [InlineData(-2, "prije 2 dana")] + [InlineData(-1, "jučer")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(10, "za 10 dana")] - [InlineData(5, "za 5 dana")] - [InlineData(1, "sutra")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(10, "za 10 dana")] + [InlineData(5, "za 5 dana")] + [InlineData(1, "sutra")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-10, "prije 10 sati")] - [InlineData(-5, "prije 5 sati")] - [InlineData(-4, "prije 4 sata")] - [InlineData(-3, "prije 3 sata")] - [InlineData(-2, "prije 2 sata")] - [InlineData(-1, "prije sat vremena")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-10, "prije 10 sati")] + [InlineData(-5, "prije 5 sati")] + [InlineData(-4, "prije 4 sata")] + [InlineData(-3, "prije 3 sata")] + [InlineData(-2, "prije 2 sata")] + [InlineData(-1, "prije sat vremena")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(5, "za 5 sati")] - [InlineData(4, "za 4 sata")] - [InlineData(3, "za 3 sata")] - [InlineData(2, "za 2 sata")] - [InlineData(1, "za sat vremena")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(5, "za 5 sati")] + [InlineData(4, "za 4 sata")] + [InlineData(3, "za 3 sata")] + [InlineData(2, "za 2 sata")] + [InlineData(1, "za sat vremena")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-10, "prije 10 minuta")] - [InlineData(-5, "prije 5 minuta")] - [InlineData(-4, "prije 4 minute")] - [InlineData(-3, "prije 3 minute")] - [InlineData(-2, "prije 2 minute")] - [InlineData(-1, "prije jedne minute")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-10, "prije 10 minuta")] + [InlineData(-5, "prije 5 minuta")] + [InlineData(-4, "prije 4 minute")] + [InlineData(-3, "prije 3 minute")] + [InlineData(-2, "prije 2 minute")] + [InlineData(-1, "prije jedne minute")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(5, "za 5 minuta")] - [InlineData(4, "za 4 minute")] - [InlineData(3, "za 3 minute")] - [InlineData(2, "za 2 minute")] - [InlineData(1, "za jednu minutu")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(5, "za 5 minuta")] + [InlineData(4, "za 4 minute")] + [InlineData(3, "za 3 minute")] + [InlineData(2, "za 2 minute")] + [InlineData(1, "za jednu minutu")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-10, "prije 10 sekundi")] - [InlineData(-5, "prije 5 sekundi")] - [InlineData(-4, "prije 4 sekunde")] - [InlineData(-3, "prije 3 sekunde")] - [InlineData(-2, "prije 2 sekunde")] - [InlineData(-1, "prije jedne sekunde")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-10, "prije 10 sekundi")] + [InlineData(-5, "prije 5 sekundi")] + [InlineData(-4, "prije 4 sekunde")] + [InlineData(-3, "prije 3 sekunde")] + [InlineData(-2, "prije 2 sekunde")] + [InlineData(-1, "prije jedne sekunde")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(10, "za 10 sekundi")] - [InlineData(5, "za 5 sekundi")] - [InlineData(4, "za 4 sekunde")] - [InlineData(3, "za 3 sekunde")] - [InlineData(2, "za 2 sekunde")] - [InlineData(1, "za jednu sekundu")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - } -} + [Theory] + [InlineData(10, "za 10 sekundi")] + [InlineData(5, "za 5 sekundi")] + [InlineData(4, "za 4 sekunde")] + [InlineData(3, "za 3 sekunde")] + [InlineData(2, "za 2 sekunde")] + [InlineData(1, "za jednu sekundu")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hr/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/hr/NumberToWordsTests.cs index 05d27686d..b34ff341f 100644 --- a/src/Humanizer.Tests/Localisation/hr/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/hr/NumberToWordsTests.cs @@ -1,127 +1,126 @@ -namespace Humanizer.Tests.Localisation.hr +namespace Humanizer.Tests.Localisation.hr; + +[UseCulture("hr-HR")] +public class NumberToWordsTests { - [UseCulture("hr-HR")] - public class NumberToWordsTests + [Theory] + [InlineData(0, "nula")] + [InlineData(1, "jedan")] + [InlineData(10, "deset")] + [InlineData(11, "jedanaest")] + [InlineData(20, "dvadeset")] + [InlineData(122, "sto dvadeset dva")] + [InlineData(3501, "tri tisuće petsto jedan")] + [InlineData(100, "sto")] + [InlineData(200, "dvjesto")] + [InlineData(300, "tristo")] + [InlineData(400, "četiristo")] + [InlineData(500, "petsto")] + [InlineData(1000, "tisuću")] + [InlineData(1001, "tisuću jedan")] + [InlineData(2000, "dvije tisuće")] + [InlineData(3000, "tri tisuće")] + [InlineData(4000, "četiri tisuće")] + [InlineData(5000, "pet tisuća")] + [InlineData(10000, "deset tisuća")] + [InlineData(20000, "dvadeset tisuća")] + [InlineData(21000, "dvadeset jedna tisuća")] + [InlineData(22000, "dvadeset dvije tisuće")] + [InlineData(23000, "dvadeset tri tisuće")] + [InlineData(24000, "dvadeset četiri tisuće")] + [InlineData(25000, "dvadeset pet tisuća")] + [InlineData(100000, "sto tisuća")] + [InlineData(200000, "dvjesto tisuća")] + [InlineData(201000, "dvjesto jedna tisuća")] + [InlineData(202000, "dvjesto dvije tisuće")] + [InlineData(203000, "dvjesto tri tisuće")] + [InlineData(204000, "dvjesto četiri tisuće")] + [InlineData(205000, "dvjesto pet tisuća")] + [InlineData(222222, "dvjesto dvadeset dvije tisuće dvjesto dvadeset dva")] + [InlineData(1000000, "milijun")] + [InlineData(2000000, "dva milijuna")] + [InlineData(10000000, "deset milijuna")] + [InlineData(11000000, "jedanaest milijuna")] + [InlineData(20000000, "dvadeset milijuna")] + [InlineData(21000000, "dvadeset jedan milijun")] + [InlineData(22000000, "dvadeset dva milijuna")] + [InlineData(30000000, "trideset milijuna")] + [InlineData(31000000, "trideset jedan milijun")] + [InlineData(32000000, "trideset dva milijuna")] + [InlineData(100000000, "sto milijuna")] + [InlineData(101000000, "sto jedan milijun")] + [InlineData(102000000, "sto dva milijuna")] + [InlineData(111000000, "sto jedanaest milijuna")] + [InlineData(200000000, "dvjesto milijuna")] + [InlineData(201000000, "dvjesto jedan milijun")] + [InlineData(202000000, "dvjesto dva milijuna")] + [InlineData(211000000, "dvjesto jedanaest milijuna")] + [InlineData(1000000000, "milijarda")] + [InlineData(2100000000, "dvije milijarde sto milijuna")] + [InlineData(2200000000, "dvije milijarde dvjesto milijuna")] + [InlineData(2300000000, "dvije milijarde tristo milijuna")] + [InlineData(2500000000, "dvije milijarde petsto milijuna")] + [InlineData(10000000000, "deset milijardi")] + [InlineData(11000000000, "jedanaest milijardi")] + [InlineData(20000000000, "dvadeset milijardi")] + [InlineData(21000000000, "dvadeset jedna milijarda")] + [InlineData(22000000000, "dvadeset dvije milijarde")] + [InlineData(23000000000, "dvadeset tri milijarde")] + [InlineData(24000000000, "dvadeset četiri milijarde")] + [InlineData(25000000000, "dvadeset pet milijardi")] + [InlineData(111, "sto jedanaest")] + [InlineData(1111, "tisuću sto jedanaest")] + [InlineData(111111, "sto jedanaest tisuća sto jedanaest")] + [InlineData(1111111, "milijun sto jedanaest tisuća sto jedanaest")] + [InlineData(11111111, "jedanaest milijuna sto jedanaest tisuća sto jedanaest")] + [InlineData(111111111, "sto jedanaest milijuna sto jedanaest tisuća sto jedanaest")] + [InlineData(1111111111, "milijarda sto jedanaest milijuna sto jedanaest tisuća sto jedanaest")] + [InlineData(101, "sto jedan")] + [InlineData(1011, "tisuću jedanaest")] + [InlineData(100011, "sto tisuća jedanaest")] + [InlineData(1100001, "milijun sto tisuća jedan")] + [InlineData(11000011, "jedanaest milijuna jedanaest")] + [InlineData(110000011, "sto deset milijuna jedanaest")] + [InlineData(1100000111, "milijarda sto milijuna sto jedanaest")] + [InlineData(123, "sto dvadeset tri")] + [InlineData(1234, "tisuću dvjesto trideset četiri")] + [InlineData(12345, "dvanaest tisuća tristo četrdeset pet")] + [InlineData(123456, "sto dvadeset tri tisuće četiristo pedeset šest")] + [InlineData(1234567, "milijun dvjesto trideset četiri tisuće petsto šezdeset sedam")] + [InlineData(12345678, "dvanaest milijuna tristo četrdeset pet tisuća šeststo sedamdeset osam")] + [InlineData(123456789, "sto dvadeset tri milijuna četiristo pedeset šest tisuća sedamsto osamdeset devet")] + [InlineData(1234567890, "milijarda dvjesto trideset četiri milijuna petsto šezdeset sedam tisuća osamsto devedeset")] + [InlineData(1000000000000, "bilijun")] + [InlineData(2000000000000, "dva bilijuna")] + [InlineData(10000000000000, "deset bilijuna")] + [InlineData(11000000000000, "jedanaest bilijuna")] + [InlineData(20000000000000, "dvadeset bilijuna")] + [InlineData(21000000000000, "dvadeset jedan bilijun")] + [InlineData(22000000000000, "dvadeset dva bilijuna")] + [InlineData(45678912345678, "četrdeset pet bilijuna šeststo sedamdeset osam milijardi devetsto dvanaest milijuna tristo četrdeset pet tisuća šeststo sedamdeset osam")] + [InlineData(1000000000000000, "bilijarda")] + [InlineData(2000000000000000, "dvije bilijarde")] + [InlineData(3000000000000000, "tri bilijarde")] + [InlineData(4000000000000000, "četiri bilijarde")] + [InlineData(5000000000000000, "pet bilijardi")] + [InlineData(10000000000000000, "deset bilijardi")] + [InlineData(11000000000000000, "jedanaest bilijardi")] + [InlineData(20000000000000000, "dvadeset bilijardi")] + [InlineData(21000000000000000, "dvadeset jedna bilijarda")] + [InlineData(22000000000000000, "dvadeset dvije bilijarde")] + [InlineData(23000000000000000, "dvadeset tri bilijarde")] + [InlineData(24000000000000000, "dvadeset četiri bilijarde")] + [InlineData(25000000000000000, "dvadeset pet bilijardi")] + [InlineData(1000000000000000000, "trilijun")] + [InlineData(2000000000000000000, "dva trilijuna")] + [InlineData(9000000000000000000, "devet trilijuna")] + [InlineData(-7516, "minus sedam tisuća petsto šesnaest")] + [InlineData(long.MaxValue, "devet trilijuna dvjesto dvadeset tri bilijarde tristo sedamdeset dva bilijuna trideset šest milijardi osamsto pedeset četiri milijuna sedamsto sedamdeset pet tisuća osamsto sedam")] + [InlineData(long.MinValue, "minus devet trilijuna dvjesto dvadeset tri bilijarde tristo sedamdeset dva bilijuna trideset šest milijardi osamsto pedeset četiri milijuna sedamsto sedamdeset pet tisuća osamsto osam")] + public void NumberToWords(long stubNumber, string expectedWords) { - [Theory] - [InlineData(0, "nula")] - [InlineData(1, "jedan")] - [InlineData(10, "deset")] - [InlineData(11, "jedanaest")] - [InlineData(20, "dvadeset")] - [InlineData(122, "sto dvadeset dva")] - [InlineData(3501, "tri tisuće petsto jedan")] - [InlineData(100, "sto")] - [InlineData(200, "dvjesto")] - [InlineData(300, "tristo")] - [InlineData(400, "četiristo")] - [InlineData(500, "petsto")] - [InlineData(1000, "tisuću")] - [InlineData(1001, "tisuću jedan")] - [InlineData(2000, "dvije tisuće")] - [InlineData(3000, "tri tisuće")] - [InlineData(4000, "četiri tisuće")] - [InlineData(5000, "pet tisuća")] - [InlineData(10000, "deset tisuća")] - [InlineData(20000, "dvadeset tisuća")] - [InlineData(21000, "dvadeset jedna tisuća")] - [InlineData(22000, "dvadeset dvije tisuće")] - [InlineData(23000, "dvadeset tri tisuće")] - [InlineData(24000, "dvadeset četiri tisuće")] - [InlineData(25000, "dvadeset pet tisuća")] - [InlineData(100000, "sto tisuća")] - [InlineData(200000, "dvjesto tisuća")] - [InlineData(201000, "dvjesto jedna tisuća")] - [InlineData(202000, "dvjesto dvije tisuće")] - [InlineData(203000, "dvjesto tri tisuće")] - [InlineData(204000, "dvjesto četiri tisuće")] - [InlineData(205000, "dvjesto pet tisuća")] - [InlineData(222222, "dvjesto dvadeset dvije tisuće dvjesto dvadeset dva")] - [InlineData(1000000, "milijun")] - [InlineData(2000000, "dva milijuna")] - [InlineData(10000000, "deset milijuna")] - [InlineData(11000000, "jedanaest milijuna")] - [InlineData(20000000, "dvadeset milijuna")] - [InlineData(21000000, "dvadeset jedan milijun")] - [InlineData(22000000, "dvadeset dva milijuna")] - [InlineData(30000000, "trideset milijuna")] - [InlineData(31000000, "trideset jedan milijun")] - [InlineData(32000000, "trideset dva milijuna")] - [InlineData(100000000, "sto milijuna")] - [InlineData(101000000, "sto jedan milijun")] - [InlineData(102000000, "sto dva milijuna")] - [InlineData(111000000, "sto jedanaest milijuna")] - [InlineData(200000000, "dvjesto milijuna")] - [InlineData(201000000, "dvjesto jedan milijun")] - [InlineData(202000000, "dvjesto dva milijuna")] - [InlineData(211000000, "dvjesto jedanaest milijuna")] - [InlineData(1000000000, "milijarda")] - [InlineData(2100000000, "dvije milijarde sto milijuna")] - [InlineData(2200000000, "dvije milijarde dvjesto milijuna")] - [InlineData(2300000000, "dvije milijarde tristo milijuna")] - [InlineData(2500000000, "dvije milijarde petsto milijuna")] - [InlineData(10000000000, "deset milijardi")] - [InlineData(11000000000, "jedanaest milijardi")] - [InlineData(20000000000, "dvadeset milijardi")] - [InlineData(21000000000, "dvadeset jedna milijarda")] - [InlineData(22000000000, "dvadeset dvije milijarde")] - [InlineData(23000000000, "dvadeset tri milijarde")] - [InlineData(24000000000, "dvadeset četiri milijarde")] - [InlineData(25000000000, "dvadeset pet milijardi")] - [InlineData(111, "sto jedanaest")] - [InlineData(1111, "tisuću sto jedanaest")] - [InlineData(111111, "sto jedanaest tisuća sto jedanaest")] - [InlineData(1111111, "milijun sto jedanaest tisuća sto jedanaest")] - [InlineData(11111111, "jedanaest milijuna sto jedanaest tisuća sto jedanaest")] - [InlineData(111111111, "sto jedanaest milijuna sto jedanaest tisuća sto jedanaest")] - [InlineData(1111111111, "milijarda sto jedanaest milijuna sto jedanaest tisuća sto jedanaest")] - [InlineData(101, "sto jedan")] - [InlineData(1011, "tisuću jedanaest")] - [InlineData(100011, "sto tisuća jedanaest")] - [InlineData(1100001, "milijun sto tisuća jedan")] - [InlineData(11000011, "jedanaest milijuna jedanaest")] - [InlineData(110000011, "sto deset milijuna jedanaest")] - [InlineData(1100000111, "milijarda sto milijuna sto jedanaest")] - [InlineData(123, "sto dvadeset tri")] - [InlineData(1234, "tisuću dvjesto trideset četiri")] - [InlineData(12345, "dvanaest tisuća tristo četrdeset pet")] - [InlineData(123456, "sto dvadeset tri tisuće četiristo pedeset šest")] - [InlineData(1234567, "milijun dvjesto trideset četiri tisuće petsto šezdeset sedam")] - [InlineData(12345678, "dvanaest milijuna tristo četrdeset pet tisuća šeststo sedamdeset osam")] - [InlineData(123456789, "sto dvadeset tri milijuna četiristo pedeset šest tisuća sedamsto osamdeset devet")] - [InlineData(1234567890, "milijarda dvjesto trideset četiri milijuna petsto šezdeset sedam tisuća osamsto devedeset")] - [InlineData(1000000000000, "bilijun")] - [InlineData(2000000000000, "dva bilijuna")] - [InlineData(10000000000000, "deset bilijuna")] - [InlineData(11000000000000, "jedanaest bilijuna")] - [InlineData(20000000000000, "dvadeset bilijuna")] - [InlineData(21000000000000, "dvadeset jedan bilijun")] - [InlineData(22000000000000, "dvadeset dva bilijuna")] - [InlineData(45678912345678, "četrdeset pet bilijuna šeststo sedamdeset osam milijardi devetsto dvanaest milijuna tristo četrdeset pet tisuća šeststo sedamdeset osam")] - [InlineData(1000000000000000, "bilijarda")] - [InlineData(2000000000000000, "dvije bilijarde")] - [InlineData(3000000000000000, "tri bilijarde")] - [InlineData(4000000000000000, "četiri bilijarde")] - [InlineData(5000000000000000, "pet bilijardi")] - [InlineData(10000000000000000, "deset bilijardi")] - [InlineData(11000000000000000, "jedanaest bilijardi")] - [InlineData(20000000000000000, "dvadeset bilijardi")] - [InlineData(21000000000000000, "dvadeset jedna bilijarda")] - [InlineData(22000000000000000, "dvadeset dvije bilijarde")] - [InlineData(23000000000000000, "dvadeset tri bilijarde")] - [InlineData(24000000000000000, "dvadeset četiri bilijarde")] - [InlineData(25000000000000000, "dvadeset pet bilijardi")] - [InlineData(1000000000000000000, "trilijun")] - [InlineData(2000000000000000000, "dva trilijuna")] - [InlineData(9000000000000000000, "devet trilijuna")] - [InlineData(-7516, "minus sedam tisuća petsto šesnaest")] - [InlineData(long.MaxValue, "devet trilijuna dvjesto dvadeset tri bilijarde tristo sedamdeset dva bilijuna trideset šest milijardi osamsto pedeset četiri milijuna sedamsto sedamdeset pet tisuća osamsto sedam")] - [InlineData(long.MinValue, "minus devet trilijuna dvjesto dvadeset tri bilijarde tristo sedamdeset dva bilijuna trideset šest milijardi osamsto pedeset četiri milijuna sedamsto sedamdeset pet tisuća osamsto osam")] - public void NumberToWords(long stubNumber, string expectedWords) - { - var actualWords = stubNumber.ToWords(); + var actualWords = stubNumber.ToWords(); - Assert.Equal(expectedWords, actualWords); - } + Assert.Equal(expectedWords, actualWords); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hr/TimeSpanHumanizeTests.cs index e940a7e53..9ccc65174 100644 --- a/src/Humanizer.Tests/Localisation/hr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hr/TimeSpanHumanizeTests.cs @@ -1,35 +1,34 @@ -namespace Humanizer.Tests.Localisation.hr +namespace Humanizer.Tests.Localisation.hr; + +[UseCulture("hr-HR")] +public class TimeSpanHumanizeTests { - [UseCulture("hr-HR")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 godina")] - [InlineData(731, "2 godine")] - [InlineData(1096, "3 godine")] - [InlineData(4018, "11 godina")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 godina")] + [InlineData(731, "2 godine")] + [InlineData(1096, "3 godine")] + [InlineData(4018, "11 godina")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mjesec")] - [InlineData(61, "2 mjeseca")] - [InlineData(92, "3 mjeseca")] - [InlineData(335, "11 mjeseci")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mjesec")] + [InlineData(61, "2 mjeseca")] + [InlineData(92, "3 mjeseca")] + [InlineData(335, "11 mjeseci")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(1, "1 dan")] - [InlineData(2, "2 dana")] - [InlineData(3, "3 dana")] - [InlineData(4, "4 dana")] - [InlineData(5, "5 dana")] - [InlineData(7, "1 tjedan")] - [InlineData(14, "2 tjedna")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - } -} + [Theory] + [InlineData(1, "1 dan")] + [InlineData(2, "2 dana")] + [InlineData(3, "3 dana")] + [InlineData(4, "4 dana")] + [InlineData(5, "5 dana")] + [InlineData(7, "1 tjedan")] + [InlineData(14, "2 tjedna")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs index 95b93c040..50019b5ea 100644 --- a/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.hu +namespace Humanizer.Tests.Localisation.hu; + +[UseCulture("hu-HU")] +public class DateHumanizeTests { - [UseCulture("hu-HU")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "egy másodperce")] - [InlineData(10, "10 másodperce")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "egy másodperce")] + [InlineData(10, "10 másodperce")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "egy másodperc múlva")] - [InlineData(10, "10 másodperc múlva")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "egy másodperc múlva")] + [InlineData(10, "10 másodperc múlva")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "egy perce")] - [InlineData(10, "10 perce")] - [InlineData(60, "egy órája")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "egy perce")] + [InlineData(10, "10 perce")] + [InlineData(60, "egy órája")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "egy perc múlva")] - [InlineData(10, "10 perc múlva")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "egy perc múlva")] + [InlineData(10, "10 perc múlva")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "egy órája")] - [InlineData(10, "10 órája")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "egy órája")] + [InlineData(10, "10 órája")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "egy óra múlva")] - [InlineData(10, "10 óra múlva")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "egy óra múlva")] + [InlineData(10, "10 óra múlva")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "tegnap")] - [InlineData(10, "10 napja")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "tegnap")] + [InlineData(10, "10 napja")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "holnap")] - [InlineData(10, "10 nap múlva")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "holnap")] + [InlineData(10, "10 nap múlva")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "egy hónapja")] - [InlineData(10, "10 hónapja")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "egy hónapja")] + [InlineData(10, "10 hónapja")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "egy hónap múlva")] - [InlineData(10, "10 hónap múlva")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "egy hónap múlva")] + [InlineData(10, "10 hónap múlva")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "egy éve")] - [InlineData(2, "2 éve")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "egy éve")] + [InlineData(2, "2 éve")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "egy év múlva")] - [InlineData(2, "2 év múlva")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "egy év múlva")] + [InlineData(2, "2 év múlva")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs index 75923a8fb..cd54cc47e 100644 --- a/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs @@ -1,70 +1,69 @@ -namespace Humanizer.Tests.Localisation.hu +namespace Humanizer.Tests.Localisation.hu; + +[UseCulture("hu-HU")] +public class TimeSpanHumanizeTests { - [UseCulture("hu-HU")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "egy év")] - [InlineData(731, "2 év")] - [InlineData(1096, "3 év")] - [InlineData(4018, "11 év")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "egy év")] + [InlineData(731, "2 év")] + [InlineData(1096, "3 év")] + [InlineData(4018, "11 év")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "egy hónap")] - [InlineData(61, "2 hónap")] - [InlineData(92, "3 hónap")] - [InlineData(335, "11 hónap")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "egy hónap")] + [InlineData(61, "2 hónap")] + [InlineData(92, "3 hónap")] + [InlineData(335, "11 hónap")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 hét")] - [InlineData(7, "1 hét")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(14, "2 hét")] + [InlineData(7, "1 hét")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(2, "2 nap")] - [InlineData(1, "1 nap")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(2, "2 nap")] + [InlineData(1, "1 nap")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(2, "2 óra")] - [InlineData(1, "1 óra")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(2, "2 óra")] + [InlineData(1, "1 óra")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(2, "2 perc")] - [InlineData(1, "1 perc")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(2, "2 perc")] + [InlineData(1, "1 perc")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(2, "2 másodperc")] - [InlineData(1, "1 másodperc")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(2, "2 másodperc")] + [InlineData(1, "1 másodperc")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Fact] - public void NoTime() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(); - Assert.Equal("0 ezredmásodperc", actual); - } + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("0 ezredmásodperc", actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("nincs idő", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("nincs idő", actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hy/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hy/DateHumanizeTests.cs index c9a859e1a..035cc16ad 100644 --- a/src/Humanizer.Tests/Localisation/hy/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hy/DateHumanizeTests.cs @@ -1,113 +1,112 @@ -namespace Humanizer.Tests.Localisation.hy +namespace Humanizer.Tests.Localisation.hy; + +[UseCulture("hy")] +public class DateHumanizeTests { - [UseCulture("hy")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "մեկ վայրկյան առաջ")] - [InlineData(2, "2 վայրկյան առաջ")] - [InlineData(3, "3 վայրկյան առաջ")] - [InlineData(4, "4 վայրկյան առաջ")] - [InlineData(11, "11 վայրկյան առաջ")] - [InlineData(21, "21 վայրկյան առաջ")] - [InlineData(24, "24 վայրկյան առաջ")] - [InlineData(40, "40 վայրկյան առաջ")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "մեկ վայրկյան առաջ")] + [InlineData(2, "2 վայրկյան առաջ")] + [InlineData(3, "3 վայրկյան առաջ")] + [InlineData(4, "4 վայրկյան առաջ")] + [InlineData(11, "11 վայրկյան առաջ")] + [InlineData(21, "21 վայրկյան առաջ")] + [InlineData(24, "24 վայրկյան առաջ")] + [InlineData(40, "40 վայրկյան առաջ")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "մեկ վայրկյանից")] - [InlineData(2, "2 վայրկյանից")] - [InlineData(11, "11 վայրկյանից")] - [InlineData(20, "20 վայրկյանից")] - [InlineData(40, "40 վայրկյանից")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "մեկ վայրկյանից")] + [InlineData(2, "2 վայրկյանից")] + [InlineData(11, "11 վայրկյանից")] + [InlineData(20, "20 վայրկյանից")] + [InlineData(40, "40 վայրկյանից")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "մեկ րոպե առաջ")] - [InlineData(2, "2 րոպե առաջ")] - [InlineData(10, "10 րոպե առաջ")] - [InlineData(25, "25 րոպե առաջ")] - [InlineData(40, "40 րոպե առաջ")] - [InlineData(60, "մեկ ժամ առաջ")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "մեկ րոպե առաջ")] + [InlineData(2, "2 րոպե առաջ")] + [InlineData(10, "10 րոպե առաջ")] + [InlineData(25, "25 րոպե առաջ")] + [InlineData(40, "40 րոպե առաջ")] + [InlineData(60, "մեկ ժամ առաջ")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "մեկ րոպեից")] - [InlineData(2, "2 րոպեից")] - [InlineData(19, "19 րոպեից")] - [InlineData(25, "25 րոպեից")] - [InlineData(40, "40 րոպեից")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "մեկ րոպեից")] + [InlineData(2, "2 րոպեից")] + [InlineData(19, "19 րոպեից")] + [InlineData(25, "25 րոպեից")] + [InlineData(40, "40 րոպեից")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "մեկ ժամ առաջ")] - [InlineData(2, "2 ժամ առաջ")] - [InlineData(19, "19 ժամ առաջ")] - [InlineData(20, "20 ժամ առաջ")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "մեկ ժամ առաջ")] + [InlineData(2, "2 ժամ առաջ")] + [InlineData(19, "19 ժամ առաջ")] + [InlineData(20, "20 ժամ առաջ")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "մեկ ժամից")] - [InlineData(5, "5 ժամից")] - [InlineData(23, "23 ժամից")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "մեկ ժամից")] + [InlineData(5, "5 ժամից")] + [InlineData(23, "23 ժամից")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "երեկ")] - [InlineData(2, "2 օր առաջ")] - [InlineData(25, "25 օր առաջ")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "երեկ")] + [InlineData(2, "2 օր առաջ")] + [InlineData(25, "25 օր առաջ")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "վաղը")] - [InlineData(2, "2 օրից")] - [InlineData(25, "25 օրից")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "վաղը")] + [InlineData(2, "2 օրից")] + [InlineData(25, "25 օրից")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "մեկ ամիս առաջ")] - [InlineData(11, "11 ամիս առաջ")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "մեկ ամիս առաջ")] + [InlineData(11, "11 ամիս առաջ")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "մեկ ամսից")] - [InlineData(11, "11 ամսից")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "մեկ ամսից")] + [InlineData(11, "11 ամսից")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "մեկ տարի առաջ")] - [InlineData(2, "2 տարի առաջ")] - [InlineData(21, "21 տարի առաջ")] - [InlineData(111, "111 տարի առաջ")] - [InlineData(121, "121 տարի առաջ")] - [InlineData(222, "222 տարի առաջ")] - [InlineData(325, "325 տարի առաջ")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "մեկ տարի առաջ")] + [InlineData(2, "2 տարի առաջ")] + [InlineData(21, "21 տարի առաջ")] + [InlineData(111, "111 տարի առաջ")] + [InlineData(121, "121 տարի առաջ")] + [InlineData(222, "222 տարի առաջ")] + [InlineData(325, "325 տարի առաջ")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "մեկ տարուց")] - [InlineData(2, "2 տարուց")] - [InlineData(21, "21 տարուց")] - [InlineData(111, "111 տարուց")] - [InlineData(121, "121 տարուց")] - [InlineData(222, "222 տարուց")] - [InlineData(325, "325 տարուց")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "մեկ տարուց")] + [InlineData(2, "2 տարուց")] + [InlineData(21, "21 տարուց")] + [InlineData(111, "111 տարուց")] + [InlineData(121, "121 տարուց")] + [InlineData(222, "222 տարուց")] + [InlineData(325, "325 տարուց")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("հիմա", 0, TimeUnit.Day, Tense.Past); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("հիմա", 0, TimeUnit.Day, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hy/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/hy/NumberToWordsTests.cs index bd19859db..e82b1a564 100644 --- a/src/Humanizer.Tests/Localisation/hy/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/hy/NumberToWordsTests.cs @@ -1,156 +1,155 @@ -namespace Humanizer.Tests.Localisation.hy +namespace Humanizer.Tests.Localisation.hy; + +[UseCulture("hy")] +public class NumberToWordsTests { - [UseCulture("hy")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "զրո")] - [InlineData(1, "մեկ")] - [InlineData(10, "տաս")] - [InlineData(11, "տասնմեկ")] - [InlineData(12, "տասներկու")] - [InlineData(13, "տասներեք")] - [InlineData(14, "տասնչորս")] - [InlineData(15, "տասնհինգ")] - [InlineData(16, "տասնվեց")] - [InlineData(17, "տասնյոթ")] - [InlineData(18, "տասնութ")] - [InlineData(19, "տասնինը")] - [InlineData(20, "քսան")] - [InlineData(30, "երեսուն")] - [InlineData(40, "քառասուն")] - [InlineData(50, "հիսուն")] - [InlineData(60, "վաթսուն")] - [InlineData(70, "յոթանասուն")] - [InlineData(80, "ութսուն")] - [InlineData(90, "իննսուն")] - [InlineData(100, "հարյուր")] - [InlineData(200, "երկու հարյուր")] - [InlineData(300, "երեք հարյուր")] - [InlineData(400, "չորս հարյուր")] - [InlineData(500, "հինգ հարյուր")] - [InlineData(600, "վեց հարյուր")] - [InlineData(700, "յոթ հարյուր")] - [InlineData(800, "ութ հարյուր")] - [InlineData(900, "ինը հարյուր")] - [InlineData(1000, "հազար")] - [InlineData(2000, "երկու հազար")] - [InlineData(3000, "երեք հազար")] - [InlineData(4000, "չորս հազար")] - [InlineData(5000, "հինգ հազար")] - [InlineData(10000, "տաս հազար")] - [InlineData(100000, "հարյուր հազար")] - [InlineData(1000000, "մեկ միլիոն")] - [InlineData(2000000, "երկու միլիոն")] - [InlineData(10000000, "տաս միլիոն")] - [InlineData(100000000, "հարյուր միլիոն")] - [InlineData(1000000000, "մեկ միլիարդ")] - [InlineData(2000000000, "երկու միլիարդ")] - [InlineData(3000000000, "երեք միլիարդ")] - [InlineData(4000000000, "չորս միլիարդ")] - [InlineData(122, "հարյուր քսաներկու")] - [InlineData(3501, "երեք հազար հինգ հարյուր մեկ")] - [InlineData(111, "հարյուր տասնմեկ")] - [InlineData(1112, "հազար հարյուր տասներկու")] - [InlineData(11213, "տասնմեկ հազար երկու հարյուր տասներեք")] - [InlineData(121314, "հարյուր քսանմեկ հազար երեք հարյուր տասնչորս")] - [InlineData(2132415, "երկու միլիոն հարյուր երեսուներկու հազար չորս հարյուր տասնհինգ")] - [InlineData(12345516, "տասներկու միլիոն երեք հարյուր քառասունհինգ հազար հինգ հարյուր տասնվեց")] - [InlineData(751633617, "յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթ")] - [InlineData(1111111118, "մեկ միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազար հարյուր տասնութ")] - [InlineData(4111111118, "չորս միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազար հարյուր տասնութ")] - [InlineData(-751633617, "մինուս յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթ")] - [InlineData(999999999999, "ինը հարյուր իննսունինը միլիարդ ինը հարյուր իննսունինը միլիոն ինը հարյուր իննսունինը հազար ինը հարյուր իննսունինը")] - [InlineData(1_000_000_000_000, "մեկ տրիլիոն")] - [InlineData(3_000_000_000_000, "երեք տրիլիոն")] - [InlineData(5_000_000_000_000, "հինգ տրիլիոն")] - [InlineData(999_000_000_000_000, "ինը հարյուր իննսունինը տրիլիոն")] - [InlineData( - long.MaxValue, - "ինը քվինտիլիոն " + - "երկու հարյուր քսաներեք կվադրիլիոն " + - "երեք հարյուր յոթանասուներկու տրիլիոն " + - "երեսունվեց միլիարդ " + - "ութ հարյուր հիսունչորս միլիոն " + - "յոթ հարյուր յոթանասունհինգ հազար " + - "ութ հարյուր յոթ")] - [InlineData( - long.MinValue, - "մինուս ինը քվինտիլիոն " + - "երկու հարյուր քսաներեք կվադրիլիոն " + - "երեք հարյուր յոթանասուներկու տրիլիոն " + - "երեսունվեց միլիարդ " + - "ութ հարյուր հիսունչորս միլիոն " + - "յոթ հարյուր յոթանասունհինգ հազար " + - "ութ հարյուր ութ")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "զրո")] + [InlineData(1, "մեկ")] + [InlineData(10, "տաս")] + [InlineData(11, "տասնմեկ")] + [InlineData(12, "տասներկու")] + [InlineData(13, "տասներեք")] + [InlineData(14, "տասնչորս")] + [InlineData(15, "տասնհինգ")] + [InlineData(16, "տասնվեց")] + [InlineData(17, "տասնյոթ")] + [InlineData(18, "տասնութ")] + [InlineData(19, "տասնինը")] + [InlineData(20, "քսան")] + [InlineData(30, "երեսուն")] + [InlineData(40, "քառասուն")] + [InlineData(50, "հիսուն")] + [InlineData(60, "վաթսուն")] + [InlineData(70, "յոթանասուն")] + [InlineData(80, "ութսուն")] + [InlineData(90, "իննսուն")] + [InlineData(100, "հարյուր")] + [InlineData(200, "երկու հարյուր")] + [InlineData(300, "երեք հարյուր")] + [InlineData(400, "չորս հարյուր")] + [InlineData(500, "հինգ հարյուր")] + [InlineData(600, "վեց հարյուր")] + [InlineData(700, "յոթ հարյուր")] + [InlineData(800, "ութ հարյուր")] + [InlineData(900, "ինը հարյուր")] + [InlineData(1000, "հազար")] + [InlineData(2000, "երկու հազար")] + [InlineData(3000, "երեք հազար")] + [InlineData(4000, "չորս հազար")] + [InlineData(5000, "հինգ հազար")] + [InlineData(10000, "տաս հազար")] + [InlineData(100000, "հարյուր հազար")] + [InlineData(1000000, "մեկ միլիոն")] + [InlineData(2000000, "երկու միլիոն")] + [InlineData(10000000, "տաս միլիոն")] + [InlineData(100000000, "հարյուր միլիոն")] + [InlineData(1000000000, "մեկ միլիարդ")] + [InlineData(2000000000, "երկու միլիարդ")] + [InlineData(3000000000, "երեք միլիարդ")] + [InlineData(4000000000, "չորս միլիարդ")] + [InlineData(122, "հարյուր քսաներկու")] + [InlineData(3501, "երեք հազար հինգ հարյուր մեկ")] + [InlineData(111, "հարյուր տասնմեկ")] + [InlineData(1112, "հազար հարյուր տասներկու")] + [InlineData(11213, "տասնմեկ հազար երկու հարյուր տասներեք")] + [InlineData(121314, "հարյուր քսանմեկ հազար երեք հարյուր տասնչորս")] + [InlineData(2132415, "երկու միլիոն հարյուր երեսուներկու հազար չորս հարյուր տասնհինգ")] + [InlineData(12345516, "տասներկու միլիոն երեք հարյուր քառասունհինգ հազար հինգ հարյուր տասնվեց")] + [InlineData(751633617, "յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթ")] + [InlineData(1111111118, "մեկ միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազար հարյուր տասնութ")] + [InlineData(4111111118, "չորս միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազար հարյուր տասնութ")] + [InlineData(-751633617, "մինուս յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթ")] + [InlineData(999999999999, "ինը հարյուր իննսունինը միլիարդ ինը հարյուր իննսունինը միլիոն ինը հարյուր իննսունինը հազար ինը հարյուր իննսունինը")] + [InlineData(1_000_000_000_000, "մեկ տրիլիոն")] + [InlineData(3_000_000_000_000, "երեք տրիլիոն")] + [InlineData(5_000_000_000_000, "հինգ տրիլիոն")] + [InlineData(999_000_000_000_000, "ինը հարյուր իննսունինը տրիլիոն")] + [InlineData( + long.MaxValue, + "ինը քվինտիլիոն " + + "երկու հարյուր քսաներեք կվադրիլիոն " + + "երեք հարյուր յոթանասուներկու տրիլիոն " + + "երեսունվեց միլիարդ " + + "ութ հարյուր հիսունչորս միլիոն " + + "յոթ հարյուր յոթանասունհինգ հազար " + + "ութ հարյուր յոթ")] + [InlineData( + long.MinValue, + "մինուս ինը քվինտիլիոն " + + "երկու հարյուր քսաներեք կվադրիլիոն " + + "երեք հարյուր յոթանասուներկու տրիլիոն " + + "երեսունվեց միլիարդ " + + "ութ հարյուր հիսունչորս միլիոն " + + "յոթ հարյուր յոթանասունհինգ հազար " + + "ութ հարյուր ութ")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "զրոյական")] - [InlineData(1, "առաջին")] - [InlineData(2, "երկրորդ")] - [InlineData(3, "երրորդ")] - [InlineData(10, "տասերորդ")] - [InlineData(11, "տասնմեկերորդ")] - [InlineData(12, "տասներկուերորդ")] - [InlineData(13, "տասներեքերորդ")] - [InlineData(14, "տասնչորսերորդ")] - [InlineData(15, "տասնհինգերորդ")] - [InlineData(16, "տասնվեցերորդ")] - [InlineData(17, "տասնյոթերորդ")] - [InlineData(18, "տասնութերորդ")] - [InlineData(19, "տասնինըերորդ")] - [InlineData(20, "քսաներորդ")] - [InlineData(30, "երեսուներորդ")] - [InlineData(40, "քառասուներորդ")] - [InlineData(50, "հիսուներորդ")] - [InlineData(60, "վաթսուներորդ")] - [InlineData(70, "յոթանասուներորդ")] - [InlineData(80, "ութսուներորդ")] - [InlineData(90, "իննսուներորդ")] - [InlineData(100, "հարյուրերորդ")] - [InlineData(200, "երկու հարյուրերորդ")] - [InlineData(300, "երեք հարյուրերորդ")] - [InlineData(400, "չորս հարյուրերորդ")] - [InlineData(500, "հինգ հարյուրերորդ")] - [InlineData(600, "վեց հարյուրերորդ")] - [InlineData(700, "յոթ հարյուրերորդ")] - [InlineData(800, "ութ հարյուրերորդ")] - [InlineData(900, "ինը հարյուրերորդ")] - [InlineData(1000, "հազարերորդ")] - [InlineData(2000, "երկու հազարերորդ")] - [InlineData(3000, "երեք հազարերորդ")] - [InlineData(4000, "չորս հազարերորդ")] - [InlineData(5000, "հինգ հազարերորդ")] - [InlineData(10000, "տաս հազարերորդ")] - [InlineData(21000, "քսանմեկ հազարերորդ")] - [InlineData(100000, "հարյուր հազարերորդ")] - [InlineData(101000, "հարյուր մեկ հազարերորդ")] - [InlineData(1000000, "մեկ միլիոներորդ")] - [InlineData(121000, "հարյուր քսանմեկ հազարերորդ")] - [InlineData(200000, "երկու հարյուր հազարերորդ")] - [InlineData(2000000, "երկու միլիոներորդ")] - [InlineData(10000000, "տաս միլիոներորդ")] - [InlineData(21000000, "քսանմեկ միլիոներորդ")] - [InlineData(100000000, "հարյուր միլիոներորդ")] - [InlineData(230000000, "երկու հարյուր երեսուն միլիոներորդ")] - [InlineData(1000000000, "մեկ միլիարդերորդ")] - [InlineData(2000000000, "երկու միլիարդերորդ")] - [InlineData(122, "հարյուր քսաներկուերորդ")] - [InlineData(3501, "երեք հազար հինգ հարյուր մեկերորդ")] - [InlineData(111, "հարյուր տասնմեկերորդ")] - [InlineData(1112, "հազար հարյուր տասներկուերորդ")] - [InlineData(11213, "տասնմեկ հազար երկու հարյուր տասներեքերորդ")] - [InlineData(121314, "հարյուր քսանմեկ հազար երեք հարյուր տասնչորսերորդ")] - [InlineData(2132415, "երկու միլիոն հարյուր երեսուներկու հազար չորս հարյուր տասնհինգերորդ")] - [InlineData(12345516, "տասներկու միլիոն երեք հարյուր քառասունհինգ հազար հինգ հարյուր տասնվեցերորդ")] - [InlineData(751633617, "յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթերորդ")] - [InlineData(1111111118, "մեկ միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազար հարյուր տասնութերորդ")] - [InlineData(1111111000, "մեկ միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազարերորդ")] - [InlineData(1234567000, "մեկ միլիարդ երկու հարյուր երեսունչորս միլիոն հինգ հարյուր վաթսունյոթ հազարերորդ")] - [InlineData(-751633617, "մինուս յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթերորդ")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "զրոյական")] + [InlineData(1, "առաջին")] + [InlineData(2, "երկրորդ")] + [InlineData(3, "երրորդ")] + [InlineData(10, "տասերորդ")] + [InlineData(11, "տասնմեկերորդ")] + [InlineData(12, "տասներկուերորդ")] + [InlineData(13, "տասներեքերորդ")] + [InlineData(14, "տասնչորսերորդ")] + [InlineData(15, "տասնհինգերորդ")] + [InlineData(16, "տասնվեցերորդ")] + [InlineData(17, "տասնյոթերորդ")] + [InlineData(18, "տասնութերորդ")] + [InlineData(19, "տասնինըերորդ")] + [InlineData(20, "քսաներորդ")] + [InlineData(30, "երեսուներորդ")] + [InlineData(40, "քառասուներորդ")] + [InlineData(50, "հիսուներորդ")] + [InlineData(60, "վաթսուներորդ")] + [InlineData(70, "յոթանասուներորդ")] + [InlineData(80, "ութսուներորդ")] + [InlineData(90, "իննսուներորդ")] + [InlineData(100, "հարյուրերորդ")] + [InlineData(200, "երկու հարյուրերորդ")] + [InlineData(300, "երեք հարյուրերորդ")] + [InlineData(400, "չորս հարյուրերորդ")] + [InlineData(500, "հինգ հարյուրերորդ")] + [InlineData(600, "վեց հարյուրերորդ")] + [InlineData(700, "յոթ հարյուրերորդ")] + [InlineData(800, "ութ հարյուրերորդ")] + [InlineData(900, "ինը հարյուրերորդ")] + [InlineData(1000, "հազարերորդ")] + [InlineData(2000, "երկու հազարերորդ")] + [InlineData(3000, "երեք հազարերորդ")] + [InlineData(4000, "չորս հազարերորդ")] + [InlineData(5000, "հինգ հազարերորդ")] + [InlineData(10000, "տաս հազարերորդ")] + [InlineData(21000, "քսանմեկ հազարերորդ")] + [InlineData(100000, "հարյուր հազարերորդ")] + [InlineData(101000, "հարյուր մեկ հազարերորդ")] + [InlineData(1000000, "մեկ միլիոներորդ")] + [InlineData(121000, "հարյուր քսանմեկ հազարերորդ")] + [InlineData(200000, "երկու հարյուր հազարերորդ")] + [InlineData(2000000, "երկու միլիոներորդ")] + [InlineData(10000000, "տաս միլիոներորդ")] + [InlineData(21000000, "քսանմեկ միլիոներորդ")] + [InlineData(100000000, "հարյուր միլիոներորդ")] + [InlineData(230000000, "երկու հարյուր երեսուն միլիոներորդ")] + [InlineData(1000000000, "մեկ միլիարդերորդ")] + [InlineData(2000000000, "երկու միլիարդերորդ")] + [InlineData(122, "հարյուր քսաներկուերորդ")] + [InlineData(3501, "երեք հազար հինգ հարյուր մեկերորդ")] + [InlineData(111, "հարյուր տասնմեկերորդ")] + [InlineData(1112, "հազար հարյուր տասներկուերորդ")] + [InlineData(11213, "տասնմեկ հազար երկու հարյուր տասներեքերորդ")] + [InlineData(121314, "հարյուր քսանմեկ հազար երեք հարյուր տասնչորսերորդ")] + [InlineData(2132415, "երկու միլիոն հարյուր երեսուներկու հազար չորս հարյուր տասնհինգերորդ")] + [InlineData(12345516, "տասներկու միլիոն երեք հարյուր քառասունհինգ հազար հինգ հարյուր տասնվեցերորդ")] + [InlineData(751633617, "յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթերորդ")] + [InlineData(1111111118, "մեկ միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազար հարյուր տասնութերորդ")] + [InlineData(1111111000, "մեկ միլիարդ հարյուր տասնմեկ միլիոն հարյուր տասնմեկ հազարերորդ")] + [InlineData(1234567000, "մեկ միլիարդ երկու հարյուր երեսունչորս միլիոն հինգ հարյուր վաթսունյոթ հազարերորդ")] + [InlineData(-751633617, "մինուս յոթ հարյուր հիսունմեկ միլիոն վեց հարյուր երեսուներեք հազար վեց հարյուր տասնյոթերորդ")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hy/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/hy/OrdinalizeTests.cs index ab6be652e..d0e22356e 100644 --- a/src/Humanizer.Tests/Localisation/hy/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hy/OrdinalizeTests.cs @@ -1,33 +1,32 @@ -namespace Humanizer.Tests.Localisation.hy +namespace Humanizer.Tests.Localisation.hy; + +[UseCulture("hy")] +public class OrdinalizeTests { - [UseCulture("hy")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0-րդ")] - [InlineData("1", "1-ին")] - [InlineData("2", "2-րդ")] - [InlineData("103", "103-րդ")] - [InlineData("1001", "1001-րդ")] - public void OrdinalizeStringMasculine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("0", "0-րդ")] + [InlineData("1", "1-ին")] + [InlineData("2", "2-րդ")] + [InlineData("103", "103-րդ")] + [InlineData("1001", "1001-րդ")] + public void OrdinalizeStringMasculine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0-րդ")] - [InlineData("1", "1-ին")] - [InlineData("2", "2-րդ")] - [InlineData("103", "103-րդ")] - [InlineData("1001", "1001-րդ")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0-րդ")] + [InlineData("1", "1-ին")] + [InlineData("2", "2-րդ")] + [InlineData("103", "103-րդ")] + [InlineData("1001", "1001-րդ")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData("0", "0-րդ")] - [InlineData("1", "1-ին")] - [InlineData("2", "2-րդ")] - [InlineData("103", "103-րդ")] - [InlineData("1001", "1001-րդ")] - public void OrdinalizeStringNeuter(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - } -} + [Theory] + [InlineData("0", "0-րդ")] + [InlineData("1", "1-ին")] + [InlineData("2", "2-րդ")] + [InlineData("103", "103-րդ")] + [InlineData("1001", "1001-րդ")] + public void OrdinalizeStringNeuter(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/hy/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/hy/TimeSpanHumanizeTests.cs index c54a119ae..b3a1c971e 100644 --- a/src/Humanizer.Tests/Localisation/hy/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/hy/TimeSpanHumanizeTests.cs @@ -1,130 +1,129 @@ -namespace Humanizer.Tests.Localisation.hy +namespace Humanizer.Tests.Localisation.hy; + +[UseCulture("hy")] +public class TimeSpanHumanizeTests { - [UseCulture("hy")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "մեկ տարի")] - [InlineData(731, "2 տարի")] - [InlineData(1096, "3 տարի")] - [InlineData(4018, "11 տարի")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "մեկ տարի")] + [InlineData(731, "2 տարի")] + [InlineData(1096, "3 տարի")] + [InlineData(4018, "11 տարի")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "մեկ ամիս")] - [InlineData(61, "2 ամիս")] - [InlineData(92, "3 ամիս")] - [InlineData(335, "11 ամիս")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "մեկ ամիս")] + [InlineData(61, "2 ամիս")] + [InlineData(92, "3 ամիս")] + [InlineData(335, "11 ամիս")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "մեկ շաբաթ")] - [InlineData(14, "2 շաբաթ")] - [InlineData(21, "3 շաբաթ")] - [InlineData(28, "4 շաբաթ")] - [InlineData(35, "5 շաբաթ")] - [InlineData(77, "11 շաբաթ")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "մեկ շաբաթ")] + [InlineData(14, "2 շաբաթ")] + [InlineData(21, "3 շաբաթ")] + [InlineData(28, "4 շաբաթ")] + [InlineData(35, "5 շաբաթ")] + [InlineData(77, "11 շաբաթ")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "մեկ օր")] - [InlineData(2, "2 օր")] - [InlineData(3, "3 օր")] - [InlineData(4, "4 օր")] - [InlineData(5, "5 օր")] - [InlineData(6, "6 օր")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "մեկ օր")] + [InlineData(2, "2 օր")] + [InlineData(3, "3 օր")] + [InlineData(4, "4 օր")] + [InlineData(5, "5 օր")] + [InlineData(6, "6 օր")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "մեկ ժամ")] - [InlineData(2, "2 ժամ")] - [InlineData(3, "3 ժամ")] - [InlineData(4, "4 ժամ")] - [InlineData(5, "5 ժամ")] - [InlineData(6, "6 ժամ")] - [InlineData(10, "10 ժամ")] - [InlineData(11, "11 ժամ")] - [InlineData(19, "19 ժամ")] - [InlineData(20, "20 ժամ")] - [InlineData(21, "21 ժամ")] - [InlineData(22, "22 ժամ")] - [InlineData(23, "23 ժամ")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "մեկ ժամ")] + [InlineData(2, "2 ժամ")] + [InlineData(3, "3 ժամ")] + [InlineData(4, "4 ժամ")] + [InlineData(5, "5 ժամ")] + [InlineData(6, "6 ժամ")] + [InlineData(10, "10 ժամ")] + [InlineData(11, "11 ժամ")] + [InlineData(19, "19 ժամ")] + [InlineData(20, "20 ժամ")] + [InlineData(21, "21 ժամ")] + [InlineData(22, "22 ժամ")] + [InlineData(23, "23 ժամ")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "մեկ րոպե")] - [InlineData(2, "2 րոպե")] - [InlineData(3, "3 րոպե")] - [InlineData(4, "4 րոպե")] - [InlineData(5, "5 րոպե")] - [InlineData(6, "6 րոպե")] - [InlineData(10, "10 րոպե")] - [InlineData(11, "11 րոպե")] - [InlineData(19, "19 րոպե")] - [InlineData(20, "20 րոպե")] - [InlineData(21, "21 րոպե")] - [InlineData(22, "22 րոպե")] - [InlineData(23, "23 րոպե")] - [InlineData(24, "24 րոպե")] - [InlineData(25, "25 րոպե")] - [InlineData(40, "40 րոպե")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "մեկ րոպե")] + [InlineData(2, "2 րոպե")] + [InlineData(3, "3 րոպե")] + [InlineData(4, "4 րոպե")] + [InlineData(5, "5 րոպե")] + [InlineData(6, "6 րոպե")] + [InlineData(10, "10 րոպե")] + [InlineData(11, "11 րոպե")] + [InlineData(19, "19 րոպե")] + [InlineData(20, "20 րոպե")] + [InlineData(21, "21 րոպե")] + [InlineData(22, "22 րոպե")] + [InlineData(23, "23 րոպե")] + [InlineData(24, "24 րոպե")] + [InlineData(25, "25 րոպե")] + [InlineData(40, "40 րոպե")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "մեկ վայրկյան")] - [InlineData(2, "2 վայրկյան")] - [InlineData(3, "3 վայրկյան")] - [InlineData(4, "4 վայրկյան")] - [InlineData(5, "5 վայրկյան")] - [InlineData(6, "6 վայրկյան")] - [InlineData(10, "10 վայրկյան")] - [InlineData(11, "11 վայրկյան")] - [InlineData(19, "19 վայրկյան")] - [InlineData(20, "20 վայրկյան")] - [InlineData(21, "21 վայրկյան")] - [InlineData(22, "22 վայրկյան")] - [InlineData(23, "23 վայրկյան")] - [InlineData(24, "24 վայրկյան")] - [InlineData(25, "25 վայրկյան")] - [InlineData(40, "40 վայրկյան")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "մեկ վայրկյան")] + [InlineData(2, "2 վայրկյան")] + [InlineData(3, "3 վայրկյան")] + [InlineData(4, "4 վայրկյան")] + [InlineData(5, "5 վայրկյան")] + [InlineData(6, "6 վայրկյան")] + [InlineData(10, "10 վայրկյան")] + [InlineData(11, "11 վայրկյան")] + [InlineData(19, "19 վայրկյան")] + [InlineData(20, "20 վայրկյան")] + [InlineData(21, "21 վայրկյան")] + [InlineData(22, "22 վայրկյան")] + [InlineData(23, "23 վայրկյան")] + [InlineData(24, "24 վայրկյան")] + [InlineData(25, "25 վայրկյան")] + [InlineData(40, "40 վայրկյան")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "մեկ միլիվայրկյան")] - [InlineData(2, "2 միլիվայրկյան")] - [InlineData(3, "3 միլիվայրկյան")] - [InlineData(4, "4 միլիվայրկյան")] - [InlineData(5, "5 միլիվայրկյան")] - [InlineData(6, "6 միլիվայրկյան")] - [InlineData(10, "10 միլիվայրկյան")] - [InlineData(11, "11 միլիվայրկյան")] - [InlineData(19, "19 միլիվայրկյան")] - [InlineData(20, "20 միլիվայրկյան")] - [InlineData(21, "21 միլիվայրկյան")] - [InlineData(22, "22 միլիվայրկյան")] - [InlineData(23, "23 միլիվայրկյան")] - [InlineData(24, "24 միլիվայրկյան")] - [InlineData(25, "25 միլիվայրկյան")] - [InlineData(40, "40 միլիվայրկյան")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "մեկ միլիվայրկյան")] + [InlineData(2, "2 միլիվայրկյան")] + [InlineData(3, "3 միլիվայրկյան")] + [InlineData(4, "4 միլիվայրկյան")] + [InlineData(5, "5 միլիվայրկյան")] + [InlineData(6, "6 միլիվայրկյան")] + [InlineData(10, "10 միլիվայրկյան")] + [InlineData(11, "11 միլիվայրկյան")] + [InlineData(19, "19 միլիվայրկյան")] + [InlineData(20, "20 միլիվայրկյան")] + [InlineData(21, "21 միլիվայրկյան")] + [InlineData(22, "22 միլիվայրկյան")] + [InlineData(23, "23 միլիվայրկյան")] + [InlineData(24, "24 միլիվայրկյան")] + [InlineData(25, "25 միլիվայրկյան")] + [InlineData(40, "40 միլիվայրկյան")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 միլիվայրկյան", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 միլիվայրկյան", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("ժամանակը բացակայում է", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("ժամանակը բացակայում է", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/id/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/id/DateHumanizeTests.cs index 11d87b475..ccbfc04f3 100644 --- a/src/Humanizer.Tests/Localisation/id/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/id/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.id +namespace Humanizer.Tests.Localisation.id; + +[UseCulture("id-ID")] +public class DateHumanizeTests { - [UseCulture("id-ID")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "sedetik yang lalu")] - [InlineData(10, "10 detik yang lalu")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "sedetik yang lalu")] + [InlineData(10, "10 detik yang lalu")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "sedetik dari sekarang")] - [InlineData(10, "10 detik dari sekarang")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "sedetik dari sekarang")] + [InlineData(10, "10 detik dari sekarang")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "semenit yang lalu")] - [InlineData(10, "10 menit yang lalu")] - [InlineData(60, "sejam yang lalu")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "semenit yang lalu")] + [InlineData(10, "10 menit yang lalu")] + [InlineData(60, "sejam yang lalu")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "semenit dari sekarang")] - [InlineData(10, "10 menit dari sekarang")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "semenit dari sekarang")] + [InlineData(10, "10 menit dari sekarang")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "sejam yang lalu")] - [InlineData(10, "10 jam yang lalu")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "sejam yang lalu")] + [InlineData(10, "10 jam yang lalu")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "sejam dari sekarang")] - [InlineData(10, "10 jam dari sekarang")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "sejam dari sekarang")] + [InlineData(10, "10 jam dari sekarang")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "kemarin")] - [InlineData(10, "10 hari yang lalu")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "kemarin")] + [InlineData(10, "10 hari yang lalu")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "besok")] - [InlineData(10, "10 hari dari sekarang")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "besok")] + [InlineData(10, "10 hari dari sekarang")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "sebulan yang lalu")] - [InlineData(10, "10 bulan yang lalu")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "sebulan yang lalu")] + [InlineData(10, "10 bulan yang lalu")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "sebulan dari sekarang")] - [InlineData(10, "10 bulan dari sekarang")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "sebulan dari sekarang")] + [InlineData(10, "10 bulan dari sekarang")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "setahun yang lalu")] - [InlineData(2, "2 tahun yang lalu")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "setahun yang lalu")] + [InlineData(2, "2 tahun yang lalu")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "setahun dari sekarang")] - [InlineData(2, "2 tahun dari sekarang")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "setahun dari sekarang")] + [InlineData(2, "2 tahun dari sekarang")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/id/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/id/TimeSpanHumanizeTests.cs index a6f3c4d82..3cd210136 100644 --- a/src/Humanizer.Tests/Localisation/id/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/id/TimeSpanHumanizeTests.cs @@ -1,94 +1,93 @@ -namespace Humanizer.Tests.Localisation.id +namespace Humanizer.Tests.Localisation.id; + +[UseCulture("id-ID")] +public class TimeSpanHumanizeTests { - [UseCulture("id-ID")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 tahun")] - [InlineData(731, "2 tahun")] - [InlineData(1096, "3 tahun")] - [InlineData(4018, "11 tahun")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 tahun")] + [InlineData(731, "2 tahun")] + [InlineData(1096, "3 tahun")] + [InlineData(4018, "11 tahun")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 bulan")] - [InlineData(61, "2 bulan")] - [InlineData(92, "3 bulan")] - [InlineData(335, "11 bulan")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 bulan")] + [InlineData(61, "2 bulan")] + [InlineData(92, "3 bulan")] + [InlineData(335, "11 bulan")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 minggu")] - [InlineData(7, "1 minggu")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(14, "2 minggu")] + [InlineData(7, "1 minggu")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 hari")] - [InlineData(1, "1 hari")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 hari")] + [InlineData(1, "1 hari")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 jam")] - [InlineData(1, "1 jam")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 jam")] + [InlineData(1, "1 jam")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 menit")] - [InlineData(1, "1 menit")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 menit")] + [InlineData(1, "1 menit")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 detik")] - [InlineData(1, "1 detik")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 detik")] + [InlineData(1, "1 detik")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 milidetik")] - [InlineData(1, "1 milidetik")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 milidetik")] + [InlineData(1, "1 milidetik")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } - [Fact] - public void NoTime() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(); - Assert.Equal("0 milidetik", actual); - } + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("0 milidetik", actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("waktu kosong", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("waktu kosong", actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs index 590effc04..c4926f159 100644 --- a/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/invariant/NumberToWordsTests.cs @@ -1,38 +1,37 @@ -namespace Humanizer.Tests.Localisation.invariant +namespace Humanizer.Tests.Localisation.invariant; + +[UseCulture("")] +public class NumberToWordsTests { - [UseCulture("")] - public class NumberToWordsTests - { - [InlineData(1, "one")] - [InlineData(10, "ten")] - [InlineData(11, "eleven")] - [InlineData(20, "twenty")] - [InlineData(122, "one hundred and twenty-two")] - [InlineData(3501, "three thousand five hundred and one")] - [InlineData(100, "one hundred")] - [InlineData(1000, "one thousand")] - [InlineData(100000, "one hundred thousand")] - [InlineData(1000000, "one million")] - [InlineData(10000000, "ten million")] - [InlineData(100000000, "one hundred million")] - [InlineData(1000000000, "one billion")] - [InlineData(111, "one hundred and eleven")] - [InlineData(1111, "one thousand one hundred and eleven")] - [InlineData(111111, "one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111, "one million one hundred and eleven thousand one hundred and eleven")] - [InlineData(11111111, "eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(111111111, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111111, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(123, "one hundred and twenty-three")] - [InlineData(1234, "one thousand two hundred and thirty-four")] - [InlineData(12345, "twelve thousand three hundred and forty-five")] - [InlineData(123456, "one hundred and twenty-three thousand four hundred and fifty-six")] - [InlineData(1234567, "one million two hundred and thirty-four thousand five hundred and sixty-seven")] - [InlineData(12345678, "twelve million three hundred and forty-five thousand six hundred and seventy-eight")] - [InlineData(123456789, "one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine")] - [InlineData(1234567890, "one billion two hundred and thirty-four million five hundred and sixty-seven thousand eight hundred and ninety")] - [Theory] - public void ToWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [InlineData(1, "one")] + [InlineData(10, "ten")] + [InlineData(11, "eleven")] + [InlineData(20, "twenty")] + [InlineData(122, "one hundred and twenty-two")] + [InlineData(3501, "three thousand five hundred and one")] + [InlineData(100, "one hundred")] + [InlineData(1000, "one thousand")] + [InlineData(100000, "one hundred thousand")] + [InlineData(1000000, "one million")] + [InlineData(10000000, "ten million")] + [InlineData(100000000, "one hundred million")] + [InlineData(1000000000, "one billion")] + [InlineData(111, "one hundred and eleven")] + [InlineData(1111, "one thousand one hundred and eleven")] + [InlineData(111111, "one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111, "one million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111, "eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(123, "one hundred and twenty-three")] + [InlineData(1234, "one thousand two hundred and thirty-four")] + [InlineData(12345, "twelve thousand three hundred and forty-five")] + [InlineData(123456, "one hundred and twenty-three thousand four hundred and fifty-six")] + [InlineData(1234567, "one million two hundred and thirty-four thousand five hundred and sixty-seven")] + [InlineData(12345678, "twelve million three hundred and forty-five thousand six hundred and seventy-eight")] + [InlineData(123456789, "one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine")] + [InlineData(1234567890, "one billion two hundred and thirty-four million five hundred and sixty-seven thousand eight hundred and ninety")] + [Theory] + public void ToWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs b/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs index 539070c67..186e302d4 100644 --- a/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs +++ b/src/Humanizer.Tests/Localisation/invariant/ToQuantityTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.invariant +namespace Humanizer.Tests.Localisation.invariant; + +[UseCulture("")] +public class ToQuantityTests { - [UseCulture("")] - public class ToQuantityTests - { - [Theory] - [InlineData("case", 0, "0 cases")] - [InlineData("case", 1, "1 case")] - [InlineData("case", 5, "5 cases")] - [InlineData("man", 0, "0 men")] - [InlineData("man", 1, "1 man")] - [InlineData("man", 2, "2 men")] - [InlineData("men", 2, "2 men")] - [InlineData("process", 2, "2 processes")] - [InlineData("process", 1, "1 process")] - [InlineData("processes", 2, "2 processes")] - [InlineData("processes", 1, "1 process")] - public void ToQuantity(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity)); + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1, "1 process")] + public void ToQuantity(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity)); - [Theory] - [InlineData("case", 0, "cases")] - [InlineData("case", 1, "case")] - [InlineData("case", 5, "cases")] - [InlineData("man", 0, "men")] - [InlineData("man", 1, "man")] - [InlineData("man", 2, "men")] - [InlineData("men", 2, "men")] - [InlineData("process", 2, "processes")] - [InlineData("process", 1, "process")] - [InlineData("processes", 2, "processes")] - [InlineData("processes", 1, "process")] - public void ToQuantityWithNoQuantity(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.None)); + [Theory] + [InlineData("case", 0, "cases")] + [InlineData("case", 1, "case")] + [InlineData("case", 5, "cases")] + [InlineData("man", 0, "men")] + [InlineData("man", 1, "man")] + [InlineData("man", 2, "men")] + [InlineData("men", 2, "men")] + [InlineData("process", 2, "processes")] + [InlineData("process", 1, "process")] + [InlineData("processes", 2, "processes")] + [InlineData("processes", 1, "process")] + public void ToQuantityWithNoQuantity(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.None)); - [Theory] - [InlineData("case", 0, "0 cases")] - [InlineData("case", 1, "1 case")] - [InlineData("case", 5, "5 cases")] - [InlineData("man", 0, "0 men")] - [InlineData("man", 1, "1 man")] - [InlineData("man", 2, "2 men")] - [InlineData("men", 2, "2 men")] - [InlineData("process", 2, "2 processes")] - [InlineData("process", 1, "1 process")] - [InlineData("processes", 2, "2 processes")] - [InlineData("processes", 1, "1 process")] - public void ToQuantityNumeric(string word, int quantity, string expected) => - // ReSharper disable once RedundantArgumentDefaultValue - Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Numeric)); + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1, "1 process")] + public void ToQuantityNumeric(string word, int quantity, string expected) => + // ReSharper disable once RedundantArgumentDefaultValue + Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Numeric)); - [Theory] - [InlineData("case", 0, "zero cases")] - [InlineData("case", 1, "one case")] - [InlineData("case", 5, "five cases")] - [InlineData("man", 0, "zero men")] - [InlineData("man", 1, "one man")] - [InlineData("man", 2, "two men")] - [InlineData("men", 2, "two men")] - [InlineData("process", 2, "two processes")] - [InlineData("process", 1, "one process")] - [InlineData("processes", 2, "two processes")] - [InlineData("processes", 1200, "one thousand two hundred processes")] - [InlineData("processes", 1, "one process")] - public void ToQuantityWords(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Words)); - } -} + [Theory] + [InlineData("case", 0, "zero cases")] + [InlineData("case", 1, "one case")] + [InlineData("case", 5, "five cases")] + [InlineData("man", 0, "zero men")] + [InlineData("man", 1, "one man")] + [InlineData("man", 2, "two men")] + [InlineData("men", 2, "two men")] + [InlineData("process", 2, "two processes")] + [InlineData("process", 1, "one process")] + [InlineData("processes", 2, "two processes")] + [InlineData("processes", 1200, "one thousand two hundred processes")] + [InlineData("processes", 1, "one process")] + public void ToQuantityWords(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Words)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/Bytes/ByteSizeExtensionsTests.cs b/src/Humanizer.Tests/Localisation/is/Bytes/ByteSizeExtensionsTests.cs index 4e265d988..6f658c3e5 100644 --- a/src/Humanizer.Tests/Localisation/is/Bytes/ByteSizeExtensionsTests.cs +++ b/src/Humanizer.Tests/Localisation/is/Bytes/ByteSizeExtensionsTests.cs @@ -1,63 +1,62 @@ -namespace Humanizer.Tests.Localisation.@is.Bytes +namespace Humanizer.Tests.Localisation.@is.Bytes; + +[UseCulture("is")] +public class ByteSizeExtensionsTests { - [UseCulture("is")] - public class ByteSizeExtensionsTests - { - [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, 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(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) => - Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); + [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) => + Assert.Equal(expectedValue, input.Gigabytes().Humanize(format)); - [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) => - Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); + [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) => + Assert.Equal(expectedValue, input.Megabytes().Humanize(format)); - [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) => - Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); + [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) => + Assert.Equal(expectedValue, input.Kilobytes().Humanize(format)); - [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) => - Assert.Equal(expectedValue, input.Bytes().Humanize(format)); + [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) => + Assert.Equal(expectedValue, input.Bytes().Humanize(format)); - [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)); - } -} + [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)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/Bytes/ToFullWordsTests.cs b/src/Humanizer.Tests/Localisation/is/Bytes/ToFullWordsTests.cs index 42dc647eb..793452b22 100644 --- a/src/Humanizer.Tests/Localisation/is/Bytes/ToFullWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/is/Bytes/ToFullWordsTests.cs @@ -1,60 +1,59 @@ -namespace Humanizer.Tests.Localisation.@is.Bytes +namespace Humanizer.Tests.Localisation.@is.Bytes; + +[UseCulture("is")] +public class ToFullWordsTests { - [UseCulture("is")] - public class ToFullWordsTests - { - [Fact] - public void ReturnsSingularBit() => - Assert.Equal("1 biti", ByteSize.FromBits(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBits() => - Assert.Equal("2 biti", ByteSize.FromBits(2).ToFullWords()); - - [Fact] - public void ReturnsSingularByte() => - Assert.Equal("1 bæti", ByteSize.FromBytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralBytes() => - Assert.Equal("10 bæti", ByteSize.FromBytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularKiloByte() => - Assert.Equal("1 kílóbæti", ByteSize.FromKilobytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralKilobytes() => - Assert.Equal("10 kílóbæti", ByteSize.FromKilobytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularMegabyte() => - Assert.Equal("1 megabæti", ByteSize.FromMegabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralMegabytes() => - Assert.Equal("10 megabæti", ByteSize.FromMegabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularGigabyte() => - Assert.Equal("1 gígabæti", ByteSize.FromGigabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralGigabytes() => - Assert.Equal("10 gígabæti", ByteSize.FromGigabytes(10).ToFullWords()); - - [Fact] - public void ReturnsSingularTerabyte() => - Assert.Equal("1 terabæti", ByteSize.FromTerabytes(1).ToFullWords()); - - [Fact] - public void ReturnsPluralTerabytes() => - Assert.Equal("10 terabæti", ByteSize.FromTerabytes(10).ToFullWords()); - - [Theory] - [InlineData(229376, "B", "229376 bæti")] - [InlineData(229376, "# KB", "224 kílóbæti")] - public void ToFullWordsFormatted(double input, string format, string expectedValue) => - Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); - } -} + [Fact] + public void ReturnsSingularBit() => + Assert.Equal("1 biti", ByteSize.FromBits(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBits() => + Assert.Equal("2 biti", ByteSize.FromBits(2).ToFullWords()); + + [Fact] + public void ReturnsSingularByte() => + Assert.Equal("1 bæti", ByteSize.FromBytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralBytes() => + Assert.Equal("10 bæti", ByteSize.FromBytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularKiloByte() => + Assert.Equal("1 kílóbæti", ByteSize.FromKilobytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralKilobytes() => + Assert.Equal("10 kílóbæti", ByteSize.FromKilobytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularMegabyte() => + Assert.Equal("1 megabæti", ByteSize.FromMegabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralMegabytes() => + Assert.Equal("10 megabæti", ByteSize.FromMegabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularGigabyte() => + Assert.Equal("1 gígabæti", ByteSize.FromGigabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralGigabytes() => + Assert.Equal("10 gígabæti", ByteSize.FromGigabytes(10).ToFullWords()); + + [Fact] + public void ReturnsSingularTerabyte() => + Assert.Equal("1 terabæti", ByteSize.FromTerabytes(1).ToFullWords()); + + [Fact] + public void ReturnsPluralTerabytes() => + Assert.Equal("10 terabæti", ByteSize.FromTerabytes(10).ToFullWords()); + + [Theory] + [InlineData(229376, "B", "229376 bæti")] + [InlineData(229376, "# KB", "224 kílóbæti")] + public void ToFullWordsFormatted(double input, string format, string expectedValue) => + Assert.Equal(expectedValue, ByteSize.FromBytes(input).ToFullWords(format)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/Bytes/ToStringTests.cs b/src/Humanizer.Tests/Localisation/is/Bytes/ToStringTests.cs index 1510db7c9..44e1a0729 100644 --- a/src/Humanizer.Tests/Localisation/is/Bytes/ToStringTests.cs +++ b/src/Humanizer.Tests/Localisation/is/Bytes/ToStringTests.cs @@ -1,58 +1,57 @@ -namespace Humanizer.Tests.Localisation.@is.Bytes +namespace Humanizer.Tests.Localisation.@is.Bytes; + +[UseCulture("is")] +public class ToStringTests { - [UseCulture("is")] - public class ToStringTests - { - [Fact] - public void ReturnsLargestMetricSuffix() => - Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString()); - - [Fact] - public void ReturnsDefaultNumberFormat() => - Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString("KB")); - - [Fact] - public void ReturnsProvidedNumberFormat() => - Assert.Equal("10,1234 kB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); - - [Fact] - public void ReturnsBits() => - Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); - - [Fact] - public void ReturnsBytes() => - Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B")); - - [Fact] - public void ReturnsKilobytes() => - Assert.Equal("10 kB", ByteSize.FromKilobytes(10).ToString("##.#### KB")); - - [Fact] - public void ReturnsMegabytes() => - Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB")); - - [Fact] - public void ReturnsGigabytes() => - Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB")); - - [Fact] - public void ReturnsTerabytes() => - Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB")); - - [Fact] - public void ReturnsSelectedFormat() => - Assert.Equal("10,0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB")); - - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZero() => - Assert.Equal("512 kB", ByteSize.FromMegabytes(.5).ToString("#.#")); - - [Fact] - public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => - Assert.Equal("-512 kB", ByteSize.FromMegabytes(-.5).ToString("#.#")); - - [Fact] - public void ReturnsBytesViaGeneralFormat() => - Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}"); - } -} + [Fact] + public void ReturnsLargestMetricSuffix() => + Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString()); + + [Fact] + public void ReturnsDefaultNumberFormat() => + Assert.Equal("10,5 kB", ByteSize.FromKilobytes(10.5).ToString("KB")); + + [Fact] + public void ReturnsProvidedNumberFormat() => + Assert.Equal("10,1234 kB", ByteSize.FromKilobytes(10.1234).ToString("#.#### KB")); + + [Fact] + public void ReturnsBits() => + Assert.Equal("10 b", ByteSize.FromBits(10).ToString("##.#### b")); + + [Fact] + public void ReturnsBytes() => + Assert.Equal("10 B", ByteSize.FromBytes(10).ToString("##.#### B")); + + [Fact] + public void ReturnsKilobytes() => + Assert.Equal("10 kB", ByteSize.FromKilobytes(10).ToString("##.#### KB")); + + [Fact] + public void ReturnsMegabytes() => + Assert.Equal("10 MB", ByteSize.FromMegabytes(10).ToString("##.#### MB")); + + [Fact] + public void ReturnsGigabytes() => + Assert.Equal("10 GB", ByteSize.FromGigabytes(10).ToString("##.#### GB")); + + [Fact] + public void ReturnsTerabytes() => + Assert.Equal("10 TB", ByteSize.FromTerabytes(10).ToString("##.#### TB")); + + [Fact] + public void ReturnsSelectedFormat() => + Assert.Equal("10,0 TB", ByteSize.FromTerabytes(10).ToString("0.0 TB")); + + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZero() => + Assert.Equal("512 kB", ByteSize.FromMegabytes(.5).ToString("#.#")); + + [Fact] + public void ReturnsLargestMetricPrefixLargerThanZeroForNegativeValues() => + Assert.Equal("-512 kB", ByteSize.FromMegabytes(-.5).ToString("#.#")); + + [Fact] + public void ReturnsBytesViaGeneralFormat() => + Assert.Equal("10 B", $"{ByteSize.FromBytes(10)}"); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/CollectionFormatterTests.cs b/src/Humanizer.Tests/Localisation/is/CollectionFormatterTests.cs index 41031bbd6..225b9aa3d 100644 --- a/src/Humanizer.Tests/Localisation/is/CollectionFormatterTests.cs +++ b/src/Humanizer.Tests/Localisation/is/CollectionFormatterTests.cs @@ -1,30 +1,29 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +[UseCulture("is")] +public class CollectionFormatterTests { - [UseCulture("is")] - public class CollectionFormatterTests + [Fact] + public void OneItem() { - [Fact] - public void OneItem() - { var collection = new List(new[] { 1 }); var humanized = "1"; Assert.Equal(humanized, collection.Humanize()); } - [Fact] - public void TwoItems() - { + [Fact] + public void TwoItems() + { var collection = new List(new[] { 1, 2 }); var humanized = "1 og 2"; Assert.Equal(humanized, collection.Humanize()); } - [Fact] - public void MoreThanTwoItems() - { + [Fact] + public void MoreThanTwoItems() + { var collection = new List(new[] { 1, 2, 3 }); var humanized = "1, 2 og 3"; Assert.Equal(humanized, collection.Humanize()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/is/DateHumanizeTests.cs index 3ff985b97..62e7f3d7e 100644 --- a/src/Humanizer.Tests/Localisation/is/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/is/DateHumanizeTests.cs @@ -1,89 +1,88 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +[UseCulture("is")] +public class DateHumanizeTests { - [UseCulture("is")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "fyrir 2 dögum")] - [InlineData(1, "í gær")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "fyrir 2 dögum")] + [InlineData(1, "í gær")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "eftir 2 daga")] - [InlineData(1, "á morgun")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "eftir 2 daga")] + [InlineData(1, "á morgun")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "fyrir 2 klukkustundum")] - [InlineData(1, "fyrir einni klukkustund")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "fyrir 2 klukkustundum")] + [InlineData(1, "fyrir einni klukkustund")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "eftir 2 klukkustundir")] - [InlineData(1, "eftir eina klukkustund")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "eftir 2 klukkustundir")] + [InlineData(1, "eftir eina klukkustund")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "fyrir 2 mínútum")] - [InlineData(-1, "fyrir einni mínútu")] - [InlineData(60, "fyrir einni klukkustund")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "fyrir 2 mínútum")] + [InlineData(-1, "fyrir einni mínútu")] + [InlineData(60, "fyrir einni klukkustund")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "eftir 2 mínútur")] - [InlineData(1, "eftir eina mínútu")] - [InlineData(10, "eftir 10 mínútur")] - [InlineData(59, "eftir 59 mínútur")] - [InlineData(60, "eftir eina klukkustund")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "eftir 2 mínútur")] + [InlineData(1, "eftir eina mínútu")] + [InlineData(10, "eftir 10 mínútur")] + [InlineData(59, "eftir 59 mínútur")] + [InlineData(60, "eftir eina klukkustund")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(2, "fyrir 2 mánuðum")] - [InlineData(1, "fyrir einum mánuði")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(2, "fyrir 2 mánuðum")] + [InlineData(1, "fyrir einum mánuði")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "eftir 2 mánuði")] - [InlineData(1, "eftir einn mánuð")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "eftir 2 mánuði")] + [InlineData(1, "eftir einn mánuð")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(2, "fyrir 2 sekúndum")] - [InlineData(1, "fyrir einni sekúndu")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(2, "fyrir 2 sekúndum")] + [InlineData(1, "fyrir einni sekúndu")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "eftir 2 sekúndur")] - [InlineData(1, "eftir eina sekúndu")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "eftir 2 sekúndur")] + [InlineData(1, "eftir eina sekúndu")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(2, "fyrir 2 árum")] - [InlineData(1, "fyrir einu ári")] - [InlineData(20, "fyrir 20 árum")] - [InlineData(30, "fyrir 30 árum")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(2, "fyrir 2 árum")] + [InlineData(1, "fyrir einu ári")] + [InlineData(20, "fyrir 20 árum")] + [InlineData(30, "fyrir 30 árum")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "eftir 2 ár")] - [InlineData(1, "eftir eitt ár")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(2, "eftir 2 ár")] + [InlineData(1, "eftir eitt ár")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "núna")] - public void RightNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - } -} + [Theory] + [InlineData(0, "núna")] + public void RightNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/HeadingTests.cs b/src/Humanizer.Tests/Localisation/is/HeadingTests.cs index e27168451..76091ef9a 100644 --- a/src/Humanizer.Tests/Localisation/is/HeadingTests.cs +++ b/src/Humanizer.Tests/Localisation/is/HeadingTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +[UseCulture("is")] +public class HeadingTests { - [UseCulture("is")] - public class HeadingTests - { - [InlineData(0, "N")] - [InlineData(11.2, "N")] - [InlineData(11.3, "NNA")] - [InlineData(22.5, "NNA")] - [InlineData(33.7, "NNA")] - [InlineData(33.8, "NA")] - [InlineData(45, "NA")] - [InlineData(56.2, "NA")] - [InlineData(56.3, "ANA")] - [InlineData(67.5, "ANA")] - [InlineData(78.7, "ANA")] - [InlineData(78.8, "A")] - [InlineData(90, "A")] - [InlineData(101.2, "A")] - [InlineData(101.3, "ASA")] - [InlineData(112.5, "ASA")] - [InlineData(123.7, "ASA")] - [InlineData(123.8, "SA")] - [InlineData(135, "SA")] - [InlineData(146.2, "SA")] - [InlineData(146.3, "SSA")] - [InlineData(157.5, "SSA")] - [InlineData(168.7, "SSA")] - [InlineData(168.8, "S")] - [InlineData(180, "S")] - [InlineData(191.2, "S")] - [InlineData(191.3, "SSV")] - [InlineData(202.5, "SSV")] - [InlineData(213.7, "SSV")] - [InlineData(213.8, "SV")] - [InlineData(225, "SV")] - [InlineData(236.2, "SV")] - [InlineData(236.3, "VSV")] - [InlineData(247.5, "VSV")] - [InlineData(258.7, "VSV")] - [InlineData(258.8, "V")] - [InlineData(270, "V")] - [InlineData(281.2, "V")] - [InlineData(281.3, "VNV")] - [InlineData(292.5, "VNV")] - [InlineData(303.7, "VNV")] - [InlineData(303.8, "NV")] - [InlineData(315, "NV")] - [InlineData(326.2, "NV")] - [InlineData(326.3, "NNV")] - [InlineData(337.5, "NNV")] - [InlineData(348.7, "NNV")] - [InlineData(348.8, "N")] - [InlineData(720, "N")] - [Theory] - public void ToHeadingAbbreviated(double heading, string expected) => - Assert.Equal(expected, heading.ToHeading()); + [InlineData(0, "N")] + [InlineData(11.2, "N")] + [InlineData(11.3, "NNA")] + [InlineData(22.5, "NNA")] + [InlineData(33.7, "NNA")] + [InlineData(33.8, "NA")] + [InlineData(45, "NA")] + [InlineData(56.2, "NA")] + [InlineData(56.3, "ANA")] + [InlineData(67.5, "ANA")] + [InlineData(78.7, "ANA")] + [InlineData(78.8, "A")] + [InlineData(90, "A")] + [InlineData(101.2, "A")] + [InlineData(101.3, "ASA")] + [InlineData(112.5, "ASA")] + [InlineData(123.7, "ASA")] + [InlineData(123.8, "SA")] + [InlineData(135, "SA")] + [InlineData(146.2, "SA")] + [InlineData(146.3, "SSA")] + [InlineData(157.5, "SSA")] + [InlineData(168.7, "SSA")] + [InlineData(168.8, "S")] + [InlineData(180, "S")] + [InlineData(191.2, "S")] + [InlineData(191.3, "SSV")] + [InlineData(202.5, "SSV")] + [InlineData(213.7, "SSV")] + [InlineData(213.8, "SV")] + [InlineData(225, "SV")] + [InlineData(236.2, "SV")] + [InlineData(236.3, "VSV")] + [InlineData(247.5, "VSV")] + [InlineData(258.7, "VSV")] + [InlineData(258.8, "V")] + [InlineData(270, "V")] + [InlineData(281.2, "V")] + [InlineData(281.3, "VNV")] + [InlineData(292.5, "VNV")] + [InlineData(303.7, "VNV")] + [InlineData(303.8, "NV")] + [InlineData(315, "NV")] + [InlineData(326.2, "NV")] + [InlineData(326.3, "NNV")] + [InlineData(337.5, "NNV")] + [InlineData(348.7, "NNV")] + [InlineData(348.8, "N")] + [InlineData(720, "N")] + [Theory] + public void ToHeadingAbbreviated(double heading, string expected) => + Assert.Equal(expected, heading.ToHeading()); - [InlineData(0, "norður")] - [InlineData(45, "norðaustur")] - [InlineData(67.5, "austnorðaustur")] - [InlineData(90, "austur")] - [InlineData(112.5, "austsuðaustur")] - [InlineData(135, "suðaustur")] - [InlineData(157.5, "suðsuðaustur")] - [InlineData(180, "suður")] - [InlineData(202.5, "suðsuðvestur")] - [InlineData(225, "suðvestur")] - [InlineData(247.5, "vestsuðvestur")] - [InlineData(270, "vestur")] - [InlineData(292.5, "vestnorðvestur")] - [InlineData(315, "norðvestur")] - [InlineData(337.5, "norðnorðvestur")] - [InlineData(720, "norður")] - [Theory] - public void ToHeading(double heading, string expected) => - Assert.Equal(expected, heading.ToHeading(HeadingStyle.Full)); - } -} + [InlineData(0, "norður")] + [InlineData(45, "norðaustur")] + [InlineData(67.5, "austnorðaustur")] + [InlineData(90, "austur")] + [InlineData(112.5, "austsuðaustur")] + [InlineData(135, "suðaustur")] + [InlineData(157.5, "suðsuðaustur")] + [InlineData(180, "suður")] + [InlineData(202.5, "suðsuðvestur")] + [InlineData(225, "suðvestur")] + [InlineData(247.5, "vestsuðvestur")] + [InlineData(270, "vestur")] + [InlineData(292.5, "vestnorðvestur")] + [InlineData(315, "norðvestur")] + [InlineData(337.5, "norðnorðvestur")] + [InlineData(720, "norður")] + [Theory] + public void ToHeading(double heading, string expected) => + Assert.Equal(expected, heading.ToHeading(HeadingStyle.Full)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/is/NumberToWordsTests.cs index f2e801e38..ff167ea37 100644 --- a/src/Humanizer.Tests/Localisation/is/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/is/NumberToWordsTests.cs @@ -1,177 +1,176 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +[UseCulture("is")] +public class NumberToWordsTests { - [UseCulture("is")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "núll")] - [InlineData(1, "einn")] - [InlineData(-10, "mínus tíu")] - [InlineData(10, "tíu")] - [InlineData(11, "ellefu")] - [InlineData(122, "eitt hundrað tuttugu og tveir")] - [InlineData(3501, "þrjú þúsund fimm hundruð og einn")] - [InlineData(100, "eitt hundrað")] - [InlineData(1000, "eitt þúsund")] - [InlineData(100000, "eitt hundrað þúsund")] - [InlineData(1000000, "ein milljón")] - [InlineData(10000000, "tíu milljónir")] - [InlineData(100000000, "eitt hundrað milljónir")] - [InlineData(100000001L, "eitt hundrað milljónir og einn")] - [InlineData(100000001L, "eitt hundrað milljónir og ein", GrammaticalGender.Feminine)] - [InlineData(100000001L, "eitt hundrað milljónir og eitt", GrammaticalGender.Neuter)] - [InlineData(100000002L, "eitt hundrað milljónir og tveir")] - [InlineData(100001999L, "eitt hundrað milljónir eitt þúsund níu hundruð níutíu og níu")] - [InlineData(100002000L, "eitt hundrað milljónir og tvö þúsund")] - [InlineData(100002000L, "eitt hundrað milljónir og tvö þúsund", GrammaticalGender.Feminine)] - [InlineData(100002000L, "eitt hundrað milljónir og tvö þúsund", GrammaticalGender.Neuter)] - [InlineData(100002001L, "eitt hundrað milljónir tvö þúsund og einn")] - [InlineData(100002002L, "eitt hundrað milljónir tvö þúsund og tveir")] - [InlineData(100031999L, "eitt hundrað milljónir þrjátíu og eitt þúsund níu hundruð níutíu og níu")] - [InlineData(1000000000, "einn milljarður")] - [InlineData(111, "eitt hundrað og ellefu")] - [InlineData(1111, "eitt þúsund eitt hundrað og ellefu")] - [InlineData(111111, "eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] - [InlineData(1111111, "ein milljón eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] - [InlineData(11111111, "ellefu milljónir eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] - [InlineData(111111111, "eitt hundrað og ellefu milljónir eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] - [InlineData(1111111111, "einn milljarður eitt hundrað og ellefu milljónir eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] - [InlineData(10000000000L, "tíu milljarðar")] - [InlineData(10000000001L, "tíu milljarðar og einn")] - [InlineData(10000000002L, "tíu milljarðar og tveir")] - [InlineData(123, "eitt hundrað tuttugu og þrír")] - [InlineData(124, "eitt hundrað tuttugu og fjórir")] - [InlineData(1234, "eitt þúsund tvö hundruð þrjátíu og fjórir")] - [InlineData(12345, "tólf þúsund þrjú hundruð fjörutíu og fimm")] - [InlineData(123456, "eitt hundrað tuttugu og þrjú þúsund fjögur hundruð fimmtíu og sex")] - [InlineData(1234567, "ein milljón tvö hundruð þrjátíu og fjögur þúsund fimm hundruð sextíu og sjö")] - [InlineData(12345678, "tólf milljónir þrjú hundruð fjörutíu og fimm þúsund sex hundruð sjötíu og átta")] - [InlineData(123456789, "eitt hundrað tuttugu og þrjár milljónir fjögur hundruð fimmtíu og sex þúsund sjö hundruð áttatíu og níu")] - [InlineData(1234567890, "einn milljarður tvö hundruð þrjátíu og fjórar milljónir fimm hundruð sextíu og sjö þúsund átta hundruð og níutíu")] - [InlineData(1234567899, "einn milljarður tvö hundruð þrjátíu og fjórar milljónir fimm hundruð sextíu og sjö þúsund átta hundruð níutíu og níu")] - [InlineData(108, "eitt hundrað og átta")] - [InlineData(678, "sex hundruð sjötíu og átta")] - [InlineData(2013, "tvö þúsund og þrettán")] - [InlineData(2577, "tvö þúsund fimm hundruð sjötíu og sjö")] - [InlineData(17053980, "sautján milljónir fimmtíu og þrjú þúsund níu hundruð og áttatíu")] - [InlineData(415618, "fjögur hundruð og fimmtán þúsund sex hundruð og átján")] - [InlineData(16415618, "sextán milljónir fjögur hundruð og fimmtán þúsund sex hundruð og átján")] - [InlineData(322, "þrjú hundruð tuttugu og tveir")] - [InlineData(322, "þrjú hundruð tuttugu og tvær", GrammaticalGender.Feminine)] - public void IntToWords(long number, string expected, GrammaticalGender gender = GrammaticalGender.Masculine) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(0, "núll")] + [InlineData(1, "einn")] + [InlineData(-10, "mínus tíu")] + [InlineData(10, "tíu")] + [InlineData(11, "ellefu")] + [InlineData(122, "eitt hundrað tuttugu og tveir")] + [InlineData(3501, "þrjú þúsund fimm hundruð og einn")] + [InlineData(100, "eitt hundrað")] + [InlineData(1000, "eitt þúsund")] + [InlineData(100000, "eitt hundrað þúsund")] + [InlineData(1000000, "ein milljón")] + [InlineData(10000000, "tíu milljónir")] + [InlineData(100000000, "eitt hundrað milljónir")] + [InlineData(100000001L, "eitt hundrað milljónir og einn")] + [InlineData(100000001L, "eitt hundrað milljónir og ein", GrammaticalGender.Feminine)] + [InlineData(100000001L, "eitt hundrað milljónir og eitt", GrammaticalGender.Neuter)] + [InlineData(100000002L, "eitt hundrað milljónir og tveir")] + [InlineData(100001999L, "eitt hundrað milljónir eitt þúsund níu hundruð níutíu og níu")] + [InlineData(100002000L, "eitt hundrað milljónir og tvö þúsund")] + [InlineData(100002000L, "eitt hundrað milljónir og tvö þúsund", GrammaticalGender.Feminine)] + [InlineData(100002000L, "eitt hundrað milljónir og tvö þúsund", GrammaticalGender.Neuter)] + [InlineData(100002001L, "eitt hundrað milljónir tvö þúsund og einn")] + [InlineData(100002002L, "eitt hundrað milljónir tvö þúsund og tveir")] + [InlineData(100031999L, "eitt hundrað milljónir þrjátíu og eitt þúsund níu hundruð níutíu og níu")] + [InlineData(1000000000, "einn milljarður")] + [InlineData(111, "eitt hundrað og ellefu")] + [InlineData(1111, "eitt þúsund eitt hundrað og ellefu")] + [InlineData(111111, "eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] + [InlineData(1111111, "ein milljón eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] + [InlineData(11111111, "ellefu milljónir eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] + [InlineData(111111111, "eitt hundrað og ellefu milljónir eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] + [InlineData(1111111111, "einn milljarður eitt hundrað og ellefu milljónir eitt hundrað og ellefu þúsund eitt hundrað og ellefu")] + [InlineData(10000000000L, "tíu milljarðar")] + [InlineData(10000000001L, "tíu milljarðar og einn")] + [InlineData(10000000002L, "tíu milljarðar og tveir")] + [InlineData(123, "eitt hundrað tuttugu og þrír")] + [InlineData(124, "eitt hundrað tuttugu og fjórir")] + [InlineData(1234, "eitt þúsund tvö hundruð þrjátíu og fjórir")] + [InlineData(12345, "tólf þúsund þrjú hundruð fjörutíu og fimm")] + [InlineData(123456, "eitt hundrað tuttugu og þrjú þúsund fjögur hundruð fimmtíu og sex")] + [InlineData(1234567, "ein milljón tvö hundruð þrjátíu og fjögur þúsund fimm hundruð sextíu og sjö")] + [InlineData(12345678, "tólf milljónir þrjú hundruð fjörutíu og fimm þúsund sex hundruð sjötíu og átta")] + [InlineData(123456789, "eitt hundrað tuttugu og þrjár milljónir fjögur hundruð fimmtíu og sex þúsund sjö hundruð áttatíu og níu")] + [InlineData(1234567890, "einn milljarður tvö hundruð þrjátíu og fjórar milljónir fimm hundruð sextíu og sjö þúsund átta hundruð og níutíu")] + [InlineData(1234567899, "einn milljarður tvö hundruð þrjátíu og fjórar milljónir fimm hundruð sextíu og sjö þúsund átta hundruð níutíu og níu")] + [InlineData(108, "eitt hundrað og átta")] + [InlineData(678, "sex hundruð sjötíu og átta")] + [InlineData(2013, "tvö þúsund og þrettán")] + [InlineData(2577, "tvö þúsund fimm hundruð sjötíu og sjö")] + [InlineData(17053980, "sautján milljónir fimmtíu og þrjú þúsund níu hundruð og áttatíu")] + [InlineData(415618, "fjögur hundruð og fimmtán þúsund sex hundruð og átján")] + [InlineData(16415618, "sextán milljónir fjögur hundruð og fimmtán þúsund sex hundruð og átján")] + [InlineData(322, "þrjú hundruð tuttugu og tveir")] + [InlineData(322, "þrjú hundruð tuttugu og tvær", GrammaticalGender.Feminine)] + public void IntToWords(long number, string expected, GrammaticalGender gender = GrammaticalGender.Masculine) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(100_000_000_000L, "eitt hundrað milljarðar")] - [InlineData(1_000_000_000_000L, "ein billjón")] - [InlineData(100_000_000_000_000L, "eitt hundrað billjónir")] - [InlineData(1_000_000_000_000_000L, "einn billjarður")] - [InlineData(100_000_000_000_000_000L, "eitt hundrað billjarðar")] - [InlineData(1_000_000_000_000_000_000L, "ein trilljón")] - [InlineData(9_223_372_036_854_775_807L, "níu trilljónir tvö hundruð tuttugu og þrír billjarðar þrjú hundruð sjötíu og tvær billjónir þrjátíu og sex milljarðar átta hundruð fimmtíu og fjórar milljónir sjö hundruð sjötíu og fimm þúsund átta hundruð og sjö")] - public void LongToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(100_000_000_000L, "eitt hundrað milljarðar")] + [InlineData(1_000_000_000_000L, "ein billjón")] + [InlineData(100_000_000_000_000L, "eitt hundrað billjónir")] + [InlineData(1_000_000_000_000_000L, "einn billjarður")] + [InlineData(100_000_000_000_000_000L, "eitt hundrað billjarðar")] + [InlineData(1_000_000_000_000_000_000L, "ein trilljón")] + [InlineData(9_223_372_036_854_775_807L, "níu trilljónir tvö hundruð tuttugu og þrír billjarðar þrjú hundruð sjötíu og tvær billjónir þrjátíu og sex milljarðar átta hundruð fimmtíu og fjórar milljónir sjö hundruð sjötíu og fimm þúsund átta hundruð og sjö")] + public void LongToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "núllti")] - [InlineData(1, "fyrsti")] - [InlineData(2, "annar", GrammaticalGender.Masculine)] - [InlineData(2, "önnur", GrammaticalGender.Feminine)] - [InlineData(2, "annað", GrammaticalGender.Neuter)] - [InlineData(3, "þriðji")] - [InlineData(4, "fjórði")] - [InlineData(5, "fimmti")] - [InlineData(5, "fimmta", GrammaticalGender.Neuter)] - [InlineData(6, "sjötti")] - [InlineData(7, "sjöundi")] - [InlineData(8, "áttundi")] - [InlineData(9, "níundi")] - [InlineData(10, "tíundi")] - [InlineData(11, "ellefti")] - [InlineData(12, "tólfti")] - [InlineData(13, "þrettándi")] - [InlineData(14, "fjórtándi")] - [InlineData(15, "fimmtándi")] - [InlineData(16, "sextándi")] - [InlineData(17, "sautjándi")] - [InlineData(18, "átjándi")] - [InlineData(19, "nítjándi")] - [InlineData(6, "sjötta", GrammaticalGender.Feminine)] - [InlineData(7, "sjöunda", GrammaticalGender.Feminine)] - [InlineData(8, "áttunda", GrammaticalGender.Feminine)] - [InlineData(9, "níunda", GrammaticalGender.Feminine)] - [InlineData(10, "tíunda", GrammaticalGender.Feminine)] - [InlineData(11, "ellefta", GrammaticalGender.Feminine)] - [InlineData(12, "tólfta", GrammaticalGender.Feminine)] - [InlineData(13, "þrettánda", GrammaticalGender.Feminine)] - [InlineData(14, "fjórtánda", GrammaticalGender.Feminine)] - [InlineData(15, "fimmtánda", GrammaticalGender.Feminine)] - [InlineData(16, "sextánda", GrammaticalGender.Feminine)] - [InlineData(17, "sautjánda", GrammaticalGender.Feminine)] - [InlineData(18, "átjánda", GrammaticalGender.Feminine)] - [InlineData(19, "nítjánda", GrammaticalGender.Feminine)] - [InlineData(20, "tuttugasti")] - [InlineData(21, "tuttugasti og fyrsti")] - [InlineData(22, "tuttugasti og annar")] - [InlineData(30, "þrítugasti")] - [InlineData(40, "fertugasti")] - [InlineData(50, "fimmtugasti")] - [InlineData(60, "sextugasti")] - [InlineData(70, "sjötugasti")] - [InlineData(80, "áttugasti")] - [InlineData(90, "nítugasti")] - [InlineData(95, "nítugasti og fimmti")] - [InlineData(96, "nítugasti og sjötti")] - [InlineData(44, "fertugasta og fjórða", GrammaticalGender.Feminine)] - [InlineData(44, "fertugasti og fjórði")] - [InlineData(77, "sjötugasti og sjöundi")] - [InlineData(87, "áttugasta og sjöunda", GrammaticalGender.Feminine)] - [InlineData(99, "nítugasta og níunda", GrammaticalGender.Neuter)] - [InlineData(100, "eitt hundraðasti")] - [InlineData(101, "eitt hundraðasti og fyrsti")] - [InlineData(106, "eitt hundraðasti og sjötti")] - [InlineData(108, "eitt hundraðasti og áttundi")] - [InlineData(112, "eitt hundraðasti og tólfti")] - [InlineData(119, "eitt hundraðasti og nítjándi")] - [InlineData(120, "eitt hundrað og tuttugasti")] - [InlineData(121, "eitt hundrað tuttugasti og fyrsti")] - [InlineData(130, "eitt hundrað og þrítugasti")] - [InlineData(131, "eitt hundrað þrítugasti og fyrsti")] - [InlineData(1000, "eitt þúsundasta", GrammaticalGender.Feminine)] - [InlineData(1001, "eitt þúsundasti og fyrsti")] - [InlineData(1005, "eitt þúsundasti og fimmti")] - [InlineData(1008, "eitt þúsundasti og áttundi")] - [InlineData(1012, "eitt þúsundasti og tólfti")] - [InlineData(1021, "eitt þúsund tuttugasti og fyrsti")] - [InlineData(10000, "tíu þúsundasti")] - [InlineData(10121, "tíu þúsund eitt hundrað tuttugasti og fyrsti")] - [InlineData(100000, "eitt hundrað þúsundasti")] - [InlineData(100001, "eitt hundrað þúsundasti og fyrsti")] - [InlineData(1000000, "ein milljónasti")] - [InlineData(2000000, "tvær milljónasti")] // https://www.mbl.is/frettir/innlent/2012/12/19/tvo_milljonasti_eda_tvimilljonasti/ - [InlineData(1530, "eitt þúsund fimm hundruð og þrítugasti")] - [InlineData(530, "fimm hundruð og þrítugasti")] - [InlineData(2070, "tvö þúsund og sjötugasti")] - [InlineData(4444, "fjögur þúsund fjögur hundruð fertugasti og fjórði")] - [InlineData(267, "tvö hundruð sextugasti og sjöundi")] - [InlineData(700, "sjö hundruðasti")] - [InlineData(707, "sjö hundruðasti og sjöundi")] - [InlineData(717, "sjö hundruðasti og sautjándi")] - [InlineData(777, "sjö hundruð sjötugasti og sjöundi")] - [InlineData(3019, "þrjú þúsundasti og nítjándi")] - [InlineData(5315, "fimm þúsund þrjú hundruðasti og fimmtándi")] - [InlineData(6471, "sex þúsund fjögur hundruð sjötugasti og fyrsti")] - [InlineData(7000, "sjö þúsundasti")] - [InlineData(7007, "sjö þúsundasti og sjöundi")] - [InlineData(7017, "sjö þúsundasti og sautjándi")] - [InlineData(7777, "sjö þúsund sjö hundruð sjötugasti og sjöundi")] - [InlineData(5315, "fimm þúsund þrjú hundruðasta og fimmtánda", GrammaticalGender.Feminine)] - [InlineData(1044, "eitt þúsund fertugasti og fjórði")] - [InlineData(315, "þrjú hundruðasti og fimmtándi")] - [InlineData(777, "sjö hundruð sjötugasta og sjöunda", GrammaticalGender.Neuter)] - [InlineData(102000, "eitt hundrað og tvö þúsundasti")] - [InlineData(1002000, "ein milljón og tvö þúsundasti")] - public void ToOrdinalWords(int number, string words, GrammaticalGender gender = GrammaticalGender.Masculine) => - Assert.Equal(words, number.ToOrdinalWords(gender)); - } -} + [Theory] + [InlineData(0, "núllti")] + [InlineData(1, "fyrsti")] + [InlineData(2, "annar", GrammaticalGender.Masculine)] + [InlineData(2, "önnur", GrammaticalGender.Feminine)] + [InlineData(2, "annað", GrammaticalGender.Neuter)] + [InlineData(3, "þriðji")] + [InlineData(4, "fjórði")] + [InlineData(5, "fimmti")] + [InlineData(5, "fimmta", GrammaticalGender.Neuter)] + [InlineData(6, "sjötti")] + [InlineData(7, "sjöundi")] + [InlineData(8, "áttundi")] + [InlineData(9, "níundi")] + [InlineData(10, "tíundi")] + [InlineData(11, "ellefti")] + [InlineData(12, "tólfti")] + [InlineData(13, "þrettándi")] + [InlineData(14, "fjórtándi")] + [InlineData(15, "fimmtándi")] + [InlineData(16, "sextándi")] + [InlineData(17, "sautjándi")] + [InlineData(18, "átjándi")] + [InlineData(19, "nítjándi")] + [InlineData(6, "sjötta", GrammaticalGender.Feminine)] + [InlineData(7, "sjöunda", GrammaticalGender.Feminine)] + [InlineData(8, "áttunda", GrammaticalGender.Feminine)] + [InlineData(9, "níunda", GrammaticalGender.Feminine)] + [InlineData(10, "tíunda", GrammaticalGender.Feminine)] + [InlineData(11, "ellefta", GrammaticalGender.Feminine)] + [InlineData(12, "tólfta", GrammaticalGender.Feminine)] + [InlineData(13, "þrettánda", GrammaticalGender.Feminine)] + [InlineData(14, "fjórtánda", GrammaticalGender.Feminine)] + [InlineData(15, "fimmtánda", GrammaticalGender.Feminine)] + [InlineData(16, "sextánda", GrammaticalGender.Feminine)] + [InlineData(17, "sautjánda", GrammaticalGender.Feminine)] + [InlineData(18, "átjánda", GrammaticalGender.Feminine)] + [InlineData(19, "nítjánda", GrammaticalGender.Feminine)] + [InlineData(20, "tuttugasti")] + [InlineData(21, "tuttugasti og fyrsti")] + [InlineData(22, "tuttugasti og annar")] + [InlineData(30, "þrítugasti")] + [InlineData(40, "fertugasti")] + [InlineData(50, "fimmtugasti")] + [InlineData(60, "sextugasti")] + [InlineData(70, "sjötugasti")] + [InlineData(80, "áttugasti")] + [InlineData(90, "nítugasti")] + [InlineData(95, "nítugasti og fimmti")] + [InlineData(96, "nítugasti og sjötti")] + [InlineData(44, "fertugasta og fjórða", GrammaticalGender.Feminine)] + [InlineData(44, "fertugasti og fjórði")] + [InlineData(77, "sjötugasti og sjöundi")] + [InlineData(87, "áttugasta og sjöunda", GrammaticalGender.Feminine)] + [InlineData(99, "nítugasta og níunda", GrammaticalGender.Neuter)] + [InlineData(100, "eitt hundraðasti")] + [InlineData(101, "eitt hundraðasti og fyrsti")] + [InlineData(106, "eitt hundraðasti og sjötti")] + [InlineData(108, "eitt hundraðasti og áttundi")] + [InlineData(112, "eitt hundraðasti og tólfti")] + [InlineData(119, "eitt hundraðasti og nítjándi")] + [InlineData(120, "eitt hundrað og tuttugasti")] + [InlineData(121, "eitt hundrað tuttugasti og fyrsti")] + [InlineData(130, "eitt hundrað og þrítugasti")] + [InlineData(131, "eitt hundrað þrítugasti og fyrsti")] + [InlineData(1000, "eitt þúsundasta", GrammaticalGender.Feminine)] + [InlineData(1001, "eitt þúsundasti og fyrsti")] + [InlineData(1005, "eitt þúsundasti og fimmti")] + [InlineData(1008, "eitt þúsundasti og áttundi")] + [InlineData(1012, "eitt þúsundasti og tólfti")] + [InlineData(1021, "eitt þúsund tuttugasti og fyrsti")] + [InlineData(10000, "tíu þúsundasti")] + [InlineData(10121, "tíu þúsund eitt hundrað tuttugasti og fyrsti")] + [InlineData(100000, "eitt hundrað þúsundasti")] + [InlineData(100001, "eitt hundrað þúsundasti og fyrsti")] + [InlineData(1000000, "ein milljónasti")] + [InlineData(2000000, "tvær milljónasti")] // https://www.mbl.is/frettir/innlent/2012/12/19/tvo_milljonasti_eda_tvimilljonasti/ + [InlineData(1530, "eitt þúsund fimm hundruð og þrítugasti")] + [InlineData(530, "fimm hundruð og þrítugasti")] + [InlineData(2070, "tvö þúsund og sjötugasti")] + [InlineData(4444, "fjögur þúsund fjögur hundruð fertugasti og fjórði")] + [InlineData(267, "tvö hundruð sextugasti og sjöundi")] + [InlineData(700, "sjö hundruðasti")] + [InlineData(707, "sjö hundruðasti og sjöundi")] + [InlineData(717, "sjö hundruðasti og sautjándi")] + [InlineData(777, "sjö hundruð sjötugasti og sjöundi")] + [InlineData(3019, "þrjú þúsundasti og nítjándi")] + [InlineData(5315, "fimm þúsund þrjú hundruðasti og fimmtándi")] + [InlineData(6471, "sex þúsund fjögur hundruð sjötugasti og fyrsti")] + [InlineData(7000, "sjö þúsundasti")] + [InlineData(7007, "sjö þúsundasti og sjöundi")] + [InlineData(7017, "sjö þúsundasti og sautjándi")] + [InlineData(7777, "sjö þúsund sjö hundruð sjötugasti og sjöundi")] + [InlineData(5315, "fimm þúsund þrjú hundruðasta og fimmtánda", GrammaticalGender.Feminine)] + [InlineData(1044, "eitt þúsund fertugasti og fjórði")] + [InlineData(315, "þrjú hundruðasti og fimmtándi")] + [InlineData(777, "sjö hundruð sjötugasta og sjöunda", GrammaticalGender.Neuter)] + [InlineData(102000, "eitt hundrað og tvö þúsundasti")] + [InlineData(1002000, "ein milljón og tvö þúsundasti")] + public void ToOrdinalWords(int number, string words, GrammaticalGender gender = GrammaticalGender.Masculine) => + Assert.Equal(words, number.ToOrdinalWords(gender)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/is/OrdinalizeTests.cs index dcd809256..683111147 100644 --- a/src/Humanizer.Tests/Localisation/is/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/is/OrdinalizeTests.cs @@ -1,23 +1,22 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +[UseCulture("is")] +public class OrdinalizeTests { - [UseCulture("is")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0.")] - [InlineData("1", "1.")] - [InlineData("2", "2.")] - [InlineData("3", "3.")] - [InlineData("4", "4.")] - [InlineData("5", "5.")] - [InlineData("6", "6.")] - [InlineData("23", "23.")] - [InlineData("100", "100.")] - [InlineData("101", "101.")] - [InlineData("102", "102.")] - [InlineData("103", "103.")] - [InlineData("1001", "1001.")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(ordinalized, number.Ordinalize()); - } -} + [Theory] + [InlineData("0", "0.")] + [InlineData("1", "1.")] + [InlineData("2", "2.")] + [InlineData("3", "3.")] + [InlineData("4", "4.")] + [InlineData("5", "5.")] + [InlineData("6", "6.")] + [InlineData("23", "23.")] + [InlineData("100", "100.")] + [InlineData("101", "101.")] + [InlineData("102", "102.")] + [InlineData("103", "103.")] + [InlineData("1001", "1001.")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(ordinalized, number.Ordinalize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/ResourcesTests.cs b/src/Humanizer.Tests/Localisation/is/ResourcesTests.cs index 8a6766f6f..d6773b180 100644 --- a/src/Humanizer.Tests/Localisation/is/ResourcesTests.cs +++ b/src/Humanizer.Tests/Localisation/is/ResourcesTests.cs @@ -1,20 +1,19 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +public class ResourcesTests { - public class ResourcesTests + [Fact] + [UseCulture("is")] + public void GetCultureSpecificTranslationsWithImplicitCulture() { - [Fact] - [UseCulture("is")] - public void GetCultureSpecificTranslationsWithImplicitCulture() - { - var format = Resources.GetResource("DateHumanize_MultipleYearsAgo"); - Assert.Equal("fyrir {0} árum", format); - } + var format = Resources.GetResource("DateHumanize_MultipleYearsAgo"); + Assert.Equal("fyrir {0} árum", format); + } - [Fact] - public void GetCultureSpecificTranslationsWithExplicitCulture() - { - var format = Resources.GetResource("DateHumanize_SingleYearAgo", new("is")); - Assert.Equal("fyrir einu ári", format); - } + [Fact] + public void GetCultureSpecificTranslationsWithExplicitCulture() + { + var format = Resources.GetResource("DateHumanize_SingleYearAgo", new("is")); + Assert.Equal("fyrir einu ári", format); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/is/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/is/TimeSpanHumanizeTests.cs index 14aba65a0..adaec0199 100644 --- a/src/Humanizer.Tests/Localisation/is/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/is/TimeSpanHumanizeTests.cs @@ -1,135 +1,134 @@ -namespace Humanizer.Tests.Localisation.@is +namespace Humanizer.Tests.Localisation.@is; + +[UseCulture("is")] +public class TimeSpanHumanizeTests { - [UseCulture("is")] - public class TimeSpanHumanizeTests + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 ár")] + [InlineData(731, "2 ár")] + [InlineData(1096, "3 ár")] + [InlineData(4018, "11 ár")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "eitt ár")] + [InlineData(731, "tvö ár")] + [InlineData(1096, "þrjú ár")] + [InlineData(4018, "ellefu ár")] + public void YearsToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 mánuður")] + [InlineData(61, "2 mánuðir")] + [InlineData(92, "3 mánuðir")] + [InlineData(335, "11 mánuðir")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "einn mánuður")] + [InlineData(61, "tveir mánuðir")] + [InlineData(92, "þrír mánuðir")] + [InlineData(335, "ellefu mánuðir")] + public void MonthsToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); + + [Theory] + [InlineData(7, "ein vika")] + [InlineData(14, "2 vikur")] + [InlineData(21, "3 vikur")] + [InlineData(77, "11 vikur")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + + [Theory] + [InlineData(7, "ein vika")] + [InlineData(14, "tvær vikur")] + [InlineData(21, "þrjár vikur")] + [InlineData(77, "ellefu vikur")] + public void WeeksToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "einn dagur")] + [InlineData(2, "2 dagar")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + + [Theory] + [InlineData(1, "einn dagur")] + [InlineData(2, "tveir dagar")] + public void DaysToWords(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "ein klukkustund")] + [InlineData(2, "2 klukkustundir")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + + [Theory] + [InlineData(1, "ein klukkustund")] + [InlineData(2, "tvær klukkustundir")] + public void HoursToWords(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "ein mínúta")] + [InlineData(2, "2 mínútur")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + + [Theory] + [InlineData(1, "ein mínúta")] + [InlineData(2, "tvær mínútur")] + public void MinutesToWords(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "ein sekúnda")] + [InlineData(2, "2 sekúndur")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + + [Theory] + [InlineData(1, "ein sekúnda")] + [InlineData(2, "tvær sekúndur")] + public void SecondsToWords(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: true)); + + [Theory] + [InlineData(1, "ein millisekúnda")] + [InlineData(2, "2 millisekúndur")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + + [Theory] + [InlineData(1, "ein millisekúnda")] + [InlineData(2, "tvær millisekúndur")] + public void MillisecondsToWords(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: true)); + + [Fact] + public void NoTime() => + Assert.Equal("0 millisekúndur", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("engin stund", TimeSpan.Zero.Humanize(toWords: true)); + + [Theory] + [InlineData(1299630020, 5, "tvær vikur, einn dagur, ein klukkustund, þrjátíu sekúndur, tuttugu millisekúndur")] + public void TimeSpanWithNumbersConvertedToWords(int milliseconds, int precision, string expected) { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 ár")] - [InlineData(731, "2 ár")] - [InlineData(1096, "3 ár")] - [InlineData(4018, "11 ár")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "eitt ár")] - [InlineData(731, "tvö ár")] - [InlineData(1096, "þrjú ár")] - [InlineData(4018, "ellefu ár")] - public void YearsToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 mánuður")] - [InlineData(61, "2 mánuðir")] - [InlineData(92, "3 mánuðir")] - [InlineData(335, "11 mánuðir")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "einn mánuður")] - [InlineData(61, "tveir mánuðir")] - [InlineData(92, "þrír mánuðir")] - [InlineData(335, "ellefu mánuðir")] - public void MonthsToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year,toWords:true)); - - [Theory] - [InlineData(7, "ein vika")] - [InlineData(14, "2 vikur")] - [InlineData(21, "3 vikur")] - [InlineData(77, "11 vikur")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - - [Theory] - [InlineData(7, "ein vika")] - [InlineData(14, "tvær vikur")] - [InlineData(21, "þrjár vikur")] - [InlineData(77, "ellefu vikur")] - public void WeeksToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "einn dagur")] - [InlineData(2, "2 dagar")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - - [Theory] - [InlineData(1, "einn dagur")] - [InlineData(2, "tveir dagar")] - public void DaysToWords(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "ein klukkustund")] - [InlineData(2, "2 klukkustundir")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - - [Theory] - [InlineData(1, "ein klukkustund")] - [InlineData(2, "tvær klukkustundir")] - public void HoursToWords(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "ein mínúta")] - [InlineData(2, "2 mínútur")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - - [Theory] - [InlineData(1, "ein mínúta")] - [InlineData(2, "tvær mínútur")] - public void MinutesToWords(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "ein sekúnda")] - [InlineData(2, "2 sekúndur")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - - [Theory] - [InlineData(1, "ein sekúnda")] - [InlineData(2, "tvær sekúndur")] - public void SecondsToWords(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: true)); - - [Theory] - [InlineData(1, "ein millisekúnda")] - [InlineData(2, "2 millisekúndur")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - - [Theory] - [InlineData(1, "ein millisekúnda")] - [InlineData(2, "tvær millisekúndur")] - public void MillisecondsToWords(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: true)); - - [Fact] - public void NoTime() => - Assert.Equal("0 millisekúndur", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("engin stund", TimeSpan.Zero.Humanize(toWords: true)); - - [Theory] - [InlineData(1299630020, 5, "tvær vikur, einn dagur, ein klukkustund, þrjátíu sekúndur, tuttugu millisekúndur")] - public void TimeSpanWithNumbersConvertedToWords(int milliseconds, int precision, string expected) - { var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, toWords: true); Assert.Equal(expected, actual); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/it/CollectionFormatterTests.cs b/src/Humanizer.Tests/Localisation/it/CollectionFormatterTests.cs index 9a0b53082..5cdaa8f65 100644 --- a/src/Humanizer.Tests/Localisation/it/CollectionFormatterTests.cs +++ b/src/Humanizer.Tests/Localisation/it/CollectionFormatterTests.cs @@ -1,30 +1,29 @@ -namespace Humanizer.Tests.Localisation.it +namespace Humanizer.Tests.Localisation.it; + +[UseCulture("it")] +public class CollectionFormatterTests { - [UseCulture("it")] - public class CollectionFormatterTests + [Fact] + public void OneItem() { - [Fact] - public void OneItem() - { var collection = new List(new[] { 1 }); var humanized = "1"; Assert.Equal(humanized, collection.Humanize()); } - [Fact] - public void TwoItems() - { + [Fact] + public void TwoItems() + { var collection = new List(new[] { 1, 2 }); var humanized = "1 e 2"; Assert.Equal(humanized, collection.Humanize()); } - [Fact] - public void MoreThanTwoItems() - { + [Fact] + public void MoreThanTwoItems() + { var collection = new List(new[] { 1, 2, 3 }); var humanized = "1, 2 e 3"; Assert.Equal(humanized, collection.Humanize()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/it/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/it/DateHumanizeTests.cs index 196123be4..361e030b2 100644 --- a/src/Humanizer.Tests/Localisation/it/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/it/DateHumanizeTests.cs @@ -1,84 +1,83 @@ -namespace Humanizer.Tests.Localisation.it +namespace Humanizer.Tests.Localisation.it; + +[UseCulture("it")] +public class DateHumanizeTests { - [UseCulture("it")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "2 giorni fa")] - [InlineData(-1, "ieri")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "2 giorni fa")] + [InlineData(-1, "ieri")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "tra 2 giorni")] - [InlineData(1, "domani")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "tra 2 giorni")] + [InlineData(1, "domani")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-2, "2 ore fa")] - [InlineData(-1, "un'ora fa")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "2 ore fa")] + [InlineData(-1, "un'ora fa")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "tra 2 ore")] - [InlineData(1, "tra un'ora")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "tra 2 ore")] + [InlineData(1, "tra un'ora")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 minuti fa")] - [InlineData(-1, "un minuto fa")] - [InlineData(60, "un'ora fa")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 minuti fa")] + [InlineData(-1, "un minuto fa")] + [InlineData(60, "un'ora fa")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "tra 2 minuti")] - [InlineData(1, "tra un minuto")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "tra 2 minuti")] + [InlineData(1, "tra un minuto")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 mesi fa")] - [InlineData(-1, "un mese fa")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 mesi fa")] + [InlineData(-1, "un mese fa")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "tra 2 mesi")] - [InlineData(1, "tra un mese")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "tra 2 mesi")] + [InlineData(1, "tra un mese")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 secondi fa")] - [InlineData(-1, "un secondo fa")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 secondi fa")] + [InlineData(-1, "un secondo fa")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "tra 2 secondi")] - [InlineData(1, "tra un secondo")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "tra 2 secondi")] + [InlineData(1, "tra un secondo")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 anni fa")] - [InlineData(-1, "un anno fa")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 anni fa")] + [InlineData(-1, "un anno fa")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "tra 2 anni")] - [InlineData(1, "tra un anno")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(2, "tra 2 anni")] + [InlineData(1, "tra un anno")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "adesso")] - public void Now(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(0, "adesso")] + public void Now(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/it/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/it/NumberToWordsTests.cs index bea8e9646..96ef2134f 100644 --- a/src/Humanizer.Tests/Localisation/it/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/it/NumberToWordsTests.cs @@ -1,194 +1,193 @@ -namespace Humanizer.Tests.Localisation.it +namespace Humanizer.Tests.Localisation.it; + +[UseCulture("it")] +public class NumberToWordsTests { - [UseCulture("it")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "uno")] - [InlineData(-1, "meno uno")] - [InlineData(3, "tre")] - [InlineData(10, "dieci")] - [InlineData(11, "undici")] - [InlineData(21, "ventuno")] - [InlineData(38, "trentotto")] - [InlineData(122, "centoventidue")] - [InlineData(3501, "tremilacinquecentouno")] - [InlineData(-3501, "meno tremilacinquecentouno")] - [InlineData(100, "cento")] - [InlineData(1000, "mille")] - [InlineData(2000, "duemila")] - [InlineData(10000, "diecimila")] - [InlineData(100000, "centomila")] - [InlineData(1000000, "un milione")] - [InlineData(5000000, "cinque milioni")] - [InlineData(10000000, "dieci milioni")] - [InlineData(100000000, "cento milioni")] - [InlineData(1000000000, "un miliardo")] - [InlineData(2000000000, "due miliardi")] - [InlineData(2147483647, "due miliardi centoquarantasette milioni quattrocentoottantatremilaseicentoquarantasette")] // int.MaxValue - //[InlineData(9000000000, "nove miliardi")] // int = System.Int32, fixed in API, is not big enough - //[InlineData(10000000000, "dieci miliardi")] // int = System.Int32, fixed in API, is not big enough - //[InlineData(100000000000, "cento miliardi")] // int = System.Int32, fixed in API, is not big enough - [InlineData(101, "centouno")] - [InlineData(1001, "milleuno")] - [InlineData(10001, "diecimilauno")] - [InlineData(100001, "centomilauno")] - [InlineData(1000001, "un milione uno")] - [InlineData(10000001, "dieci milioni uno")] - [InlineData(100000001, "cento milioni uno")] - [InlineData(1000000001, "un miliardo uno")] - [InlineData(111, "centoundici")] - [InlineData(1111, "millecentoundici")] - [InlineData(111111, "centoundicimilacentoundici")] - [InlineData(1111101, "un milione centoundicimilacentouno")] - [InlineData(1111111, "un milione centoundicimilacentoundici")] - [InlineData(11111111, "undici milioni centoundicimilacentoundici")] - [InlineData(111111111, "centoundici milioni centoundicimilacentoundici")] - [InlineData(1101111101, "un miliardo centouno milioni centoundicimilacentouno")] - [InlineData(1111111111, "un miliardo centoundici milioni centoundicimilacentoundici")] - [InlineData(8100, "ottomilacento")] - [InlineData(43, "quarantatré")] // Ref. http://dizionari.corriere.it/dizionario-si-dice/V/ventitre.shtml - [InlineData(123, "centoventitré")] - [InlineData(1234, "milleduecentotrentaquattro")] - [InlineData(12345, "dodicimilatrecentoquarantacinque")] - [InlineData(123456, "centoventitremilaquattrocentocinquantasei")] - [InlineData(1234567, "un milione duecentotrentaquattromilacinquecentosessantasette")] - [InlineData(12345678, "dodici milioni trecentoquarantacinquemilaseicentosettantotto")] - [InlineData(123456789, "centoventitré milioni quattrocentocinquantaseimilasettecentoottantanove")] - [InlineData(1234567890, "un miliardo duecentotrentaquattro milioni cinquecentosessantasettemilaottocentonovanta")] - [InlineData(1999, "millenovecentonovantanove")] - [InlineData(2014, "duemilaquattordici")] - [InlineData(2048, "duemilaquarantotto")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "uno")] + [InlineData(-1, "meno uno")] + [InlineData(3, "tre")] + [InlineData(10, "dieci")] + [InlineData(11, "undici")] + [InlineData(21, "ventuno")] + [InlineData(38, "trentotto")] + [InlineData(122, "centoventidue")] + [InlineData(3501, "tremilacinquecentouno")] + [InlineData(-3501, "meno tremilacinquecentouno")] + [InlineData(100, "cento")] + [InlineData(1000, "mille")] + [InlineData(2000, "duemila")] + [InlineData(10000, "diecimila")] + [InlineData(100000, "centomila")] + [InlineData(1000000, "un milione")] + [InlineData(5000000, "cinque milioni")] + [InlineData(10000000, "dieci milioni")] + [InlineData(100000000, "cento milioni")] + [InlineData(1000000000, "un miliardo")] + [InlineData(2000000000, "due miliardi")] + [InlineData(2147483647, "due miliardi centoquarantasette milioni quattrocentoottantatremilaseicentoquarantasette")] // int.MaxValue + //[InlineData(9000000000, "nove miliardi")] // int = System.Int32, fixed in API, is not big enough + //[InlineData(10000000000, "dieci miliardi")] // int = System.Int32, fixed in API, is not big enough + //[InlineData(100000000000, "cento miliardi")] // int = System.Int32, fixed in API, is not big enough + [InlineData(101, "centouno")] + [InlineData(1001, "milleuno")] + [InlineData(10001, "diecimilauno")] + [InlineData(100001, "centomilauno")] + [InlineData(1000001, "un milione uno")] + [InlineData(10000001, "dieci milioni uno")] + [InlineData(100000001, "cento milioni uno")] + [InlineData(1000000001, "un miliardo uno")] + [InlineData(111, "centoundici")] + [InlineData(1111, "millecentoundici")] + [InlineData(111111, "centoundicimilacentoundici")] + [InlineData(1111101, "un milione centoundicimilacentouno")] + [InlineData(1111111, "un milione centoundicimilacentoundici")] + [InlineData(11111111, "undici milioni centoundicimilacentoundici")] + [InlineData(111111111, "centoundici milioni centoundicimilacentoundici")] + [InlineData(1101111101, "un miliardo centouno milioni centoundicimilacentouno")] + [InlineData(1111111111, "un miliardo centoundici milioni centoundicimilacentoundici")] + [InlineData(8100, "ottomilacento")] + [InlineData(43, "quarantatré")] // Ref. http://dizionari.corriere.it/dizionario-si-dice/V/ventitre.shtml + [InlineData(123, "centoventitré")] + [InlineData(1234, "milleduecentotrentaquattro")] + [InlineData(12345, "dodicimilatrecentoquarantacinque")] + [InlineData(123456, "centoventitremilaquattrocentocinquantasei")] + [InlineData(1234567, "un milione duecentotrentaquattromilacinquecentosessantasette")] + [InlineData(12345678, "dodici milioni trecentoquarantacinquemilaseicentosettantotto")] + [InlineData(123456789, "centoventitré milioni quattrocentocinquantaseimilasettecentoottantanove")] + [InlineData(1234567890, "un miliardo duecentotrentaquattro milioni cinquecentosessantasettemilaottocentonovanta")] + [InlineData(1999, "millenovecentonovantanove")] + [InlineData(2014, "duemilaquattordici")] + [InlineData(2048, "duemilaquarantotto")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "una")] - [InlineData(-1, "meno una")] - [InlineData(3, "tre")] - [InlineData(21, "ventuno")] - [InlineData(101, "centouno")] - [InlineData(1001, "milleuno")] - [InlineData(10001, "diecimilauno")] - [InlineData(100001, "centomilauno")] - public void ToFeminineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "una")] + [InlineData(-1, "meno una")] + [InlineData(3, "tre")] + [InlineData(21, "ventuno")] + [InlineData(101, "centouno")] + [InlineData(1001, "milleuno")] + [InlineData(10001, "diecimilauno")] + [InlineData(100001, "centomilauno")] + public void ToFeminineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "uno")] - [InlineData(-1, "meno uno")] - [InlineData(3, "tre")] - [InlineData(21, "ventuno")] - [InlineData(101, "centouno")] - [InlineData(1001, "milleuno")] - [InlineData(10001, "diecimilauno")] - [InlineData(100001, "centomilauno")] - public void ToMasculineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "uno")] + [InlineData(-1, "meno uno")] + [InlineData(3, "tre")] + [InlineData(21, "ventuno")] + [InlineData(101, "centouno")] + [InlineData(1001, "milleuno")] + [InlineData(10001, "diecimilauno")] + [InlineData(100001, "centomilauno")] + public void ToMasculineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primo")] - [InlineData(2, "secondo")] - [InlineData(9, "nono")] - [InlineData(10, "decimo")] - [InlineData(11, "undicesimo")] - [InlineData(15, "quindicesimo")] - [InlineData(18, "diciottesimo")] - [InlineData(20, "ventesimo")] - [InlineData(21, "ventunesimo")] - [InlineData(22, "ventiduesimo")] - [InlineData(28, "ventottesimo")] - [InlineData(30, "trentesimo")] - [InlineData(44, "quarantaquattresimo")] - [InlineData(55, "cinquantacinquesimo")] - [InlineData(60, "sessantesimo")] - [InlineData(63, "sessantatreesimo")] - [InlineData(66, "sessantaseiesimo")] - [InlineData(77, "settantasettesimo")] - [InlineData(88, "ottantottesimo")] - [InlineData(99, "novantanovesimo")] - [InlineData(100, "centesimo")] - [InlineData(101, "centounesimo")] - [InlineData(102, "centoduesimo")] - [InlineData(105, "centocinquesimo")] - [InlineData(109, "centonovesimo")] - [InlineData(110, "centodecimo")] - [InlineData(119, "centodiciannovesimo")] - [InlineData(120, "centoventesimo")] - [InlineData(121, "centoventunesimo")] - [InlineData(200, "duecentesimo")] - [InlineData(201, "duecentounesimo")] - [InlineData(240, "duecentoquarantesimo")] - [InlineData(300, "trecentesimo")] - [InlineData(900, "novecentesimo")] - [InlineData(1000, "millesimo")] - [InlineData(1001, "milleunesimo")] - [InlineData(1002, "milleduesimo")] - [InlineData(1003, "milletreesimo")] - [InlineData(1009, "millenovesimo")] - [InlineData(1010, "milledecimo")] - [InlineData(1021, "milleventunesimo")] - [InlineData(2000, "duemillesimo")] - [InlineData(2001, "duemilaunesimo")] - [InlineData(3000, "tremillesimo")] - [InlineData(10000, "diecimillesimo")] - [InlineData(10001, "diecimilaunesimo")] - [InlineData(10121, "diecimilacentoventunesimo")] - [InlineData(100000, "centomillesimo")] - [InlineData(100001, "centomilaunesimo")] - [InlineData(1000000, "milionesimo")] - [InlineData(1000001, "un milione unesimo")] - [InlineData(1000002, "un milione duesimo")] - [InlineData(2000000, "duemilionesimo")] - [InlineData(10000000, "diecimilionesimo")] - [InlineData(100000000, "centomilionesimo")] - [InlineData(1000000000, "miliardesimo")] - [InlineData(2000000000, "duemiliardesimo")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primo")] + [InlineData(2, "secondo")] + [InlineData(9, "nono")] + [InlineData(10, "decimo")] + [InlineData(11, "undicesimo")] + [InlineData(15, "quindicesimo")] + [InlineData(18, "diciottesimo")] + [InlineData(20, "ventesimo")] + [InlineData(21, "ventunesimo")] + [InlineData(22, "ventiduesimo")] + [InlineData(28, "ventottesimo")] + [InlineData(30, "trentesimo")] + [InlineData(44, "quarantaquattresimo")] + [InlineData(55, "cinquantacinquesimo")] + [InlineData(60, "sessantesimo")] + [InlineData(63, "sessantatreesimo")] + [InlineData(66, "sessantaseiesimo")] + [InlineData(77, "settantasettesimo")] + [InlineData(88, "ottantottesimo")] + [InlineData(99, "novantanovesimo")] + [InlineData(100, "centesimo")] + [InlineData(101, "centounesimo")] + [InlineData(102, "centoduesimo")] + [InlineData(105, "centocinquesimo")] + [InlineData(109, "centonovesimo")] + [InlineData(110, "centodecimo")] + [InlineData(119, "centodiciannovesimo")] + [InlineData(120, "centoventesimo")] + [InlineData(121, "centoventunesimo")] + [InlineData(200, "duecentesimo")] + [InlineData(201, "duecentounesimo")] + [InlineData(240, "duecentoquarantesimo")] + [InlineData(300, "trecentesimo")] + [InlineData(900, "novecentesimo")] + [InlineData(1000, "millesimo")] + [InlineData(1001, "milleunesimo")] + [InlineData(1002, "milleduesimo")] + [InlineData(1003, "milletreesimo")] + [InlineData(1009, "millenovesimo")] + [InlineData(1010, "milledecimo")] + [InlineData(1021, "milleventunesimo")] + [InlineData(2000, "duemillesimo")] + [InlineData(2001, "duemilaunesimo")] + [InlineData(3000, "tremillesimo")] + [InlineData(10000, "diecimillesimo")] + [InlineData(10001, "diecimilaunesimo")] + [InlineData(10121, "diecimilacentoventunesimo")] + [InlineData(100000, "centomillesimo")] + [InlineData(100001, "centomilaunesimo")] + [InlineData(1000000, "milionesimo")] + [InlineData(1000001, "un milione unesimo")] + [InlineData(1000002, "un milione duesimo")] + [InlineData(2000000, "duemilionesimo")] + [InlineData(10000000, "diecimilionesimo")] + [InlineData(100000000, "centomilionesimo")] + [InlineData(1000000000, "miliardesimo")] + [InlineData(2000000000, "duemiliardesimo")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "prima")] - [InlineData(2, "seconda")] - [InlineData(5, "quinta")] - [InlineData(9, "nona")] - [InlineData(10, "decima")] - [InlineData(11, "undicesima")] - [InlineData(18, "diciottesima")] - [InlineData(20, "ventesima")] - [InlineData(21, "ventunesima")] - [InlineData(100, "centesima")] - [InlineData(101, "centounesima")] - [InlineData(200, "duecentesima")] - [InlineData(1000, "millesima")] - [InlineData(1001, "milleunesima")] - [InlineData(10000, "diecimillesima")] - public void ToFeminineOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "prima")] + [InlineData(2, "seconda")] + [InlineData(5, "quinta")] + [InlineData(9, "nona")] + [InlineData(10, "decima")] + [InlineData(11, "undicesima")] + [InlineData(18, "diciottesima")] + [InlineData(20, "ventesima")] + [InlineData(21, "ventunesima")] + [InlineData(100, "centesima")] + [InlineData(101, "centounesima")] + [InlineData(200, "duecentesima")] + [InlineData(1000, "millesima")] + [InlineData(1001, "milleunesima")] + [InlineData(10000, "diecimillesima")] + public void ToFeminineOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primo")] - [InlineData(2, "secondo")] - [InlineData(5, "quinto")] - [InlineData(9, "nono")] - [InlineData(10, "decimo")] - [InlineData(11, "undicesimo")] - [InlineData(18, "diciottesimo")] - [InlineData(20, "ventesimo")] - [InlineData(21, "ventunesimo")] - [InlineData(100, "centesimo")] - [InlineData(101, "centounesimo")] - [InlineData(200, "duecentesimo")] - [InlineData(1000, "millesimo")] - [InlineData(1001, "milleunesimo")] - [InlineData(10000, "diecimillesimo")] - public void ToMasculineOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); - } -} + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primo")] + [InlineData(2, "secondo")] + [InlineData(5, "quinto")] + [InlineData(9, "nono")] + [InlineData(10, "decimo")] + [InlineData(11, "undicesimo")] + [InlineData(18, "diciottesimo")] + [InlineData(20, "ventesimo")] + [InlineData(21, "ventunesimo")] + [InlineData(100, "centesimo")] + [InlineData(101, "centounesimo")] + [InlineData(200, "duecentesimo")] + [InlineData(1000, "millesimo")] + [InlineData(1001, "milleunesimo")] + [InlineData(10000, "diecimillesimo")] + public void ToMasculineOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/it/OrdinalizerTests.cs b/src/Humanizer.Tests/Localisation/it/OrdinalizerTests.cs index 75907214d..3cee13be6 100644 --- a/src/Humanizer.Tests/Localisation/it/OrdinalizerTests.cs +++ b/src/Humanizer.Tests/Localisation/it/OrdinalizerTests.cs @@ -1,54 +1,53 @@ -namespace Humanizer.Tests.Localisation.it +namespace Humanizer.Tests.Localisation.it; + +[UseCulture("it")] +public class OrdinalizerTests { - [UseCulture("it")] - public class OrdinalizerTests - { - [Theory] - [InlineData(0, "0")] // No ordinal for 0 in italian (neologism apart) - [InlineData(1, "1°")] - [InlineData(11, "11°")] - [InlineData(111, "111°")] - public void GenderlessNumber(int number, string expected) => - Assert.Equal(expected, number.Ordinalize()); + [Theory] + [InlineData(0, "0")] // No ordinal for 0 in italian (neologism apart) + [InlineData(1, "1°")] + [InlineData(11, "11°")] + [InlineData(111, "111°")] + public void GenderlessNumber(int number, string expected) => + Assert.Equal(expected, number.Ordinalize()); - [Theory] - [InlineData("0", "0")] // No ordinal for 0 in italian (neologism apart) - [InlineData("1", "1°")] - [InlineData("11", "11°")] - [InlineData("111", "111°")] - public void GenderlessText(string number, string expected) => - Assert.Equal(expected, number.Ordinalize()); + [Theory] + [InlineData("0", "0")] // No ordinal for 0 in italian (neologism apart) + [InlineData("1", "1°")] + [InlineData("11", "11°")] + [InlineData("111", "111°")] + public void GenderlessText(string number, string expected) => + Assert.Equal(expected, number.Ordinalize()); - [Theory] - [InlineData(0, "0")] // No ordinal for 0 in italian (neologism apart) - [InlineData(1, "1°")] - [InlineData(11, "11°")] - [InlineData(111, "111°")] - public void MasculineNumber(int number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "0")] // No ordinal for 0 in italian (neologism apart) + [InlineData(1, "1°")] + [InlineData(11, "11°")] + [InlineData(111, "111°")] + public void MasculineNumber(int number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); - [Theory] - [InlineData("0", "0")] // No ordinal for 0 in italian (neologism apart) - [InlineData("1", "1°")] - [InlineData("11", "11°")] - [InlineData("111", "111°")] - public void MasculineText(string number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); + [Theory] + [InlineData("0", "0")] // No ordinal for 0 in italian (neologism apart) + [InlineData("1", "1°")] + [InlineData("11", "11°")] + [InlineData("111", "111°")] + public void MasculineText(string number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); - [Theory] - [InlineData(0, "0")] // No ordinal for 0 in italian (neologism apart) - [InlineData(1, "1ª")] - [InlineData(11, "11ª")] - [InlineData(111, "111ª")] - public void FeminineNumber(int number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "0")] // No ordinal for 0 in italian (neologism apart) + [InlineData(1, "1ª")] + [InlineData(11, "11ª")] + [InlineData(111, "111ª")] + public void FeminineNumber(int number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); - [Theory] - [InlineData("0", "0")] // No ordinal for 0 in italian (neologism apart) - [InlineData("1", "1ª")] - [InlineData("11", "11ª")] - [InlineData("111", "111ª")] - public void FeminineText(string number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData("0", "0")] // No ordinal for 0 in italian (neologism apart) + [InlineData("1", "1ª")] + [InlineData("11", "11ª")] + [InlineData("111", "111ª")] + public void FeminineText(string number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/it/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/it/TimeSpanHumanizeTests.cs index ac1fec3b9..a2446dd51 100644 --- a/src/Humanizer.Tests/Localisation/it/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/it/TimeSpanHumanizeTests.cs @@ -1,77 +1,76 @@ -namespace Humanizer.Tests.Localisation.it +namespace Humanizer.Tests.Localisation.it; + +[UseCulture("it")] +public class TimeSpanHumanizeTests { - [UseCulture("it")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 anno")] - [InlineData(366, "un anno", true)] - [InlineData(731, "2 anni")] - [InlineData(1096, "3 anni")] - [InlineData(4018, "11 anni")] - public void Years(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 anno")] + [InlineData(366, "un anno", true)] + [InlineData(731, "2 anni")] + [InlineData(1096, "3 anni")] + [InlineData(4018, "11 anni")] + public void Years(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mese")] - [InlineData(31, "un mese", true)] - [InlineData(61, "2 mesi")] - [InlineData(92, "3 mesi")] - [InlineData(335, "11 mesi")] - public void Months(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mese")] + [InlineData(31, "un mese", true)] + [InlineData(61, "2 mesi")] + [InlineData(92, "3 mesi")] + [InlineData(335, "11 mesi")] + public void Months(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); - [Theory] - [InlineData(7, "1 settimana")] - [InlineData(7, "una settimana", true)] - [InlineData(14, "2 settimane")] - public void Weeks(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); + [Theory] + [InlineData(7, "1 settimana")] + [InlineData(7, "una settimana", true)] + [InlineData(14, "2 settimane")] + public void Weeks(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "1 giorno")] - [InlineData(1, "un giorno", true)] - [InlineData(2, "2 giorni")] - public void Days(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "1 giorno")] + [InlineData(1, "un giorno", true)] + [InlineData(2, "2 giorni")] + public void Days(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "1 ora")] - [InlineData(1, "una ora", true)] - [InlineData(2, "2 ore")] - public void Hours(int hours, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "1 ora")] + [InlineData(1, "una ora", true)] + [InlineData(2, "2 ore")] + public void Hours(int hours, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "1 minuto")] - [InlineData(1, "un minuto", true)] - [InlineData(2, "2 minuti")] - public void Minutes(int minutes, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "1 minuto")] + [InlineData(1, "un minuto", true)] + [InlineData(2, "2 minuti")] + public void Minutes(int minutes, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "1 secondo")] - [InlineData(1, "un secondo", true)] - [InlineData(2, "2 secondi")] - public void Seconds(int seconds, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "1 secondo")] + [InlineData(1, "un secondo", true)] + [InlineData(2, "2 secondi")] + public void Seconds(int seconds, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "1 millisecondo")] - [InlineData(1, "un millisecondo", true)] - [InlineData(2, "2 millisecondi")] - public void Milliseconds(int milliseconds, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "1 millisecondo")] + [InlineData(1, "un millisecondo", true)] + [InlineData(2, "2 millisecondi")] + public void Milliseconds(int milliseconds, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: toWords)); - [Fact] - public void NoTime() => - Assert.Equal("0 millisecondi", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 millisecondi", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This does not make much sense in italian, anyway - Assert.Equal("0 secondi", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This does not make much sense in italian, anyway + Assert.Equal("0 secondi", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ja/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ja/DateHumanizeTests.cs index ca3de041a..c2805648b 100644 --- a/src/Humanizer.Tests/Localisation/ja/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ja/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.ja +namespace Humanizer.Tests.Localisation.ja; + +[UseCulture("ja")] +public class DateHumanizeTests { - [UseCulture("ja")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "1 秒前")] - [InlineData(2, "2 秒前")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "1 秒前")] + [InlineData(2, "2 秒前")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "1 秒後")] - [InlineData(2, "2 秒後")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "1 秒後")] + [InlineData(2, "2 秒後")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "1 分前")] - [InlineData(2, "2 分前")] - [InlineData(60, "1 時間前")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "1 分前")] + [InlineData(2, "2 分前")] + [InlineData(60, "1 時間前")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "1 分後")] - [InlineData(2, "2 分後")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "1 分後")] + [InlineData(2, "2 分後")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "1 時間前")] - [InlineData(2, "2 時間前")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "1 時間前")] + [InlineData(2, "2 時間前")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "1 時間後")] - [InlineData(2, "2 時間後")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "1 時間後")] + [InlineData(2, "2 時間後")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "昨日")] - [InlineData(2, "2 日前")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "昨日")] + [InlineData(2, "2 日前")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "明日")] - [InlineData(2, "2 日後")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "明日")] + [InlineData(2, "2 日後")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "先月")] - [InlineData(2, "2 か月前")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "先月")] + [InlineData(2, "2 か月前")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "来月")] - [InlineData(2, "2 か月後")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "来月")] + [InlineData(2, "2 か月後")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "去年")] - [InlineData(2, "2 年前")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "去年")] + [InlineData(2, "2 年前")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "来年")] - [InlineData(2, "2 年後")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "来年")] + [InlineData(2, "2 年後")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("今", 0, TimeUnit.Day, Tense.Past); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("今", 0, TimeUnit.Day, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ja/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ja/NumberToWordsTests.cs index 70ecf4380..82aa03269 100644 --- a/src/Humanizer.Tests/Localisation/ja/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ja/NumberToWordsTests.cs @@ -1,77 +1,76 @@ -namespace Humanizer.Tests.Localisation.ja +namespace Humanizer.Tests.Localisation.ja; + +[UseCulture("ja")] +public class NumberToWordsTests { - [UseCulture("ja")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "〇")] - [InlineData(1, "一")] - [InlineData(10, "十")] - [InlineData(11, "十一")] - [InlineData(122, "百二十二")] - [InlineData(3501, "三千五百一")] - [InlineData(100, "百")] - [InlineData(1000, "千")] - [InlineData(10000, "一万")] - [InlineData(100000, "十万")] - [InlineData(1000000, "百万")] - [InlineData(10000000, "千万")] - [InlineData(100000000, "一億")] - [InlineData(1000000000, "十億")] - [InlineData(111, "百十一")] - [InlineData(1111, "千百十一")] - [InlineData(11111, "一万千百十一")] - [InlineData(111111, "十一万千百十一")] - [InlineData(1111111, "百十一万千百十一")] - [InlineData(11111111, "千百十一万千百十一")] - [InlineData(111111111, "一億千百十一万千百十一")] - [InlineData(1111111111, "十一億千百十一万千百十一")] - [InlineData(123, "百二十三")] - [InlineData(1234, "千二百三十四")] - [InlineData(12345, "一万二千三百四十五")] - [InlineData(123456, "十二万三千四百五十六")] - [InlineData(1234567, "百二十三万四千五百六十七")] - [InlineData(12345678, "千二百三十四万五千六百七十八")] - [InlineData(123456789, "一億二千三百四十五万六千七百八十九")] - [InlineData(1234567890, "十二億三千四百五十六万七千八百九十")] - [InlineData(-123, "マイナス 百二十三")] - public void ToWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "〇")] + [InlineData(1, "一")] + [InlineData(10, "十")] + [InlineData(11, "十一")] + [InlineData(122, "百二十二")] + [InlineData(3501, "三千五百一")] + [InlineData(100, "百")] + [InlineData(1000, "千")] + [InlineData(10000, "一万")] + [InlineData(100000, "十万")] + [InlineData(1000000, "百万")] + [InlineData(10000000, "千万")] + [InlineData(100000000, "一億")] + [InlineData(1000000000, "十億")] + [InlineData(111, "百十一")] + [InlineData(1111, "千百十一")] + [InlineData(11111, "一万千百十一")] + [InlineData(111111, "十一万千百十一")] + [InlineData(1111111, "百十一万千百十一")] + [InlineData(11111111, "千百十一万千百十一")] + [InlineData(111111111, "一億千百十一万千百十一")] + [InlineData(1111111111, "十一億千百十一万千百十一")] + [InlineData(123, "百二十三")] + [InlineData(1234, "千二百三十四")] + [InlineData(12345, "一万二千三百四十五")] + [InlineData(123456, "十二万三千四百五十六")] + [InlineData(1234567, "百二十三万四千五百六十七")] + [InlineData(12345678, "千二百三十四万五千六百七十八")] + [InlineData(123456789, "一億二千三百四十五万六千七百八十九")] + [InlineData(1234567890, "十二億三千四百五十六万七千八百九十")] + [InlineData(-123, "マイナス 百二十三")] + public void ToWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1L, "一")] - [InlineData(11L, "十一")] - [InlineData(111L, "百十一")] - [InlineData(1111L, "千百十一")] - [InlineData(11111L, "一万千百十一")] - [InlineData(111111L, "十一万千百十一")] - [InlineData(1111111L, "百十一万千百十一")] - [InlineData(11111111L, "千百十一万千百十一")] - [InlineData(111111111L, "一億千百十一万千百十一")] - [InlineData(1111111111L, "十一億千百十一万千百十一")] - [InlineData(11111111111L, "百十一億千百十一万千百十一")] - [InlineData(111111111111L, "千百十一億千百十一万千百十一")] - [InlineData(1111111111111L, "一兆千百十一億千百十一万千百十一")] - [InlineData(11111111111111L, "十一兆千百十一億千百十一万千百十一")] - [InlineData(111111111111111L, "百十一兆千百十一億千百十一万千百十一")] - [InlineData(1111111111111111L, "千百十一兆千百十一億千百十一万千百十一")] - [InlineData(11111111111111111L, "一京千百十一兆千百十一億千百十一万千百十一")] - [InlineData(111111111111111111L, "十一京千百十一兆千百十一億千百十一万千百十一")] - [InlineData(1111111111111111111L, "百十一京千百十一兆千百十一億千百十一万千百十一")] - public void ToWordsLong(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(1L, "一")] + [InlineData(11L, "十一")] + [InlineData(111L, "百十一")] + [InlineData(1111L, "千百十一")] + [InlineData(11111L, "一万千百十一")] + [InlineData(111111L, "十一万千百十一")] + [InlineData(1111111L, "百十一万千百十一")] + [InlineData(11111111L, "千百十一万千百十一")] + [InlineData(111111111L, "一億千百十一万千百十一")] + [InlineData(1111111111L, "十一億千百十一万千百十一")] + [InlineData(11111111111L, "百十一億千百十一万千百十一")] + [InlineData(111111111111L, "千百十一億千百十一万千百十一")] + [InlineData(1111111111111L, "一兆千百十一億千百十一万千百十一")] + [InlineData(11111111111111L, "十一兆千百十一億千百十一万千百十一")] + [InlineData(111111111111111L, "百十一兆千百十一億千百十一万千百十一")] + [InlineData(1111111111111111L, "千百十一兆千百十一億千百十一万千百十一")] + [InlineData(11111111111111111L, "一京千百十一兆千百十一億千百十一万千百十一")] + [InlineData(111111111111111111L, "十一京千百十一兆千百十一億千百十一万千百十一")] + [InlineData(1111111111111111111L, "百十一京千百十一兆千百十一億千百十一万千百十一")] + public void ToWordsLong(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "〇番目")] - [InlineData(1, "一番目")] - [InlineData(2, "二番目")] - [InlineData(3, "三番目")] - [InlineData(10, "十番目")] - [InlineData(11, "十一番目")] - [InlineData(100, "百番目")] - [InlineData(112, "百十二番目")] - [InlineData(1000000, "百万番目")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "〇番目")] + [InlineData(1, "一番目")] + [InlineData(2, "二番目")] + [InlineData(3, "三番目")] + [InlineData(10, "十番目")] + [InlineData(11, "十一番目")] + [InlineData(100, "百番目")] + [InlineData(112, "百十二番目")] + [InlineData(1000000, "百万番目")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ja/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ja/TimeSpanHumanizeTests.cs index 581b5dad6..f70b961e7 100644 --- a/src/Humanizer.Tests/Localisation/ja/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ja/TimeSpanHumanizeTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.ja +namespace Humanizer.Tests.Localisation.ja; + +[UseCulture("ja")] +public class TimeSpanHumanizeTests { - [UseCulture("ja")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 年")] - [InlineData(731, "2 年")] - [InlineData(1096, "3 年")] - [InlineData(4018, "11 年")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 ヶ月")] - [InlineData(61, "2 ヶ月")] - [InlineData(92, "3 ヶ月")] - [InlineData(335, "11 ヶ月")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ヶ月")] + [InlineData(61, "2 ヶ月")] + [InlineData(92, "3 ヶ月")] + [InlineData(335, "11 ヶ月")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 週間")] - [InlineData(14, "2 週間")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 週間")] + [InlineData(14, "2 週間")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 日")] - [InlineData(2, "2 日")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 日")] + [InlineData(2, "2 日")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 時間")] - [InlineData(2, "2 時間")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 時間")] + [InlineData(2, "2 時間")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 分")] - [InlineData(2, "2 分")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 分")] + [InlineData(2, "2 分")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 秒")] - [InlineData(2, "2 秒")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 秒")] + [InlineData(2, "2 秒")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 ミリ秒")] - [InlineData(2, "2 ミリ秒")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 ミリ秒")] + [InlineData(2, "2 ミリ秒")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 ミリ秒", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 ミリ秒", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("0 秒", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("0 秒", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ko-KR/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ko-KR/NumberToWordsTests.cs index 606ecc037..fe2c8a052 100644 --- a/src/Humanizer.Tests/Localisation/ko-KR/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ko-KR/NumberToWordsTests.cs @@ -1,77 +1,76 @@ -namespace Humanizer.Tests.Localisation.koKR +namespace Humanizer.Tests.Localisation.koKR; + +[UseCulture("ko-KR")] +public class NumberToWordsTests { - [UseCulture("ko-KR")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "영")] - [InlineData(1, "일")] - [InlineData(10, "십")] - [InlineData(11, "십일")] - [InlineData(122, "백이십이")] - [InlineData(3501, "삼천오백일")] - [InlineData(100, "백")] - [InlineData(1000, "천")] - [InlineData(10000, "일만")] - [InlineData(100000, "십만")] - [InlineData(1000000, "백만")] - [InlineData(10000000, "천만")] - [InlineData(100000000, "일억")] - [InlineData(1000000000, "십억")] - [InlineData(111, "백십일")] - [InlineData(1111, "천백십일")] - [InlineData(11111, "일만천백십일")] - [InlineData(111111, "십일만천백십일")] - [InlineData(1111111, "백십일만천백십일")] - [InlineData(11111111, "천백십일만천백십일")] - [InlineData(111111111, "일억천백십일만천백십일")] - [InlineData(1111111111, "십일억천백십일만천백십일")] - [InlineData(123, "백이십삼")] - [InlineData(1234, "천이백삼십사")] - [InlineData(12345, "일만이천삼백사십오")] - [InlineData(123456, "십이만삼천사백오십육")] - [InlineData(1234567, "백이십삼만사천오백육십칠")] - [InlineData(12345678, "천이백삼십사만오천육백칠십팔")] - [InlineData(123456789, "일억이천삼백사십오만육천칠백팔십구")] - [InlineData(1234567890, "십이억삼천사백오십육만칠천팔백구십")] - [InlineData(-123, "마이너스 백이십삼")] - public void ToWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "영")] + [InlineData(1, "일")] + [InlineData(10, "십")] + [InlineData(11, "십일")] + [InlineData(122, "백이십이")] + [InlineData(3501, "삼천오백일")] + [InlineData(100, "백")] + [InlineData(1000, "천")] + [InlineData(10000, "일만")] + [InlineData(100000, "십만")] + [InlineData(1000000, "백만")] + [InlineData(10000000, "천만")] + [InlineData(100000000, "일억")] + [InlineData(1000000000, "십억")] + [InlineData(111, "백십일")] + [InlineData(1111, "천백십일")] + [InlineData(11111, "일만천백십일")] + [InlineData(111111, "십일만천백십일")] + [InlineData(1111111, "백십일만천백십일")] + [InlineData(11111111, "천백십일만천백십일")] + [InlineData(111111111, "일억천백십일만천백십일")] + [InlineData(1111111111, "십일억천백십일만천백십일")] + [InlineData(123, "백이십삼")] + [InlineData(1234, "천이백삼십사")] + [InlineData(12345, "일만이천삼백사십오")] + [InlineData(123456, "십이만삼천사백오십육")] + [InlineData(1234567, "백이십삼만사천오백육십칠")] + [InlineData(12345678, "천이백삼십사만오천육백칠십팔")] + [InlineData(123456789, "일억이천삼백사십오만육천칠백팔십구")] + [InlineData(1234567890, "십이억삼천사백오십육만칠천팔백구십")] + [InlineData(-123, "마이너스 백이십삼")] + public void ToWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1L, "일")] - [InlineData(11L, "십일")] - [InlineData(111L, "백십일")] - [InlineData(1111L, "천백십일")] - [InlineData(11111L, "일만천백십일")] - [InlineData(111111L, "십일만천백십일")] - [InlineData(1111111L, "백십일만천백십일")] - [InlineData(11111111L, "천백십일만천백십일")] - [InlineData(111111111L, "일억천백십일만천백십일")] - [InlineData(1111111111L, "십일억천백십일만천백십일")] - [InlineData(11111111111L, "백십일억천백십일만천백십일")] - [InlineData(111111111111L, "천백십일억천백십일만천백십일")] - [InlineData(1111111111111L, "일조천백십일억천백십일만천백십일")] - [InlineData(11111111111111L, "십일조천백십일억천백십일만천백십일")] - [InlineData(111111111111111L, "백십일조천백십일억천백십일만천백십일")] - [InlineData(1111111111111111L, "천백십일조천백십일억천백십일만천백십일")] - [InlineData(11111111111111111L, "일경천백십일조천백십일억천백십일만천백십일")] - [InlineData(111111111111111111L, "십일경천백십일조천백십일억천백십일만천백십일")] - [InlineData(1111111111111111111L, "백십일경천백십일조천백십일억천백십일만천백십일")] - public void ToWordsLong(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(1L, "일")] + [InlineData(11L, "십일")] + [InlineData(111L, "백십일")] + [InlineData(1111L, "천백십일")] + [InlineData(11111L, "일만천백십일")] + [InlineData(111111L, "십일만천백십일")] + [InlineData(1111111L, "백십일만천백십일")] + [InlineData(11111111L, "천백십일만천백십일")] + [InlineData(111111111L, "일억천백십일만천백십일")] + [InlineData(1111111111L, "십일억천백십일만천백십일")] + [InlineData(11111111111L, "백십일억천백십일만천백십일")] + [InlineData(111111111111L, "천백십일억천백십일만천백십일")] + [InlineData(1111111111111L, "일조천백십일억천백십일만천백십일")] + [InlineData(11111111111111L, "십일조천백십일억천백십일만천백십일")] + [InlineData(111111111111111L, "백십일조천백십일억천백십일만천백십일")] + [InlineData(1111111111111111L, "천백십일조천백십일억천백십일만천백십일")] + [InlineData(11111111111111111L, "일경천백십일조천백십일억천백십일만천백십일")] + [InlineData(111111111111111111L, "십일경천백십일조천백십일억천백십일만천백십일")] + [InlineData(1111111111111111111L, "백십일경천백십일조천백십일억천백십일만천백십일")] + public void ToWordsLong(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "영번째")] - [InlineData(1, "첫번째")] - [InlineData(2, "두번째")] - [InlineData(3, "세번째")] - [InlineData(10, "열번째")] - [InlineData(11, "열한번째")] - [InlineData(100, "백번째")] - [InlineData(112, "백십이번째")] - [InlineData(1000000, "백만번째")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "영번째")] + [InlineData(1, "첫번째")] + [InlineData(2, "두번째")] + [InlineData(3, "세번째")] + [InlineData(10, "열번째")] + [InlineData(11, "열한번째")] + [InlineData(100, "백번째")] + [InlineData(112, "백십이번째")] + [InlineData(1000000, "백만번째")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ko-KR/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ko-KR/TimeSpanHumanizeTests.cs index 5cb65ae80..b14ffefed 100644 --- a/src/Humanizer.Tests/Localisation/ko-KR/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ko-KR/TimeSpanHumanizeTests.cs @@ -1,75 +1,74 @@ -namespace Humanizer.Tests.Localisation.koKR +namespace Humanizer.Tests.Localisation.koKR; + +[UseCulture("ko-KR")] +public class TimeSpanHumanizeTests { - [UseCulture("ko-KR")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1년")] - [InlineData(731, "2년")] - [InlineData(1096, "3년")] - [InlineData(4018, "11년")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1년")] + [InlineData(731, "2년")] + [InlineData(1096, "3년")] + [InlineData(4018, "11년")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1개월")] - [InlineData(61, "2개월")] - [InlineData(92, "3개월")] - [InlineData(335, "11개월")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1개월")] + [InlineData(61, "2개월")] + [InlineData(92, "3개월")] + [InlineData(335, "11개월")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(7, "1주")] - [InlineData(14, "2주")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(7, "1주")] + [InlineData(14, "2주")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1일")] - [InlineData(2, "2일")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1일")] + [InlineData(2, "2일")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1시간")] - [InlineData(2, "2시간")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1시간")] + [InlineData(2, "2시간")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1분")] - [InlineData(2, "2분")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1분")] + [InlineData(2, "2분")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1초")] - [InlineData(2, "2초")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1초")] + [InlineData(2, "2초")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1밀리초")] - [InlineData(2, "2밀리초")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1밀리초")] + [InlineData(2, "2밀리초")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - [Trait("Translation", "Google")] - public void NoTime() => - Assert.Equal("0밀리초", TimeSpan.Zero.Humanize()); + [Fact] + [Trait("Translation", "Google")] + public void NoTime() => + Assert.Equal("0밀리초", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("방금", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("방금", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ku/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ku/DateHumanizeTests.cs index e6553f640..523dca44b 100644 --- a/src/Humanizer.Tests/Localisation/ku/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ku/DateHumanizeTests.cs @@ -1,103 +1,102 @@ -namespace Humanizer.Tests.Localisation.ku +namespace Humanizer.Tests.Localisation.ku; + +[UseCulture("ku")] +public class DateHumanizeTests { - [UseCulture("ku")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-1, "دوێنێ")] - [InlineData(-2, "2 ڕۆژ لەمەوبەر")] - [InlineData(-3, "3 ڕۆژ لەمەوبەر")] - [InlineData(-11, "11 ڕۆژ لەمەوبەر")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-1, "دوێنێ")] + [InlineData(-2, "2 ڕۆژ لەمەوبەر")] + [InlineData(-3, "3 ڕۆژ لەمەوبەر")] + [InlineData(-11, "11 ڕۆژ لەمەوبەر")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "بەیانی")] - [InlineData(2, "2 ڕۆژی دیکە")] - [InlineData(10, "10 ڕۆژی دیکە")] - [InlineData(17, "17 ڕۆژی دیکە")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "بەیانی")] + [InlineData(2, "2 ڕۆژی دیکە")] + [InlineData(10, "10 ڕۆژی دیکە")] + [InlineData(17, "17 ڕۆژی دیکە")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-2, "2 کاتژمێر لەمەوبەر")] - [InlineData(-1, "کاتژمێرێک لەمەوبەر")] - [InlineData(-3, "3 کاتژمێر لەمەوبەر")] - [InlineData(-11, "11 کاتژمێر لەمەوبەر")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "2 کاتژمێر لەمەوبەر")] + [InlineData(-1, "کاتژمێرێک لەمەوبەر")] + [InlineData(-3, "3 کاتژمێر لەمەوبەر")] + [InlineData(-11, "11 کاتژمێر لەمەوبەر")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "کاتژمێرێکی دیکە")] - [InlineData(2, "2 کاتژمێری دیکە")] - [InlineData(10, "10 کاتژمێری دیکە")] - [InlineData(23, "23 کاتژمێری دیکە")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "کاتژمێرێکی دیکە")] + [InlineData(2, "2 کاتژمێری دیکە")] + [InlineData(10, "10 کاتژمێری دیکە")] + [InlineData(23, "23 کاتژمێری دیکە")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 خولەک لەمەوبەر")] - [InlineData(-1, "خولەکێک لەمەوبەر")] - [InlineData(-3, "3 خولەک لەمەوبەر")] - [InlineData(-11, "11 خولەک لەمەوبەر")] - [InlineData(60, "کاتژمێرێک لەمەوبەر")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 خولەک لەمەوبەر")] + [InlineData(-1, "خولەکێک لەمەوبەر")] + [InlineData(-3, "3 خولەک لەمەوبەر")] + [InlineData(-11, "11 خولەک لەمەوبەر")] + [InlineData(60, "کاتژمێرێک لەمەوبەر")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "خولەکێکی دیکە")] - [InlineData(2, "2 خولەکی دیکە")] - [InlineData(10, "10 خولەکی دیکە")] - [InlineData(23, "23 خولەکی دیکە")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "خولەکێکی دیکە")] + [InlineData(2, "2 خولەکی دیکە")] + [InlineData(10, "10 خولەکی دیکە")] + [InlineData(23, "23 خولەکی دیکە")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 مانگ لەمەوبەر")] - [InlineData(-1, "مانگێک لەمەوبەر")] - [InlineData(-3, "3 مانگ لەمەوبەر")] - [InlineData(-11, "11 مانگ لەمەوبەر")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 مانگ لەمەوبەر")] + [InlineData(-1, "مانگێک لەمەوبەر")] + [InlineData(-3, "3 مانگ لەمەوبەر")] + [InlineData(-11, "11 مانگ لەمەوبەر")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "مانگێکی دیکە")] - [InlineData(2, "2 مانگی دیکە")] - [InlineData(10, "10 مانگی دیکە")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "مانگێکی دیکە")] + [InlineData(2, "2 مانگی دیکە")] + [InlineData(10, "10 مانگی دیکە")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 چرکە لەمەوبەر")] - [InlineData(-1, "چرکەیەک لەمەوبەر")] - [InlineData(-3, "3 چرکە لەمەوبەر")] - [InlineData(-11, "11 چرکە لەمەوبەر")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 چرکە لەمەوبەر")] + [InlineData(-1, "چرکەیەک لەمەوبەر")] + [InlineData(-3, "3 چرکە لەمەوبەر")] + [InlineData(-11, "11 چرکە لەمەوبەر")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(0, "ئێستا")] - [InlineData(1, "چرکەیەکی دیکە")] - [InlineData(2, "2 چرکەی دیکە")] - [InlineData(10, "10 چرکەی دیکە")] - [InlineData(24, "24 چرکەی دیکە")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(0, "ئێستا")] + [InlineData(1, "چرکەیەکی دیکە")] + [InlineData(2, "2 چرکەی دیکە")] + [InlineData(10, "10 چرکەی دیکە")] + [InlineData(24, "24 چرکەی دیکە")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 ساڵ لەمەوبەر")] - [InlineData(-1, "ساڵێک لەمەوبەر")] - [InlineData(-3, "3 ساڵ لەمەوبەر")] - [InlineData(-11, "11 ساڵ لەمەوبەر")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 ساڵ لەمەوبەر")] + [InlineData(-1, "ساڵێک لەمەوبەر")] + [InlineData(-3, "3 ساڵ لەمەوبەر")] + [InlineData(-11, "11 ساڵ لەمەوبەر")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "ساڵێکی دیکە")] - [InlineData(2, "2 ساڵی دیکە")] - [InlineData(7, "7 ساڵی دیکە")] - [InlineData(55, "55 ساڵی دیکە")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "ساڵێکی دیکە")] + [InlineData(2, "2 ساڵی دیکە")] + [InlineData(7, "7 ساڵی دیکە")] + [InlineData(55, "55 ساڵی دیکە")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ku/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ku/NumberToWordsTests.cs index 90cc9a473..6109803a0 100644 --- a/src/Humanizer.Tests/Localisation/ku/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ku/NumberToWordsTests.cs @@ -1,84 +1,83 @@ -namespace Humanizer.Tests.Localisation.ku +namespace Humanizer.Tests.Localisation.ku; + +[UseCulture("ku")] +public class NumberToWordsTests { - [UseCulture("ku")] - public class NumberToWordsTests - { - [Theory] - [InlineData(-1, "نێگەتیڤ یەک")] - [InlineData(-10, "نێگەتیڤ دە")] - [InlineData(-100, "نێگەتیڤ سەد")] - [InlineData(-999, "نێگەتیڤ نۆ سەد و نەوەد و نۆ")] - [InlineData(-1000, "نێگەتیڤ هەزار")] - [InlineData(-1000000, "نێگەتیڤ یەک میلیۆن")] - [InlineData(1, "یەک")] - [InlineData(10, "دە")] - [InlineData(11, "یازدە")] - [InlineData(122, "سەد و بیست و دوو")] - [InlineData(3501, "سێ هەزار و پێنج سەد و یەک")] - [InlineData(100, "سەد")] - [InlineData(1000, "هەزار")] - [InlineData(100000, "سەد هەزار")] - [InlineData(100001, "سەد هەزار و یەک")] - [InlineData(101000, "سەد و یەک هەزار")] - [InlineData(1000000, "یەک میلیۆن")] - [InlineData(51000, "پەنجا و یەک هەزار")] - [InlineData(151000, "سەد و پەنجا و یەک هەزار")] - [InlineData(10000000, "دە میلیۆن")] - [InlineData(100000000, "سەد میلیۆن")] - [InlineData(1000000000, "یەک میلیارد")] - [InlineData(111, "سەد و یازدە")] - [InlineData(1111, "هەزار و سەد و یازدە")] - [InlineData(111111, "سەد و یازدە هەزار و سەد و یازدە")] - [InlineData(1001001, "یەک میلیۆن و یەک هەزار و یەک")] - [InlineData(1111111, "یەک میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] - [InlineData(11111111, "یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] - [InlineData(111111111, "سەد و یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] - [InlineData(1111111111, "یەک میلیارد و سەد و یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] - [InlineData(123, "سەد و بیست و سێ")] - [InlineData(1234, "هەزار و دوو سەد و سی و چوار")] - [InlineData(12345, "دوازدە هەزار و سێ سەد و چل و پێنج")] - [InlineData(123456, "سەد و بیست و سێ هەزار و چوار سەد و پەنجا و شەش")] - [InlineData(1234567, "یەک میلیۆن و دوو سەد و سی و چوار هەزار و پێنج سەد و شەست و حەوت")] - [InlineData(12345678, "دوازدە میلیۆن و سێ سەد و چل و پێنج هەزار و شەش سەد و حەفتا و هەشت")] - [InlineData(123456789, "سەد و بیست و سێ میلیۆن و چوار سەد و پەنجا و شەش هەزار و حەوت سەد و هەشتا و نۆ")] - [InlineData(1234567890, "یەک میلیارد و دوو سەد و سی و چوار میلیۆن و پێنج سەد و شەست و حەوت هەزار و هەشت سەد و نەوەد")] - public void ToWordsKurdish(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(-1, "نێگەتیڤ یەک")] + [InlineData(-10, "نێگەتیڤ دە")] + [InlineData(-100, "نێگەتیڤ سەد")] + [InlineData(-999, "نێگەتیڤ نۆ سەد و نەوەد و نۆ")] + [InlineData(-1000, "نێگەتیڤ هەزار")] + [InlineData(-1000000, "نێگەتیڤ یەک میلیۆن")] + [InlineData(1, "یەک")] + [InlineData(10, "دە")] + [InlineData(11, "یازدە")] + [InlineData(122, "سەد و بیست و دوو")] + [InlineData(3501, "سێ هەزار و پێنج سەد و یەک")] + [InlineData(100, "سەد")] + [InlineData(1000, "هەزار")] + [InlineData(100000, "سەد هەزار")] + [InlineData(100001, "سەد هەزار و یەک")] + [InlineData(101000, "سەد و یەک هەزار")] + [InlineData(1000000, "یەک میلیۆن")] + [InlineData(51000, "پەنجا و یەک هەزار")] + [InlineData(151000, "سەد و پەنجا و یەک هەزار")] + [InlineData(10000000, "دە میلیۆن")] + [InlineData(100000000, "سەد میلیۆن")] + [InlineData(1000000000, "یەک میلیارد")] + [InlineData(111, "سەد و یازدە")] + [InlineData(1111, "هەزار و سەد و یازدە")] + [InlineData(111111, "سەد و یازدە هەزار و سەد و یازدە")] + [InlineData(1001001, "یەک میلیۆن و یەک هەزار و یەک")] + [InlineData(1111111, "یەک میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] + [InlineData(11111111, "یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] + [InlineData(111111111, "سەد و یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] + [InlineData(1111111111, "یەک میلیارد و سەد و یازدە میلیۆن و سەد و یازدە هەزار و سەد و یازدە")] + [InlineData(123, "سەد و بیست و سێ")] + [InlineData(1234, "هەزار و دوو سەد و سی و چوار")] + [InlineData(12345, "دوازدە هەزار و سێ سەد و چل و پێنج")] + [InlineData(123456, "سەد و بیست و سێ هەزار و چوار سەد و پەنجا و شەش")] + [InlineData(1234567, "یەک میلیۆن و دوو سەد و سی و چوار هەزار و پێنج سەد و شەست و حەوت")] + [InlineData(12345678, "دوازدە میلیۆن و سێ سەد و چل و پێنج هەزار و شەش سەد و حەفتا و هەشت")] + [InlineData(123456789, "سەد و بیست و سێ میلیۆن و چوار سەد و پەنجا و شەش هەزار و حەوت سەد و هەشتا و نۆ")] + [InlineData(1234567890, "یەک میلیارد و دوو سەد و سی و چوار میلیۆن و پێنج سەد و شەست و حەوت هەزار و هەشت سەد و نەوەد")] + public void ToWordsKurdish(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "سفرەم")] - [InlineData(1, "یەکەم")] - [InlineData(2, "دووەم")] - [InlineData(3, "سێیەم")] - [InlineData(4, "چوارەم")] - [InlineData(5, "پێنجەم")] - [InlineData(6, "شەشەم")] - [InlineData(7, "حەوتەم")] - [InlineData(8, "هەشتەم")] - [InlineData(9, "نۆیەم")] - [InlineData(10, "دەیەم")] - [InlineData(11, "یازدەیەم")] - [InlineData(12, "دوازدەیەم")] - [InlineData(13, "سێزدەیەم")] - [InlineData(21, "بیست و یەکەم")] - [InlineData(22, "بیست و دووەم")] - [InlineData(23, "بیست و سێیەم")] - [InlineData(24, "بیست و چوارەم")] - [InlineData(25, "بیست و پێنجەم")] - [InlineData(30, "سییەم")] - [InlineData(40, "چلەم")] - [InlineData(50, "پەنجایەم")] - [InlineData(60, "شەستەم")] - [InlineData(70, "حەفتایەم")] - [InlineData(80, "هەشتایەم")] - [InlineData(90, "نەوەدەم")] - [InlineData(100, "سەدەم")] - [InlineData(200, "دوو سەدەم")] - [InlineData(1000, "هەزارەم")] - [InlineData(1001, "هەزار و یەکەم")] - [InlineData(1333, "هەزار و سێ سەد و سی و سێیەم")] - [InlineData(1000000, "یەک میلیۆنەم")] - public void ToOrdinalWordsKurdish(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "سفرەم")] + [InlineData(1, "یەکەم")] + [InlineData(2, "دووەم")] + [InlineData(3, "سێیەم")] + [InlineData(4, "چوارەم")] + [InlineData(5, "پێنجەم")] + [InlineData(6, "شەشەم")] + [InlineData(7, "حەوتەم")] + [InlineData(8, "هەشتەم")] + [InlineData(9, "نۆیەم")] + [InlineData(10, "دەیەم")] + [InlineData(11, "یازدەیەم")] + [InlineData(12, "دوازدەیەم")] + [InlineData(13, "سێزدەیەم")] + [InlineData(21, "بیست و یەکەم")] + [InlineData(22, "بیست و دووەم")] + [InlineData(23, "بیست و سێیەم")] + [InlineData(24, "بیست و چوارەم")] + [InlineData(25, "بیست و پێنجەم")] + [InlineData(30, "سییەم")] + [InlineData(40, "چلەم")] + [InlineData(50, "پەنجایەم")] + [InlineData(60, "شەستەم")] + [InlineData(70, "حەفتایەم")] + [InlineData(80, "هەشتایەم")] + [InlineData(90, "نەوەدەم")] + [InlineData(100, "سەدەم")] + [InlineData(200, "دوو سەدەم")] + [InlineData(1000, "هەزارەم")] + [InlineData(1001, "هەزار و یەکەم")] + [InlineData(1333, "هەزار و سێ سەد و سی و سێیەم")] + [InlineData(1000000, "یەک میلیۆنەم")] + public void ToOrdinalWordsKurdish(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ku/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ku/TimeSpanHumanizeTests.cs index 481f92018..0f72d1043 100644 --- a/src/Humanizer.Tests/Localisation/ku/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ku/TimeSpanHumanizeTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.ku +namespace Humanizer.Tests.Localisation.ku; + +[UseCulture("ku")] +public class TimeSpanHumanizeTests { - [UseCulture("ku")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 ساڵ")] - [InlineData(731, "2 ساڵ")] - [InlineData(1096, "3 ساڵ")] - [InlineData(4018, "11 ساڵ")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 ساڵ")] + [InlineData(731, "2 ساڵ")] + [InlineData(1096, "3 ساڵ")] + [InlineData(4018, "11 ساڵ")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 مانگ")] - [InlineData(61, "2 مانگ")] - [InlineData(92, "3 مانگ")] - [InlineData(335, "11 مانگ")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 مانگ")] + [InlineData(61, "2 مانگ")] + [InlineData(92, "3 مانگ")] + [InlineData(335, "11 مانگ")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 هەفتە")] - [InlineData(77, "11 هەفتە")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 هەفتە")] + [InlineData(77, "11 هەفتە")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 ڕۆژ")] - [InlineData(3, "3 ڕۆژ")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 ڕۆژ")] + [InlineData(3, "3 ڕۆژ")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 کاتژمێر")] - [InlineData(11, "11 کاتژمێر")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 کاتژمێر")] + [InlineData(11, "11 کاتژمێر")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 خولەک")] - [InlineData(11, "11 خولەک")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 خولەک")] + [InlineData(11, "11 خولەک")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 چرکە")] - [InlineData(11, "11 چرکە")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 چرکە")] + [InlineData(11, "11 چرکە")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 میلیچرکە")] - [InlineData(11, "11 میلیچرکە")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 میلیچرکە")] + [InlineData(11, "11 میلیچرکە")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 میلیچرکە", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 میلیچرکە", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("ئێستا", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("ئێستا", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/lt/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/lt/DateToOrdinalWordsTests.cs index 794a7c754..4e646e734 100644 --- a/src/Humanizer.Tests/Localisation/lt/DateToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/lt/DateToOrdinalWordsTests.cs @@ -1,16 +1,15 @@ -namespace Humanizer.Tests.Localisation.lt +namespace Humanizer.Tests.Localisation.lt; + +[UseCulture("lt")] +public class DateToOrdinalWordsTests { - [UseCulture("lt")] - public class DateToOrdinalWordsTests - { - [Fact] - public void OrdinalizeString() => - Assert.Equal("2015 m. sausio 1 d.", new DateTime(2015, 1, 1).ToOrdinalWords()); + [Fact] + public void OrdinalizeString() => + Assert.Equal("2015 m. sausio 1 d.", new DateTime(2015, 1, 1).ToOrdinalWords()); #if NET6_0_OR_GREATER - [Fact] - public void OrdinalizeDateOnlyString() => - Assert.Equal("2015 m. sausio 1 d.", new DateOnly(2015, 1, 1).ToOrdinalWords()); + [Fact] + public void OrdinalizeDateOnlyString() => + Assert.Equal("2015 m. sausio 1 d.", new DateOnly(2015, 1, 1).ToOrdinalWords()); #endif - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/lt/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/lt/NumberToWordsTests.cs index 73a3a6bb1..b8bc64bfe 100644 --- a/src/Humanizer.Tests/Localisation/lt/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/lt/NumberToWordsTests.cs @@ -1,546 +1,545 @@ -namespace Humanizer.Tests.Localisation.lt +namespace Humanizer.Tests.Localisation.lt; + +[UseCulture("lt")] +public class NumberToWordsTests { - [UseCulture("lt")] - public class NumberToWordsTests - { - [Theory] - [InlineData(-1, "minus vienas")] - [InlineData(0, "nulis")] - [InlineData(1, "vienas")] - [InlineData(11, "vienuolika")] - [InlineData(21, "dvidešimt vienas")] - [InlineData(22, "dvidešimt du")] - [InlineData(26, "dvidešimt šeši")] - [InlineData(30, "trisdešimt")] - [InlineData(31, "trisdešimt vienas")] - [InlineData(33, "trisdešimt trys")] - [InlineData(37, "trisdešimt septyni")] - [InlineData(40, "keturiasdešimt")] - [InlineData(41, "keturiasdešimt vienas")] - [InlineData(44, "keturiasdešimt keturi")] - [InlineData(48, "keturiasdešimt aštuoni")] - [InlineData(50, "penkiasdešimt")] - [InlineData(51, "penkiasdešimt vienas")] - [InlineData(55, "penkiasdešimt penki")] - [InlineData(59, "penkiasdešimt devyni")] - [InlineData(60, "šešiasdešimt")] - [InlineData(61, "šešiasdešimt vienas")] - [InlineData(62, "šešiasdešimt du")] - [InlineData(66, "šešiasdešimt šeši")] - [InlineData(70, "septyniasdešimt")] - [InlineData(71, "septyniasdešimt vienas")] - [InlineData(73, "septyniasdešimt trys")] - [InlineData(77, "septyniasdešimt septyni")] - [InlineData(80, "aštuoniasdešimt")] - [InlineData(81, "aštuoniasdešimt vienas")] - [InlineData(84, "aštuoniasdešimt keturi")] - [InlineData(88, "aštuoniasdešimt aštuoni")] - [InlineData(90, "devyniasdešimt")] - [InlineData(91, "devyniasdešimt vienas")] - [InlineData(95, "devyniasdešimt penki")] - [InlineData(99, "devyniasdešimt devyni")] - [InlineData(100, "šimtas")] - [InlineData(101, "šimtas vienas")] - [InlineData(105, "šimtas penki")] - [InlineData(110, "šimtas dešimt")] - [InlineData(151, "šimtas penkiasdešimt vienas")] - [InlineData(200, "du šimtai")] - [InlineData(202, "du šimtai du")] - [InlineData(206, "du šimtai šeši")] - [InlineData(220, "du šimtai dvidešimt")] - [InlineData(262, "du šimtai šešiasdešimt du")] - [InlineData(300, "trys šimtai")] - [InlineData(303, "trys šimtai trys")] - [InlineData(307, "trys šimtai septyni")] - [InlineData(330, "trys šimtai trisdešimt")] - [InlineData(373, "trys šimtai septyniasdešimt trys")] - [InlineData(400, "keturi šimtai")] - [InlineData(404, "keturi šimtai keturi")] - [InlineData(408, "keturi šimtai aštuoni")] - [InlineData(440, "keturi šimtai keturiasdešimt")] - [InlineData(484, "keturi šimtai aštuoniasdešimt keturi")] - [InlineData(500, "penki šimtai")] - [InlineData(505, "penki šimtai penki")] - [InlineData(509, "penki šimtai devyni")] - [InlineData(550, "penki šimtai penkiasdešimt")] - [InlineData(595, "penki šimtai devyniasdešimt penki")] - [InlineData(600, "šeši šimtai")] - [InlineData(601, "šeši šimtai vienas")] - [InlineData(606, "šeši šimtai šeši")] - [InlineData(616, "šeši šimtai šešiolika")] - [InlineData(660, "šeši šimtai šešiasdešimt")] - [InlineData(700, "septyni šimtai")] - [InlineData(702, "septyni šimtai du")] - [InlineData(707, "septyni šimtai septyni")] - [InlineData(727, "septyni šimtai dvidešimt septyni")] - [InlineData(770, "septyni šimtai septyniasdešimt")] - [InlineData(800, "aštuoni šimtai")] - [InlineData(803, "aštuoni šimtai trys")] - [InlineData(808, "aštuoni šimtai aštuoni")] - [InlineData(838, "aštuoni šimtai trisdešimt aštuoni")] - [InlineData(880, "aštuoni šimtai aštuoniasdešimt")] - [InlineData(900, "devyni šimtai")] - [InlineData(904, "devyni šimtai keturi")] - [InlineData(909, "devyni šimtai devyni")] - [InlineData(949, "devyni šimtai keturiasdešimt devyni")] - [InlineData(990, "devyni šimtai devyniasdešimt")] - [InlineData(1000, "tūkstantis")] - [InlineData(1001, "tūkstantis vienas")] - [InlineData(1012, "tūkstantis dvylika")] - [InlineData(1100, "tūkstantis šimtas")] - [InlineData(1234, "tūkstantis du šimtai trisdešimt keturi")] - [InlineData(2000, "du tūkstančiai")] - [InlineData(2002, "du tūkstančiai du")] - [InlineData(2023, "du tūkstančiai dvidešimt trys")] - [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penki")] - [InlineData(3000, "trys tūkstančiai")] - [InlineData(3003, "trys tūkstančiai trys")] - [InlineData(3034, "trys tūkstančiai trisdešimt keturi")] - [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šeši")] - [InlineData(4000, "keturi tūkstančiai")] - [InlineData(4004, "keturi tūkstančiai keturi")] - [InlineData(4045, "keturi tūkstančiai keturiasdešimt penki")] - [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septyni")] - [InlineData(5000, "penki tūkstančiai")] - [InlineData(5005, "penki tūkstančiai penki")] - [InlineData(5056, "penki tūkstančiai penkiasdešimt šeši")] - [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštuoni")] - [InlineData(6000, "šeši tūkstančiai")] - [InlineData(6006, "šeši tūkstančiai šeši")] - [InlineData(6067, "šeši tūkstančiai šešiasdešimt septyni")] - [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devyni")] - [InlineData(7000, "septyni tūkstančiai")] - [InlineData(7007, "septyni tūkstančiai septyni")] - [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštuoni")] - [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimt")] - [InlineData(8000, "aštuoni tūkstančiai")] - [InlineData(8008, "aštuoni tūkstančiai aštuoni")] - [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devyni")] - [InlineData(8901, "aštuoni tūkstančiai devyni šimtai vienas")] - [InlineData(9000, "devyni tūkstančiai")] - [InlineData(9009, "devyni tūkstančiai devyni")] - [InlineData(9012, "devyni tūkstančiai dvylika")] - [InlineData(9090, "devyni tūkstančiai devyniasdešimt")] - [InlineData(10000, "dešimt tūkstančių")] - [InlineData(10001, "dešimt tūkstančių vienas")] - [InlineData(20020, "dvidešimt tūkstančių dvidešimt")] - [InlineData(30300, "trisdešimt tūkstančių trys šimtai")] - [InlineData(44000, "keturiasdešimt keturi tūkstančiai")] - [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt vienas")] - [InlineData(100000, "šimtas tūkstančių")] - [InlineData(500000, "penki šimtai tūkstančių")] - [InlineData(1000000, "milijonas")] - [InlineData(6000000, "šeši milijonai")] - [InlineData(10000000, "dešimt milijonų")] - [InlineData(70000000, "septyniasdešimt milijonų")] - [InlineData(100000000, "šimtas milijonų")] - [InlineData(800000000, "aštuoni šimtai milijonų")] - [InlineData(9223372036854775807, "devyni kvintilijonai du šimtai dvidešimt trys kvadrilijonai trys šimtai septyniasdešimt du trilijonai trisdešimt šeši milijardai aštuoni šimtai penkiasdešimt keturi milijonai septyni šimtai septyniasdešimt penki tūkstančiai aštuoni šimtai septyni")] - public void ToWordsMasculine(long number, string expected) => - Assert.Equal(expected, number.ToWords(gender: GrammaticalGender.Masculine)); + [Theory] + [InlineData(-1, "minus vienas")] + [InlineData(0, "nulis")] + [InlineData(1, "vienas")] + [InlineData(11, "vienuolika")] + [InlineData(21, "dvidešimt vienas")] + [InlineData(22, "dvidešimt du")] + [InlineData(26, "dvidešimt šeši")] + [InlineData(30, "trisdešimt")] + [InlineData(31, "trisdešimt vienas")] + [InlineData(33, "trisdešimt trys")] + [InlineData(37, "trisdešimt septyni")] + [InlineData(40, "keturiasdešimt")] + [InlineData(41, "keturiasdešimt vienas")] + [InlineData(44, "keturiasdešimt keturi")] + [InlineData(48, "keturiasdešimt aštuoni")] + [InlineData(50, "penkiasdešimt")] + [InlineData(51, "penkiasdešimt vienas")] + [InlineData(55, "penkiasdešimt penki")] + [InlineData(59, "penkiasdešimt devyni")] + [InlineData(60, "šešiasdešimt")] + [InlineData(61, "šešiasdešimt vienas")] + [InlineData(62, "šešiasdešimt du")] + [InlineData(66, "šešiasdešimt šeši")] + [InlineData(70, "septyniasdešimt")] + [InlineData(71, "septyniasdešimt vienas")] + [InlineData(73, "septyniasdešimt trys")] + [InlineData(77, "septyniasdešimt septyni")] + [InlineData(80, "aštuoniasdešimt")] + [InlineData(81, "aštuoniasdešimt vienas")] + [InlineData(84, "aštuoniasdešimt keturi")] + [InlineData(88, "aštuoniasdešimt aštuoni")] + [InlineData(90, "devyniasdešimt")] + [InlineData(91, "devyniasdešimt vienas")] + [InlineData(95, "devyniasdešimt penki")] + [InlineData(99, "devyniasdešimt devyni")] + [InlineData(100, "šimtas")] + [InlineData(101, "šimtas vienas")] + [InlineData(105, "šimtas penki")] + [InlineData(110, "šimtas dešimt")] + [InlineData(151, "šimtas penkiasdešimt vienas")] + [InlineData(200, "du šimtai")] + [InlineData(202, "du šimtai du")] + [InlineData(206, "du šimtai šeši")] + [InlineData(220, "du šimtai dvidešimt")] + [InlineData(262, "du šimtai šešiasdešimt du")] + [InlineData(300, "trys šimtai")] + [InlineData(303, "trys šimtai trys")] + [InlineData(307, "trys šimtai septyni")] + [InlineData(330, "trys šimtai trisdešimt")] + [InlineData(373, "trys šimtai septyniasdešimt trys")] + [InlineData(400, "keturi šimtai")] + [InlineData(404, "keturi šimtai keturi")] + [InlineData(408, "keturi šimtai aštuoni")] + [InlineData(440, "keturi šimtai keturiasdešimt")] + [InlineData(484, "keturi šimtai aštuoniasdešimt keturi")] + [InlineData(500, "penki šimtai")] + [InlineData(505, "penki šimtai penki")] + [InlineData(509, "penki šimtai devyni")] + [InlineData(550, "penki šimtai penkiasdešimt")] + [InlineData(595, "penki šimtai devyniasdešimt penki")] + [InlineData(600, "šeši šimtai")] + [InlineData(601, "šeši šimtai vienas")] + [InlineData(606, "šeši šimtai šeši")] + [InlineData(616, "šeši šimtai šešiolika")] + [InlineData(660, "šeši šimtai šešiasdešimt")] + [InlineData(700, "septyni šimtai")] + [InlineData(702, "septyni šimtai du")] + [InlineData(707, "septyni šimtai septyni")] + [InlineData(727, "septyni šimtai dvidešimt septyni")] + [InlineData(770, "septyni šimtai septyniasdešimt")] + [InlineData(800, "aštuoni šimtai")] + [InlineData(803, "aštuoni šimtai trys")] + [InlineData(808, "aštuoni šimtai aštuoni")] + [InlineData(838, "aštuoni šimtai trisdešimt aštuoni")] + [InlineData(880, "aštuoni šimtai aštuoniasdešimt")] + [InlineData(900, "devyni šimtai")] + [InlineData(904, "devyni šimtai keturi")] + [InlineData(909, "devyni šimtai devyni")] + [InlineData(949, "devyni šimtai keturiasdešimt devyni")] + [InlineData(990, "devyni šimtai devyniasdešimt")] + [InlineData(1000, "tūkstantis")] + [InlineData(1001, "tūkstantis vienas")] + [InlineData(1012, "tūkstantis dvylika")] + [InlineData(1100, "tūkstantis šimtas")] + [InlineData(1234, "tūkstantis du šimtai trisdešimt keturi")] + [InlineData(2000, "du tūkstančiai")] + [InlineData(2002, "du tūkstančiai du")] + [InlineData(2023, "du tūkstančiai dvidešimt trys")] + [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penki")] + [InlineData(3000, "trys tūkstančiai")] + [InlineData(3003, "trys tūkstančiai trys")] + [InlineData(3034, "trys tūkstančiai trisdešimt keturi")] + [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šeši")] + [InlineData(4000, "keturi tūkstančiai")] + [InlineData(4004, "keturi tūkstančiai keturi")] + [InlineData(4045, "keturi tūkstančiai keturiasdešimt penki")] + [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septyni")] + [InlineData(5000, "penki tūkstančiai")] + [InlineData(5005, "penki tūkstančiai penki")] + [InlineData(5056, "penki tūkstančiai penkiasdešimt šeši")] + [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštuoni")] + [InlineData(6000, "šeši tūkstančiai")] + [InlineData(6006, "šeši tūkstančiai šeši")] + [InlineData(6067, "šeši tūkstančiai šešiasdešimt septyni")] + [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devyni")] + [InlineData(7000, "septyni tūkstančiai")] + [InlineData(7007, "septyni tūkstančiai septyni")] + [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštuoni")] + [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimt")] + [InlineData(8000, "aštuoni tūkstančiai")] + [InlineData(8008, "aštuoni tūkstančiai aštuoni")] + [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devyni")] + [InlineData(8901, "aštuoni tūkstančiai devyni šimtai vienas")] + [InlineData(9000, "devyni tūkstančiai")] + [InlineData(9009, "devyni tūkstančiai devyni")] + [InlineData(9012, "devyni tūkstančiai dvylika")] + [InlineData(9090, "devyni tūkstančiai devyniasdešimt")] + [InlineData(10000, "dešimt tūkstančių")] + [InlineData(10001, "dešimt tūkstančių vienas")] + [InlineData(20020, "dvidešimt tūkstančių dvidešimt")] + [InlineData(30300, "trisdešimt tūkstančių trys šimtai")] + [InlineData(44000, "keturiasdešimt keturi tūkstančiai")] + [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt vienas")] + [InlineData(100000, "šimtas tūkstančių")] + [InlineData(500000, "penki šimtai tūkstančių")] + [InlineData(1000000, "milijonas")] + [InlineData(6000000, "šeši milijonai")] + [InlineData(10000000, "dešimt milijonų")] + [InlineData(70000000, "septyniasdešimt milijonų")] + [InlineData(100000000, "šimtas milijonų")] + [InlineData(800000000, "aštuoni šimtai milijonų")] + [InlineData(9223372036854775807, "devyni kvintilijonai du šimtai dvidešimt trys kvadrilijonai trys šimtai septyniasdešimt du trilijonai trisdešimt šeši milijardai aštuoni šimtai penkiasdešimt keturi milijonai septyni šimtai septyniasdešimt penki tūkstančiai aštuoni šimtai septyni")] + public void ToWordsMasculine(long number, string expected) => + Assert.Equal(expected, number.ToWords(gender: GrammaticalGender.Masculine)); - [Theory] - [InlineData(-1, "minus viena")] - [InlineData(0, "nulis")] - [InlineData(1, "viena")] - [InlineData(11, "vienuolika")] - [InlineData(21, "dvidešimt viena")] - [InlineData(22, "dvidešimt dvi")] - [InlineData(26, "dvidešimt šešios")] - [InlineData(30, "trisdešimt")] - [InlineData(31, "trisdešimt viena")] - [InlineData(33, "trisdešimt trys")] - [InlineData(37, "trisdešimt septynios")] - [InlineData(40, "keturiasdešimt")] - [InlineData(41, "keturiasdešimt viena")] - [InlineData(44, "keturiasdešimt keturios")] - [InlineData(48, "keturiasdešimt aštuonios")] - [InlineData(50, "penkiasdešimt")] - [InlineData(51, "penkiasdešimt viena")] - [InlineData(55, "penkiasdešimt penkios")] - [InlineData(59, "penkiasdešimt devynios")] - [InlineData(60, "šešiasdešimt")] - [InlineData(61, "šešiasdešimt viena")] - [InlineData(62, "šešiasdešimt dvi")] - [InlineData(66, "šešiasdešimt šešios")] - [InlineData(70, "septyniasdešimt")] - [InlineData(71, "septyniasdešimt viena")] - [InlineData(73, "septyniasdešimt trys")] - [InlineData(77, "septyniasdešimt septynios")] - [InlineData(80, "aštuoniasdešimt")] - [InlineData(81, "aštuoniasdešimt viena")] - [InlineData(84, "aštuoniasdešimt keturios")] - [InlineData(88, "aštuoniasdešimt aštuonios")] - [InlineData(90, "devyniasdešimt")] - [InlineData(91, "devyniasdešimt viena")] - [InlineData(95, "devyniasdešimt penkios")] - [InlineData(99, "devyniasdešimt devynios")] - [InlineData(100, "šimtas")] - [InlineData(101, "šimtas viena")] - [InlineData(105, "šimtas penkios")] - [InlineData(110, "šimtas dešimt")] - [InlineData(151, "šimtas penkiasdešimt viena")] - [InlineData(200, "du šimtai")] - [InlineData(202, "du šimtai dvi")] - [InlineData(206, "du šimtai šešios")] - [InlineData(220, "du šimtai dvidešimt")] - [InlineData(262, "du šimtai šešiasdešimt dvi")] - [InlineData(300, "trys šimtai")] - [InlineData(303, "trys šimtai trys")] - [InlineData(307, "trys šimtai septynios")] - [InlineData(330, "trys šimtai trisdešimt")] - [InlineData(373, "trys šimtai septyniasdešimt trys")] - [InlineData(400, "keturi šimtai")] - [InlineData(404, "keturi šimtai keturios")] - [InlineData(408, "keturi šimtai aštuonios")] - [InlineData(440, "keturi šimtai keturiasdešimt")] - [InlineData(484, "keturi šimtai aštuoniasdešimt keturios")] - [InlineData(500, "penki šimtai")] - [InlineData(505, "penki šimtai penkios")] - [InlineData(509, "penki šimtai devynios")] - [InlineData(550, "penki šimtai penkiasdešimt")] - [InlineData(595, "penki šimtai devyniasdešimt penkios")] - [InlineData(600, "šeši šimtai")] - [InlineData(601, "šeši šimtai viena")] - [InlineData(606, "šeši šimtai šešios")] - [InlineData(616, "šeši šimtai šešiolika")] - [InlineData(660, "šeši šimtai šešiasdešimt")] - [InlineData(700, "septyni šimtai")] - [InlineData(702, "septyni šimtai dvi")] - [InlineData(707, "septyni šimtai septynios")] - [InlineData(727, "septyni šimtai dvidešimt septynios")] - [InlineData(770, "septyni šimtai septyniasdešimt")] - [InlineData(800, "aštuoni šimtai")] - [InlineData(803, "aštuoni šimtai trys")] - [InlineData(808, "aštuoni šimtai aštuonios")] - [InlineData(838, "aštuoni šimtai trisdešimt aštuonios")] - [InlineData(880, "aštuoni šimtai aštuoniasdešimt")] - [InlineData(900, "devyni šimtai")] - [InlineData(904, "devyni šimtai keturios")] - [InlineData(909, "devyni šimtai devynios")] - [InlineData(949, "devyni šimtai keturiasdešimt devynios")] - [InlineData(990, "devyni šimtai devyniasdešimt")] - [InlineData(1000, "tūkstantis")] - [InlineData(1001, "tūkstantis viena")] - [InlineData(1012, "tūkstantis dvylika")] - [InlineData(1100, "tūkstantis šimtas")] - [InlineData(1234, "tūkstantis du šimtai trisdešimt keturios")] - [InlineData(2000, "du tūkstančiai")] - [InlineData(2002, "du tūkstančiai dvi")] - [InlineData(2023, "du tūkstančiai dvidešimt trys")] - [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penkios")] - [InlineData(3000, "trys tūkstančiai")] - [InlineData(3003, "trys tūkstančiai trys")] - [InlineData(3034, "trys tūkstančiai trisdešimt keturios")] - [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šešios")] - [InlineData(4000, "keturi tūkstančiai")] - [InlineData(4004, "keturi tūkstančiai keturios")] - [InlineData(4045, "keturi tūkstančiai keturiasdešimt penkios")] - [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septynios")] - [InlineData(5000, "penki tūkstančiai")] - [InlineData(5005, "penki tūkstančiai penkios")] - [InlineData(5056, "penki tūkstančiai penkiasdešimt šešios")] - [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštuonios")] - [InlineData(6000, "šeši tūkstančiai")] - [InlineData(6006, "šeši tūkstančiai šešios")] - [InlineData(6067, "šeši tūkstančiai šešiasdešimt septynios")] - [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devynios")] - [InlineData(7000, "septyni tūkstančiai")] - [InlineData(7007, "septyni tūkstančiai septynios")] - [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštuonios")] - [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimt")] - [InlineData(8000, "aštuoni tūkstančiai")] - [InlineData(8008, "aštuoni tūkstančiai aštuonios")] - [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devynios")] - [InlineData(8901, "aštuoni tūkstančiai devyni šimtai viena")] - [InlineData(9000, "devyni tūkstančiai")] - [InlineData(9009, "devyni tūkstančiai devynios")] - [InlineData(9012, "devyni tūkstančiai dvylika")] - [InlineData(9090, "devyni tūkstančiai devyniasdešimt")] - [InlineData(10000, "dešimt tūkstančių")] - [InlineData(10001, "dešimt tūkstančių viena")] - [InlineData(20020, "dvidešimt tūkstančių dvidešimt")] - [InlineData(30300, "trisdešimt tūkstančių trys šimtai")] - [InlineData(44000, "keturiasdešimt keturi tūkstančiai")] - [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt viena")] - [InlineData(100000, "šimtas tūkstančių")] - [InlineData(500000, "penki šimtai tūkstančių")] - [InlineData(1000000, "milijonas")] - [InlineData(6000000, "šeši milijonai")] - [InlineData(10000000, "dešimt milijonų")] - [InlineData(70000000, "septyniasdešimt milijonų")] - [InlineData(100000000, "šimtas milijonų")] - [InlineData(800000000, "aštuoni šimtai milijonų")] - [InlineData(9223372036854775807, "devyni kvintilijonai du šimtai dvidešimt trys kvadrilijonai trys šimtai septyniasdešimt du trilijonai trisdešimt šeši milijardai aštuoni šimtai penkiasdešimt keturi milijonai septyni šimtai septyniasdešimt penki tūkstančiai aštuoni šimtai septynios")] - public void ToWordsFeminine(long number, string expected) => - Assert.Equal(expected, number.ToWords(gender: GrammaticalGender.Feminine)); + [Theory] + [InlineData(-1, "minus viena")] + [InlineData(0, "nulis")] + [InlineData(1, "viena")] + [InlineData(11, "vienuolika")] + [InlineData(21, "dvidešimt viena")] + [InlineData(22, "dvidešimt dvi")] + [InlineData(26, "dvidešimt šešios")] + [InlineData(30, "trisdešimt")] + [InlineData(31, "trisdešimt viena")] + [InlineData(33, "trisdešimt trys")] + [InlineData(37, "trisdešimt septynios")] + [InlineData(40, "keturiasdešimt")] + [InlineData(41, "keturiasdešimt viena")] + [InlineData(44, "keturiasdešimt keturios")] + [InlineData(48, "keturiasdešimt aštuonios")] + [InlineData(50, "penkiasdešimt")] + [InlineData(51, "penkiasdešimt viena")] + [InlineData(55, "penkiasdešimt penkios")] + [InlineData(59, "penkiasdešimt devynios")] + [InlineData(60, "šešiasdešimt")] + [InlineData(61, "šešiasdešimt viena")] + [InlineData(62, "šešiasdešimt dvi")] + [InlineData(66, "šešiasdešimt šešios")] + [InlineData(70, "septyniasdešimt")] + [InlineData(71, "septyniasdešimt viena")] + [InlineData(73, "septyniasdešimt trys")] + [InlineData(77, "septyniasdešimt septynios")] + [InlineData(80, "aštuoniasdešimt")] + [InlineData(81, "aštuoniasdešimt viena")] + [InlineData(84, "aštuoniasdešimt keturios")] + [InlineData(88, "aštuoniasdešimt aštuonios")] + [InlineData(90, "devyniasdešimt")] + [InlineData(91, "devyniasdešimt viena")] + [InlineData(95, "devyniasdešimt penkios")] + [InlineData(99, "devyniasdešimt devynios")] + [InlineData(100, "šimtas")] + [InlineData(101, "šimtas viena")] + [InlineData(105, "šimtas penkios")] + [InlineData(110, "šimtas dešimt")] + [InlineData(151, "šimtas penkiasdešimt viena")] + [InlineData(200, "du šimtai")] + [InlineData(202, "du šimtai dvi")] + [InlineData(206, "du šimtai šešios")] + [InlineData(220, "du šimtai dvidešimt")] + [InlineData(262, "du šimtai šešiasdešimt dvi")] + [InlineData(300, "trys šimtai")] + [InlineData(303, "trys šimtai trys")] + [InlineData(307, "trys šimtai septynios")] + [InlineData(330, "trys šimtai trisdešimt")] + [InlineData(373, "trys šimtai septyniasdešimt trys")] + [InlineData(400, "keturi šimtai")] + [InlineData(404, "keturi šimtai keturios")] + [InlineData(408, "keturi šimtai aštuonios")] + [InlineData(440, "keturi šimtai keturiasdešimt")] + [InlineData(484, "keturi šimtai aštuoniasdešimt keturios")] + [InlineData(500, "penki šimtai")] + [InlineData(505, "penki šimtai penkios")] + [InlineData(509, "penki šimtai devynios")] + [InlineData(550, "penki šimtai penkiasdešimt")] + [InlineData(595, "penki šimtai devyniasdešimt penkios")] + [InlineData(600, "šeši šimtai")] + [InlineData(601, "šeši šimtai viena")] + [InlineData(606, "šeši šimtai šešios")] + [InlineData(616, "šeši šimtai šešiolika")] + [InlineData(660, "šeši šimtai šešiasdešimt")] + [InlineData(700, "septyni šimtai")] + [InlineData(702, "septyni šimtai dvi")] + [InlineData(707, "septyni šimtai septynios")] + [InlineData(727, "septyni šimtai dvidešimt septynios")] + [InlineData(770, "septyni šimtai septyniasdešimt")] + [InlineData(800, "aštuoni šimtai")] + [InlineData(803, "aštuoni šimtai trys")] + [InlineData(808, "aštuoni šimtai aštuonios")] + [InlineData(838, "aštuoni šimtai trisdešimt aštuonios")] + [InlineData(880, "aštuoni šimtai aštuoniasdešimt")] + [InlineData(900, "devyni šimtai")] + [InlineData(904, "devyni šimtai keturios")] + [InlineData(909, "devyni šimtai devynios")] + [InlineData(949, "devyni šimtai keturiasdešimt devynios")] + [InlineData(990, "devyni šimtai devyniasdešimt")] + [InlineData(1000, "tūkstantis")] + [InlineData(1001, "tūkstantis viena")] + [InlineData(1012, "tūkstantis dvylika")] + [InlineData(1100, "tūkstantis šimtas")] + [InlineData(1234, "tūkstantis du šimtai trisdešimt keturios")] + [InlineData(2000, "du tūkstančiai")] + [InlineData(2002, "du tūkstančiai dvi")] + [InlineData(2023, "du tūkstančiai dvidešimt trys")] + [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penkios")] + [InlineData(3000, "trys tūkstančiai")] + [InlineData(3003, "trys tūkstančiai trys")] + [InlineData(3034, "trys tūkstančiai trisdešimt keturios")] + [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šešios")] + [InlineData(4000, "keturi tūkstančiai")] + [InlineData(4004, "keturi tūkstančiai keturios")] + [InlineData(4045, "keturi tūkstančiai keturiasdešimt penkios")] + [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septynios")] + [InlineData(5000, "penki tūkstančiai")] + [InlineData(5005, "penki tūkstančiai penkios")] + [InlineData(5056, "penki tūkstančiai penkiasdešimt šešios")] + [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštuonios")] + [InlineData(6000, "šeši tūkstančiai")] + [InlineData(6006, "šeši tūkstančiai šešios")] + [InlineData(6067, "šeši tūkstančiai šešiasdešimt septynios")] + [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devynios")] + [InlineData(7000, "septyni tūkstančiai")] + [InlineData(7007, "septyni tūkstančiai septynios")] + [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštuonios")] + [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimt")] + [InlineData(8000, "aštuoni tūkstančiai")] + [InlineData(8008, "aštuoni tūkstančiai aštuonios")] + [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devynios")] + [InlineData(8901, "aštuoni tūkstančiai devyni šimtai viena")] + [InlineData(9000, "devyni tūkstančiai")] + [InlineData(9009, "devyni tūkstančiai devynios")] + [InlineData(9012, "devyni tūkstančiai dvylika")] + [InlineData(9090, "devyni tūkstančiai devyniasdešimt")] + [InlineData(10000, "dešimt tūkstančių")] + [InlineData(10001, "dešimt tūkstančių viena")] + [InlineData(20020, "dvidešimt tūkstančių dvidešimt")] + [InlineData(30300, "trisdešimt tūkstančių trys šimtai")] + [InlineData(44000, "keturiasdešimt keturi tūkstančiai")] + [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt viena")] + [InlineData(100000, "šimtas tūkstančių")] + [InlineData(500000, "penki šimtai tūkstančių")] + [InlineData(1000000, "milijonas")] + [InlineData(6000000, "šeši milijonai")] + [InlineData(10000000, "dešimt milijonų")] + [InlineData(70000000, "septyniasdešimt milijonų")] + [InlineData(100000000, "šimtas milijonų")] + [InlineData(800000000, "aštuoni šimtai milijonų")] + [InlineData(9223372036854775807, "devyni kvintilijonai du šimtai dvidešimt trys kvadrilijonai trys šimtai septyniasdešimt du trilijonai trisdešimt šeši milijardai aštuoni šimtai penkiasdešimt keturi milijonai septyni šimtai septyniasdešimt penki tūkstančiai aštuoni šimtai septynios")] + public void ToWordsFeminine(long number, string expected) => + Assert.Equal(expected, number.ToWords(gender: GrammaticalGender.Feminine)); - [Theory] - [InlineData(-1, "minus pirmas")] - [InlineData(0, "nulinis")] - [InlineData(1, "pirmas")] - [InlineData(21, "dvidešimt pirmas")] - [InlineData(22, "dvidešimt antras")] - [InlineData(26, "dvidešimt šeštas")] - [InlineData(30, "trisdešimtas")] - [InlineData(31, "trisdešimt pirmas")] - [InlineData(33, "trisdešimt trečias")] - [InlineData(37, "trisdešimt septintas")] - [InlineData(40, "keturiasdešimtas")] - [InlineData(41, "keturiasdešimt pirmas")] - [InlineData(44, "keturiasdešimt ketvirtas")] - [InlineData(48, "keturiasdešimt aštuntas")] - [InlineData(50, "penkiasdešimtas")] - [InlineData(51, "penkiasdešimt pirmas")] - [InlineData(55, "penkiasdešimt penktas")] - [InlineData(59, "penkiasdešimt devintas")] - [InlineData(60, "šešiasdešimtas")] - [InlineData(61, "šešiasdešimt pirmas")] - [InlineData(62, "šešiasdešimt antras")] - [InlineData(66, "šešiasdešimt šeštas")] - [InlineData(70, "septyniasdešimtas")] - [InlineData(71, "septyniasdešimt pirmas")] - [InlineData(73, "septyniasdešimt trečias")] - [InlineData(77, "septyniasdešimt septintas")] - [InlineData(80, "aštuoniasdešimtas")] - [InlineData(81, "aštuoniasdešimt pirmas")] - [InlineData(84, "aštuoniasdešimt ketvirtas")] - [InlineData(88, "aštuoniasdešimt aštuntas")] - [InlineData(90, "devyniasdešimtas")] - [InlineData(91, "devyniasdešimt pirmas")] - [InlineData(95, "devyniasdešimt penktas")] - [InlineData(99, "devyniasdešimt devintas")] - [InlineData(100, "šimtas")] - [InlineData(101, "šimtas pirmas")] - [InlineData(105, "šimtas penktas")] - [InlineData(110, "šimtas dešimtas")] - [InlineData(151, "šimtas penkiasdešimt pirmas")] - [InlineData(200, "du šimtas")] - [InlineData(202, "du šimtai antras")] - [InlineData(206, "du šimtai šeštas")] - [InlineData(220, "du šimtai dvidešimtas")] - [InlineData(262, "du šimtai šešiasdešimt antras")] - [InlineData(300, "trys šimtas")] - [InlineData(303, "trys šimtai trečias")] - [InlineData(307, "trys šimtai septintas")] - [InlineData(330, "trys šimtai trisdešimtas")] - [InlineData(373, "trys šimtai septyniasdešimt trečias")] - [InlineData(400, "keturi šimtas")] - [InlineData(404, "keturi šimtai ketvirtas")] - [InlineData(408, "keturi šimtai aštuntas")] - [InlineData(440, "keturi šimtai keturiasdešimtas")] - [InlineData(484, "keturi šimtai aštuoniasdešimt ketvirtas")] - [InlineData(500, "penki šimtas")] - [InlineData(505, "penki šimtai penktas")] - [InlineData(509, "penki šimtai devintas")] - [InlineData(550, "penki šimtai penkiasdešimtas")] - [InlineData(595, "penki šimtai devyniasdešimt penktas")] - [InlineData(600, "šeši šimtas")] - [InlineData(601, "šeši šimtai pirmas")] - [InlineData(606, "šeši šimtai šeštas")] - [InlineData(616, "šeši šimtai šešioliktas")] - [InlineData(660, "šeši šimtai šešiasdešimtas")] - [InlineData(700, "septyni šimtas")] - [InlineData(702, "septyni šimtai antras")] - [InlineData(707, "septyni šimtai septintas")] - [InlineData(727, "septyni šimtai dvidešimt septintas")] - [InlineData(770, "septyni šimtai septyniasdešimtas")] - [InlineData(800, "aštuoni šimtas")] - [InlineData(803, "aštuoni šimtai trečias")] - [InlineData(808, "aštuoni šimtai aštuntas")] - [InlineData(838, "aštuoni šimtai trisdešimt aštuntas")] - [InlineData(880, "aštuoni šimtai aštuoniasdešimtas")] - [InlineData(900, "devyni šimtas")] - [InlineData(904, "devyni šimtai ketvirtas")] - [InlineData(909, "devyni šimtai devintas")] - [InlineData(949, "devyni šimtai keturiasdešimt devintas")] - [InlineData(990, "devyni šimtai devyniasdešimtas")] - [InlineData(1000, "tūkstantas")] - [InlineData(1001, "tūkstantis pirmas")] - [InlineData(1012, "tūkstantis dvyliktas")] - [InlineData(1100, "tūkstantis šimtas")] - [InlineData(1234, "tūkstantis du šimtai trisdešimt ketvirtas")] - [InlineData(2000, "du tūkstantas")] - [InlineData(2002, "du tūkstančiai antras")] - [InlineData(2023, "du tūkstančiai dvidešimt trečias")] - [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penktas")] - [InlineData(3000, "trys tūkstantas")] - [InlineData(3003, "trys tūkstančiai trečias")] - [InlineData(3034, "trys tūkstančiai trisdešimt ketvirtas")] - [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šeštas")] - [InlineData(4000, "keturi tūkstantas")] - [InlineData(4004, "keturi tūkstančiai ketvirtas")] - [InlineData(4045, "keturi tūkstančiai keturiasdešimt penktas")] - [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septintas")] - [InlineData(5000, "penki tūkstantas")] - [InlineData(5005, "penki tūkstančiai penktas")] - [InlineData(5056, "penki tūkstančiai penkiasdešimt šeštas")] - [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštuntas")] - [InlineData(6000, "šeši tūkstantas")] - [InlineData(6006, "šeši tūkstančiai šeštas")] - [InlineData(6067, "šeši tūkstančiai šešiasdešimt septintas")] - [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devintas")] - [InlineData(7000, "septyni tūkstantas")] - [InlineData(7007, "septyni tūkstančiai septintas")] - [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštuntas")] - [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimtas")] - [InlineData(8000, "aštuoni tūkstantas")] - [InlineData(8008, "aštuoni tūkstančiai aštuntas")] - [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devintas")] - [InlineData(8901, "aštuoni tūkstančiai devyni šimtai pirmas")] - [InlineData(9000, "devyni tūkstantas")] - [InlineData(9009, "devyni tūkstančiai devintas")] - [InlineData(9012, "devyni tūkstančiai dvyliktas")] - [InlineData(9090, "devyni tūkstančiai devyniasdešimtas")] - [InlineData(10000, "dešimt tūkstantas")] - [InlineData(10001, "dešimt tūkstančių pirmas")] - [InlineData(20020, "dvidešimt tūkstančių dvidešimtas")] - [InlineData(30300, "trisdešimt tūkstančių trys šimtas")] - [InlineData(44000, "keturiasdešimt keturi tūkstantas")] - [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt pirmas")] - [InlineData(100000, "šimtas tūkstantas")] - [InlineData(500000, "penki šimtai tūkstantas")] - [InlineData(1000000, "milijonas")] - [InlineData(6000000, "šeši milijonas")] - [InlineData(10000000, "dešimt milijonas")] - [InlineData(70000000, "septyniasdešimt milijonas")] - [InlineData(100000000, "šimtas milijonas")] - [InlineData(800000000, "aštuoni šimtai milijonas")] - public void ToOrdinalWordsMasculine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(-1, "minus pirmas")] + [InlineData(0, "nulinis")] + [InlineData(1, "pirmas")] + [InlineData(21, "dvidešimt pirmas")] + [InlineData(22, "dvidešimt antras")] + [InlineData(26, "dvidešimt šeštas")] + [InlineData(30, "trisdešimtas")] + [InlineData(31, "trisdešimt pirmas")] + [InlineData(33, "trisdešimt trečias")] + [InlineData(37, "trisdešimt septintas")] + [InlineData(40, "keturiasdešimtas")] + [InlineData(41, "keturiasdešimt pirmas")] + [InlineData(44, "keturiasdešimt ketvirtas")] + [InlineData(48, "keturiasdešimt aštuntas")] + [InlineData(50, "penkiasdešimtas")] + [InlineData(51, "penkiasdešimt pirmas")] + [InlineData(55, "penkiasdešimt penktas")] + [InlineData(59, "penkiasdešimt devintas")] + [InlineData(60, "šešiasdešimtas")] + [InlineData(61, "šešiasdešimt pirmas")] + [InlineData(62, "šešiasdešimt antras")] + [InlineData(66, "šešiasdešimt šeštas")] + [InlineData(70, "septyniasdešimtas")] + [InlineData(71, "septyniasdešimt pirmas")] + [InlineData(73, "septyniasdešimt trečias")] + [InlineData(77, "septyniasdešimt septintas")] + [InlineData(80, "aštuoniasdešimtas")] + [InlineData(81, "aštuoniasdešimt pirmas")] + [InlineData(84, "aštuoniasdešimt ketvirtas")] + [InlineData(88, "aštuoniasdešimt aštuntas")] + [InlineData(90, "devyniasdešimtas")] + [InlineData(91, "devyniasdešimt pirmas")] + [InlineData(95, "devyniasdešimt penktas")] + [InlineData(99, "devyniasdešimt devintas")] + [InlineData(100, "šimtas")] + [InlineData(101, "šimtas pirmas")] + [InlineData(105, "šimtas penktas")] + [InlineData(110, "šimtas dešimtas")] + [InlineData(151, "šimtas penkiasdešimt pirmas")] + [InlineData(200, "du šimtas")] + [InlineData(202, "du šimtai antras")] + [InlineData(206, "du šimtai šeštas")] + [InlineData(220, "du šimtai dvidešimtas")] + [InlineData(262, "du šimtai šešiasdešimt antras")] + [InlineData(300, "trys šimtas")] + [InlineData(303, "trys šimtai trečias")] + [InlineData(307, "trys šimtai septintas")] + [InlineData(330, "trys šimtai trisdešimtas")] + [InlineData(373, "trys šimtai septyniasdešimt trečias")] + [InlineData(400, "keturi šimtas")] + [InlineData(404, "keturi šimtai ketvirtas")] + [InlineData(408, "keturi šimtai aštuntas")] + [InlineData(440, "keturi šimtai keturiasdešimtas")] + [InlineData(484, "keturi šimtai aštuoniasdešimt ketvirtas")] + [InlineData(500, "penki šimtas")] + [InlineData(505, "penki šimtai penktas")] + [InlineData(509, "penki šimtai devintas")] + [InlineData(550, "penki šimtai penkiasdešimtas")] + [InlineData(595, "penki šimtai devyniasdešimt penktas")] + [InlineData(600, "šeši šimtas")] + [InlineData(601, "šeši šimtai pirmas")] + [InlineData(606, "šeši šimtai šeštas")] + [InlineData(616, "šeši šimtai šešioliktas")] + [InlineData(660, "šeši šimtai šešiasdešimtas")] + [InlineData(700, "septyni šimtas")] + [InlineData(702, "septyni šimtai antras")] + [InlineData(707, "septyni šimtai septintas")] + [InlineData(727, "septyni šimtai dvidešimt septintas")] + [InlineData(770, "septyni šimtai septyniasdešimtas")] + [InlineData(800, "aštuoni šimtas")] + [InlineData(803, "aštuoni šimtai trečias")] + [InlineData(808, "aštuoni šimtai aštuntas")] + [InlineData(838, "aštuoni šimtai trisdešimt aštuntas")] + [InlineData(880, "aštuoni šimtai aštuoniasdešimtas")] + [InlineData(900, "devyni šimtas")] + [InlineData(904, "devyni šimtai ketvirtas")] + [InlineData(909, "devyni šimtai devintas")] + [InlineData(949, "devyni šimtai keturiasdešimt devintas")] + [InlineData(990, "devyni šimtai devyniasdešimtas")] + [InlineData(1000, "tūkstantas")] + [InlineData(1001, "tūkstantis pirmas")] + [InlineData(1012, "tūkstantis dvyliktas")] + [InlineData(1100, "tūkstantis šimtas")] + [InlineData(1234, "tūkstantis du šimtai trisdešimt ketvirtas")] + [InlineData(2000, "du tūkstantas")] + [InlineData(2002, "du tūkstančiai antras")] + [InlineData(2023, "du tūkstančiai dvidešimt trečias")] + [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penktas")] + [InlineData(3000, "trys tūkstantas")] + [InlineData(3003, "trys tūkstančiai trečias")] + [InlineData(3034, "trys tūkstančiai trisdešimt ketvirtas")] + [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šeštas")] + [InlineData(4000, "keturi tūkstantas")] + [InlineData(4004, "keturi tūkstančiai ketvirtas")] + [InlineData(4045, "keturi tūkstančiai keturiasdešimt penktas")] + [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septintas")] + [InlineData(5000, "penki tūkstantas")] + [InlineData(5005, "penki tūkstančiai penktas")] + [InlineData(5056, "penki tūkstančiai penkiasdešimt šeštas")] + [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštuntas")] + [InlineData(6000, "šeši tūkstantas")] + [InlineData(6006, "šeši tūkstančiai šeštas")] + [InlineData(6067, "šeši tūkstančiai šešiasdešimt septintas")] + [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devintas")] + [InlineData(7000, "septyni tūkstantas")] + [InlineData(7007, "septyni tūkstančiai septintas")] + [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštuntas")] + [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimtas")] + [InlineData(8000, "aštuoni tūkstantas")] + [InlineData(8008, "aštuoni tūkstančiai aštuntas")] + [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devintas")] + [InlineData(8901, "aštuoni tūkstančiai devyni šimtai pirmas")] + [InlineData(9000, "devyni tūkstantas")] + [InlineData(9009, "devyni tūkstančiai devintas")] + [InlineData(9012, "devyni tūkstančiai dvyliktas")] + [InlineData(9090, "devyni tūkstančiai devyniasdešimtas")] + [InlineData(10000, "dešimt tūkstantas")] + [InlineData(10001, "dešimt tūkstančių pirmas")] + [InlineData(20020, "dvidešimt tūkstančių dvidešimtas")] + [InlineData(30300, "trisdešimt tūkstančių trys šimtas")] + [InlineData(44000, "keturiasdešimt keturi tūkstantas")] + [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt pirmas")] + [InlineData(100000, "šimtas tūkstantas")] + [InlineData(500000, "penki šimtai tūkstantas")] + [InlineData(1000000, "milijonas")] + [InlineData(6000000, "šeši milijonas")] + [InlineData(10000000, "dešimt milijonas")] + [InlineData(70000000, "septyniasdešimt milijonas")] + [InlineData(100000000, "šimtas milijonas")] + [InlineData(800000000, "aštuoni šimtai milijonas")] + public void ToOrdinalWordsMasculine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(-1, "minus pirma")] - [InlineData(0, "nulinė")] - [InlineData(1, "pirma")] - [InlineData(21, "dvidešimt pirma")] - [InlineData(22, "dvidešimt antra")] - [InlineData(26, "dvidešimt šešta")] - [InlineData(30, "trisdešimta")] - [InlineData(31, "trisdešimt pirma")] - [InlineData(33, "trisdešimt trečia")] - [InlineData(37, "trisdešimt septinta")] - [InlineData(40, "keturiasdešimta")] - [InlineData(41, "keturiasdešimt pirma")] - [InlineData(44, "keturiasdešimt ketvirta")] - [InlineData(48, "keturiasdešimt aštunta")] - [InlineData(50, "penkiasdešimta")] - [InlineData(51, "penkiasdešimt pirma")] - [InlineData(55, "penkiasdešimt penkta")] - [InlineData(59, "penkiasdešimt devinta")] - [InlineData(60, "šešiasdešimta")] - [InlineData(61, "šešiasdešimt pirma")] - [InlineData(62, "šešiasdešimt antra")] - [InlineData(66, "šešiasdešimt šešta")] - [InlineData(70, "septyniasdešimta")] - [InlineData(71, "septyniasdešimt pirma")] - [InlineData(73, "septyniasdešimt trečia")] - [InlineData(77, "septyniasdešimt septinta")] - [InlineData(80, "aštuoniasdešimta")] - [InlineData(81, "aštuoniasdešimt pirma")] - [InlineData(84, "aštuoniasdešimt ketvirta")] - [InlineData(88, "aštuoniasdešimt aštunta")] - [InlineData(90, "devyniasdešimta")] - [InlineData(91, "devyniasdešimt pirma")] - [InlineData(95, "devyniasdešimt penkta")] - [InlineData(99, "devyniasdešimt devinta")] - [InlineData(100, "šimta")] - [InlineData(101, "šimtas pirma")] - [InlineData(105, "šimtas penkta")] - [InlineData(110, "šimtas dešimta")] - [InlineData(151, "šimtas penkiasdešimt pirma")] - [InlineData(200, "du šimta")] - [InlineData(202, "du šimtai antra")] - [InlineData(206, "du šimtai šešta")] - [InlineData(220, "du šimtai dvidešimta")] - [InlineData(262, "du šimtai šešiasdešimt antra")] - [InlineData(300, "trys šimta")] - [InlineData(303, "trys šimtai trečia")] - [InlineData(307, "trys šimtai septinta")] - [InlineData(330, "trys šimtai trisdešimta")] - [InlineData(373, "trys šimtai septyniasdešimt trečia")] - [InlineData(400, "keturi šimta")] - [InlineData(404, "keturi šimtai ketvirta")] - [InlineData(408, "keturi šimtai aštunta")] - [InlineData(440, "keturi šimtai keturiasdešimta")] - [InlineData(484, "keturi šimtai aštuoniasdešimt ketvirta")] - [InlineData(500, "penki šimta")] - [InlineData(505, "penki šimtai penkta")] - [InlineData(509, "penki šimtai devinta")] - [InlineData(550, "penki šimtai penkiasdešimta")] - [InlineData(595, "penki šimtai devyniasdešimt penkta")] - [InlineData(600, "šeši šimta")] - [InlineData(601, "šeši šimtai pirma")] - [InlineData(606, "šeši šimtai šešta")] - [InlineData(616, "šeši šimtai šešiolikta")] - [InlineData(660, "šeši šimtai šešiasdešimta")] - [InlineData(700, "septyni šimta")] - [InlineData(702, "septyni šimtai antra")] - [InlineData(707, "septyni šimtai septinta")] - [InlineData(727, "septyni šimtai dvidešimt septinta")] - [InlineData(770, "septyni šimtai septyniasdešimta")] - [InlineData(800, "aštuoni šimta")] - [InlineData(803, "aštuoni šimtai trečia")] - [InlineData(808, "aštuoni šimtai aštunta")] - [InlineData(838, "aštuoni šimtai trisdešimt aštunta")] - [InlineData(880, "aštuoni šimtai aštuoniasdešimta")] - [InlineData(900, "devyni šimta")] - [InlineData(904, "devyni šimtai ketvirta")] - [InlineData(909, "devyni šimtai devinta")] - [InlineData(949, "devyni šimtai keturiasdešimt devinta")] - [InlineData(990, "devyni šimtai devyniasdešimta")] - [InlineData(1000, "tūkstanta")] - [InlineData(1001, "tūkstantis pirma")] - [InlineData(1012, "tūkstantis dvylikta")] - [InlineData(1100, "tūkstantis šimta")] - [InlineData(1234, "tūkstantis du šimtai trisdešimt ketvirta")] - [InlineData(2000, "du tūkstanta")] - [InlineData(2002, "du tūkstančiai antra")] - [InlineData(2023, "du tūkstančiai dvidešimt trečia")] - [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penkta")] - [InlineData(3000, "trys tūkstanta")] - [InlineData(3003, "trys tūkstančiai trečia")] - [InlineData(3034, "trys tūkstančiai trisdešimt ketvirta")] - [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šešta")] - [InlineData(4000, "keturi tūkstanta")] - [InlineData(4004, "keturi tūkstančiai ketvirta")] - [InlineData(4045, "keturi tūkstančiai keturiasdešimt penkta")] - [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septinta")] - [InlineData(5000, "penki tūkstanta")] - [InlineData(5005, "penki tūkstančiai penkta")] - [InlineData(5056, "penki tūkstančiai penkiasdešimt šešta")] - [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštunta")] - [InlineData(6000, "šeši tūkstanta")] - [InlineData(6006, "šeši tūkstančiai šešta")] - [InlineData(6067, "šeši tūkstančiai šešiasdešimt septinta")] - [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devinta")] - [InlineData(7000, "septyni tūkstanta")] - [InlineData(7007, "septyni tūkstančiai septinta")] - [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštunta")] - [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimta")] - [InlineData(8000, "aštuoni tūkstanta")] - [InlineData(8008, "aštuoni tūkstančiai aštunta")] - [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devinta")] - [InlineData(8901, "aštuoni tūkstančiai devyni šimtai pirma")] - [InlineData(9000, "devyni tūkstanta")] - [InlineData(9009, "devyni tūkstančiai devinta")] - [InlineData(9012, "devyni tūkstančiai dvylikta")] - [InlineData(9090, "devyni tūkstančiai devyniasdešimta")] - [InlineData(10000, "dešimt tūkstanta")] - [InlineData(10001, "dešimt tūkstančių pirma")] - [InlineData(20020, "dvidešimt tūkstančių dvidešimta")] - [InlineData(30300, "trisdešimt tūkstančių trys šimta")] - [InlineData(44000, "keturiasdešimt keturi tūkstanta")] - [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt pirma")] - [InlineData(100000, "šimtas tūkstanta")] - [InlineData(500000, "penki šimtai tūkstanta")] - [InlineData(1000000, "milijona")] - [InlineData(6000000, "šeši milijona")] - [InlineData(10000000, "dešimt milijona")] - [InlineData(70000000, "septyniasdešimt milijona")] - [InlineData(100000000, "šimtas milijona")] - [InlineData(800000000, "aštuoni šimtai milijona")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(-1, "minus pirma")] + [InlineData(0, "nulinė")] + [InlineData(1, "pirma")] + [InlineData(21, "dvidešimt pirma")] + [InlineData(22, "dvidešimt antra")] + [InlineData(26, "dvidešimt šešta")] + [InlineData(30, "trisdešimta")] + [InlineData(31, "trisdešimt pirma")] + [InlineData(33, "trisdešimt trečia")] + [InlineData(37, "trisdešimt septinta")] + [InlineData(40, "keturiasdešimta")] + [InlineData(41, "keturiasdešimt pirma")] + [InlineData(44, "keturiasdešimt ketvirta")] + [InlineData(48, "keturiasdešimt aštunta")] + [InlineData(50, "penkiasdešimta")] + [InlineData(51, "penkiasdešimt pirma")] + [InlineData(55, "penkiasdešimt penkta")] + [InlineData(59, "penkiasdešimt devinta")] + [InlineData(60, "šešiasdešimta")] + [InlineData(61, "šešiasdešimt pirma")] + [InlineData(62, "šešiasdešimt antra")] + [InlineData(66, "šešiasdešimt šešta")] + [InlineData(70, "septyniasdešimta")] + [InlineData(71, "septyniasdešimt pirma")] + [InlineData(73, "septyniasdešimt trečia")] + [InlineData(77, "septyniasdešimt septinta")] + [InlineData(80, "aštuoniasdešimta")] + [InlineData(81, "aštuoniasdešimt pirma")] + [InlineData(84, "aštuoniasdešimt ketvirta")] + [InlineData(88, "aštuoniasdešimt aštunta")] + [InlineData(90, "devyniasdešimta")] + [InlineData(91, "devyniasdešimt pirma")] + [InlineData(95, "devyniasdešimt penkta")] + [InlineData(99, "devyniasdešimt devinta")] + [InlineData(100, "šimta")] + [InlineData(101, "šimtas pirma")] + [InlineData(105, "šimtas penkta")] + [InlineData(110, "šimtas dešimta")] + [InlineData(151, "šimtas penkiasdešimt pirma")] + [InlineData(200, "du šimta")] + [InlineData(202, "du šimtai antra")] + [InlineData(206, "du šimtai šešta")] + [InlineData(220, "du šimtai dvidešimta")] + [InlineData(262, "du šimtai šešiasdešimt antra")] + [InlineData(300, "trys šimta")] + [InlineData(303, "trys šimtai trečia")] + [InlineData(307, "trys šimtai septinta")] + [InlineData(330, "trys šimtai trisdešimta")] + [InlineData(373, "trys šimtai septyniasdešimt trečia")] + [InlineData(400, "keturi šimta")] + [InlineData(404, "keturi šimtai ketvirta")] + [InlineData(408, "keturi šimtai aštunta")] + [InlineData(440, "keturi šimtai keturiasdešimta")] + [InlineData(484, "keturi šimtai aštuoniasdešimt ketvirta")] + [InlineData(500, "penki šimta")] + [InlineData(505, "penki šimtai penkta")] + [InlineData(509, "penki šimtai devinta")] + [InlineData(550, "penki šimtai penkiasdešimta")] + [InlineData(595, "penki šimtai devyniasdešimt penkta")] + [InlineData(600, "šeši šimta")] + [InlineData(601, "šeši šimtai pirma")] + [InlineData(606, "šeši šimtai šešta")] + [InlineData(616, "šeši šimtai šešiolikta")] + [InlineData(660, "šeši šimtai šešiasdešimta")] + [InlineData(700, "septyni šimta")] + [InlineData(702, "septyni šimtai antra")] + [InlineData(707, "septyni šimtai septinta")] + [InlineData(727, "septyni šimtai dvidešimt septinta")] + [InlineData(770, "septyni šimtai septyniasdešimta")] + [InlineData(800, "aštuoni šimta")] + [InlineData(803, "aštuoni šimtai trečia")] + [InlineData(808, "aštuoni šimtai aštunta")] + [InlineData(838, "aštuoni šimtai trisdešimt aštunta")] + [InlineData(880, "aštuoni šimtai aštuoniasdešimta")] + [InlineData(900, "devyni šimta")] + [InlineData(904, "devyni šimtai ketvirta")] + [InlineData(909, "devyni šimtai devinta")] + [InlineData(949, "devyni šimtai keturiasdešimt devinta")] + [InlineData(990, "devyni šimtai devyniasdešimta")] + [InlineData(1000, "tūkstanta")] + [InlineData(1001, "tūkstantis pirma")] + [InlineData(1012, "tūkstantis dvylikta")] + [InlineData(1100, "tūkstantis šimta")] + [InlineData(1234, "tūkstantis du šimtai trisdešimt ketvirta")] + [InlineData(2000, "du tūkstanta")] + [InlineData(2002, "du tūkstančiai antra")] + [InlineData(2023, "du tūkstančiai dvidešimt trečia")] + [InlineData(2345, "du tūkstančiai trys šimtai keturiasdešimt penkta")] + [InlineData(3000, "trys tūkstanta")] + [InlineData(3003, "trys tūkstančiai trečia")] + [InlineData(3034, "trys tūkstančiai trisdešimt ketvirta")] + [InlineData(3456, "trys tūkstančiai keturi šimtai penkiasdešimt šešta")] + [InlineData(4000, "keturi tūkstanta")] + [InlineData(4004, "keturi tūkstančiai ketvirta")] + [InlineData(4045, "keturi tūkstančiai keturiasdešimt penkta")] + [InlineData(4567, "keturi tūkstančiai penki šimtai šešiasdešimt septinta")] + [InlineData(5000, "penki tūkstanta")] + [InlineData(5005, "penki tūkstančiai penkta")] + [InlineData(5056, "penki tūkstančiai penkiasdešimt šešta")] + [InlineData(5678, "penki tūkstančiai šeši šimtai septyniasdešimt aštunta")] + [InlineData(6000, "šeši tūkstanta")] + [InlineData(6006, "šeši tūkstančiai šešta")] + [InlineData(6067, "šeši tūkstančiai šešiasdešimt septinta")] + [InlineData(6789, "šeši tūkstančiai septyni šimtai aštuoniasdešimt devinta")] + [InlineData(7000, "septyni tūkstanta")] + [InlineData(7007, "septyni tūkstančiai septinta")] + [InlineData(7078, "septyni tūkstančiai septyniasdešimt aštunta")] + [InlineData(7890, "septyni tūkstančiai aštuoni šimtai devyniasdešimta")] + [InlineData(8000, "aštuoni tūkstanta")] + [InlineData(8008, "aštuoni tūkstančiai aštunta")] + [InlineData(8089, "aštuoni tūkstančiai aštuoniasdešimt devinta")] + [InlineData(8901, "aštuoni tūkstančiai devyni šimtai pirma")] + [InlineData(9000, "devyni tūkstanta")] + [InlineData(9009, "devyni tūkstančiai devinta")] + [InlineData(9012, "devyni tūkstančiai dvylikta")] + [InlineData(9090, "devyni tūkstančiai devyniasdešimta")] + [InlineData(10000, "dešimt tūkstanta")] + [InlineData(10001, "dešimt tūkstančių pirma")] + [InlineData(20020, "dvidešimt tūkstančių dvidešimta")] + [InlineData(30300, "trisdešimt tūkstančių trys šimta")] + [InlineData(44000, "keturiasdešimt keturi tūkstanta")] + [InlineData(44231, "keturiasdešimt keturi tūkstančiai du šimtai trisdešimt pirma")] + [InlineData(100000, "šimtas tūkstanta")] + [InlineData(500000, "penki šimtai tūkstanta")] + [InlineData(1000000, "milijona")] + [InlineData(6000000, "šeši milijona")] + [InlineData(10000000, "dešimt milijona")] + [InlineData(70000000, "septyniasdešimt milijona")] + [InlineData(100000000, "šimtas milijona")] + [InlineData(800000000, "aštuoni šimtai milijona")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/lt/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/lt/TimeSpanHumanizeTests.cs index 291371043..4662e30ca 100644 --- a/src/Humanizer.Tests/Localisation/lt/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/lt/TimeSpanHumanizeTests.cs @@ -1,95 +1,94 @@ -namespace Humanizer.Tests.Localisation.lt +namespace Humanizer.Tests.Localisation.lt; + +[UseCulture("lt")] +public class TimeSpanHumanizeTests { - [UseCulture("lt")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 metai")] - [InlineData(731, "2 metai")] - [InlineData(1096, "3 metai")] - [InlineData(4018, "11 metų")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 metai")] + [InlineData(731, "2 metai")] + [InlineData(1096, "3 metai")] + [InlineData(4018, "11 metų")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 mėnuo")] - [InlineData(61, "2 mėnesiai")] - [InlineData(280, "9 mėnesiai")] - [InlineData(330, "10 mėnesių")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 mėnuo")] + [InlineData(61, "2 mėnesiai")] + [InlineData(280, "9 mėnesiai")] + [InlineData(330, "10 mėnesių")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 savaitė")] - [InlineData(14, "2 savaitės")] - [InlineData(21, "3 savaitės")] - [InlineData(77, "11 savaičių")] - [InlineData(147, "21 savaitė")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 savaitė")] + [InlineData(14, "2 savaitės")] + [InlineData(21, "3 savaitės")] + [InlineData(77, "11 savaičių")] + [InlineData(147, "21 savaitė")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 diena")] - [InlineData(2, "2 dienos")] - [InlineData(9, "9 dienos")] - [InlineData(10, "10 dienų")] - [InlineData(17, "17 dienų")] - [InlineData(21, "21 diena")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Day)); + [Theory] + [InlineData(1, "1 diena")] + [InlineData(2, "2 dienos")] + [InlineData(9, "9 dienos")] + [InlineData(10, "10 dienų")] + [InlineData(17, "17 dienų")] + [InlineData(21, "21 diena")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Day)); - [Theory] - [InlineData(1, "1 valanda")] - [InlineData(2, "2 valandos")] - [InlineData(3, "3 valandos")] - [InlineData(9, "9 valandos")] - [InlineData(10, "10 valandų")] - [InlineData(19, "19 valandų")] - [InlineData(21, "21 valanda")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 valanda")] + [InlineData(2, "2 valandos")] + [InlineData(3, "3 valandos")] + [InlineData(9, "9 valandos")] + [InlineData(10, "10 valandų")] + [InlineData(19, "19 valandų")] + [InlineData(21, "21 valanda")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 minutė")] - [InlineData(2, "2 minutės")] - [InlineData(3, "3 minutės")] - [InlineData(9, "9 minutės")] - [InlineData(10, "10 minučių")] - [InlineData(19, "19 minučių")] - [InlineData(21, "21 minutė")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 minutė")] + [InlineData(2, "2 minutės")] + [InlineData(3, "3 minutės")] + [InlineData(9, "9 minutės")] + [InlineData(10, "10 minučių")] + [InlineData(19, "19 minučių")] + [InlineData(21, "21 minutė")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 sekundė")] - [InlineData(2, "2 sekundės")] - [InlineData(3, "3 sekundės")] - [InlineData(9, "9 sekundės")] - [InlineData(10, "10 sekundžių")] - [InlineData(19, "19 sekundžių")] - [InlineData(21, "21 sekundė")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 sekundė")] + [InlineData(2, "2 sekundės")] + [InlineData(3, "3 sekundės")] + [InlineData(9, "9 sekundės")] + [InlineData(10, "10 sekundžių")] + [InlineData(19, "19 sekundžių")] + [InlineData(21, "21 sekundė")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 milisekundė")] - [InlineData(2, "2 milisekundės")] - [InlineData(3, "3 milisekundės")] - [InlineData(9, "9 milisekundės")] - [InlineData(10, "10 milisekundžių")] - [InlineData(19, "19 milisekundžių")] - [InlineData(21, "21 milisekundė")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 milisekundė")] + [InlineData(2, "2 milisekundės")] + [InlineData(3, "3 milisekundės")] + [InlineData(9, "9 milisekundės")] + [InlineData(10, "10 milisekundžių")] + [InlineData(19, "19 milisekundžių")] + [InlineData(21, "21 milisekundė")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 milisekundžių", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 milisekundžių", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("nėra laiko", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("nėra laiko", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/lv/DateToOrdinalWordsTests.cs b/src/Humanizer.Tests/Localisation/lv/DateToOrdinalWordsTests.cs index 39301336b..87a896532 100644 --- a/src/Humanizer.Tests/Localisation/lv/DateToOrdinalWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/lv/DateToOrdinalWordsTests.cs @@ -1,10 +1,9 @@ -namespace Humanizer.Tests.Localisation.lv +namespace Humanizer.Tests.Localisation.lv; + +[UseCulture("lv")] +public class DateToOrdinalWordsTests { - [UseCulture("lv")] - public class DateToOrdinalWordsTests - { - [Fact] - public void OrdinalizeString() => - Assert.Equal("1 janvāris 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); - } -} + [Fact] + public void OrdinalizeString() => + Assert.Equal("1 janvāris 2015", new DateTime(2015, 1, 1).ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/lv/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/lv/NumberToWordsTests.cs index 224d86945..4937ca295 100644 --- a/src/Humanizer.Tests/Localisation/lv/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/lv/NumberToWordsTests.cs @@ -1,399 +1,398 @@ -namespace Humanizer.Tests.Localisation.lv +namespace Humanizer.Tests.Localisation.lv; + +[UseCulture("lv-LV")] +public class NumberToWordsTests { - [UseCulture("lv-LV")] - public class NumberToWordsTests - { - [Theory] - [InlineData(21, "divdesmit viens")] - [InlineData(22, "divdesmit divi")] - [InlineData(26, "divdesmit seši")] - [InlineData(30, "trīsdesmit")] - [InlineData(31, "trīsdesmit viens")] - [InlineData(33, "trīsdesmit trīs")] - [InlineData(37, "trīsdesmit septiņi")] - [InlineData(40, "četrdesmit")] - [InlineData(41, "četrdesmit viens")] - [InlineData(44, "četrdesmit četri")] - [InlineData(48, "četrdesmit astoņi")] - [InlineData(50, "piecdesmit")] - [InlineData(51, "piecdesmit viens")] - [InlineData(55, "piecdesmit pieci")] - [InlineData(59, "piecdesmit deviņi")] - [InlineData(60, "sešdesmit")] - [InlineData(61, "sešdesmit viens")] - [InlineData(62, "sešdesmit divi")] - [InlineData(66, "sešdesmit seši")] - [InlineData(70, "septiņdesmit")] - [InlineData(71, "septiņdesmit viens")] - [InlineData(73, "septiņdesmit trīs")] - [InlineData(77, "septiņdesmit septiņi")] - [InlineData(80, "astoņdesmit")] - [InlineData(81, "astoņdesmit viens")] - [InlineData(84, "astoņdesmit četri")] - [InlineData(88, "astoņdesmit astoņi")] - [InlineData(90, "deviņdesmit")] - [InlineData(91, "deviņdesmit viens")] - [InlineData(95, "deviņdesmit pieci")] - [InlineData(99, "deviņdesmit deviņi")] - [InlineData(100, "simts")] - [InlineData(101, "simtu viens")] - [InlineData(105, "simtu pieci")] - [InlineData(110, "simtu desmit")] - [InlineData(151, "simtu piecdesmit viens")] - [InlineData(200, "divi simti")] - [InlineData(202, "divi simti divi")] - [InlineData(206, "divi simti seši")] - [InlineData(220, "divi simti divdesmit")] - [InlineData(262, "divi simti sešdesmit divi")] - [InlineData(300, "trīs simti")] - [InlineData(303, "trīs simti trīs")] - [InlineData(307, "trīs simti septiņi")] - [InlineData(330, "trīs simti trīsdesmit")] - [InlineData(373, "trīs simti septiņdesmit trīs")] - [InlineData(400, "četri simti")] - [InlineData(404, "četri simti četri")] - [InlineData(408, "četri simti astoņi")] - [InlineData(440, "četri simti četrdesmit")] - [InlineData(484, "četri simti astoņdesmit četri")] - [InlineData(500, "pieci simti")] - [InlineData(505, "pieci simti pieci")] - [InlineData(509, "pieci simti deviņi")] - [InlineData(550, "pieci simti piecdesmit")] - [InlineData(595, "pieci simti deviņdesmit pieci")] - [InlineData(600, "seši simti")] - [InlineData(601, "seši simti viens")] - [InlineData(606, "seši simti seši")] - [InlineData(616, "seši simti sešpadsmit")] - [InlineData(660, "seši simti sešdesmit")] - [InlineData(700, "septiņi simti")] - [InlineData(702, "septiņi simti divi")] - [InlineData(707, "septiņi simti septiņi")] - [InlineData(727, "septiņi simti divdesmit septiņi")] - [InlineData(770, "septiņi simti septiņdesmit")] - [InlineData(800, "astoņi simti")] - [InlineData(803, "astoņi simti trīs")] - [InlineData(808, "astoņi simti astoņi")] - [InlineData(838, "astoņi simti trīsdesmit astoņi")] - [InlineData(880, "astoņi simti astoņdesmit")] - [InlineData(900, "deviņi simti")] - [InlineData(904, "deviņi simti četri")] - [InlineData(909, "deviņi simti deviņi")] - [InlineData(949, "deviņi simti četrdesmit deviņi")] - [InlineData(990, "deviņi simti deviņdesmit")] - [InlineData(1000, "tūkstotis")] - [InlineData(1001, "tūkstoš viens")] - [InlineData(1012, "tūkstoš divpadsmit")] - [InlineData(1100, "tūkstoš viens simts")] - [InlineData(1234, "tūkstoš divi simti trīsdesmit četri")] - [InlineData(2000, "divi tūkstoši")] - [InlineData(2002, "divi tūkstoši divi")] - [InlineData(2023, "divi tūkstoši divdesmit trīs")] - [InlineData(2345, "divi tūkstoši trīs simti četrdesmit pieci")] - [InlineData(3000, "trīs tūkstoši")] - [InlineData(3003, "trīs tūkstoši trīs")] - [InlineData(3034, "trīs tūkstoši trīsdesmit četri")] - [InlineData(3456, "trīs tūkstoši četri simti piecdesmit seši")] - [InlineData(4000, "četri tūkstoši")] - [InlineData(4004, "četri tūkstoši četri")] - [InlineData(4045, "četri tūkstoši četrdesmit pieci")] - [InlineData(4567, "četri tūkstoši pieci simti sešdesmit septiņi")] - [InlineData(5000, "pieci tūkstoši")] - [InlineData(5005, "pieci tūkstoši pieci")] - [InlineData(5056, "pieci tūkstoši piecdesmit seši")] - [InlineData(5678, "pieci tūkstoši seši simti septiņdesmit astoņi")] - [InlineData(6000, "seši tūkstoši")] - [InlineData(6006, "seši tūkstoši seši")] - [InlineData(6067, "seši tūkstoši sešdesmit septiņi")] - [InlineData(6789, "seši tūkstoši septiņi simti astoņdesmit deviņi")] - [InlineData(7000, "septiņi tūkstoši")] - [InlineData(7007, "septiņi tūkstoši septiņi")] - [InlineData(7078, "septiņi tūkstoši septiņdesmit astoņi")] - [InlineData(7890, "septiņi tūkstoši astoņi simti deviņdesmit")] - [InlineData(8000, "astoņi tūkstoši")] - [InlineData(8008, "astoņi tūkstoši astoņi")] - [InlineData(8089, "astoņi tūkstoši astoņdesmit deviņi")] - [InlineData(8901, "astoņi tūkstoši deviņi simti viens")] - [InlineData(9000, "deviņi tūkstoši")] - [InlineData(9009, "deviņi tūkstoši deviņi")] - [InlineData(9012, "deviņi tūkstoši divpadsmit")] - [InlineData(9090, "deviņi tūkstoši deviņdesmit")] - [InlineData(10000, "desmit tūkstoši")] - [InlineData(10001, "desmit tūkstoši viens")] - [InlineData(20020, "divdesmit tūkstoši divdesmit")] - [InlineData(30300, "trīsdesmit tūkstoši trīs simti")] - [InlineData(44000, "četrdesmit četri tūkstoši")] - [InlineData(44231, "četrdesmit četri tūkstoši divi simti trīsdesmit viens")] - [InlineData(100000, "simts tūkstoši")] - [InlineData(500000, "pieci simti tūkstoši")] - [InlineData(1000000, "miljons")] - [InlineData(6000000, "seši miljoni")] - [InlineData(10000000, "desmit miljoni")] - [InlineData(70000000, "septiņdesmit miljoni")] - [InlineData(100000000, "simts miljoni")] - [InlineData(800000000, "astoņi simti miljoni")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(21, "divdesmit viens")] + [InlineData(22, "divdesmit divi")] + [InlineData(26, "divdesmit seši")] + [InlineData(30, "trīsdesmit")] + [InlineData(31, "trīsdesmit viens")] + [InlineData(33, "trīsdesmit trīs")] + [InlineData(37, "trīsdesmit septiņi")] + [InlineData(40, "četrdesmit")] + [InlineData(41, "četrdesmit viens")] + [InlineData(44, "četrdesmit četri")] + [InlineData(48, "četrdesmit astoņi")] + [InlineData(50, "piecdesmit")] + [InlineData(51, "piecdesmit viens")] + [InlineData(55, "piecdesmit pieci")] + [InlineData(59, "piecdesmit deviņi")] + [InlineData(60, "sešdesmit")] + [InlineData(61, "sešdesmit viens")] + [InlineData(62, "sešdesmit divi")] + [InlineData(66, "sešdesmit seši")] + [InlineData(70, "septiņdesmit")] + [InlineData(71, "septiņdesmit viens")] + [InlineData(73, "septiņdesmit trīs")] + [InlineData(77, "septiņdesmit septiņi")] + [InlineData(80, "astoņdesmit")] + [InlineData(81, "astoņdesmit viens")] + [InlineData(84, "astoņdesmit četri")] + [InlineData(88, "astoņdesmit astoņi")] + [InlineData(90, "deviņdesmit")] + [InlineData(91, "deviņdesmit viens")] + [InlineData(95, "deviņdesmit pieci")] + [InlineData(99, "deviņdesmit deviņi")] + [InlineData(100, "simts")] + [InlineData(101, "simtu viens")] + [InlineData(105, "simtu pieci")] + [InlineData(110, "simtu desmit")] + [InlineData(151, "simtu piecdesmit viens")] + [InlineData(200, "divi simti")] + [InlineData(202, "divi simti divi")] + [InlineData(206, "divi simti seši")] + [InlineData(220, "divi simti divdesmit")] + [InlineData(262, "divi simti sešdesmit divi")] + [InlineData(300, "trīs simti")] + [InlineData(303, "trīs simti trīs")] + [InlineData(307, "trīs simti septiņi")] + [InlineData(330, "trīs simti trīsdesmit")] + [InlineData(373, "trīs simti septiņdesmit trīs")] + [InlineData(400, "četri simti")] + [InlineData(404, "četri simti četri")] + [InlineData(408, "četri simti astoņi")] + [InlineData(440, "četri simti četrdesmit")] + [InlineData(484, "četri simti astoņdesmit četri")] + [InlineData(500, "pieci simti")] + [InlineData(505, "pieci simti pieci")] + [InlineData(509, "pieci simti deviņi")] + [InlineData(550, "pieci simti piecdesmit")] + [InlineData(595, "pieci simti deviņdesmit pieci")] + [InlineData(600, "seši simti")] + [InlineData(601, "seši simti viens")] + [InlineData(606, "seši simti seši")] + [InlineData(616, "seši simti sešpadsmit")] + [InlineData(660, "seši simti sešdesmit")] + [InlineData(700, "septiņi simti")] + [InlineData(702, "septiņi simti divi")] + [InlineData(707, "septiņi simti septiņi")] + [InlineData(727, "septiņi simti divdesmit septiņi")] + [InlineData(770, "septiņi simti septiņdesmit")] + [InlineData(800, "astoņi simti")] + [InlineData(803, "astoņi simti trīs")] + [InlineData(808, "astoņi simti astoņi")] + [InlineData(838, "astoņi simti trīsdesmit astoņi")] + [InlineData(880, "astoņi simti astoņdesmit")] + [InlineData(900, "deviņi simti")] + [InlineData(904, "deviņi simti četri")] + [InlineData(909, "deviņi simti deviņi")] + [InlineData(949, "deviņi simti četrdesmit deviņi")] + [InlineData(990, "deviņi simti deviņdesmit")] + [InlineData(1000, "tūkstotis")] + [InlineData(1001, "tūkstoš viens")] + [InlineData(1012, "tūkstoš divpadsmit")] + [InlineData(1100, "tūkstoš viens simts")] + [InlineData(1234, "tūkstoš divi simti trīsdesmit četri")] + [InlineData(2000, "divi tūkstoši")] + [InlineData(2002, "divi tūkstoši divi")] + [InlineData(2023, "divi tūkstoši divdesmit trīs")] + [InlineData(2345, "divi tūkstoši trīs simti četrdesmit pieci")] + [InlineData(3000, "trīs tūkstoši")] + [InlineData(3003, "trīs tūkstoši trīs")] + [InlineData(3034, "trīs tūkstoši trīsdesmit četri")] + [InlineData(3456, "trīs tūkstoši četri simti piecdesmit seši")] + [InlineData(4000, "četri tūkstoši")] + [InlineData(4004, "četri tūkstoši četri")] + [InlineData(4045, "četri tūkstoši četrdesmit pieci")] + [InlineData(4567, "četri tūkstoši pieci simti sešdesmit septiņi")] + [InlineData(5000, "pieci tūkstoši")] + [InlineData(5005, "pieci tūkstoši pieci")] + [InlineData(5056, "pieci tūkstoši piecdesmit seši")] + [InlineData(5678, "pieci tūkstoši seši simti septiņdesmit astoņi")] + [InlineData(6000, "seši tūkstoši")] + [InlineData(6006, "seši tūkstoši seši")] + [InlineData(6067, "seši tūkstoši sešdesmit septiņi")] + [InlineData(6789, "seši tūkstoši septiņi simti astoņdesmit deviņi")] + [InlineData(7000, "septiņi tūkstoši")] + [InlineData(7007, "septiņi tūkstoši septiņi")] + [InlineData(7078, "septiņi tūkstoši septiņdesmit astoņi")] + [InlineData(7890, "septiņi tūkstoši astoņi simti deviņdesmit")] + [InlineData(8000, "astoņi tūkstoši")] + [InlineData(8008, "astoņi tūkstoši astoņi")] + [InlineData(8089, "astoņi tūkstoši astoņdesmit deviņi")] + [InlineData(8901, "astoņi tūkstoši deviņi simti viens")] + [InlineData(9000, "deviņi tūkstoši")] + [InlineData(9009, "deviņi tūkstoši deviņi")] + [InlineData(9012, "deviņi tūkstoši divpadsmit")] + [InlineData(9090, "deviņi tūkstoši deviņdesmit")] + [InlineData(10000, "desmit tūkstoši")] + [InlineData(10001, "desmit tūkstoši viens")] + [InlineData(20020, "divdesmit tūkstoši divdesmit")] + [InlineData(30300, "trīsdesmit tūkstoši trīs simti")] + [InlineData(44000, "četrdesmit četri tūkstoši")] + [InlineData(44231, "četrdesmit četri tūkstoši divi simti trīsdesmit viens")] + [InlineData(100000, "simts tūkstoši")] + [InlineData(500000, "pieci simti tūkstoši")] + [InlineData(1000000, "miljons")] + [InlineData(6000000, "seši miljoni")] + [InlineData(10000000, "desmit miljoni")] + [InlineData(70000000, "septiņdesmit miljoni")] + [InlineData(100000000, "simts miljoni")] + [InlineData(800000000, "astoņi simti miljoni")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(21, "divdesmit pirmais")] - [InlineData(22, "divdesmit otrais")] - [InlineData(26, "divdesmit sestais")] - [InlineData(30, "trīsdesmitais")] - [InlineData(31, "trīsdesmit pirmais")] - [InlineData(33, "trīsdesmit trešais")] - [InlineData(37, "trīsdesmit septītais")] - [InlineData(40, "četrdesmitais")] - [InlineData(41, "četrdesmit pirmais")] - [InlineData(44, "četrdesmit ceturtais")] - [InlineData(48, "četrdesmit astotais")] - [InlineData(50, "piecdesmitais")] - [InlineData(51, "piecdesmit pirmais")] - [InlineData(55, "piecdesmit piektais")] - [InlineData(59, "piecdesmit devītais")] - [InlineData(60, "sešdesmitais")] - [InlineData(61, "sešdesmit pirmais")] - [InlineData(62, "sešdesmit otrais")] - [InlineData(66, "sešdesmit sestais")] - [InlineData(70, "septiņdesmitais")] - [InlineData(71, "septiņdesmit pirmais")] - [InlineData(73, "septiņdesmit trešais")] - [InlineData(77, "septiņdesmit septītais")] - [InlineData(80, "astoņdesmitais")] - [InlineData(81, "astoņdesmit pirmais")] - [InlineData(84, "astoņdesmit ceturtais")] - [InlineData(88, "astoņdesmit astotais")] - [InlineData(90, "deviņdesmitais")] - [InlineData(91, "deviņdesmit pirmais")] - [InlineData(95, "deviņdesmit piektais")] - [InlineData(99, "deviņdesmit devītais")] - [InlineData(100, "simtais")] - [InlineData(101, "simtu pirmais")] - [InlineData(105, "simtu piektais")] - [InlineData(110, "simtu desmitais")] - [InlineData(151, "simtu piecdesmit pirmais")] - [InlineData(200, "divsimtais")] - [InlineData(202, "divi simti otrais")] - [InlineData(206, "divi simti sestais")] - [InlineData(220, "divi simti divdesmitais")] - [InlineData(262, "divi simti sešdesmit otrais")] - [InlineData(300, "trīssimtais")] - [InlineData(303, "trīs simti trešais")] - [InlineData(307, "trīs simti septītais")] - [InlineData(330, "trīs simti trīsdesmitais")] - [InlineData(373, "trīs simti septiņdesmit trešais")] - [InlineData(400, "četrsimtais")] - [InlineData(404, "četri simti ceturtais")] - [InlineData(408, "četri simti astotais")] - [InlineData(440, "četri simti četrdesmitais")] - [InlineData(484, "četri simti astoņdesmit ceturtais")] - [InlineData(500, "piecsimtais")] - [InlineData(505, "pieci simti piektais")] - [InlineData(509, "pieci simti devītais")] - [InlineData(550, "pieci simti piecdesmitais")] - [InlineData(595, "pieci simti deviņdesmit piektais")] - [InlineData(600, "sešsimtais")] - [InlineData(601, "seši simti pirmais")] - [InlineData(606, "seši simti sestais")] - [InlineData(616, "seši simti sešpadsmitais")] - [InlineData(660, "seši simti sešdesmitais")] - [InlineData(700, "septiņsimtais")] - [InlineData(702, "septiņi simti otrais")] - [InlineData(707, "septiņi simti septītais")] - [InlineData(727, "septiņi simti divdesmit septītais")] - [InlineData(770, "septiņi simti septiņdesmitais")] - [InlineData(800, "astoņsimtais")] - [InlineData(803, "astoņi simti trešais")] - [InlineData(808, "astoņi simti astotais")] - [InlineData(838, "astoņi simti trīsdesmit astotais")] - [InlineData(880, "astoņi simti astoņdesmitais")] - [InlineData(900, "deviņsimtais")] - [InlineData(904, "deviņi simti ceturtais")] - [InlineData(909, "deviņi simti devītais")] - [InlineData(949, "deviņi simti četrdesmit devītais")] - [InlineData(990, "deviņi simti deviņdesmitais")] - [InlineData(1000, "tūkstošais")] - [InlineData(1001, "tūkstoš pirmais")] - [InlineData(1012, "tūkstoš divpadsmitais")] - [InlineData(1100, "tūkstoš simtais")] - [InlineData(1234, "tūkstoš divi simti trīsdesmit ceturtais")] - [InlineData(2000, "divi tūkstošais")] - [InlineData(2002, "divi tūkstoši otrais")] - [InlineData(2023, "divi tūkstoši divdesmit trešais")] - [InlineData(2345, "divi tūkstoši trīs simti četrdesmit piektais")] - [InlineData(3000, "trīs tūkstošais")] - [InlineData(3003, "trīs tūkstoši trešais")] - [InlineData(3034, "trīs tūkstoši trīsdesmit ceturtais")] - [InlineData(3456, "trīs tūkstoši četri simti piecdesmit sestais")] - [InlineData(4000, "četri tūkstošais")] - [InlineData(4004, "četri tūkstoši ceturtais")] - [InlineData(4045, "četri tūkstoši četrdesmit piektais")] - [InlineData(4567, "četri tūkstoši pieci simti sešdesmit septītais")] - [InlineData(5000, "pieci tūkstošais")] - [InlineData(5005, "pieci tūkstoši piektais")] - [InlineData(5056, "pieci tūkstoši piecdesmit sestais")] - [InlineData(5678, "pieci tūkstoši seši simti septiņdesmit astotais")] - [InlineData(6000, "seši tūkstošais")] - [InlineData(6006, "seši tūkstoši sestais")] - [InlineData(6067, "seši tūkstoši sešdesmit septītais")] - [InlineData(6789, "seši tūkstoši septiņi simti astoņdesmit devītais")] - [InlineData(7000, "septiņi tūkstošais")] - [InlineData(7007, "septiņi tūkstoši septītais")] - [InlineData(7078, "septiņi tūkstoši septiņdesmit astotais")] - [InlineData(7890, "septiņi tūkstoši astoņi simti deviņdesmitais")] - [InlineData(8000, "astoņi tūkstošais")] - [InlineData(8008, "astoņi tūkstoši astotais")] - [InlineData(8089, "astoņi tūkstoši astoņdesmit devītais")] - [InlineData(8901, "astoņi tūkstoši deviņi simti pirmais")] - [InlineData(9000, "deviņi tūkstošais")] - [InlineData(9009, "deviņi tūkstoši devītais")] - [InlineData(9012, "deviņi tūkstoši divpadsmitais")] - [InlineData(9090, "deviņi tūkstoši deviņdesmitais")] - [InlineData(10000, "desmit tūkstošais")] - [InlineData(10001, "desmit tūkstoši pirmais")] - [InlineData(20020, "divdesmit tūkstoši divdesmitais")] - [InlineData(30300, "trīsdesmit tūkstoši trīssimtais")] - [InlineData(44000, "četrdesmit četri tūkstošais")] - [InlineData(44231, "četrdesmit četri tūkstoši divi simti trīsdesmit pirmais")] - [InlineData(100000, "simts tūkstošais")] - [InlineData(500000, "pieci simti tūkstošais")] - [InlineData(1000000, "miljonais")] - [InlineData(6000000, "seši miljonais")] - [InlineData(10000000, "desmit miljonais")] - [InlineData(70000000, "septiņdesmit miljonais")] - [InlineData(100000000, "simts miljonais")] - [InlineData(800000000, "astoņi simti miljonais")] - public void ToOrdinalWordsMasculine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(21, "divdesmit pirmais")] + [InlineData(22, "divdesmit otrais")] + [InlineData(26, "divdesmit sestais")] + [InlineData(30, "trīsdesmitais")] + [InlineData(31, "trīsdesmit pirmais")] + [InlineData(33, "trīsdesmit trešais")] + [InlineData(37, "trīsdesmit septītais")] + [InlineData(40, "četrdesmitais")] + [InlineData(41, "četrdesmit pirmais")] + [InlineData(44, "četrdesmit ceturtais")] + [InlineData(48, "četrdesmit astotais")] + [InlineData(50, "piecdesmitais")] + [InlineData(51, "piecdesmit pirmais")] + [InlineData(55, "piecdesmit piektais")] + [InlineData(59, "piecdesmit devītais")] + [InlineData(60, "sešdesmitais")] + [InlineData(61, "sešdesmit pirmais")] + [InlineData(62, "sešdesmit otrais")] + [InlineData(66, "sešdesmit sestais")] + [InlineData(70, "septiņdesmitais")] + [InlineData(71, "septiņdesmit pirmais")] + [InlineData(73, "septiņdesmit trešais")] + [InlineData(77, "septiņdesmit septītais")] + [InlineData(80, "astoņdesmitais")] + [InlineData(81, "astoņdesmit pirmais")] + [InlineData(84, "astoņdesmit ceturtais")] + [InlineData(88, "astoņdesmit astotais")] + [InlineData(90, "deviņdesmitais")] + [InlineData(91, "deviņdesmit pirmais")] + [InlineData(95, "deviņdesmit piektais")] + [InlineData(99, "deviņdesmit devītais")] + [InlineData(100, "simtais")] + [InlineData(101, "simtu pirmais")] + [InlineData(105, "simtu piektais")] + [InlineData(110, "simtu desmitais")] + [InlineData(151, "simtu piecdesmit pirmais")] + [InlineData(200, "divsimtais")] + [InlineData(202, "divi simti otrais")] + [InlineData(206, "divi simti sestais")] + [InlineData(220, "divi simti divdesmitais")] + [InlineData(262, "divi simti sešdesmit otrais")] + [InlineData(300, "trīssimtais")] + [InlineData(303, "trīs simti trešais")] + [InlineData(307, "trīs simti septītais")] + [InlineData(330, "trīs simti trīsdesmitais")] + [InlineData(373, "trīs simti septiņdesmit trešais")] + [InlineData(400, "četrsimtais")] + [InlineData(404, "četri simti ceturtais")] + [InlineData(408, "četri simti astotais")] + [InlineData(440, "četri simti četrdesmitais")] + [InlineData(484, "četri simti astoņdesmit ceturtais")] + [InlineData(500, "piecsimtais")] + [InlineData(505, "pieci simti piektais")] + [InlineData(509, "pieci simti devītais")] + [InlineData(550, "pieci simti piecdesmitais")] + [InlineData(595, "pieci simti deviņdesmit piektais")] + [InlineData(600, "sešsimtais")] + [InlineData(601, "seši simti pirmais")] + [InlineData(606, "seši simti sestais")] + [InlineData(616, "seši simti sešpadsmitais")] + [InlineData(660, "seši simti sešdesmitais")] + [InlineData(700, "septiņsimtais")] + [InlineData(702, "septiņi simti otrais")] + [InlineData(707, "septiņi simti septītais")] + [InlineData(727, "septiņi simti divdesmit septītais")] + [InlineData(770, "septiņi simti septiņdesmitais")] + [InlineData(800, "astoņsimtais")] + [InlineData(803, "astoņi simti trešais")] + [InlineData(808, "astoņi simti astotais")] + [InlineData(838, "astoņi simti trīsdesmit astotais")] + [InlineData(880, "astoņi simti astoņdesmitais")] + [InlineData(900, "deviņsimtais")] + [InlineData(904, "deviņi simti ceturtais")] + [InlineData(909, "deviņi simti devītais")] + [InlineData(949, "deviņi simti četrdesmit devītais")] + [InlineData(990, "deviņi simti deviņdesmitais")] + [InlineData(1000, "tūkstošais")] + [InlineData(1001, "tūkstoš pirmais")] + [InlineData(1012, "tūkstoš divpadsmitais")] + [InlineData(1100, "tūkstoš simtais")] + [InlineData(1234, "tūkstoš divi simti trīsdesmit ceturtais")] + [InlineData(2000, "divi tūkstošais")] + [InlineData(2002, "divi tūkstoši otrais")] + [InlineData(2023, "divi tūkstoši divdesmit trešais")] + [InlineData(2345, "divi tūkstoši trīs simti četrdesmit piektais")] + [InlineData(3000, "trīs tūkstošais")] + [InlineData(3003, "trīs tūkstoši trešais")] + [InlineData(3034, "trīs tūkstoši trīsdesmit ceturtais")] + [InlineData(3456, "trīs tūkstoši četri simti piecdesmit sestais")] + [InlineData(4000, "četri tūkstošais")] + [InlineData(4004, "četri tūkstoši ceturtais")] + [InlineData(4045, "četri tūkstoši četrdesmit piektais")] + [InlineData(4567, "četri tūkstoši pieci simti sešdesmit septītais")] + [InlineData(5000, "pieci tūkstošais")] + [InlineData(5005, "pieci tūkstoši piektais")] + [InlineData(5056, "pieci tūkstoši piecdesmit sestais")] + [InlineData(5678, "pieci tūkstoši seši simti septiņdesmit astotais")] + [InlineData(6000, "seši tūkstošais")] + [InlineData(6006, "seši tūkstoši sestais")] + [InlineData(6067, "seši tūkstoši sešdesmit septītais")] + [InlineData(6789, "seši tūkstoši septiņi simti astoņdesmit devītais")] + [InlineData(7000, "septiņi tūkstošais")] + [InlineData(7007, "septiņi tūkstoši septītais")] + [InlineData(7078, "septiņi tūkstoši septiņdesmit astotais")] + [InlineData(7890, "septiņi tūkstoši astoņi simti deviņdesmitais")] + [InlineData(8000, "astoņi tūkstošais")] + [InlineData(8008, "astoņi tūkstoši astotais")] + [InlineData(8089, "astoņi tūkstoši astoņdesmit devītais")] + [InlineData(8901, "astoņi tūkstoši deviņi simti pirmais")] + [InlineData(9000, "deviņi tūkstošais")] + [InlineData(9009, "deviņi tūkstoši devītais")] + [InlineData(9012, "deviņi tūkstoši divpadsmitais")] + [InlineData(9090, "deviņi tūkstoši deviņdesmitais")] + [InlineData(10000, "desmit tūkstošais")] + [InlineData(10001, "desmit tūkstoši pirmais")] + [InlineData(20020, "divdesmit tūkstoši divdesmitais")] + [InlineData(30300, "trīsdesmit tūkstoši trīssimtais")] + [InlineData(44000, "četrdesmit četri tūkstošais")] + [InlineData(44231, "četrdesmit četri tūkstoši divi simti trīsdesmit pirmais")] + [InlineData(100000, "simts tūkstošais")] + [InlineData(500000, "pieci simti tūkstošais")] + [InlineData(1000000, "miljonais")] + [InlineData(6000000, "seši miljonais")] + [InlineData(10000000, "desmit miljonais")] + [InlineData(70000000, "septiņdesmit miljonais")] + [InlineData(100000000, "simts miljonais")] + [InlineData(800000000, "astoņi simti miljonais")] + public void ToOrdinalWordsMasculine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(21, "divdesmit pirmā")] - [InlineData(22, "divdesmit otrā")] - [InlineData(26, "divdesmit sestā")] - [InlineData(30, "trīsdesmitā")] - [InlineData(31, "trīsdesmit pirmā")] - [InlineData(33, "trīsdesmit trešā")] - [InlineData(37, "trīsdesmit septītā")] - [InlineData(40, "četrdesmitā")] - [InlineData(41, "četrdesmit pirmā")] - [InlineData(44, "četrdesmit ceturtā")] - [InlineData(48, "četrdesmit astotā")] - [InlineData(50, "piecdesmitā")] - [InlineData(51, "piecdesmit pirmā")] - [InlineData(55, "piecdesmit piektā")] - [InlineData(59, "piecdesmit devītā")] - [InlineData(60, "sešdesmitā")] - [InlineData(61, "sešdesmit pirmā")] - [InlineData(62, "sešdesmit otrā")] - [InlineData(66, "sešdesmit sestā")] - [InlineData(70, "septiņdesmitā")] - [InlineData(71, "septiņdesmit pirmā")] - [InlineData(73, "septiņdesmit trešā")] - [InlineData(77, "septiņdesmit septītā")] - [InlineData(80, "astoņdesmitā")] - [InlineData(81, "astoņdesmit pirmā")] - [InlineData(84, "astoņdesmit ceturtā")] - [InlineData(88, "astoņdesmit astotā")] - [InlineData(90, "deviņdesmitā")] - [InlineData(91, "deviņdesmit pirmā")] - [InlineData(95, "deviņdesmit piektā")] - [InlineData(99, "deviņdesmit devītā")] - [InlineData(100, "simtā")] - [InlineData(101, "simtu pirmā")] - [InlineData(105, "simtu piektā")] - [InlineData(110, "simtu desmitā")] - [InlineData(151, "simtu piecdesmit pirmā")] - [InlineData(200, "divsimtā")] - [InlineData(202, "divi simti otrā")] - [InlineData(206, "divi simti sestā")] - [InlineData(220, "divi simti divdesmitā")] - [InlineData(262, "divi simti sešdesmit otrā")] - [InlineData(300, "trīssimtā")] - [InlineData(303, "trīs simti trešā")] - [InlineData(307, "trīs simti septītā")] - [InlineData(330, "trīs simti trīsdesmitā")] - [InlineData(373, "trīs simti septiņdesmit trešā")] - [InlineData(400, "četrsimtā")] - [InlineData(404, "četri simti ceturtā")] - [InlineData(408, "četri simti astotā")] - [InlineData(440, "četri simti četrdesmitā")] - [InlineData(484, "četri simti astoņdesmit ceturtā")] - [InlineData(500, "piecsimtā")] - [InlineData(505, "pieci simti piektā")] - [InlineData(509, "pieci simti devītā")] - [InlineData(550, "pieci simti piecdesmitā")] - [InlineData(595, "pieci simti deviņdesmit piektā")] - [InlineData(600, "sešsimtā")] - [InlineData(601, "seši simti pirmā")] - [InlineData(606, "seši simti sestā")] - [InlineData(616, "seši simti sešpadsmitā")] - [InlineData(660, "seši simti sešdesmitā")] - [InlineData(700, "septiņsimtā")] - [InlineData(702, "septiņi simti otrā")] - [InlineData(707, "septiņi simti septītā")] - [InlineData(727, "septiņi simti divdesmit septītā")] - [InlineData(770, "septiņi simti septiņdesmitā")] - [InlineData(800, "astoņsimtā")] - [InlineData(803, "astoņi simti trešā")] - [InlineData(808, "astoņi simti astotā")] - [InlineData(838, "astoņi simti trīsdesmit astotā")] - [InlineData(880, "astoņi simti astoņdesmitā")] - [InlineData(900, "deviņsimtā")] - [InlineData(904, "deviņi simti ceturtā")] - [InlineData(909, "deviņi simti devītā")] - [InlineData(949, "deviņi simti četrdesmit devītā")] - [InlineData(990, "deviņi simti deviņdesmitā")] - [InlineData(1000, "tūkstošā")] - [InlineData(1001, "tūkstoš pirmā")] - [InlineData(1012, "tūkstoš divpadsmitā")] - [InlineData(1100, "tūkstoš simtā")] - [InlineData(1234, "tūkstoš divi simti trīsdesmit ceturtā")] - [InlineData(2000, "divi tūkstošā")] - [InlineData(2002, "divi tūkstoši otrā")] - [InlineData(2023, "divi tūkstoši divdesmit trešā")] - [InlineData(2345, "divi tūkstoši trīs simti četrdesmit piektā")] - [InlineData(3000, "trīs tūkstošā")] - [InlineData(3003, "trīs tūkstoši trešā")] - [InlineData(3034, "trīs tūkstoši trīsdesmit ceturtā")] - [InlineData(3456, "trīs tūkstoši četri simti piecdesmit sestā")] - [InlineData(4000, "četri tūkstošā")] - [InlineData(4004, "četri tūkstoši ceturtā")] - [InlineData(4045, "četri tūkstoši četrdesmit piektā")] - [InlineData(4567, "četri tūkstoši pieci simti sešdesmit septītā")] - [InlineData(5000, "pieci tūkstošā")] - [InlineData(5005, "pieci tūkstoši piektā")] - [InlineData(5056, "pieci tūkstoši piecdesmit sestā")] - [InlineData(5678, "pieci tūkstoši seši simti septiņdesmit astotā")] - [InlineData(6000, "seši tūkstošā")] - [InlineData(6006, "seši tūkstoši sestā")] - [InlineData(6067, "seši tūkstoši sešdesmit septītā")] - [InlineData(6789, "seši tūkstoši septiņi simti astoņdesmit devītā")] - [InlineData(7000, "septiņi tūkstošā")] - [InlineData(7007, "septiņi tūkstoši septītā")] - [InlineData(7078, "septiņi tūkstoši septiņdesmit astotā")] - [InlineData(7890, "septiņi tūkstoši astoņi simti deviņdesmitā")] - [InlineData(8000, "astoņi tūkstošā")] - [InlineData(8008, "astoņi tūkstoši astotā")] - [InlineData(8089, "astoņi tūkstoši astoņdesmit devītā")] - [InlineData(8901, "astoņi tūkstoši deviņi simti pirmā")] - [InlineData(9000, "deviņi tūkstošā")] - [InlineData(9009, "deviņi tūkstoši devītā")] - [InlineData(9012, "deviņi tūkstoši divpadsmitā")] - [InlineData(9090, "deviņi tūkstoši deviņdesmitā")] - [InlineData(10000, "desmit tūkstošā")] - [InlineData(10001, "desmit tūkstoši pirmā")] - [InlineData(20020, "divdesmit tūkstoši divdesmitā")] - [InlineData(30300, "trīsdesmit tūkstoši trīssimtā")] - [InlineData(44000, "četrdesmit četri tūkstošā")] - [InlineData(44231, "četrdesmit četri tūkstoši divi simti trīsdesmit pirmā")] - [InlineData(100000, "simts tūkstošā")] - [InlineData(500000, "pieci simti tūkstošā")] - [InlineData(1000000, "miljonā")] - [InlineData(6000000, "seši miljonā")] - [InlineData(10000000, "desmit miljonā")] - [InlineData(70000000, "septiņdesmit miljonā")] - [InlineData(100000000, "simts miljonā")] - [InlineData(800000000, "astoņi simti miljonā")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(21, "divdesmit pirmā")] + [InlineData(22, "divdesmit otrā")] + [InlineData(26, "divdesmit sestā")] + [InlineData(30, "trīsdesmitā")] + [InlineData(31, "trīsdesmit pirmā")] + [InlineData(33, "trīsdesmit trešā")] + [InlineData(37, "trīsdesmit septītā")] + [InlineData(40, "četrdesmitā")] + [InlineData(41, "četrdesmit pirmā")] + [InlineData(44, "četrdesmit ceturtā")] + [InlineData(48, "četrdesmit astotā")] + [InlineData(50, "piecdesmitā")] + [InlineData(51, "piecdesmit pirmā")] + [InlineData(55, "piecdesmit piektā")] + [InlineData(59, "piecdesmit devītā")] + [InlineData(60, "sešdesmitā")] + [InlineData(61, "sešdesmit pirmā")] + [InlineData(62, "sešdesmit otrā")] + [InlineData(66, "sešdesmit sestā")] + [InlineData(70, "septiņdesmitā")] + [InlineData(71, "septiņdesmit pirmā")] + [InlineData(73, "septiņdesmit trešā")] + [InlineData(77, "septiņdesmit septītā")] + [InlineData(80, "astoņdesmitā")] + [InlineData(81, "astoņdesmit pirmā")] + [InlineData(84, "astoņdesmit ceturtā")] + [InlineData(88, "astoņdesmit astotā")] + [InlineData(90, "deviņdesmitā")] + [InlineData(91, "deviņdesmit pirmā")] + [InlineData(95, "deviņdesmit piektā")] + [InlineData(99, "deviņdesmit devītā")] + [InlineData(100, "simtā")] + [InlineData(101, "simtu pirmā")] + [InlineData(105, "simtu piektā")] + [InlineData(110, "simtu desmitā")] + [InlineData(151, "simtu piecdesmit pirmā")] + [InlineData(200, "divsimtā")] + [InlineData(202, "divi simti otrā")] + [InlineData(206, "divi simti sestā")] + [InlineData(220, "divi simti divdesmitā")] + [InlineData(262, "divi simti sešdesmit otrā")] + [InlineData(300, "trīssimtā")] + [InlineData(303, "trīs simti trešā")] + [InlineData(307, "trīs simti septītā")] + [InlineData(330, "trīs simti trīsdesmitā")] + [InlineData(373, "trīs simti septiņdesmit trešā")] + [InlineData(400, "četrsimtā")] + [InlineData(404, "četri simti ceturtā")] + [InlineData(408, "četri simti astotā")] + [InlineData(440, "četri simti četrdesmitā")] + [InlineData(484, "četri simti astoņdesmit ceturtā")] + [InlineData(500, "piecsimtā")] + [InlineData(505, "pieci simti piektā")] + [InlineData(509, "pieci simti devītā")] + [InlineData(550, "pieci simti piecdesmitā")] + [InlineData(595, "pieci simti deviņdesmit piektā")] + [InlineData(600, "sešsimtā")] + [InlineData(601, "seši simti pirmā")] + [InlineData(606, "seši simti sestā")] + [InlineData(616, "seši simti sešpadsmitā")] + [InlineData(660, "seši simti sešdesmitā")] + [InlineData(700, "septiņsimtā")] + [InlineData(702, "septiņi simti otrā")] + [InlineData(707, "septiņi simti septītā")] + [InlineData(727, "septiņi simti divdesmit septītā")] + [InlineData(770, "septiņi simti septiņdesmitā")] + [InlineData(800, "astoņsimtā")] + [InlineData(803, "astoņi simti trešā")] + [InlineData(808, "astoņi simti astotā")] + [InlineData(838, "astoņi simti trīsdesmit astotā")] + [InlineData(880, "astoņi simti astoņdesmitā")] + [InlineData(900, "deviņsimtā")] + [InlineData(904, "deviņi simti ceturtā")] + [InlineData(909, "deviņi simti devītā")] + [InlineData(949, "deviņi simti četrdesmit devītā")] + [InlineData(990, "deviņi simti deviņdesmitā")] + [InlineData(1000, "tūkstošā")] + [InlineData(1001, "tūkstoš pirmā")] + [InlineData(1012, "tūkstoš divpadsmitā")] + [InlineData(1100, "tūkstoš simtā")] + [InlineData(1234, "tūkstoš divi simti trīsdesmit ceturtā")] + [InlineData(2000, "divi tūkstošā")] + [InlineData(2002, "divi tūkstoši otrā")] + [InlineData(2023, "divi tūkstoši divdesmit trešā")] + [InlineData(2345, "divi tūkstoši trīs simti četrdesmit piektā")] + [InlineData(3000, "trīs tūkstošā")] + [InlineData(3003, "trīs tūkstoši trešā")] + [InlineData(3034, "trīs tūkstoši trīsdesmit ceturtā")] + [InlineData(3456, "trīs tūkstoši četri simti piecdesmit sestā")] + [InlineData(4000, "četri tūkstošā")] + [InlineData(4004, "četri tūkstoši ceturtā")] + [InlineData(4045, "četri tūkstoši četrdesmit piektā")] + [InlineData(4567, "četri tūkstoši pieci simti sešdesmit septītā")] + [InlineData(5000, "pieci tūkstošā")] + [InlineData(5005, "pieci tūkstoši piektā")] + [InlineData(5056, "pieci tūkstoši piecdesmit sestā")] + [InlineData(5678, "pieci tūkstoši seši simti septiņdesmit astotā")] + [InlineData(6000, "seši tūkstošā")] + [InlineData(6006, "seši tūkstoši sestā")] + [InlineData(6067, "seši tūkstoši sešdesmit septītā")] + [InlineData(6789, "seši tūkstoši septiņi simti astoņdesmit devītā")] + [InlineData(7000, "septiņi tūkstošā")] + [InlineData(7007, "septiņi tūkstoši septītā")] + [InlineData(7078, "septiņi tūkstoši septiņdesmit astotā")] + [InlineData(7890, "septiņi tūkstoši astoņi simti deviņdesmitā")] + [InlineData(8000, "astoņi tūkstošā")] + [InlineData(8008, "astoņi tūkstoši astotā")] + [InlineData(8089, "astoņi tūkstoši astoņdesmit devītā")] + [InlineData(8901, "astoņi tūkstoši deviņi simti pirmā")] + [InlineData(9000, "deviņi tūkstošā")] + [InlineData(9009, "deviņi tūkstoši devītā")] + [InlineData(9012, "deviņi tūkstoši divpadsmitā")] + [InlineData(9090, "deviņi tūkstoši deviņdesmitā")] + [InlineData(10000, "desmit tūkstošā")] + [InlineData(10001, "desmit tūkstoši pirmā")] + [InlineData(20020, "divdesmit tūkstoši divdesmitā")] + [InlineData(30300, "trīsdesmit tūkstoši trīssimtā")] + [InlineData(44000, "četrdesmit četri tūkstošā")] + [InlineData(44231, "četrdesmit četri tūkstoši divi simti trīsdesmit pirmā")] + [InlineData(100000, "simts tūkstošā")] + [InlineData(500000, "pieci simti tūkstošā")] + [InlineData(1000000, "miljonā")] + [InlineData(6000000, "seši miljonā")] + [InlineData(10000000, "desmit miljonā")] + [InlineData(70000000, "septiņdesmit miljonā")] + [InlineData(100000000, "simts miljonā")] + [InlineData(800000000, "astoņi simti miljonā")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/lv/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/lv/TimeSpanHumanizeTests.cs index 02a217a48..a5a1665e5 100644 --- a/src/Humanizer.Tests/Localisation/lv/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/lv/TimeSpanHumanizeTests.cs @@ -1,75 +1,74 @@ -namespace Humanizer.Tests.Localisation.lv +namespace Humanizer.Tests.Localisation.lv; + +[UseCulture("lv")] +public class TimeSpanHumanizeTests { - [UseCulture("lv")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 gads")] - [InlineData(731, "2 gadi")] - [InlineData(1096, "3 gadi")] - [InlineData(4018, "11 gadi")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 gads")] + [InlineData(731, "2 gadi")] + [InlineData(1096, "3 gadi")] + [InlineData(4018, "11 gadi")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mēnesis")] - [InlineData(61, "2 mēneši")] - [InlineData(92, "3 mēneši")] - [InlineData(335, "11 mēneši")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mēnesis")] + [InlineData(61, "2 mēneši")] + [InlineData(92, "3 mēneši")] + [InlineData(335, "11 mēneši")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(7, "1 nedēļa")] - [InlineData(14, "2 nedēļas")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(7, "1 nedēļa")] + [InlineData(14, "2 nedēļas")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 diena")] - [InlineData(2, "2 dienas")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 diena")] + [InlineData(2, "2 dienas")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 stunda")] - [InlineData(2, "2 stundas")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 stunda")] + [InlineData(2, "2 stundas")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 minūte")] - [InlineData(2, "2 minūtes")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 minūte")] + [InlineData(2, "2 minūtes")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 sekunde")] - [InlineData(2, "2 sekundes")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 sekunde")] + [InlineData(2, "2 sekundes")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 milisekunde")] - [InlineData(2, "2 milisekundes")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 milisekunde")] + [InlineData(2, "2 milisekundes")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - [Trait("Translation", "Google")] - public void NoTime() => - Assert.Equal("0 milisekundes", TimeSpan.Zero.Humanize()); + [Fact] + [Trait("Translation", "Google")] + public void NoTime() => + Assert.Equal("0 milisekundes", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("bez laika", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("bez laika", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ms-MY/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ms-MY/TimeSpanHumanizeTests.cs index 8f5bed997..d431b6c74 100644 --- a/src/Humanizer.Tests/Localisation/ms-MY/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ms-MY/TimeSpanHumanizeTests.cs @@ -1,75 +1,74 @@ -namespace Humanizer.Tests.Localisation.msMY +namespace Humanizer.Tests.Localisation.msMY; + +[UseCulture("ms-MY")] +public class TimeSpanHumanizeTests { - [UseCulture("ms-MY")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 tahun")] - [InlineData(731, "2 tahun")] - [InlineData(1096, "3 tahun")] - [InlineData(4018, "11 tahun")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 tahun")] + [InlineData(731, "2 tahun")] + [InlineData(1096, "3 tahun")] + [InlineData(4018, "11 tahun")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 bulan")] - [InlineData(61, "2 bulan")] - [InlineData(92, "3 bulan")] - [InlineData(335, "11 bulan")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 bulan")] + [InlineData(61, "2 bulan")] + [InlineData(92, "3 bulan")] + [InlineData(335, "11 bulan")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(7, "1 minggu")] - [InlineData(14, "2 minggu")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(7, "1 minggu")] + [InlineData(14, "2 minggu")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 hari")] - [InlineData(2, "2 hari")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 hari")] + [InlineData(2, "2 hari")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 jam")] - [InlineData(2, "2 jam")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 jam")] + [InlineData(2, "2 jam")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 minit")] - [InlineData(2, "2 minit")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 minit")] + [InlineData(2, "2 minit")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 saat")] - [InlineData(2, "2 saat")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 saat")] + [InlineData(2, "2 saat")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(1, "1 milisaat")] - [InlineData(2, "2 milisaat")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [Trait("Translation", "Google")] + [InlineData(1, "1 milisaat")] + [InlineData(2, "2 milisaat")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - [Trait("Translation", "Google")] - public void NoTime() => - Assert.Equal("0 milisaat", TimeSpan.Zero.Humanize()); + [Fact] + [Trait("Translation", "Google")] + public void NoTime() => + Assert.Equal("0 milisaat", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("tiada masa", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("tiada masa", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/mt/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/mt/DateHumanizeTests.cs index c0f8b0794..d0d0c4115 100644 --- a/src/Humanizer.Tests/Localisation/mt/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/mt/DateHumanizeTests.cs @@ -1,93 +1,92 @@ -namespace Humanizer.Tests.Localisation.mt +namespace Humanizer.Tests.Localisation.mt; + +[UseCulture("mt")] +public class DateHumanizeTests { - [UseCulture("mt")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-3, "3 jiem ilu")] - [InlineData(-2, "jumejn ilu")] - [InlineData(-1, "il-bieraħ")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-3, "3 jiem ilu")] + [InlineData(-2, "jumejn ilu")] + [InlineData(-1, "il-bieraħ")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(3, "3 jiem oħra")] - [InlineData(2, "pitgħada")] - [InlineData(1, "għada")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(3, "3 jiem oħra")] + [InlineData(2, "pitgħada")] + [InlineData(1, "għada")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-3, "3 siegħat ilu")] - [InlineData(-2, "sagħtejn ilu")] - [InlineData(-1, "siegħa ilu")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-3, "3 siegħat ilu")] + [InlineData(-2, "sagħtejn ilu")] + [InlineData(-1, "siegħa ilu")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(3, "3 siegħat oħra")] - [InlineData(2, "sagħtejn oħra")] - [InlineData(1, "siegħa oħra")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(3, "3 siegħat oħra")] + [InlineData(2, "sagħtejn oħra")] + [InlineData(1, "siegħa oħra")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-3, "3 minuti ilu")] - [InlineData(-2, "2 minuti ilu")] - [InlineData(-1, "minuta ilu")] - [InlineData(60, "siegħa ilu")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-3, "3 minuti ilu")] + [InlineData(-2, "2 minuti ilu")] + [InlineData(-1, "minuta ilu")] + [InlineData(60, "siegħa ilu")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 minuti oħra")] - [InlineData(1, "minuta oħra")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "2 minuti oħra")] + [InlineData(1, "minuta oħra")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-3, "3 xhur ilu")] - [InlineData(-2, "xahrejn ilu")] - [InlineData(-1, "xahar ilu")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-3, "3 xhur ilu")] + [InlineData(-2, "xahrejn ilu")] + [InlineData(-1, "xahar ilu")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(3, "3 xhur oħra")] - [InlineData(2, "xahrejn oħra")] - [InlineData(1, "xahar ieħor")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(3, "3 xhur oħra")] + [InlineData(2, "xahrejn oħra")] + [InlineData(1, "xahar ieħor")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 sekondi ilu")] - [InlineData(-1, "sekonda ilu")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 sekondi ilu")] + [InlineData(-1, "sekonda ilu")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 sekondi oħra")] - [InlineData(1, "sekonda oħra")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "2 sekondi oħra")] + [InlineData(1, "sekonda oħra")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-3, "3 snin ilu")] - [InlineData(-2, "sentejn ilu")] - [InlineData(-1, "sena ilu")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-3, "3 snin ilu")] + [InlineData(-2, "sentejn ilu")] + [InlineData(-1, "sena ilu")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(3, "3 snin oħra")] - [InlineData(2, "sentejn oħra")] - [InlineData(1, "sena oħra")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(3, "3 snin oħra")] + [InlineData(2, "sentejn oħra")] + [InlineData(1, "sena oħra")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "issa")] - public void Now(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(0, "issa")] + public void Now(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/mt/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/mt/NumberToWordsTests.cs index 77b0be346..c36eab269 100644 --- a/src/Humanizer.Tests/Localisation/mt/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/mt/NumberToWordsTests.cs @@ -1,273 +1,272 @@ -namespace Humanizer.Tests.Localisation.mt +namespace Humanizer.Tests.Localisation.mt; + +[UseCulture("mt")] +public class NumberToWordsTests { - [UseCulture("mt")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "żero")] - [InlineData(1, "wieħed")] - [InlineData(-1, "wieħed inqas minn żero")] - [InlineData(3, "tlieta")] - [InlineData(10, "għaxra")] - [InlineData(11, "ħdax")] - [InlineData(20, "għoxrin")] - [InlineData(-20, "għoxrin inqas minn żero")] - [InlineData(21, "wieħed u għoxrin")] - [InlineData(38, "tmienja u tletin")] - [InlineData(43, "tlieta u erbgħin")] - [InlineData(78, "tmienja u sebgħin")] - [InlineData(99, "disgħa u disgħin")] - [InlineData(100, "mija")] - [InlineData(101, "mija u wieħed")] - [InlineData(103, "mija u tlieta")] - [InlineData(110, "mija u għaxra")] - [InlineData(111, "mija u ħdax")] - [InlineData(121, "mija u wieħed u għoxrin")] - [InlineData(122, "mija u tnejn u għoxrin")] - [InlineData(123, "mija u tlieta u għoxrin")] - [InlineData(138, "mija u tmienja u tletin")] - [InlineData(143, "mija u tlieta u erbgħin")] - [InlineData(178, "mija u tmienja u sebgħin")] - [InlineData(199, "mija u disgħa u disgħin")] - [InlineData(200, "mitejn")] - [InlineData(201, "mitejn u wieħed")] - [InlineData(203, "mitejn u tlieta")] - [InlineData(210, "mitejn u għaxra")] - [InlineData(211, "mitejn u ħdax")] - [InlineData(221, "mitejn u wieħed u għoxrin")] - [InlineData(222, "mitejn u tnejn u għoxrin")] - [InlineData(223, "mitejn u tlieta u għoxrin")] - [InlineData(238, "mitejn u tmienja u tletin")] - [InlineData(243, "mitejn u tlieta u erbgħin")] - [InlineData(278, "mitejn u tmienja u sebgħin")] - [InlineData(299, "mitejn u disgħa u disgħin")] - [InlineData(300, "tlett mija")] - [InlineData(401, "erbgħa mija u wieħed")] - [InlineData(503, "ħames mija u tlieta")] - [InlineData(610, "sitt mija u għaxra")] - [InlineData(711, "sebgħa mija u ħdax")] - [InlineData(821, "tminn mija u wieħed u għoxrin")] - [InlineData(922, "disgħa mija u tnejn u għoxrin")] - [InlineData(323, "tlett mija u tlieta u għoxrin")] - [InlineData(438, "erbgħa mija u tmienja u tletin")] - [InlineData(543, "ħames mija u tlieta u erbgħin")] - [InlineData(678, "sitt mija u tmienja u sebgħin")] - [InlineData(799, "sebgħa mija u disgħa u disgħin")] - [InlineData(1000, "elf")] - [InlineData(1001, "elf u wieħed")] - [InlineData(1111, "elf u mija u ħdax")] - [InlineData(1234, "elf u mitejn u erbgħa u tletin")] - [InlineData(1999, "elf u disgħa mija u disgħa u disgħin")] - [InlineData(2000, "elfejn")] - [InlineData(2014, "elfejn u erbatax")] - [InlineData(2048, "elfejn u tmienja u erbgħin")] - [InlineData(3000, "tlett elef")] - [InlineData(3501, "tlett elef u ħames mija u wieħed")] - [InlineData(8100, "tmint elef u mija")] - [InlineData(10000, "għaxart elef")] - [InlineData(10001, "għaxart elef u wieħed")] - [InlineData(12345, "tnax-il elf u tlett mija u ħamsa u erbgħin")] - [InlineData(18000, "tmintax-il elf")] - [InlineData(100000, "mitt elf")] - [InlineData(100001, "mitt elf u wieħed")] - [InlineData(111111, "mija u ħdax-il elf u mija u ħdax")] - [InlineData(123456, "mija u tlieta u għoxrin elf u erbgħa mija u sitta u ħamsin")] - [InlineData(1000000, "miljun")] - [InlineData(1000001, "miljun u wieħed")] - [InlineData(1111101, "miljun u mija u ħdax-il elf u mija u wieħed")] - [InlineData(1111111, "miljun u mija u ħdax-il elf u mija u ħdax")] - [InlineData(1234567, "miljun u mitejn u erbgħa u tletin elf u ħames mija u sebgħa u sittin")] - [InlineData(5000000, "ħames miljuni")] - [InlineData(10000000, "għaxar miljuni")] - [InlineData(10000001, "għaxar miljuni u wieħed")] - [InlineData(11111111, "ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] - [InlineData(12345678, "tnax-il miljun u tlett mija u ħamsa u erbgħin elf u sitt mija u tmienja u sebgħin")] - [InlineData(100000000, "mitt miljun")] - [InlineData(100000001, "mitt miljun u wieħed")] - [InlineData(111111111, "mija u ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] - [InlineData(123456789, "mija u tlieta u għoxrin miljun u erbgħa mija u sitta u ħamsin elf u sebgħa mija u disgħa u tmenin")] - [InlineData(1000000000, "biljun")] - [InlineData(1000000001, "biljun u wieħed")] - [InlineData(1101111101, "biljun u mija u miljun u mija u ħdax-il elf u mija u wieħed")] - [InlineData(2000000000, "żewġ biljuni")] - [InlineData(2147483647, "żewġ biljuni u mija u sebgħa u erbgħin miljun u erbgħa mija u tlieta u tmenin elf u sitt mija u sebgħa u erbgħin")] - [InlineData(-2147483647, "żewġ biljuni u mija u sebgħa u erbgħin miljun u erbgħa mija u tlieta u tmenin elf u sitt mija u sebgħa u erbgħin inqas minn żero")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "żero")] + [InlineData(1, "wieħed")] + [InlineData(-1, "wieħed inqas minn żero")] + [InlineData(3, "tlieta")] + [InlineData(10, "għaxra")] + [InlineData(11, "ħdax")] + [InlineData(20, "għoxrin")] + [InlineData(-20, "għoxrin inqas minn żero")] + [InlineData(21, "wieħed u għoxrin")] + [InlineData(38, "tmienja u tletin")] + [InlineData(43, "tlieta u erbgħin")] + [InlineData(78, "tmienja u sebgħin")] + [InlineData(99, "disgħa u disgħin")] + [InlineData(100, "mija")] + [InlineData(101, "mija u wieħed")] + [InlineData(103, "mija u tlieta")] + [InlineData(110, "mija u għaxra")] + [InlineData(111, "mija u ħdax")] + [InlineData(121, "mija u wieħed u għoxrin")] + [InlineData(122, "mija u tnejn u għoxrin")] + [InlineData(123, "mija u tlieta u għoxrin")] + [InlineData(138, "mija u tmienja u tletin")] + [InlineData(143, "mija u tlieta u erbgħin")] + [InlineData(178, "mija u tmienja u sebgħin")] + [InlineData(199, "mija u disgħa u disgħin")] + [InlineData(200, "mitejn")] + [InlineData(201, "mitejn u wieħed")] + [InlineData(203, "mitejn u tlieta")] + [InlineData(210, "mitejn u għaxra")] + [InlineData(211, "mitejn u ħdax")] + [InlineData(221, "mitejn u wieħed u għoxrin")] + [InlineData(222, "mitejn u tnejn u għoxrin")] + [InlineData(223, "mitejn u tlieta u għoxrin")] + [InlineData(238, "mitejn u tmienja u tletin")] + [InlineData(243, "mitejn u tlieta u erbgħin")] + [InlineData(278, "mitejn u tmienja u sebgħin")] + [InlineData(299, "mitejn u disgħa u disgħin")] + [InlineData(300, "tlett mija")] + [InlineData(401, "erbgħa mija u wieħed")] + [InlineData(503, "ħames mija u tlieta")] + [InlineData(610, "sitt mija u għaxra")] + [InlineData(711, "sebgħa mija u ħdax")] + [InlineData(821, "tminn mija u wieħed u għoxrin")] + [InlineData(922, "disgħa mija u tnejn u għoxrin")] + [InlineData(323, "tlett mija u tlieta u għoxrin")] + [InlineData(438, "erbgħa mija u tmienja u tletin")] + [InlineData(543, "ħames mija u tlieta u erbgħin")] + [InlineData(678, "sitt mija u tmienja u sebgħin")] + [InlineData(799, "sebgħa mija u disgħa u disgħin")] + [InlineData(1000, "elf")] + [InlineData(1001, "elf u wieħed")] + [InlineData(1111, "elf u mija u ħdax")] + [InlineData(1234, "elf u mitejn u erbgħa u tletin")] + [InlineData(1999, "elf u disgħa mija u disgħa u disgħin")] + [InlineData(2000, "elfejn")] + [InlineData(2014, "elfejn u erbatax")] + [InlineData(2048, "elfejn u tmienja u erbgħin")] + [InlineData(3000, "tlett elef")] + [InlineData(3501, "tlett elef u ħames mija u wieħed")] + [InlineData(8100, "tmint elef u mija")] + [InlineData(10000, "għaxart elef")] + [InlineData(10001, "għaxart elef u wieħed")] + [InlineData(12345, "tnax-il elf u tlett mija u ħamsa u erbgħin")] + [InlineData(18000, "tmintax-il elf")] + [InlineData(100000, "mitt elf")] + [InlineData(100001, "mitt elf u wieħed")] + [InlineData(111111, "mija u ħdax-il elf u mija u ħdax")] + [InlineData(123456, "mija u tlieta u għoxrin elf u erbgħa mija u sitta u ħamsin")] + [InlineData(1000000, "miljun")] + [InlineData(1000001, "miljun u wieħed")] + [InlineData(1111101, "miljun u mija u ħdax-il elf u mija u wieħed")] + [InlineData(1111111, "miljun u mija u ħdax-il elf u mija u ħdax")] + [InlineData(1234567, "miljun u mitejn u erbgħa u tletin elf u ħames mija u sebgħa u sittin")] + [InlineData(5000000, "ħames miljuni")] + [InlineData(10000000, "għaxar miljuni")] + [InlineData(10000001, "għaxar miljuni u wieħed")] + [InlineData(11111111, "ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] + [InlineData(12345678, "tnax-il miljun u tlett mija u ħamsa u erbgħin elf u sitt mija u tmienja u sebgħin")] + [InlineData(100000000, "mitt miljun")] + [InlineData(100000001, "mitt miljun u wieħed")] + [InlineData(111111111, "mija u ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] + [InlineData(123456789, "mija u tlieta u għoxrin miljun u erbgħa mija u sitta u ħamsin elf u sebgħa mija u disgħa u tmenin")] + [InlineData(1000000000, "biljun")] + [InlineData(1000000001, "biljun u wieħed")] + [InlineData(1101111101, "biljun u mija u miljun u mija u ħdax-il elf u mija u wieħed")] + [InlineData(2000000000, "żewġ biljuni")] + [InlineData(2147483647, "żewġ biljuni u mija u sebgħa u erbgħin miljun u erbgħa mija u tlieta u tmenin elf u sitt mija u sebgħa u erbgħin")] + [InlineData(-2147483647, "żewġ biljuni u mija u sebgħa u erbgħin miljun u erbgħa mija u tlieta u tmenin elf u sitt mija u sebgħa u erbgħin inqas minn żero")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "waħda")] - [InlineData(1001, "elf u waħda")] - [InlineData(100001, "mitt elf u waħda")] - [InlineData(1000000001, "biljun u waħda")] - public void ToFeminineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(1, "waħda")] + [InlineData(1001, "elf u waħda")] + [InlineData(100001, "mitt elf u waħda")] + [InlineData(1000000001, "biljun u waħda")] + public void ToFeminineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "żero")] - [InlineData(1, "wieħed")] - [InlineData(3, "tlieta")] - [InlineData(10, "għaxra")] - [InlineData(11, "ħdax")] - [InlineData(20, "għoxrin")] - [InlineData(21, "wieħed u għoxrin")] - [InlineData(38, "tmienja u tletin")] - [InlineData(43, "tlieta u erbgħin")] - [InlineData(78, "tmienja u sebgħin")] - [InlineData(99, "disgħa u disgħin")] - [InlineData(100, "mija")] - [InlineData(101, "mija u wieħed")] - [InlineData(103, "mija u tlieta")] - [InlineData(110, "mija u għaxra")] - [InlineData(111, "mija u ħdax")] - [InlineData(121, "mija u wieħed u għoxrin")] - [InlineData(122, "mija u tnejn u għoxrin")] - [InlineData(123, "mija u tlieta u għoxrin")] - [InlineData(138, "mija u tmienja u tletin")] - [InlineData(143, "mija u tlieta u erbgħin")] - [InlineData(178, "mija u tmienja u sebgħin")] - [InlineData(199, "mija u disgħa u disgħin")] - [InlineData(200, "mitejn")] - [InlineData(201, "mitejn u wieħed")] - [InlineData(203, "mitejn u tlieta")] - [InlineData(210, "mitejn u għaxra")] - [InlineData(211, "mitejn u ħdax")] - [InlineData(221, "mitejn u wieħed u għoxrin")] - [InlineData(222, "mitejn u tnejn u għoxrin")] - [InlineData(223, "mitejn u tlieta u għoxrin")] - [InlineData(238, "mitejn u tmienja u tletin")] - [InlineData(243, "mitejn u tlieta u erbgħin")] - [InlineData(278, "mitejn u tmienja u sebgħin")] - [InlineData(299, "mitejn u disgħa u disgħin")] - [InlineData(300, "tlett mija")] - [InlineData(401, "erbgħa mija u wieħed")] - [InlineData(503, "ħames mija u tlieta")] - [InlineData(610, "sitt mija u għaxra")] - [InlineData(711, "sebgħa mija u ħdax")] - [InlineData(821, "tminn mija u wieħed u għoxrin")] - [InlineData(922, "disgħa mija u tnejn u għoxrin")] - [InlineData(323, "tlett mija u tlieta u għoxrin")] - [InlineData(438, "erbgħa mija u tmienja u tletin")] - [InlineData(543, "ħames mija u tlieta u erbgħin")] - [InlineData(678, "sitt mija u tmienja u sebgħin")] - [InlineData(799, "sebgħa mija u disgħa u disgħin")] - [InlineData(1000, "elf")] - [InlineData(1001, "elf u wieħed")] - [InlineData(1111, "elf u mija u ħdax")] - [InlineData(1234, "elf u mitejn u erbgħa u tletin")] - [InlineData(1999, "elf u disgħa mija u disgħa u disgħin")] - [InlineData(2000, "elfejn")] - [InlineData(2014, "elfejn u erbatax")] - [InlineData(2048, "elfejn u tmienja u erbgħin")] - [InlineData(3000, "tlett elef")] - [InlineData(3501, "tlett elef u ħames mija u wieħed")] - [InlineData(8100, "tmint elef u mija")] - [InlineData(10000, "għaxart elef")] - [InlineData(10001, "għaxart elef u wieħed")] - [InlineData(12345, "tnax-il elf u tlett mija u ħamsa u erbgħin")] - [InlineData(18000, "tmintax-il elf")] - [InlineData(100000, "mitt elf")] - [InlineData(100001, "mitt elf u wieħed")] - [InlineData(111111, "mija u ħdax-il elf u mija u ħdax")] - [InlineData(123456, "mija u tlieta u għoxrin elf u erbgħa mija u sitta u ħamsin")] - [InlineData(1000000, "miljun")] - [InlineData(1000001, "miljun u wieħed")] - [InlineData(1111101, "miljun u mija u ħdax-il elf u mija u wieħed")] - [InlineData(1111111, "miljun u mija u ħdax-il elf u mija u ħdax")] - [InlineData(1234567, "miljun u mitejn u erbgħa u tletin elf u ħames mija u sebgħa u sittin")] - [InlineData(5000000, "ħames miljuni")] - [InlineData(10000000, "għaxar miljuni")] - [InlineData(10000001, "għaxar miljuni u wieħed")] - [InlineData(11111111, "ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] - [InlineData(12345678, "tnax-il miljun u tlett mija u ħamsa u erbgħin elf u sitt mija u tmienja u sebgħin")] - [InlineData(100000000, "mitt miljun")] - [InlineData(100000001, "mitt miljun u wieħed")] - [InlineData(111111111, "mija u ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] - [InlineData(123456789, "mija u tlieta u għoxrin miljun u erbgħa mija u sitta u ħamsin elf u sebgħa mija u disgħa u tmenin")] - [InlineData(1000000000, "biljun")] - [InlineData(1000000001, "biljun u wieħed")] - [InlineData(1101111101, "biljun u mija u miljun u mija u ħdax-il elf u mija u wieħed")] - [InlineData(2000000000, "żewġ biljuni")] - [InlineData(2147483647, "żewġ biljuni u mija u sebgħa u erbgħin miljun u erbgħa mija u tlieta u tmenin elf u sitt mija u sebgħa u erbgħin")] - public void ToMasculineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "żero")] + [InlineData(1, "wieħed")] + [InlineData(3, "tlieta")] + [InlineData(10, "għaxra")] + [InlineData(11, "ħdax")] + [InlineData(20, "għoxrin")] + [InlineData(21, "wieħed u għoxrin")] + [InlineData(38, "tmienja u tletin")] + [InlineData(43, "tlieta u erbgħin")] + [InlineData(78, "tmienja u sebgħin")] + [InlineData(99, "disgħa u disgħin")] + [InlineData(100, "mija")] + [InlineData(101, "mija u wieħed")] + [InlineData(103, "mija u tlieta")] + [InlineData(110, "mija u għaxra")] + [InlineData(111, "mija u ħdax")] + [InlineData(121, "mija u wieħed u għoxrin")] + [InlineData(122, "mija u tnejn u għoxrin")] + [InlineData(123, "mija u tlieta u għoxrin")] + [InlineData(138, "mija u tmienja u tletin")] + [InlineData(143, "mija u tlieta u erbgħin")] + [InlineData(178, "mija u tmienja u sebgħin")] + [InlineData(199, "mija u disgħa u disgħin")] + [InlineData(200, "mitejn")] + [InlineData(201, "mitejn u wieħed")] + [InlineData(203, "mitejn u tlieta")] + [InlineData(210, "mitejn u għaxra")] + [InlineData(211, "mitejn u ħdax")] + [InlineData(221, "mitejn u wieħed u għoxrin")] + [InlineData(222, "mitejn u tnejn u għoxrin")] + [InlineData(223, "mitejn u tlieta u għoxrin")] + [InlineData(238, "mitejn u tmienja u tletin")] + [InlineData(243, "mitejn u tlieta u erbgħin")] + [InlineData(278, "mitejn u tmienja u sebgħin")] + [InlineData(299, "mitejn u disgħa u disgħin")] + [InlineData(300, "tlett mija")] + [InlineData(401, "erbgħa mija u wieħed")] + [InlineData(503, "ħames mija u tlieta")] + [InlineData(610, "sitt mija u għaxra")] + [InlineData(711, "sebgħa mija u ħdax")] + [InlineData(821, "tminn mija u wieħed u għoxrin")] + [InlineData(922, "disgħa mija u tnejn u għoxrin")] + [InlineData(323, "tlett mija u tlieta u għoxrin")] + [InlineData(438, "erbgħa mija u tmienja u tletin")] + [InlineData(543, "ħames mija u tlieta u erbgħin")] + [InlineData(678, "sitt mija u tmienja u sebgħin")] + [InlineData(799, "sebgħa mija u disgħa u disgħin")] + [InlineData(1000, "elf")] + [InlineData(1001, "elf u wieħed")] + [InlineData(1111, "elf u mija u ħdax")] + [InlineData(1234, "elf u mitejn u erbgħa u tletin")] + [InlineData(1999, "elf u disgħa mija u disgħa u disgħin")] + [InlineData(2000, "elfejn")] + [InlineData(2014, "elfejn u erbatax")] + [InlineData(2048, "elfejn u tmienja u erbgħin")] + [InlineData(3000, "tlett elef")] + [InlineData(3501, "tlett elef u ħames mija u wieħed")] + [InlineData(8100, "tmint elef u mija")] + [InlineData(10000, "għaxart elef")] + [InlineData(10001, "għaxart elef u wieħed")] + [InlineData(12345, "tnax-il elf u tlett mija u ħamsa u erbgħin")] + [InlineData(18000, "tmintax-il elf")] + [InlineData(100000, "mitt elf")] + [InlineData(100001, "mitt elf u wieħed")] + [InlineData(111111, "mija u ħdax-il elf u mija u ħdax")] + [InlineData(123456, "mija u tlieta u għoxrin elf u erbgħa mija u sitta u ħamsin")] + [InlineData(1000000, "miljun")] + [InlineData(1000001, "miljun u wieħed")] + [InlineData(1111101, "miljun u mija u ħdax-il elf u mija u wieħed")] + [InlineData(1111111, "miljun u mija u ħdax-il elf u mija u ħdax")] + [InlineData(1234567, "miljun u mitejn u erbgħa u tletin elf u ħames mija u sebgħa u sittin")] + [InlineData(5000000, "ħames miljuni")] + [InlineData(10000000, "għaxar miljuni")] + [InlineData(10000001, "għaxar miljuni u wieħed")] + [InlineData(11111111, "ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] + [InlineData(12345678, "tnax-il miljun u tlett mija u ħamsa u erbgħin elf u sitt mija u tmienja u sebgħin")] + [InlineData(100000000, "mitt miljun")] + [InlineData(100000001, "mitt miljun u wieħed")] + [InlineData(111111111, "mija u ħdax-il miljun u mija u ħdax-il elf u mija u ħdax")] + [InlineData(123456789, "mija u tlieta u għoxrin miljun u erbgħa mija u sitta u ħamsin elf u sebgħa mija u disgħa u tmenin")] + [InlineData(1000000000, "biljun")] + [InlineData(1000000001, "biljun u wieħed")] + [InlineData(1101111101, "biljun u mija u miljun u mija u ħdax-il elf u mija u wieħed")] + [InlineData(2000000000, "żewġ biljuni")] + [InlineData(2147483647, "żewġ biljuni u mija u sebgħa u erbgħin miljun u erbgħa mija u tlieta u tmenin elf u sitt mija u sebgħa u erbgħin")] + public void ToMasculineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "l-ewwel")] - [InlineData(2, "it-tieni")] - [InlineData(9, "id-disa'")] - [InlineData(10, "l-għaxar")] - [InlineData(11, "il-ħdax")] - [InlineData(15, "il-ħmistax")] - [InlineData(18, "it-tmintax")] - [InlineData(20, "l-għoxrin")] - [InlineData(21, "il-wieħed u għoxrin")] - [InlineData(22, "it-tnejn u għoxrin")] - [InlineData(28, "it-tmienja u għoxrin")] - [InlineData(44, "l-erbgħa u erbgħin")] - [InlineData(55, "il-ħamsa u ħamsin")] - [InlineData(60, "is-sittin")] - [InlineData(99, "id-disgħa u disgħin")] - [InlineData(100, "il-mija")] - [InlineData(101, "il-mija u wieħed")] - [InlineData(1000, "l-elf")] - [InlineData(1001, "l-elf u wieħed")] - [InlineData(2000, "l-elfejn")] - [InlineData(3000, "it-tlett elef")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "0")] + [InlineData(1, "l-ewwel")] + [InlineData(2, "it-tieni")] + [InlineData(9, "id-disa'")] + [InlineData(10, "l-għaxar")] + [InlineData(11, "il-ħdax")] + [InlineData(15, "il-ħmistax")] + [InlineData(18, "it-tmintax")] + [InlineData(20, "l-għoxrin")] + [InlineData(21, "il-wieħed u għoxrin")] + [InlineData(22, "it-tnejn u għoxrin")] + [InlineData(28, "it-tmienja u għoxrin")] + [InlineData(44, "l-erbgħa u erbgħin")] + [InlineData(55, "il-ħamsa u ħamsin")] + [InlineData(60, "is-sittin")] + [InlineData(99, "id-disgħa u disgħin")] + [InlineData(100, "il-mija")] + [InlineData(101, "il-mija u wieħed")] + [InlineData(1000, "l-elf")] + [InlineData(1001, "l-elf u wieħed")] + [InlineData(2000, "l-elfejn")] + [InlineData(3000, "it-tlett elef")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "l-ewwel")] - [InlineData(2, "it-tieni")] - [InlineData(9, "id-disa'")] - [InlineData(10, "l-għaxar")] - [InlineData(11, "il-ħdax")] - [InlineData(15, "il-ħmistax")] - [InlineData(18, "it-tmintax")] - [InlineData(20, "l-għoxrin")] - [InlineData(21, "il-wieħed u għoxrin")] - [InlineData(22, "it-tnejn u għoxrin")] - [InlineData(28, "it-tmienja u għoxrin")] - [InlineData(44, "l-erbgħa u erbgħin")] - [InlineData(55, "il-ħamsa u ħamsin")] - [InlineData(60, "is-sittin")] - [InlineData(99, "id-disgħa u disgħin")] - [InlineData(100, "il-mija")] - [InlineData(101, "il-mija u waħda")] - [InlineData(1000, "l-elf")] - [InlineData(1001, "l-elf u waħda")] - [InlineData(2000, "l-elfejn")] - [InlineData(3000, "it-tlett elef")] - public void ToFeminineOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "0")] + [InlineData(1, "l-ewwel")] + [InlineData(2, "it-tieni")] + [InlineData(9, "id-disa'")] + [InlineData(10, "l-għaxar")] + [InlineData(11, "il-ħdax")] + [InlineData(15, "il-ħmistax")] + [InlineData(18, "it-tmintax")] + [InlineData(20, "l-għoxrin")] + [InlineData(21, "il-wieħed u għoxrin")] + [InlineData(22, "it-tnejn u għoxrin")] + [InlineData(28, "it-tmienja u għoxrin")] + [InlineData(44, "l-erbgħa u erbgħin")] + [InlineData(55, "il-ħamsa u ħamsin")] + [InlineData(60, "is-sittin")] + [InlineData(99, "id-disgħa u disgħin")] + [InlineData(100, "il-mija")] + [InlineData(101, "il-mija u waħda")] + [InlineData(1000, "l-elf")] + [InlineData(1001, "l-elf u waħda")] + [InlineData(2000, "l-elfejn")] + [InlineData(3000, "it-tlett elef")] + public void ToFeminineOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "l-ewwel")] - [InlineData(2, "it-tieni")] - [InlineData(9, "id-disa'")] - [InlineData(10, "l-għaxar")] - [InlineData(11, "il-ħdax")] - [InlineData(15, "il-ħmistax")] - [InlineData(18, "it-tmintax")] - [InlineData(20, "l-għoxrin")] - [InlineData(21, "il-wieħed u għoxrin")] - [InlineData(22, "it-tnejn u għoxrin")] - [InlineData(28, "it-tmienja u għoxrin")] - [InlineData(44, "l-erbgħa u erbgħin")] - [InlineData(55, "il-ħamsa u ħamsin")] - [InlineData(60, "is-sittin")] - [InlineData(99, "id-disgħa u disgħin")] - [InlineData(100, "il-mija")] - [InlineData(101, "il-mija u wieħed")] - [InlineData(1000, "l-elf")] - [InlineData(1001, "l-elf u wieħed")] - [InlineData(2000, "l-elfejn")] - [InlineData(3000, "it-tlett elef")] - public void ToMasculineOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); - } -} + [Theory] + [InlineData(0, "0")] + [InlineData(1, "l-ewwel")] + [InlineData(2, "it-tieni")] + [InlineData(9, "id-disa'")] + [InlineData(10, "l-għaxar")] + [InlineData(11, "il-ħdax")] + [InlineData(15, "il-ħmistax")] + [InlineData(18, "it-tmintax")] + [InlineData(20, "l-għoxrin")] + [InlineData(21, "il-wieħed u għoxrin")] + [InlineData(22, "it-tnejn u għoxrin")] + [InlineData(28, "it-tmienja u għoxrin")] + [InlineData(44, "l-erbgħa u erbgħin")] + [InlineData(55, "il-ħamsa u ħamsin")] + [InlineData(60, "is-sittin")] + [InlineData(99, "id-disgħa u disgħin")] + [InlineData(100, "il-mija")] + [InlineData(101, "il-mija u wieħed")] + [InlineData(1000, "l-elf")] + [InlineData(1001, "l-elf u wieħed")] + [InlineData(2000, "l-elfejn")] + [InlineData(3000, "it-tlett elef")] + public void ToMasculineOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/mt/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/mt/TimeSpanHumanizeTests.cs index cf414d331..375ba52e5 100644 --- a/src/Humanizer.Tests/Localisation/mt/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/mt/TimeSpanHumanizeTests.cs @@ -1,74 +1,73 @@ -namespace Humanizer.Tests.Localisation.mt +namespace Humanizer.Tests.Localisation.mt; + +[UseCulture("mt")] +public class TimeSpanHumanizeTests { - [UseCulture("mt")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "sena")] - [InlineData(731, "sentejn")] - [InlineData(1096, "3 snin")] - [InlineData(4018, "11 snin")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "sena")] + [InlineData(731, "sentejn")] + [InlineData(1096, "3 snin")] + [InlineData(4018, "11 snin")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "xahar")] - [InlineData(61, "xahrejn")] - [InlineData(92, "3 xhur")] - [InlineData(335, "11 xhur")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "xahar")] + [InlineData(61, "xahrejn")] + [InlineData(92, "3 xhur")] + [InlineData(335, "11 xhur")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "ġimgħa")] - [InlineData(14, "ġimgħatejn")] - [InlineData(21, "3 ġimgħat")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "ġimgħa")] + [InlineData(14, "ġimgħatejn")] + [InlineData(21, "3 ġimgħat")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "ġurnata")] - [InlineData(2, "jumejn")] - [InlineData(3, "3 jiem")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "ġurnata")] + [InlineData(2, "jumejn")] + [InlineData(3, "3 jiem")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "siegħa")] - [InlineData(2, "sagħtejn")] - [InlineData(3, "3 siegħat")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "siegħa")] + [InlineData(2, "sagħtejn")] + [InlineData(3, "3 siegħat")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "minuta")] - [InlineData(2, "2 minuti")] - [InlineData(3, "3 minuti")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "minuta")] + [InlineData(2, "2 minuti")] + [InlineData(3, "3 minuti")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "sekonda")] - [InlineData(2, "2 sekondi")] - [InlineData(3, "3 sekondi")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "sekonda")] + [InlineData(2, "2 sekondi")] + [InlineData(3, "3 sekondi")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "millisekonda")] - [InlineData(2, "2 millisekondi")] - [InlineData(3, "3 millisekondi")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "millisekonda")] + [InlineData(2, "2 millisekondi")] + [InlineData(3, "3 millisekondi")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 millisekondi", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 millisekondi", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("xejn", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("xejn", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs index 710185e41..80dd7c5b6 100644 --- a/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs @@ -1,85 +1,84 @@ -namespace Humanizer.Tests.Localisation.nbNO +namespace Humanizer.Tests.Localisation.nbNO; + +[UseCulture("nb-NO")] +public class DateHumanizeTests { - [UseCulture("nb-NO")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "2 dager siden")] - [InlineData(-1, "i går")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "2 dager siden")] + [InlineData(-1, "i går")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "i morgen")] - [InlineData(10, "10 dager fra nå")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "i morgen")] + [InlineData(10, "10 dager fra nå")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "ett sekund fra nå")] - [InlineData(10, "10 sekunder fra nå")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "ett sekund fra nå")] + [InlineData(10, "10 sekunder fra nå")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 timer siden")] - [InlineData(-1, "en time siden")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "2 timer siden")] + [InlineData(-1, "en time siden")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "en time fra nå")] - [InlineData(10, "10 timer fra nå")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "en time fra nå")] + [InlineData(10, "10 timer fra nå")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 minutter siden")] - [InlineData(-1, "ett minutt siden")] - [InlineData(60, "en time siden")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 minutter siden")] + [InlineData(-1, "ett minutt siden")] + [InlineData(60, "en time siden")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "ett minutt fra nå")] - [InlineData(59, "59 minutter fra nå")] - [InlineData(60, "en time fra nå")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "ett minutt fra nå")] + [InlineData(59, "59 minutter fra nå")] + [InlineData(60, "en time fra nå")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 måneder siden")] - [InlineData(-1, "en måned siden")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 måneder siden")] + [InlineData(-1, "en måned siden")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "en måned fra nå")] - [InlineData(10, "10 måneder fra nå")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "en måned fra nå")] + [InlineData(10, "10 måneder fra nå")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 sekunder siden")] - [InlineData(-1, "ett sekund siden")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 sekunder siden")] + [InlineData(-1, "ett sekund siden")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(-2, "2 år siden")] - [InlineData(-1, "ett år siden")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 år siden")] + [InlineData(-1, "ett år siden")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "ett år fra nå")] - [InlineData(2, "2 år fra nå")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "ett år fra nå")] + [InlineData(2, "2 år fra nå")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "nå")] - public void Now(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(0, "nå")] + public void Now(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs index 39a730671..67d75b673 100644 --- a/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.nbNO +namespace Humanizer.Tests.Localisation.nbNO; + +[UseCulture("nb-NO")] +public class TimeSpanHumanizeTests { - [UseCulture("nb-NO")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 år")] - [InlineData(731, "2 år")] - [InlineData(1096, "3 år")] - [InlineData(4018, "11 år")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 måned")] - [InlineData(61, "2 måneder")] - [InlineData(92, "3 måneder")] - [InlineData(335, "11 måneder")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 måned")] + [InlineData(61, "2 måneder")] + [InlineData(92, "3 måneder")] + [InlineData(335, "11 måneder")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 uke")] - [InlineData(14, "2 uker")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 uke")] + [InlineData(14, "2 uker")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 dag")] - [InlineData(2, "2 dager")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 dag")] + [InlineData(2, "2 dager")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 time")] - [InlineData(2, "2 timer")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 time")] + [InlineData(2, "2 timer")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 minutt")] - [InlineData(2, "2 minutter")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 minutt")] + [InlineData(2, "2 minutter")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 sekund")] - [InlineData(2, "2 sekunder")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 millisekund")] - [InlineData(2, "2 millisekunder")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 millisekunder", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 millisekunder", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("ingen tid", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("ingen tid", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs index b37b23894..851d153da 100644 --- a/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nb/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.nb +namespace Humanizer.Tests.Localisation.nb; + +[UseCulture("nb")] +public class DateHumanizeTests { - [UseCulture("nb")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "2 dager siden")] - [InlineData(-1, "i går")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "2 dager siden")] + [InlineData(-1, "i går")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "i morgen")] - [InlineData(10, "10 dager fra nå")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "i morgen")] + [InlineData(10, "10 dager fra nå")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "ett sekund fra nå")] - [InlineData(10, "10 sekunder fra nå")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "ett sekund fra nå")] + [InlineData(10, "10 sekunder fra nå")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 timer siden")] - [InlineData(-1, "en time siden")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "2 timer siden")] + [InlineData(-1, "en time siden")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "en time fra nå")] - [InlineData(10, "10 timer fra nå")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "en time fra nå")] + [InlineData(10, "10 timer fra nå")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 minutter siden")] - [InlineData(-1, "ett minutt siden")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 minutter siden")] + [InlineData(-1, "ett minutt siden")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "ett minutt fra nå")] - [InlineData(10, "10 minutter fra nå")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "ett minutt fra nå")] + [InlineData(10, "10 minutter fra nå")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 måneder siden")] - [InlineData(-1, "en måned siden")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 måneder siden")] + [InlineData(-1, "en måned siden")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "en måned fra nå")] - [InlineData(10, "10 måneder fra nå")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "en måned fra nå")] + [InlineData(10, "10 måneder fra nå")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 sekunder siden")] - [InlineData(-1, "ett sekund siden")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 sekunder siden")] + [InlineData(-1, "ett sekund siden")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(-2, "2 år siden")] - [InlineData(-1, "ett år siden")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 år siden")] + [InlineData(-1, "ett år siden")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "ett år fra nå")] - [InlineData(2, "2 år fra nå")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "ett år fra nå")] + [InlineData(2, "2 år fra nå")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "nå")] - public void Now(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(0, "nå")] + public void Now(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nb/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/nb/NumberToWordsTests.cs index 8ce875952..271d086de 100644 --- a/src/Humanizer.Tests/Localisation/nb/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/nb/NumberToWordsTests.cs @@ -1,128 +1,127 @@ -namespace Humanizer.Tests.Localisation.nb +namespace Humanizer.Tests.Localisation.nb; + +[UseCulture("nb-NO")] +public class NumberToWordsTests { - [UseCulture("nb-NO")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "null")] - [InlineData(1, "en")] - [InlineData(2, "to")] - [InlineData(3, "tre")] - [InlineData(4, "fire")] - [InlineData(5, "fem")] - [InlineData(6, "seks")] - [InlineData(7, "sju")] - [InlineData(8, "åtte")] - [InlineData(9, "ni")] - [InlineData(10, "ti")] - [InlineData(20, "tjue")] - [InlineData(30, "tretti")] - [InlineData(40, "førti")] - [InlineData(50, "femti")] - [InlineData(60, "seksti")] - [InlineData(70, "sytti")] - [InlineData(80, "åtti")] - [InlineData(90, "nitti")] - [InlineData(98, "nittiåtte")] - [InlineData(99, "nittini")] - [InlineData(100, "hundre")] - [InlineData(200, "tohundre")] - [InlineData(1000, "tusen")] - [InlineData(100000, "hundretusen")] - [InlineData(1000000, "en million")] - [InlineData(10000000, "ti millioner")] - [InlineData(100000000, "hundre millioner")] - [InlineData(1000000000, "en milliard")] - [InlineData(2000000000, "to milliarder")] - [InlineData(122, "hundreogtjueto")] - [InlineData(3501, "tretusenfemhundreogen")] - [InlineData(111, "hundreogelleve")] - [InlineData(1001, "tusenogen")] - [InlineData(1099, "tusenognittini")] - [InlineData(1100, "ettusenethundre")] - [InlineData(1112, "ettusenethundreogtolv")] - [InlineData(11213, "ellevetusentohundreogtretten")] - [InlineData(121314, "hundreogtjueentusentrehundreogfjorten")] - [InlineData(2132415, "to millioner hundreogtrettitotusenfirehundreogfemten")] - [InlineData(12345516, "tolv millioner trehundreogførtifemtusenfemhundreogseksten")] - [InlineData(751633617, "sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreogsytten")] - [InlineData(1111111118, "en milliard hundreogelleve millioner hundreogellevetusenethundreogatten")] - [InlineData(-751633619, "minus sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreognitten")] - [InlineData(1000010, "en million og ti")] - [InlineData(1001009, "en million tusenogni")] - [InlineData(1000099, "en million og nittini")] - [InlineData(1000000010, "en milliard og ti")] - [InlineData(1000110, "en million ethundreogti")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "null")] + [InlineData(1, "en")] + [InlineData(2, "to")] + [InlineData(3, "tre")] + [InlineData(4, "fire")] + [InlineData(5, "fem")] + [InlineData(6, "seks")] + [InlineData(7, "sju")] + [InlineData(8, "åtte")] + [InlineData(9, "ni")] + [InlineData(10, "ti")] + [InlineData(20, "tjue")] + [InlineData(30, "tretti")] + [InlineData(40, "førti")] + [InlineData(50, "femti")] + [InlineData(60, "seksti")] + [InlineData(70, "sytti")] + [InlineData(80, "åtti")] + [InlineData(90, "nitti")] + [InlineData(98, "nittiåtte")] + [InlineData(99, "nittini")] + [InlineData(100, "hundre")] + [InlineData(200, "tohundre")] + [InlineData(1000, "tusen")] + [InlineData(100000, "hundretusen")] + [InlineData(1000000, "en million")] + [InlineData(10000000, "ti millioner")] + [InlineData(100000000, "hundre millioner")] + [InlineData(1000000000, "en milliard")] + [InlineData(2000000000, "to milliarder")] + [InlineData(122, "hundreogtjueto")] + [InlineData(3501, "tretusenfemhundreogen")] + [InlineData(111, "hundreogelleve")] + [InlineData(1001, "tusenogen")] + [InlineData(1099, "tusenognittini")] + [InlineData(1100, "ettusenethundre")] + [InlineData(1112, "ettusenethundreogtolv")] + [InlineData(11213, "ellevetusentohundreogtretten")] + [InlineData(121314, "hundreogtjueentusentrehundreogfjorten")] + [InlineData(2132415, "to millioner hundreogtrettitotusenfirehundreogfemten")] + [InlineData(12345516, "tolv millioner trehundreogførtifemtusenfemhundreogseksten")] + [InlineData(751633617, "sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreogsytten")] + [InlineData(1111111118, "en milliard hundreogelleve millioner hundreogellevetusenethundreogatten")] + [InlineData(-751633619, "minus sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreognitten")] + [InlineData(1000010, "en million og ti")] + [InlineData(1001009, "en million tusenogni")] + [InlineData(1000099, "en million og nittini")] + [InlineData(1000000010, "en milliard og ti")] + [InlineData(1000110, "en million ethundreogti")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nullte")] - [InlineData(1, "første")] - [InlineData(2, "andre")] - [InlineData(3, "tredje")] - [InlineData(4, "fjerde")] - [InlineData(5, "femte")] - [InlineData(6, "sjette")] - [InlineData(7, "sjuende")] - [InlineData(8, "åttende")] - [InlineData(9, "niende")] - [InlineData(10, "tiende")] - [InlineData(20, "tjuende")] - [InlineData(30, "trettiende")] - [InlineData(40, "førtiende")] - [InlineData(50, "femtiende")] - [InlineData(60, "sekstiende")] - [InlineData(70, "syttiende")] - [InlineData(80, "åttiende")] - [InlineData(90, "nittiende")] - [InlineData(98, "nittiåttende")] - [InlineData(99, "nittiniende")] - [InlineData(100, "hundrede")] - [InlineData(200, "tohundrede")] - [InlineData(1000, "tusende")] - [InlineData(10000, "titusende")] - [InlineData(100000, "hundretusende")] - [InlineData(1000000, "millionte")] - [InlineData(10000000, "ti millionte")] - [InlineData(100000000, "hundre millionte")] - [InlineData(1000000000, "milliardte")] - [InlineData(2000000000, "to milliardte")] - [InlineData(122, "hundreogtjueandre")] - [InlineData(3501, "tretusenfemhundreogførste")] - [InlineData(111, "hundreogellevte")] - [InlineData(1112, "ettusenethundreogtolvte")] - [InlineData(11213, "ellevetusentohundreogtrettende")] - [InlineData(121314, "hundreogtjueentusentrehundreogfjortende")] - [InlineData(2132415, "to millioner hundreogtrettitotusenfirehundreogfemtende")] - [InlineData(12345516, "tolv millioner trehundreogførtifemtusenfemhundreogsekstende")] - [InlineData(751633617, "sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreogsyttende")] - [InlineData(1111111118, "en milliard hundreogelleve millioner hundreogellevetusenethundreogattende")] - [InlineData(-751633619, "minus sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreognittende")] - [InlineData(1000010, "en million og tiende")] - [InlineData(1001009, "en million tusenogniende")] - [InlineData(1000099, "en million og nittiniende")] - [InlineData(1000000010, "en milliard og tiende")] - [InlineData(1000110, "en million ethundreogtiende")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "nullte")] + [InlineData(1, "første")] + [InlineData(2, "andre")] + [InlineData(3, "tredje")] + [InlineData(4, "fjerde")] + [InlineData(5, "femte")] + [InlineData(6, "sjette")] + [InlineData(7, "sjuende")] + [InlineData(8, "åttende")] + [InlineData(9, "niende")] + [InlineData(10, "tiende")] + [InlineData(20, "tjuende")] + [InlineData(30, "trettiende")] + [InlineData(40, "førtiende")] + [InlineData(50, "femtiende")] + [InlineData(60, "sekstiende")] + [InlineData(70, "syttiende")] + [InlineData(80, "åttiende")] + [InlineData(90, "nittiende")] + [InlineData(98, "nittiåttende")] + [InlineData(99, "nittiniende")] + [InlineData(100, "hundrede")] + [InlineData(200, "tohundrede")] + [InlineData(1000, "tusende")] + [InlineData(10000, "titusende")] + [InlineData(100000, "hundretusende")] + [InlineData(1000000, "millionte")] + [InlineData(10000000, "ti millionte")] + [InlineData(100000000, "hundre millionte")] + [InlineData(1000000000, "milliardte")] + [InlineData(2000000000, "to milliardte")] + [InlineData(122, "hundreogtjueandre")] + [InlineData(3501, "tretusenfemhundreogførste")] + [InlineData(111, "hundreogellevte")] + [InlineData(1112, "ettusenethundreogtolvte")] + [InlineData(11213, "ellevetusentohundreogtrettende")] + [InlineData(121314, "hundreogtjueentusentrehundreogfjortende")] + [InlineData(2132415, "to millioner hundreogtrettitotusenfirehundreogfemtende")] + [InlineData(12345516, "tolv millioner trehundreogførtifemtusenfemhundreogsekstende")] + [InlineData(751633617, "sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreogsyttende")] + [InlineData(1111111118, "en milliard hundreogelleve millioner hundreogellevetusenethundreogattende")] + [InlineData(-751633619, "minus sjuhundreogfemtien millioner sekshundreogtrettitretusensekshundreognittende")] + [InlineData(1000010, "en million og tiende")] + [InlineData(1001009, "en million tusenogniende")] + [InlineData(1000099, "en million og nittiniende")] + [InlineData(1000000010, "en milliard og tiende")] + [InlineData(1000110, "en million ethundreogtiende")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(2, "to")] - [InlineData(1, "ei")] - [InlineData(0, "null")] - [InlineData(-1, "minus ei")] - [InlineData(-2, "minus to")] - public void ToWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(2, "to")] + [InlineData(1, "ei")] + [InlineData(0, "null")] + [InlineData(-1, "minus ei")] + [InlineData(-2, "minus to")] + public void ToWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(2, "to")] - [InlineData(1, "et")] - [InlineData(0, "null")] - [InlineData(-1, "minus et")] - [InlineData(-2, "minus to")] - public void ToWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(2, "to")] + [InlineData(1, "et")] + [InlineData(0, "null")] + [InlineData(-1, "minus et")] + [InlineData(-2, "minus to")] + public void ToWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs index dd25af2de..ea1f1ac87 100644 --- a/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nb/TimeSpanHumanizeTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.nb +namespace Humanizer.Tests.Localisation.nb; + +[UseCulture("nb")] +public class TimeSpanHumanizeTests { - [UseCulture("nb")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 år")] - [InlineData(731, "2 år")] - [InlineData(1096, "3 år")] - [InlineData(4018, "11 år")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 måned")] - [InlineData(61, "2 måneder")] - [InlineData(92, "3 måneder")] - [InlineData(335, "11 måneder")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 måned")] + [InlineData(61, "2 måneder")] + [InlineData(92, "3 måneder")] + [InlineData(335, "11 måneder")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 uke")] - [InlineData(14, "2 uker")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 uke")] + [InlineData(14, "2 uker")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 dag")] - [InlineData(2, "2 dager")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 dag")] + [InlineData(2, "2 dager")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 time")] - [InlineData(2, "2 timer")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 time")] + [InlineData(2, "2 timer")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 minutt")] - [InlineData(2, "2 minutter")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 minutt")] + [InlineData(2, "2 minutter")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 sekund")] - [InlineData(2, "2 sekunder")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 millisekund")] - [InlineData(2, "2 millisekunder")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 millisekunder", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 millisekunder", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("ingen tid", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("ingen tid", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nl/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nl/DateHumanizeTests.cs index 27f7c0922..ad8f11f8b 100644 --- a/src/Humanizer.Tests/Localisation/nl/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nl/DateHumanizeTests.cs @@ -1,85 +1,84 @@ -namespace Humanizer.Tests.Localisation.nl +namespace Humanizer.Tests.Localisation.nl; + +[UseCulture("nl-NL")] +public class DateHumanizeTests { - [UseCulture("nl-NL")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 dagen geleden")] - [InlineData(1, "gisteren")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 dagen geleden")] + [InlineData(1, "gisteren")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 uur geleden")] - [InlineData(1, "1 uur geleden")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 uur geleden")] + [InlineData(1, "1 uur geleden")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 minuten geleden")] - [InlineData(1, "1 minuut geleden")] - [InlineData(60, "1 uur geleden")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(2, "2 minuten geleden")] + [InlineData(1, "1 minuut geleden")] + [InlineData(60, "1 uur geleden")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 maanden geleden")] - [InlineData(1, "1 maand geleden")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(2, "2 maanden geleden")] + [InlineData(1, "1 maand geleden")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 seconden geleden")] - [InlineData(1, "1 seconde geleden")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(2, "2 seconden geleden")] + [InlineData(1, "1 seconde geleden")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 jaar geleden")] - [InlineData(1, "1 jaar geleden")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(2, "2 jaar geleden")] + [InlineData(1, "1 jaar geleden")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "over 2 dagen")] - [InlineData(1, "morgen")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "over 2 dagen")] + [InlineData(1, "morgen")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "over 2 uur")] - [InlineData(1, "over 1 uur")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "over 2 uur")] + [InlineData(1, "over 1 uur")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(2, "over 2 minuten")] - [InlineData(1, "over 1 minuut")] - [InlineData(60, "over 1 uur")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "over 2 minuten")] + [InlineData(1, "over 1 minuut")] + [InlineData(60, "over 1 uur")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(2, "over 2 maanden")] - [InlineData(1, "over 1 maand")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "over 2 maanden")] + [InlineData(1, "over 1 maand")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(2, "over 2 seconden")] - [InlineData(1, "over 1 seconde")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "over 2 seconden")] + [InlineData(1, "over 1 seconde")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(2, "over 2 jaar")] - [InlineData(1, "over 1 jaar")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(2, "over 2 jaar")] + [InlineData(1, "over 1 jaar")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(0, "nu")] - public void RightNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - } -} + [Theory] + [InlineData(0, "nu")] + public void RightNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nl/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/nl/NumberToWordsTests.cs index 0d5493095..80f007511 100644 --- a/src/Humanizer.Tests/Localisation/nl/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/nl/NumberToWordsTests.cs @@ -1,115 +1,114 @@ -namespace Humanizer.Tests.Localisation.nl +namespace Humanizer.Tests.Localisation.nl; + +[UseCulture("nl-NL")] +public class NumberToWordsTests { - [UseCulture("nl-NL")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "nul")] - [InlineData(1, "een")] - [InlineData(-10, "min tien")] - [InlineData(10, "tien")] - [InlineData(11, "elf")] - [InlineData(122, "honderdtweeëntwintig")] - [InlineData(3501, "drieduizend vijfhonderdeen")] - [InlineData(100, "honderd")] - [InlineData(1000, "duizend")] - [InlineData(100000, "honderdduizend")] - [InlineData(1000000, "een miljoen")] - [InlineData(10000000, "tien miljoen")] - [InlineData(100000000, "honderd miljoen")] - [InlineData(1000000000, "een miljard")] - [InlineData(111, "honderdelf")] - [InlineData(1111, "duizend honderdelf")] - [InlineData(111111, "honderdelfduizend honderdelf")] - [InlineData(1111111, "een miljoen honderdelfduizend honderdelf")] - [InlineData(11111111, "elf miljoen honderdelfduizend honderdelf")] - [InlineData(111111111, "honderdelf miljoen honderdelfduizend honderdelf")] - [InlineData(1111111111, "een miljard honderdelf miljoen honderdelfduizend honderdelf")] - [InlineData(123, "honderddrieëntwintig")] - [InlineData(124, "honderdvierentwintig")] - [InlineData(1234, "duizend tweehonderdvierendertig")] - [InlineData(12345, "twaalfduizend driehonderdvijfenveertig")] - [InlineData(123456, "honderddrieëntwintigduizend vierhonderdzesenvijftig")] - [InlineData(1234567, "een miljoen tweehonderdvierendertigduizend vijfhonderdzevenenzestig")] - [InlineData(12345678, "twaalf miljoen driehonderdvijfenveertigduizend zeshonderdachtenzeventig")] - [InlineData(123456789, "honderddrieëntwintig miljoen vierhonderdzesenvijftigduizend zevenhonderdnegenentachtig")] - [InlineData(1234567890, "een miljard tweehonderdvierendertig miljoen vijfhonderdzevenenzestigduizend achthonderdnegentig")] - [InlineData(1234567899, "een miljard tweehonderdvierendertig miljoen vijfhonderdzevenenzestigduizend achthonderdnegenennegentig")] - [InlineData(108, "honderdacht")] - [InlineData(678, "zeshonderdachtenzeventig")] - [InlineData(2013, "tweeduizend dertien")] - [InlineData(2577, "tweeduizend vijfhonderdzevenenzeventig")] - [InlineData(17053980, "zeventien miljoen drieënvijftigduizend negenhonderdtachtig")] - [InlineData(415618, "vierhonderdvijftienduizend zeshonderdachttien")] - [InlineData(16415618, "zestien miljoen vierhonderdvijftienduizend zeshonderdachttien")] - [InlineData(322, "driehonderdtweeëntwintig")] - public void IntToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "nul")] + [InlineData(1, "een")] + [InlineData(-10, "min tien")] + [InlineData(10, "tien")] + [InlineData(11, "elf")] + [InlineData(122, "honderdtweeëntwintig")] + [InlineData(3501, "drieduizend vijfhonderdeen")] + [InlineData(100, "honderd")] + [InlineData(1000, "duizend")] + [InlineData(100000, "honderdduizend")] + [InlineData(1000000, "een miljoen")] + [InlineData(10000000, "tien miljoen")] + [InlineData(100000000, "honderd miljoen")] + [InlineData(1000000000, "een miljard")] + [InlineData(111, "honderdelf")] + [InlineData(1111, "duizend honderdelf")] + [InlineData(111111, "honderdelfduizend honderdelf")] + [InlineData(1111111, "een miljoen honderdelfduizend honderdelf")] + [InlineData(11111111, "elf miljoen honderdelfduizend honderdelf")] + [InlineData(111111111, "honderdelf miljoen honderdelfduizend honderdelf")] + [InlineData(1111111111, "een miljard honderdelf miljoen honderdelfduizend honderdelf")] + [InlineData(123, "honderddrieëntwintig")] + [InlineData(124, "honderdvierentwintig")] + [InlineData(1234, "duizend tweehonderdvierendertig")] + [InlineData(12345, "twaalfduizend driehonderdvijfenveertig")] + [InlineData(123456, "honderddrieëntwintigduizend vierhonderdzesenvijftig")] + [InlineData(1234567, "een miljoen tweehonderdvierendertigduizend vijfhonderdzevenenzestig")] + [InlineData(12345678, "twaalf miljoen driehonderdvijfenveertigduizend zeshonderdachtenzeventig")] + [InlineData(123456789, "honderddrieëntwintig miljoen vierhonderdzesenvijftigduizend zevenhonderdnegenentachtig")] + [InlineData(1234567890, "een miljard tweehonderdvierendertig miljoen vijfhonderdzevenenzestigduizend achthonderdnegentig")] + [InlineData(1234567899, "een miljard tweehonderdvierendertig miljoen vijfhonderdzevenenzestigduizend achthonderdnegenennegentig")] + [InlineData(108, "honderdacht")] + [InlineData(678, "zeshonderdachtenzeventig")] + [InlineData(2013, "tweeduizend dertien")] + [InlineData(2577, "tweeduizend vijfhonderdzevenenzeventig")] + [InlineData(17053980, "zeventien miljoen drieënvijftigduizend negenhonderdtachtig")] + [InlineData(415618, "vierhonderdvijftienduizend zeshonderdachttien")] + [InlineData(16415618, "zestien miljoen vierhonderdvijftienduizend zeshonderdachttien")] + [InlineData(322, "driehonderdtweeëntwintig")] + public void IntToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(100_000_000_000L, "honderd miljard")] - [InlineData(1_000_000_000_000L, "een biljoen")] - [InlineData(100_000_000_000_000L, "honderd biljoen")] - [InlineData(1_000_000_000_000_000L, "een biljard")] - [InlineData(100_000_000_000_000_000L, "honderd biljard")] - [InlineData(1_000_000_000_000_000_000L, "een triljoen")] - [InlineData(9_223_372_036_854_775_807L, "negen triljoen tweehonderddrieëntwintig biljard driehonderdtweeënzeventig biljoen zesendertig miljard achthonderdvierenvijftig miljoen zevenhonderdvijfenzeventigduizend achthonderdzeven")] - public void LongToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(100_000_000_000L, "honderd miljard")] + [InlineData(1_000_000_000_000L, "een biljoen")] + [InlineData(100_000_000_000_000L, "honderd biljoen")] + [InlineData(1_000_000_000_000_000L, "een biljard")] + [InlineData(100_000_000_000_000_000L, "honderd biljard")] + [InlineData(1_000_000_000_000_000_000L, "een triljoen")] + [InlineData(9_223_372_036_854_775_807L, "negen triljoen tweehonderddrieëntwintig biljard driehonderdtweeënzeventig biljoen zesendertig miljard achthonderdvierenvijftig miljoen zevenhonderdvijfenzeventigduizend achthonderdzeven")] + public void LongToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nulde")] - [InlineData(1, "eerste")] - [InlineData(2, "tweede")] - [InlineData(3, "derde")] - [InlineData(4, "vierde")] - [InlineData(5, "vijfde")] - [InlineData(6, "zesde")] - [InlineData(7, "zevende")] - [InlineData(8, "achtste")] - [InlineData(9, "negende")] - [InlineData(10, "tiende")] - [InlineData(11, "elfde")] - [InlineData(12, "twaalfde")] - [InlineData(13, "dertiende")] - [InlineData(14, "veertiende")] - [InlineData(15, "vijftiende")] - [InlineData(16, "zestiende")] - [InlineData(17, "zeventiende")] - [InlineData(18, "achttiende")] - [InlineData(19, "negentiende")] - [InlineData(20, "twintigste")] - [InlineData(21, "eenentwintigste")] - [InlineData(22, "tweeëntwintigste")] - [InlineData(30, "dertigste")] - [InlineData(40, "veertigste")] - [InlineData(50, "vijftigste")] - [InlineData(60, "zestigste")] - [InlineData(70, "zeventigste")] - [InlineData(80, "tachtigste")] - [InlineData(90, "negentigste")] - [InlineData(95, "vijfennegentigste")] - [InlineData(96, "zesennegentigste")] - [InlineData(100, "honderdste")] - [InlineData(101, "honderdeerste")] - [InlineData(106, "honderdzesde")] - [InlineData(108, "honderdachtste")] - [InlineData(112, "honderdtwaalfde")] - [InlineData(120, "honderdtwintigste")] - [InlineData(121, "honderdeenentwintigste")] - [InlineData(1000, "duizendste")] - [InlineData(1001, "duizend eerste")] - [InlineData(1005, "duizend vijfde")] - [InlineData(1008, "duizend achtste")] - [InlineData(1012, "duizend twaalfde")] - [InlineData(1021, "duizend eenentwintigste")] - [InlineData(10000, "tienduizendste")] - [InlineData(10121, "tienduizend honderdeenentwintigste")] - [InlineData(100000, "honderdduizendste")] - [InlineData(100001, "honderdduizend eerste")] - [InlineData(1000000, "een miljoenste")] - [InlineData(1000001, "een miljoen eerste")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "nulde")] + [InlineData(1, "eerste")] + [InlineData(2, "tweede")] + [InlineData(3, "derde")] + [InlineData(4, "vierde")] + [InlineData(5, "vijfde")] + [InlineData(6, "zesde")] + [InlineData(7, "zevende")] + [InlineData(8, "achtste")] + [InlineData(9, "negende")] + [InlineData(10, "tiende")] + [InlineData(11, "elfde")] + [InlineData(12, "twaalfde")] + [InlineData(13, "dertiende")] + [InlineData(14, "veertiende")] + [InlineData(15, "vijftiende")] + [InlineData(16, "zestiende")] + [InlineData(17, "zeventiende")] + [InlineData(18, "achttiende")] + [InlineData(19, "negentiende")] + [InlineData(20, "twintigste")] + [InlineData(21, "eenentwintigste")] + [InlineData(22, "tweeëntwintigste")] + [InlineData(30, "dertigste")] + [InlineData(40, "veertigste")] + [InlineData(50, "vijftigste")] + [InlineData(60, "zestigste")] + [InlineData(70, "zeventigste")] + [InlineData(80, "tachtigste")] + [InlineData(90, "negentigste")] + [InlineData(95, "vijfennegentigste")] + [InlineData(96, "zesennegentigste")] + [InlineData(100, "honderdste")] + [InlineData(101, "honderdeerste")] + [InlineData(106, "honderdzesde")] + [InlineData(108, "honderdachtste")] + [InlineData(112, "honderdtwaalfde")] + [InlineData(120, "honderdtwintigste")] + [InlineData(121, "honderdeenentwintigste")] + [InlineData(1000, "duizendste")] + [InlineData(1001, "duizend eerste")] + [InlineData(1005, "duizend vijfde")] + [InlineData(1008, "duizend achtste")] + [InlineData(1012, "duizend twaalfde")] + [InlineData(1021, "duizend eenentwintigste")] + [InlineData(10000, "tienduizendste")] + [InlineData(10121, "tienduizend honderdeenentwintigste")] + [InlineData(100000, "honderdduizendste")] + [InlineData(100001, "honderdduizend eerste")] + [InlineData(1000000, "een miljoenste")] + [InlineData(1000001, "een miljoen eerste")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nl/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/nl/OrdinalizeTests.cs index 9bbe54046..badc35db2 100644 --- a/src/Humanizer.Tests/Localisation/nl/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nl/OrdinalizeTests.cs @@ -1,23 +1,22 @@ -namespace Humanizer.Tests.Localisation.nl +namespace Humanizer.Tests.Localisation.nl; + +[UseCulture("nl")] +public class OrdinalizeTests { - [UseCulture("nl")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0")] - [InlineData("1", "1e")] - [InlineData("2", "2e")] - [InlineData("3", "3e")] - [InlineData("4", "4e")] - [InlineData("5", "5e")] - [InlineData("6", "6e")] - [InlineData("23", "23e")] - [InlineData("100", "100e")] - [InlineData("101", "101e")] - [InlineData("102", "102e")] - [InlineData("103", "103e")] - [InlineData("1001", "1001e")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(), ordinalized); - } -} + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1e")] + [InlineData("2", "2e")] + [InlineData("3", "3e")] + [InlineData("4", "4e")] + [InlineData("5", "5e")] + [InlineData("6", "6e")] + [InlineData("23", "23e")] + [InlineData("100", "100e")] + [InlineData("101", "101e")] + [InlineData("102", "102e")] + [InlineData("103", "103e")] + [InlineData("1001", "1001e")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/nl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nl/TimeSpanHumanizeTests.cs index d8272c438..289f7d30b 100644 --- a/src/Humanizer.Tests/Localisation/nl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nl/TimeSpanHumanizeTests.cs @@ -1,84 +1,83 @@ -namespace Humanizer.Tests.Localisation.nl +namespace Humanizer.Tests.Localisation.nl; + +[UseCulture("nl-NL")] +public class TimeSpanHumanizeTests { - [UseCulture("nl-NL")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 jaar")] - [InlineData(731, "2 jaar")] - [InlineData(1096, "3 jaar")] - [InlineData(4018, "11 jaar")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 maand")] - [InlineData(61, "2 maanden")] - [InlineData(92, "3 maanden")] - [InlineData(335, "11 maanden")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Fact] - public void TwoWeeks() => - Assert.Equal("2 weken", TimeSpan.FromDays(14).Humanize()); - - [Fact] - public void OneWeek() => - Assert.Equal("1 week", TimeSpan.FromDays(7).Humanize()); - - [Fact] - public void SixDays() => - Assert.Equal("6 dagen", TimeSpan.FromDays(6).Humanize()); - - [Fact] - public void TwoDays() => - Assert.Equal("2 dagen", TimeSpan.FromDays(2).Humanize()); - - [Fact] - public void OneDay() => - Assert.Equal("1 dag", TimeSpan.FromDays(1).Humanize()); - - [Fact] - public void TwoHours() => - Assert.Equal("2 uur", TimeSpan.FromHours(2).Humanize()); - - [Fact] - public void OneHour() => - Assert.Equal("1 uur", TimeSpan.FromHours(1).Humanize()); - - [Fact] - public void TwoMinutes() => - Assert.Equal("2 minuten", TimeSpan.FromMinutes(2).Humanize()); - - [Fact] - public void OneMinute() => - Assert.Equal("1 minuut", TimeSpan.FromMinutes(1).Humanize()); - - [Fact] - public void TwoSeconds() => - Assert.Equal("2 seconden", TimeSpan.FromSeconds(2).Humanize()); - - [Fact] - public void OneSecond() => - Assert.Equal("1 seconde", TimeSpan.FromSeconds(1).Humanize()); - - [Fact] - public void TwoMilliseconds() => - Assert.Equal("2 milliseconden", TimeSpan.FromMilliseconds(2).Humanize()); - - [Fact] - public void OneMillisecond() => - Assert.Equal("1 milliseconde", TimeSpan.FromMilliseconds(1).Humanize()); - - [Fact] - public void NoTime() => - Assert.Equal("0 milliseconden", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - Assert.Equal("geen tijd", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 jaar")] + [InlineData(731, "2 jaar")] + [InlineData(1096, "3 jaar")] + [InlineData(4018, "11 jaar")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 maand")] + [InlineData(61, "2 maanden")] + [InlineData(92, "3 maanden")] + [InlineData(335, "11 maanden")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Fact] + public void TwoWeeks() => + Assert.Equal("2 weken", TimeSpan.FromDays(14).Humanize()); + + [Fact] + public void OneWeek() => + Assert.Equal("1 week", TimeSpan.FromDays(7).Humanize()); + + [Fact] + public void SixDays() => + Assert.Equal("6 dagen", TimeSpan.FromDays(6).Humanize()); + + [Fact] + public void TwoDays() => + Assert.Equal("2 dagen", TimeSpan.FromDays(2).Humanize()); + + [Fact] + public void OneDay() => + Assert.Equal("1 dag", TimeSpan.FromDays(1).Humanize()); + + [Fact] + public void TwoHours() => + Assert.Equal("2 uur", TimeSpan.FromHours(2).Humanize()); + + [Fact] + public void OneHour() => + Assert.Equal("1 uur", TimeSpan.FromHours(1).Humanize()); + + [Fact] + public void TwoMinutes() => + Assert.Equal("2 minuten", TimeSpan.FromMinutes(2).Humanize()); + + [Fact] + public void OneMinute() => + Assert.Equal("1 minuut", TimeSpan.FromMinutes(1).Humanize()); + + [Fact] + public void TwoSeconds() => + Assert.Equal("2 seconden", TimeSpan.FromSeconds(2).Humanize()); + + [Fact] + public void OneSecond() => + Assert.Equal("1 seconde", TimeSpan.FromSeconds(1).Humanize()); + + [Fact] + public void TwoMilliseconds() => + Assert.Equal("2 milliseconden", TimeSpan.FromMilliseconds(2).Humanize()); + + [Fact] + public void OneMillisecond() => + Assert.Equal("1 milliseconde", TimeSpan.FromMilliseconds(1).Humanize()); + + [Fact] + public void NoTime() => + Assert.Equal("0 milliseconden", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + Assert.Equal("geen tijd", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs index 18db8bb77..3450aa0e9 100644 --- a/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pl/DateHumanizeTests.cs @@ -1,142 +1,141 @@ -namespace Humanizer.Tests.Localisation.pl +namespace Humanizer.Tests.Localisation.pl; + +[UseCulture("pl")] +public class DateHumanizeTests { - [UseCulture("pl")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "za sekundę")] - [InlineData(2, "za 2 sekundy")] - [InlineData(3, "za 3 sekundy")] - [InlineData(4, "za 4 sekundy")] - [InlineData(5, "za 5 sekund")] - [InlineData(6, "za 6 sekund")] - [InlineData(10, "za 10 sekund")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "za sekundę")] + [InlineData(2, "za 2 sekundy")] + [InlineData(3, "za 3 sekundy")] + [InlineData(4, "za 4 sekundy")] + [InlineData(5, "za 5 sekund")] + [InlineData(6, "za 6 sekund")] + [InlineData(10, "za 10 sekund")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "za minutę")] - [InlineData(2, "za 2 minuty")] - [InlineData(3, "za 3 minuty")] - [InlineData(4, "za 4 minuty")] - [InlineData(5, "za 5 minut")] - [InlineData(6, "za 6 minut")] - [InlineData(10, "za 10 minut")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "za minutę")] + [InlineData(2, "za 2 minuty")] + [InlineData(3, "za 3 minuty")] + [InlineData(4, "za 4 minuty")] + [InlineData(5, "za 5 minut")] + [InlineData(6, "za 6 minut")] + [InlineData(10, "za 10 minut")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "za godzinę")] - [InlineData(2, "za 2 godziny")] - [InlineData(3, "za 3 godziny")] - [InlineData(4, "za 4 godziny")] - [InlineData(5, "za 5 godzin")] - [InlineData(6, "za 6 godzin")] - [InlineData(10, "za 10 godzin")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "za godzinę")] + [InlineData(2, "za 2 godziny")] + [InlineData(3, "za 3 godziny")] + [InlineData(4, "za 4 godziny")] + [InlineData(5, "za 5 godzin")] + [InlineData(6, "za 6 godzin")] + [InlineData(10, "za 10 godzin")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "jutro")] - [InlineData(2, "za 2 dni")] - [InlineData(3, "za 3 dni")] - [InlineData(4, "za 4 dni")] - [InlineData(5, "za 5 dni")] - [InlineData(6, "za 6 dni")] - [InlineData(10, "za 10 dni")] - public void DayFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "jutro")] + [InlineData(2, "za 2 dni")] + [InlineData(3, "za 3 dni")] + [InlineData(4, "za 4 dni")] + [InlineData(5, "za 5 dni")] + [InlineData(6, "za 6 dni")] + [InlineData(10, "za 10 dni")] + public void DayFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "za miesiąc")] - [InlineData(2, "za 2 miesiące")] - [InlineData(3, "za 3 miesiące")] - [InlineData(4, "za 4 miesiące")] - [InlineData(5, "za 5 miesięcy")] - [InlineData(6, "za 6 miesięcy")] - [InlineData(10, "za 10 miesięcy")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "za miesiąc")] + [InlineData(2, "za 2 miesiące")] + [InlineData(3, "za 3 miesiące")] + [InlineData(4, "za 4 miesiące")] + [InlineData(5, "za 5 miesięcy")] + [InlineData(6, "za 6 miesięcy")] + [InlineData(10, "za 10 miesięcy")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "za rok")] - [InlineData(2, "za 2 lata")] - [InlineData(3, "za 3 lata")] - [InlineData(4, "za 4 lata")] - [InlineData(5, "za 5 lat")] - [InlineData(6, "za 6 lat")] - [InlineData(10, "za 10 lat")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "za rok")] + [InlineData(2, "za 2 lata")] + [InlineData(3, "za 3 lata")] + [InlineData(4, "za 4 lata")] + [InlineData(5, "za 5 lat")] + [InlineData(6, "za 6 lat")] + [InlineData(10, "za 10 lat")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(1, "przed sekundą")] - [InlineData(2, "przed 2 sekundami")] - [InlineData(3, "przed 3 sekundami")] - [InlineData(4, "przed 4 sekundami")] - [InlineData(5, "przed 5 sekundami")] - [InlineData(6, "przed 6 sekundami")] - [InlineData(10, "przed 10 sekundami")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "przed sekundą")] + [InlineData(2, "przed 2 sekundami")] + [InlineData(3, "przed 3 sekundami")] + [InlineData(4, "przed 4 sekundami")] + [InlineData(5, "przed 5 sekundami")] + [InlineData(6, "przed 6 sekundami")] + [InlineData(10, "przed 10 sekundami")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "przed minutą")] - [InlineData(2, "przed 2 minutami")] - [InlineData(3, "przed 3 minutami")] - [InlineData(4, "przed 4 minutami")] - [InlineData(5, "przed 5 minutami")] - [InlineData(6, "przed 6 minutami")] - [InlineData(10, "przed 10 minutami")] - [InlineData(60, "przed godziną")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "przed minutą")] + [InlineData(2, "przed 2 minutami")] + [InlineData(3, "przed 3 minutami")] + [InlineData(4, "przed 4 minutami")] + [InlineData(5, "przed 5 minutami")] + [InlineData(6, "przed 6 minutami")] + [InlineData(10, "przed 10 minutami")] + [InlineData(60, "przed godziną")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "przed godziną")] - [InlineData(2, "przed 2 godzinami")] - [InlineData(3, "przed 3 godzinami")] - [InlineData(4, "przed 4 godzinami")] - [InlineData(5, "przed 5 godzinami")] - [InlineData(6, "przed 6 godzinami")] - [InlineData(10, "przed 10 godzinami")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "przed godziną")] + [InlineData(2, "przed 2 godzinami")] + [InlineData(3, "przed 3 godzinami")] + [InlineData(4, "przed 4 godzinami")] + [InlineData(5, "przed 5 godzinami")] + [InlineData(6, "przed 6 godzinami")] + [InlineData(10, "przed 10 godzinami")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "wczoraj")] - [InlineData(2, "przed 2 dniami")] - [InlineData(3, "przed 3 dniami")] - [InlineData(4, "przed 4 dniami")] - [InlineData(9, "przed 9 dniami")] - [InlineData(10, "przed 10 dniami")] - public void DayAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "wczoraj")] + [InlineData(2, "przed 2 dniami")] + [InlineData(3, "przed 3 dniami")] + [InlineData(4, "przed 4 dniami")] + [InlineData(9, "przed 9 dniami")] + [InlineData(10, "przed 10 dniami")] + public void DayAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "przed miesiącem")] - [InlineData(2, "przed 2 miesiącami")] - [InlineData(3, "przed 3 miesiącami")] - [InlineData(4, "przed 4 miesiącami")] - [InlineData(5, "przed 5 miesiącami")] - [InlineData(6, "przed 6 miesiącami")] - [InlineData(10, "przed 10 miesiącami")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "przed miesiącem")] + [InlineData(2, "przed 2 miesiącami")] + [InlineData(3, "przed 3 miesiącami")] + [InlineData(4, "przed 4 miesiącami")] + [InlineData(5, "przed 5 miesiącami")] + [InlineData(6, "przed 6 miesiącami")] + [InlineData(10, "przed 10 miesiącami")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "przed rokiem")] - [InlineData(2, "przed 2 laty")] - [InlineData(3, "przed 3 laty")] - [InlineData(4, "przed 4 laty")] - [InlineData(5, "przed 5 laty")] - [InlineData(6, "przed 6 laty")] - [InlineData(10, "przed 10 laty")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "przed rokiem")] + [InlineData(2, "przed 2 laty")] + [InlineData(3, "przed 3 laty")] + [InlineData(4, "przed 4 laty")] + [InlineData(5, "przed 5 laty")] + [InlineData(6, "przed 6 laty")] + [InlineData(10, "przed 10 laty")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Fact] - public void Now() => - DateHumanize.Verify("teraz", 0, TimeUnit.Day, Tense.Past); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("teraz", 0, TimeUnit.Day, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs index 19a2cc376..a79eca09e 100644 --- a/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/pl/NumberToWordsTests.cs @@ -1,107 +1,106 @@ -namespace Humanizer.Tests.Localisation.pl +namespace Humanizer.Tests.Localisation.pl; + +[UseCulture("pl")] +public class NumberToWordsTests { - [UseCulture("pl")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "jeden")] - [InlineData(2, "dwa")] - [InlineData(3, "trzy")] - [InlineData(4, "cztery")] - [InlineData(5, "pięć")] - [InlineData(6, "sześć")] - [InlineData(7, "siedem")] - [InlineData(8, "osiem")] - [InlineData(9, "dziewięć")] - [InlineData(10, "dziesięć")] - [InlineData(11, "jedenaście")] - [InlineData(12, "dwanaście")] - [InlineData(13, "trzynaście")] - [InlineData(14, "czternaście")] - [InlineData(15, "piętnaście")] - [InlineData(16, "szesnaście")] - [InlineData(17, "siedemnaście")] - [InlineData(18, "osiemnaście")] - [InlineData(19, "dziewiętnaście")] - [InlineData(20, "dwadzieścia")] - [InlineData(30, "trzydzieści")] - [InlineData(40, "czterdzieści")] - [InlineData(50, "pięćdziesiąt")] - [InlineData(60, "sześćdziesiąt")] - [InlineData(70, "siedemdziesiąt")] - [InlineData(80, "osiemdziesiąt")] - [InlineData(90, "dziewięćdziesiąt")] - [InlineData(100, "sto")] - [InlineData(112, "sto dwanaście")] - [InlineData(128, "sto dwadzieścia osiem")] - [InlineData(1000, "tysiąc")] - [InlineData(2000, "dwa tysiące")] - [InlineData(5000, "pięć tysięcy")] - [InlineData(10000, "dziesięć tysięcy")] - [InlineData(12000, "dwanaście tysięcy")] - [InlineData(20000, "dwadzieścia tysięcy")] - [InlineData(22000, "dwadzieścia dwa tysiące")] - [InlineData(25000, "dwadzieścia pięć tysięcy")] - [InlineData(31000, "trzydzieści jeden tysięcy")] - [InlineData(34000, "trzydzieści cztery tysiące")] - [InlineData(100000, "sto tysięcy")] - [InlineData(500000, "pięćset tysięcy")] - [InlineData(1000000, "milion")] - [InlineData(2000000, "dwa miliony")] - [InlineData(5000000, "pięć milionów")] - [InlineData(1000000000, "miliard")] - [InlineData(2000000000, "dwa miliardy")] - [InlineData(1501001892, "miliard pięćset jeden milionów tysiąc osiemset dziewięćdziesiąt dwa")] - [InlineData(2147483647, "dwa miliardy sto czterdzieści siedem milionów czterysta osiemdziesiąt trzy tysiące sześćset czterdzieści siedem")] - [InlineData(-1501001892, "minus miliard pięćset jeden milionów tysiąc osiemset dziewięćdziesiąt dwa")] - [InlineData(long.MaxValue, - "dziewięć trylionów " + - "dwieście dwadzieścia trzy biliardy " + - "trzysta siedemdziesiąt dwa biliony " + - "trzydzieści sześć miliardów " + - "osiemset pięćdziesiąt cztery miliony " + - "siedemset siedemdziesiąt pięć tysięcy " + - "osiemset siedem")] - [InlineData(long.MinValue, - "minus dziewięć trylionów " + - "dwieście dwadzieścia trzy biliardy " + - "trzysta siedemdziesiąt dwa biliony " + - "trzydzieści sześć miliardów " + - "osiemset pięćdziesiąt cztery miliony " + - "siedemset siedemdziesiąt pięć tysięcy " + - "osiemset osiem")] - public void ToWordsPolish(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "jeden")] + [InlineData(2, "dwa")] + [InlineData(3, "trzy")] + [InlineData(4, "cztery")] + [InlineData(5, "pięć")] + [InlineData(6, "sześć")] + [InlineData(7, "siedem")] + [InlineData(8, "osiem")] + [InlineData(9, "dziewięć")] + [InlineData(10, "dziesięć")] + [InlineData(11, "jedenaście")] + [InlineData(12, "dwanaście")] + [InlineData(13, "trzynaście")] + [InlineData(14, "czternaście")] + [InlineData(15, "piętnaście")] + [InlineData(16, "szesnaście")] + [InlineData(17, "siedemnaście")] + [InlineData(18, "osiemnaście")] + [InlineData(19, "dziewiętnaście")] + [InlineData(20, "dwadzieścia")] + [InlineData(30, "trzydzieści")] + [InlineData(40, "czterdzieści")] + [InlineData(50, "pięćdziesiąt")] + [InlineData(60, "sześćdziesiąt")] + [InlineData(70, "siedemdziesiąt")] + [InlineData(80, "osiemdziesiąt")] + [InlineData(90, "dziewięćdziesiąt")] + [InlineData(100, "sto")] + [InlineData(112, "sto dwanaście")] + [InlineData(128, "sto dwadzieścia osiem")] + [InlineData(1000, "tysiąc")] + [InlineData(2000, "dwa tysiące")] + [InlineData(5000, "pięć tysięcy")] + [InlineData(10000, "dziesięć tysięcy")] + [InlineData(12000, "dwanaście tysięcy")] + [InlineData(20000, "dwadzieścia tysięcy")] + [InlineData(22000, "dwadzieścia dwa tysiące")] + [InlineData(25000, "dwadzieścia pięć tysięcy")] + [InlineData(31000, "trzydzieści jeden tysięcy")] + [InlineData(34000, "trzydzieści cztery tysiące")] + [InlineData(100000, "sto tysięcy")] + [InlineData(500000, "pięćset tysięcy")] + [InlineData(1000000, "milion")] + [InlineData(2000000, "dwa miliony")] + [InlineData(5000000, "pięć milionów")] + [InlineData(1000000000, "miliard")] + [InlineData(2000000000, "dwa miliardy")] + [InlineData(1501001892, "miliard pięćset jeden milionów tysiąc osiemset dziewięćdziesiąt dwa")] + [InlineData(2147483647, "dwa miliardy sto czterdzieści siedem milionów czterysta osiemdziesiąt trzy tysiące sześćset czterdzieści siedem")] + [InlineData(-1501001892, "minus miliard pięćset jeden milionów tysiąc osiemset dziewięćdziesiąt dwa")] + [InlineData(long.MaxValue, + "dziewięć trylionów " + + "dwieście dwadzieścia trzy biliardy " + + "trzysta siedemdziesiąt dwa biliony " + + "trzydzieści sześć miliardów " + + "osiemset pięćdziesiąt cztery miliony " + + "siedemset siedemdziesiąt pięć tysięcy " + + "osiemset siedem")] + [InlineData(long.MinValue, + "minus dziewięć trylionów " + + "dwieście dwadzieścia trzy biliardy " + + "trzysta siedemdziesiąt dwa biliony " + + "trzydzieści sześć miliardów " + + "osiemset pięćdziesiąt cztery miliony " + + "siedemset siedemdziesiąt pięć tysięcy " + + "osiemset osiem")] + public void ToWordsPolish(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(-1, "minus jeden", GrammaticalGender.Masculine)] - [InlineData(-1, "minus jedna", GrammaticalGender.Feminine)] - [InlineData(-1, "minus jedno", GrammaticalGender.Neuter)] - [InlineData(-2, "minus dwa", GrammaticalGender.Masculine)] - [InlineData(-2, "minus dwie", GrammaticalGender.Feminine)] - [InlineData(-2, "minus dwa", GrammaticalGender.Neuter)] - [InlineData(1, "jeden", GrammaticalGender.Masculine)] - [InlineData(1, "jedna", GrammaticalGender.Feminine)] - [InlineData(1, "jedno", GrammaticalGender.Neuter)] - [InlineData(2, "dwa", GrammaticalGender.Masculine)] - [InlineData(2, "dwie", GrammaticalGender.Feminine)] - [InlineData(2, "dwa", GrammaticalGender.Neuter)] - [InlineData(121, "sto dwadzieścia jeden", GrammaticalGender.Masculine)] - [InlineData(121, "sto dwadzieścia jeden", GrammaticalGender.Feminine)] - [InlineData(121, "sto dwadzieścia jeden", GrammaticalGender.Neuter)] - [InlineData(122, "sto dwadzieścia dwa", GrammaticalGender.Masculine)] - [InlineData(122, "sto dwadzieścia dwie", GrammaticalGender.Feminine)] - [InlineData(122, "sto dwadzieścia dwa", GrammaticalGender.Neuter)] - [InlineData(-2542, "minus dwa tysiące pięćset czterdzieści dwa", GrammaticalGender.Masculine)] - [InlineData(-2542, "minus dwa tysiące pięćset czterdzieści dwie", GrammaticalGender.Feminine)] - [InlineData(-2542, "minus dwa tysiące pięćset czterdzieści dwa", GrammaticalGender.Neuter)] - [InlineData(1000001, "milion jeden", GrammaticalGender.Feminine)] - [InlineData(-1000001, "minus milion jeden", GrammaticalGender.Feminine)] - [InlineData(1000002, "milion dwa", GrammaticalGender.Masculine)] - [InlineData(1000002, "milion dwie", GrammaticalGender.Feminine)] - [InlineData(1000002, "milion dwa", GrammaticalGender.Neuter)] - public void ToWordsPolishWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); - } -} + [Theory] + [InlineData(-1, "minus jeden", GrammaticalGender.Masculine)] + [InlineData(-1, "minus jedna", GrammaticalGender.Feminine)] + [InlineData(-1, "minus jedno", GrammaticalGender.Neuter)] + [InlineData(-2, "minus dwa", GrammaticalGender.Masculine)] + [InlineData(-2, "minus dwie", GrammaticalGender.Feminine)] + [InlineData(-2, "minus dwa", GrammaticalGender.Neuter)] + [InlineData(1, "jeden", GrammaticalGender.Masculine)] + [InlineData(1, "jedna", GrammaticalGender.Feminine)] + [InlineData(1, "jedno", GrammaticalGender.Neuter)] + [InlineData(2, "dwa", GrammaticalGender.Masculine)] + [InlineData(2, "dwie", GrammaticalGender.Feminine)] + [InlineData(2, "dwa", GrammaticalGender.Neuter)] + [InlineData(121, "sto dwadzieścia jeden", GrammaticalGender.Masculine)] + [InlineData(121, "sto dwadzieścia jeden", GrammaticalGender.Feminine)] + [InlineData(121, "sto dwadzieścia jeden", GrammaticalGender.Neuter)] + [InlineData(122, "sto dwadzieścia dwa", GrammaticalGender.Masculine)] + [InlineData(122, "sto dwadzieścia dwie", GrammaticalGender.Feminine)] + [InlineData(122, "sto dwadzieścia dwa", GrammaticalGender.Neuter)] + [InlineData(-2542, "minus dwa tysiące pięćset czterdzieści dwa", GrammaticalGender.Masculine)] + [InlineData(-2542, "minus dwa tysiące pięćset czterdzieści dwie", GrammaticalGender.Feminine)] + [InlineData(-2542, "minus dwa tysiące pięćset czterdzieści dwa", GrammaticalGender.Neuter)] + [InlineData(1000001, "milion jeden", GrammaticalGender.Feminine)] + [InlineData(-1000001, "minus milion jeden", GrammaticalGender.Feminine)] + [InlineData(1000002, "milion dwa", GrammaticalGender.Masculine)] + [InlineData(1000002, "milion dwie", GrammaticalGender.Feminine)] + [InlineData(1000002, "milion dwa", GrammaticalGender.Neuter)] + public void ToWordsPolishWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs index 22ad04c8c..ee134009d 100644 --- a/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pl/TimeSpanHumanizeTests.cs @@ -1,96 +1,95 @@ -namespace Humanizer.Tests.Localisation.pl +namespace Humanizer.Tests.Localisation.pl; + +[UseCulture("pl")] +public class TimeSpanHumanizeTests { - [UseCulture("pl")] - public class TimeSpanHumanizeTests - { - [Theory] - [InlineData(1, "1 milisekunda")] - [InlineData(2, "2 milisekundy")] - [InlineData(3, "3 milisekundy")] - [InlineData(4, "4 milisekundy")] - [InlineData(5, "5 milisekund")] - [InlineData(6, "6 milisekund")] - [InlineData(10, "10 milisekund")] - public void Milliseconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); + [Theory] + [InlineData(1, "1 milisekunda")] + [InlineData(2, "2 milisekundy")] + [InlineData(3, "3 milisekundy")] + [InlineData(4, "4 milisekundy")] + [InlineData(5, "5 milisekund")] + [InlineData(6, "6 milisekund")] + [InlineData(10, "10 milisekund")] + public void Milliseconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); - [Theory] - [InlineData(1, "1 sekunda")] - [InlineData(2, "2 sekundy")] - [InlineData(3, "3 sekundy")] - [InlineData(4, "4 sekundy")] - [InlineData(5, "5 sekund")] - [InlineData(6, "6 sekund")] - [InlineData(10, "10 sekund")] - public void Seconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); + [Theory] + [InlineData(1, "1 sekunda")] + [InlineData(2, "2 sekundy")] + [InlineData(3, "3 sekundy")] + [InlineData(4, "4 sekundy")] + [InlineData(5, "5 sekund")] + [InlineData(6, "6 sekund")] + [InlineData(10, "10 sekund")] + public void Seconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); - [Theory] - [InlineData(1, "1 minuta")] - [InlineData(2, "2 minuty")] - [InlineData(3, "3 minuty")] - [InlineData(4, "4 minuty")] - [InlineData(5, "5 minut")] - [InlineData(6, "6 minut")] - [InlineData(10, "10 minut")] - public void Minutes(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); + [Theory] + [InlineData(1, "1 minuta")] + [InlineData(2, "2 minuty")] + [InlineData(3, "3 minuty")] + [InlineData(4, "4 minuty")] + [InlineData(5, "5 minut")] + [InlineData(6, "6 minut")] + [InlineData(10, "10 minut")] + public void Minutes(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); - [Theory] - [InlineData(1, "1 godzina")] - [InlineData(2, "2 godziny")] - [InlineData(3, "3 godziny")] - [InlineData(4, "4 godziny")] - [InlineData(5, "5 godzin")] - [InlineData(6, "6 godzin")] - [InlineData(10, "10 godzin")] - public void Hours(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); + [Theory] + [InlineData(1, "1 godzina")] + [InlineData(2, "2 godziny")] + [InlineData(3, "3 godziny")] + [InlineData(4, "4 godziny")] + [InlineData(5, "5 godzin")] + [InlineData(6, "6 godzin")] + [InlineData(10, "10 godzin")] + public void Hours(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); - [Theory] - [InlineData(1, "1 dzień")] - [InlineData(2, "2 dni")] - [InlineData(3, "3 dni")] - [InlineData(4, "4 dni")] - [InlineData(5, "5 dni")] - [InlineData(6, "6 dni")] - public void Days(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); + [Theory] + [InlineData(1, "1 dzień")] + [InlineData(2, "2 dni")] + [InlineData(3, "3 dni")] + [InlineData(4, "4 dni")] + [InlineData(5, "5 dni")] + [InlineData(6, "6 dni")] + public void Days(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); - [Theory] - [InlineData(1, "1 tydzień")] - [InlineData(2, "2 tygodnie")] - [InlineData(3, "3 tygodnie")] - [InlineData(4, "4 tygodnie")] - [InlineData(5, "5 tygodni")] - [InlineData(6, "6 tygodni")] - public void Weeks(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); + [Theory] + [InlineData(1, "1 tydzień")] + [InlineData(2, "2 tygodnie")] + [InlineData(3, "3 tygodnie")] + [InlineData(4, "4 tygodnie")] + [InlineData(5, "5 tygodni")] + [InlineData(6, "6 tygodni")] + public void Weeks(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 miesiąc")] - [InlineData(61, "2 miesiące")] - [InlineData(92, "3 miesiące")] - [InlineData(335, "11 miesięcy")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 miesiąc")] + [InlineData(61, "2 miesiące")] + [InlineData(92, "3 miesiące")] + [InlineData(335, "11 miesięcy")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 rok")] - [InlineData(731, "2 lata")] - [InlineData(1096, "3 lata")] - [InlineData(4018, "11 lat")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 rok")] + [InlineData(731, "2 lata")] + [InlineData(1096, "3 lata")] + [InlineData(4018, "11 lat")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Fact] - public void NoTime() => - Assert.Equal("0 milisekund", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 milisekund", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("brak czasu", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("brak czasu", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt-BR/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/DateHumanizeTests.cs index 9a736bdc0..66676572f 100644 --- a/src/Humanizer.Tests/Localisation/pt-BR/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pt-BR/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.ptBR +namespace Humanizer.Tests.Localisation.ptBR; + +[UseCulture("pt-BR")] +public class DateHumanizeTests { - [UseCulture("pt-BR")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-2, "2 segundos atrás")] - [InlineData(-1, "um segundo atrás")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 segundos atrás")] + [InlineData(-1, "um segundo atrás")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "em um segundo")] - [InlineData(2, "em 2 segundos")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "em um segundo")] + [InlineData(2, "em 2 segundos")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 minutos atrás")] - [InlineData(-1, "um minuto atrás")] - [InlineData(60, "uma hora atrás")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 minutos atrás")] + [InlineData(-1, "um minuto atrás")] + [InlineData(60, "uma hora atrás")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "em um minuto")] - [InlineData(2, "em 2 minutos")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "em um minuto")] + [InlineData(2, "em 2 minutos")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 horas atrás")] - [InlineData(-1, "uma hora atrás")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-2, "2 horas atrás")] + [InlineData(-1, "uma hora atrás")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "em uma hora")] - [InlineData(2, "em 2 horas")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "em uma hora")] + [InlineData(2, "em 2 horas")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 dias atrás")] - [InlineData(-1, "ontem")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-2, "2 dias atrás")] + [InlineData(-1, "ontem")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "amanhã")] - [InlineData(2, "em 2 dias")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "amanhã")] + [InlineData(2, "em 2 dias")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-2, "2 meses atrás")] - [InlineData(-1, "um mês atrás")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 meses atrás")] + [InlineData(-1, "um mês atrás")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "em um mês")] - [InlineData(2, "em 2 meses")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "em um mês")] + [InlineData(2, "em 2 meses")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 anos atrás")] - [InlineData(-1, "um ano atrás")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 anos atrás")] + [InlineData(-1, "um ano atrás")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "em um ano")] - [InlineData(2, "em 2 anos")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "em um ano")] + [InlineData(2, "em 2 anos")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("agora", 0, TimeUnit.Day, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("agora", 0, TimeUnit.Day, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt-BR/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/NumberToWordsTests.cs index b1c781cfb..ddd12f99f 100644 --- a/src/Humanizer.Tests/Localisation/pt-BR/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/pt-BR/NumberToWordsTests.cs @@ -1,243 +1,241 @@ -namespace Humanizer.Tests.Localisation.ptBR -{ - [UseCulture("pt-BR")] - public class NumberToWordsTests - { - [Theory] - [InlineData(1, "um")] - [InlineData(2, "dois")] - [InlineData(3, "três")] - [InlineData(4, "quatro")] - [InlineData(5, "cinco")] - [InlineData(6, "seis")] - [InlineData(7, "sete")] - [InlineData(8, "oito")] - [InlineData(9, "nove")] - [InlineData(10, "dez")] - [InlineData(11, "onze")] - [InlineData(12, "doze")] - [InlineData(13, "treze")] - [InlineData(14, "quatorze")] - [InlineData(15, "quinze")] - [InlineData(16, "dezesseis")] - [InlineData(17, "dezessete")] - [InlineData(18, "dezoito")] - [InlineData(19, "dezenove")] - [InlineData(20, "vinte")] - [InlineData(30, "trinta")] - [InlineData(40, "quarenta")] - [InlineData(50, "cinquenta")] - [InlineData(51, "cinquenta e um")] - [InlineData(60, "sessenta")] - [InlineData(66, "sessenta e seis")] - [InlineData(70, "setenta")] - [InlineData(80, "oitenta")] - [InlineData(90, "noventa")] - [InlineData(100, "cem")] - [InlineData(200, "duzentos")] - [InlineData(300, "trezentos")] - [InlineData(400, "quatrocentos")] - [InlineData(500, "quinhentos")] - [InlineData(600, "seiscentos")] - [InlineData(700, "setecentos")] - [InlineData(800, "oitocentos")] - [InlineData(900, "novecentos")] - [InlineData(1000, "mil")] - [InlineData(2000, "dois mil")] - [InlineData(3000, "três mil")] - [InlineData(4000, "quatro mil")] - [InlineData(5000, "cinco mil")] - [InlineData(6000, "seis mil")] - [InlineData(7000, "sete mil")] - [InlineData(8000, "oito mil")] - [InlineData(9000, "nove mil")] - [InlineData(10000, "dez mil")] - [InlineData(100000, "cem mil")] - [InlineData(1000000, "um milhão")] - [InlineData(1000000000, "um bilhão")] - [InlineData(37, "trinta e sete")] - [InlineData(637, "seiscentos e trinta e sete")] - [InlineData(1637, "mil seiscentos e trinta e sete")] - [InlineData(61637, "sessenta e um mil seiscentos e trinta e sete")] - [InlineData(961637, "novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(5961637, "cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(25961637, "vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(425961637, "quatrocentos e vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(10000000, "dez milhões")] - [InlineData(100000000, "cem milhões")] - [InlineData(1101111101, "um bilhão cento e um milhões cento e onze mil cento e um")] - [InlineData(111, "cento e onze")] - [InlineData(1111, "mil cento e onze")] - [InlineData(1111101, "um milhão cento e onze mil cento e um")] - [InlineData(111111, "cento e onze mil cento e onze")] - [InlineData(1111111, "um milhão cento e onze mil cento e onze")] - [InlineData(11111111, "onze milhões cento e onze mil cento e onze")] - [InlineData(111111111, "cento e onze milhões cento e onze mil cento e onze")] - [InlineData(1111111111, "um bilhão cento e onze milhões cento e onze mil cento e onze")] - [InlineData(122, "cento e vinte e dois")] - [InlineData(123, "cento e vinte e três")] - [InlineData(1234, "mil duzentos e trinta e quatro")] - [InlineData(12345, "doze mil trezentos e quarenta e cinco")] - [InlineData(123456, "cento e vinte e três mil quatrocentos e cinquenta e seis")] - [InlineData(1234567, "um milhão duzentos e trinta e quatro mil quinhentos e sessenta e sete")] - [InlineData(12345678, "doze milhões trezentos e quarenta e cinco mil seiscentos e setenta e oito")] - [InlineData(123456789, "cento e vinte e três milhões quatrocentos e cinquenta e seis mil setecentos e oitenta e nove")] - [InlineData(1234567890, "um bilhão duzentos e trinta e quatro milhões quinhentos e sessenta e sete mil oitocentos e noventa")] - [InlineData(1999, "mil novecentos e noventa e nove")] - [InlineData(2000000, "dois milhões")] - [InlineData(2000000000, "dois bilhões")] - [InlineData(2001000000, "dois bilhões um milhão")] - [InlineData(2014, "dois mil e quatorze")] - [InlineData(2048, "dois mil e quarenta e oito")] - [InlineData(21, "vinte e um")] - [InlineData(211, "duzentos e onze")] - [InlineData(2111101, "dois milhões cento e onze mil cento e um")] - [InlineData(221, "duzentos e vinte e um")] - [InlineData(3501, "três mil quinhentos e um")] - [InlineData(8100, "oito mil e cem")] - [InlineData(999999999999, "novecentos e noventa e nove bilhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] - [InlineData(-999999999999, "menos novecentos e noventa e nove bilhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); +namespace Humanizer.Tests.Localisation.ptBR; - [Theory] - [InlineData(1, "uma")] - [InlineData(2, "duas")] - [InlineData(3, "três")] - [InlineData(11, "onze")] - [InlineData(21, "vinte e uma")] - [InlineData(122, "cento e vinte e duas")] - [InlineData(232, "duzentas e trinta e duas")] - [InlineData(343, "trezentas e quarenta e três")] - [InlineData(3501, "três mil quinhentas e uma")] - [InlineData(100, "cem")] - [InlineData(1000, "mil")] - [InlineData(111, "cento e onze")] - [InlineData(1111, "mil cento e onze")] - [InlineData(111111, "cento e onze mil cento e onze")] - [InlineData(1111101, "um milhão cento e onze mil cento e uma")] - [InlineData(1111111, "um milhão cento e onze mil cento e onze")] - [InlineData(2111102, "dois milhões cento e onze mil cento e duas")] - [InlineData(3111101, "três milhões cento e onze mil cento e uma")] - [InlineData(1101111101, "um bilhão cento e um milhões cento e onze mil cento e uma")] - [InlineData(2101111101, "dois bilhões cento e um milhões cento e onze mil cento e uma")] - [InlineData(1234, "mil duzentas e trinta e quatro")] - [InlineData(8100, "oito mil e cem")] - [InlineData(12345, "doze mil trezentas e quarenta e cinco")] - public void ToFeminineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); +[UseCulture("pt-BR")] +public class NumberToWordsTests +{ + [Theory] + [InlineData(1, "um")] + [InlineData(2, "dois")] + [InlineData(3, "três")] + [InlineData(4, "quatro")] + [InlineData(5, "cinco")] + [InlineData(6, "seis")] + [InlineData(7, "sete")] + [InlineData(8, "oito")] + [InlineData(9, "nove")] + [InlineData(10, "dez")] + [InlineData(11, "onze")] + [InlineData(12, "doze")] + [InlineData(13, "treze")] + [InlineData(14, "quatorze")] + [InlineData(15, "quinze")] + [InlineData(16, "dezesseis")] + [InlineData(17, "dezessete")] + [InlineData(18, "dezoito")] + [InlineData(19, "dezenove")] + [InlineData(20, "vinte")] + [InlineData(30, "trinta")] + [InlineData(40, "quarenta")] + [InlineData(50, "cinquenta")] + [InlineData(51, "cinquenta e um")] + [InlineData(60, "sessenta")] + [InlineData(66, "sessenta e seis")] + [InlineData(70, "setenta")] + [InlineData(80, "oitenta")] + [InlineData(90, "noventa")] + [InlineData(100, "cem")] + [InlineData(200, "duzentos")] + [InlineData(300, "trezentos")] + [InlineData(400, "quatrocentos")] + [InlineData(500, "quinhentos")] + [InlineData(600, "seiscentos")] + [InlineData(700, "setecentos")] + [InlineData(800, "oitocentos")] + [InlineData(900, "novecentos")] + [InlineData(1000, "mil")] + [InlineData(2000, "dois mil")] + [InlineData(3000, "três mil")] + [InlineData(4000, "quatro mil")] + [InlineData(5000, "cinco mil")] + [InlineData(6000, "seis mil")] + [InlineData(7000, "sete mil")] + [InlineData(8000, "oito mil")] + [InlineData(9000, "nove mil")] + [InlineData(10000, "dez mil")] + [InlineData(100000, "cem mil")] + [InlineData(1000000, "um milhão")] + [InlineData(1000000000, "um bilhão")] + [InlineData(37, "trinta e sete")] + [InlineData(637, "seiscentos e trinta e sete")] + [InlineData(1637, "mil seiscentos e trinta e sete")] + [InlineData(61637, "sessenta e um mil seiscentos e trinta e sete")] + [InlineData(961637, "novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(5961637, "cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(25961637, "vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(425961637, "quatrocentos e vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(10000000, "dez milhões")] + [InlineData(100000000, "cem milhões")] + [InlineData(1101111101, "um bilhão cento e um milhões cento e onze mil cento e um")] + [InlineData(111, "cento e onze")] + [InlineData(1111, "mil cento e onze")] + [InlineData(1111101, "um milhão cento e onze mil cento e um")] + [InlineData(111111, "cento e onze mil cento e onze")] + [InlineData(1111111, "um milhão cento e onze mil cento e onze")] + [InlineData(11111111, "onze milhões cento e onze mil cento e onze")] + [InlineData(111111111, "cento e onze milhões cento e onze mil cento e onze")] + [InlineData(1111111111, "um bilhão cento e onze milhões cento e onze mil cento e onze")] + [InlineData(122, "cento e vinte e dois")] + [InlineData(123, "cento e vinte e três")] + [InlineData(1234, "mil duzentos e trinta e quatro")] + [InlineData(12345, "doze mil trezentos e quarenta e cinco")] + [InlineData(123456, "cento e vinte e três mil quatrocentos e cinquenta e seis")] + [InlineData(1234567, "um milhão duzentos e trinta e quatro mil quinhentos e sessenta e sete")] + [InlineData(12345678, "doze milhões trezentos e quarenta e cinco mil seiscentos e setenta e oito")] + [InlineData(123456789, "cento e vinte e três milhões quatrocentos e cinquenta e seis mil setecentos e oitenta e nove")] + [InlineData(1234567890, "um bilhão duzentos e trinta e quatro milhões quinhentos e sessenta e sete mil oitocentos e noventa")] + [InlineData(1999, "mil novecentos e noventa e nove")] + [InlineData(2000000, "dois milhões")] + [InlineData(2000000000, "dois bilhões")] + [InlineData(2001000000, "dois bilhões um milhão")] + [InlineData(2014, "dois mil e quatorze")] + [InlineData(2048, "dois mil e quarenta e oito")] + [InlineData(21, "vinte e um")] + [InlineData(211, "duzentos e onze")] + [InlineData(2111101, "dois milhões cento e onze mil cento e um")] + [InlineData(221, "duzentos e vinte e um")] + [InlineData(3501, "três mil quinhentos e um")] + [InlineData(8100, "oito mil e cem")] + [InlineData(999999999999, "novecentos e noventa e nove bilhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] + [InlineData(-999999999999, "menos novecentos e noventa e nove bilhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primeiro")] - [InlineData(2, "segundo")] - [InlineData(3, "terceiro")] - [InlineData(4, "quarto")] - [InlineData(5, "quinto")] - [InlineData(6, "sexto")] - [InlineData(7, "sétimo")] - [InlineData(8, "oitavo")] - [InlineData(9, "nono")] - [InlineData(10, "décimo")] - [InlineData(11, "décimo primeiro")] - [InlineData(12, "décimo segundo")] - [InlineData(13, "décimo terceiro")] - [InlineData(14, "décimo quarto")] - [InlineData(15, "décimo quinto")] - [InlineData(16, "décimo sexto")] - [InlineData(17, "décimo sétimo")] - [InlineData(18, "décimo oitavo")] - [InlineData(19, "décimo nono")] - [InlineData(20, "vigésimo")] - [InlineData(21, "vigésimo primeiro")] - [InlineData(22, "vigésimo segundo")] - [InlineData(30, "trigésimo")] - [InlineData(40, "quadragésimo")] - [InlineData(50, "quinquagésimo")] - [InlineData(60, "sexagésimo")] - [InlineData(70, "septuagésimo")] - [InlineData(80, "octogésimo")] - [InlineData(90, "nonagésimo")] - [InlineData(95, "nonagésimo quinto")] - [InlineData(96, "nonagésimo sexto")] - [InlineData(100, "centésimo")] - [InlineData(120, "centésimo vigésimo")] - [InlineData(121, "centésimo vigésimo primeiro")] - [InlineData(200, "ducentésimo")] - [InlineData(300, "trecentésimo")] - [InlineData(400, "quadringentésimo")] - [InlineData(500, "quingentésimo")] - [InlineData(600, "sexcentésimo")] - [InlineData(700, "septingentésimo")] - [InlineData(800, "octingentésimo")] - [InlineData(900, "noningentésimo")] - [InlineData(1000, "milésimo")] - [InlineData(1001, "milésimo primeiro")] - [InlineData(1021, "milésimo vigésimo primeiro")] - [InlineData(2021, "segundo milésimo vigésimo primeiro")] - [InlineData(10000, "décimo milésimo")] - [InlineData(10121, "décimo milésimo centésimo vigésimo primeiro")] - [InlineData(100000, "centésimo milésimo")] - [InlineData(1000000, "milionésimo")] - [InlineData(1000000000, "bilionésimo")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(1, "uma")] + [InlineData(2, "duas")] + [InlineData(3, "três")] + [InlineData(11, "onze")] + [InlineData(21, "vinte e uma")] + [InlineData(122, "cento e vinte e duas")] + [InlineData(232, "duzentas e trinta e duas")] + [InlineData(343, "trezentas e quarenta e três")] + [InlineData(3501, "três mil quinhentas e uma")] + [InlineData(100, "cem")] + [InlineData(1000, "mil")] + [InlineData(111, "cento e onze")] + [InlineData(1111, "mil cento e onze")] + [InlineData(111111, "cento e onze mil cento e onze")] + [InlineData(1111101, "um milhão cento e onze mil cento e uma")] + [InlineData(1111111, "um milhão cento e onze mil cento e onze")] + [InlineData(2111102, "dois milhões cento e onze mil cento e duas")] + [InlineData(3111101, "três milhões cento e onze mil cento e uma")] + [InlineData(1101111101, "um bilhão cento e um milhões cento e onze mil cento e uma")] + [InlineData(2101111101, "dois bilhões cento e um milhões cento e onze mil cento e uma")] + [InlineData(1234, "mil duzentas e trinta e quatro")] + [InlineData(8100, "oito mil e cem")] + [InlineData(12345, "doze mil trezentas e quarenta e cinco")] + public void ToFeminineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primeira")] - [InlineData(2, "segunda")] - [InlineData(3, "terceira")] - [InlineData(4, "quarta")] - [InlineData(5, "quinta")] - [InlineData(6, "sexta")] - [InlineData(7, "sétima")] - [InlineData(8, "oitava")] - [InlineData(9, "nona")] - [InlineData(10, "décima")] - [InlineData(11, "décima primeira")] - [InlineData(12, "décima segunda")] - [InlineData(13, "décima terceira")] - [InlineData(14, "décima quarta")] - [InlineData(15, "décima quinta")] - [InlineData(16, "décima sexta")] - [InlineData(17, "décima sétima")] - [InlineData(18, "décima oitava")] - [InlineData(19, "décima nona")] - [InlineData(20, "vigésima")] - [InlineData(21, "vigésima primeira")] - [InlineData(22, "vigésima segunda")] - [InlineData(30, "trigésima")] - [InlineData(40, "quadragésima")] - [InlineData(50, "quinquagésima")] - [InlineData(60, "sexagésima")] - [InlineData(70, "septuagésima")] - [InlineData(80, "octogésima")] - [InlineData(90, "nonagésima")] - [InlineData(95, "nonagésima quinta")] - [InlineData(96, "nonagésima sexta")] - [InlineData(100, "centésima")] - [InlineData(120, "centésima vigésima")] - [InlineData(121, "centésima vigésima primeira")] - [InlineData(200, "ducentésima")] - [InlineData(300, "trecentésima")] - [InlineData(400, "quadringentésima")] - [InlineData(500, "quingentésima")] - [InlineData(600, "sexcentésima")] - [InlineData(700, "septingentésima")] - [InlineData(800, "octingentésima")] - [InlineData(900, "noningentésima")] - [InlineData(1000, "milésima")] - [InlineData(1001, "milésima primeira")] - [InlineData(1021, "milésima vigésima primeira")] - [InlineData(2021, "segunda milésima vigésima primeira")] - [InlineData(10000, "décima milésima")] - [InlineData(10121, "décima milésima centésima vigésima primeira")] - [InlineData(100000, "centésima milésima")] - [InlineData(1000000, "milionésima")] - [InlineData(1000000000, "bilionésima")] - public void ToFeminineOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primeiro")] + [InlineData(2, "segundo")] + [InlineData(3, "terceiro")] + [InlineData(4, "quarto")] + [InlineData(5, "quinto")] + [InlineData(6, "sexto")] + [InlineData(7, "sétimo")] + [InlineData(8, "oitavo")] + [InlineData(9, "nono")] + [InlineData(10, "décimo")] + [InlineData(11, "décimo primeiro")] + [InlineData(12, "décimo segundo")] + [InlineData(13, "décimo terceiro")] + [InlineData(14, "décimo quarto")] + [InlineData(15, "décimo quinto")] + [InlineData(16, "décimo sexto")] + [InlineData(17, "décimo sétimo")] + [InlineData(18, "décimo oitavo")] + [InlineData(19, "décimo nono")] + [InlineData(20, "vigésimo")] + [InlineData(21, "vigésimo primeiro")] + [InlineData(22, "vigésimo segundo")] + [InlineData(30, "trigésimo")] + [InlineData(40, "quadragésimo")] + [InlineData(50, "quinquagésimo")] + [InlineData(60, "sexagésimo")] + [InlineData(70, "septuagésimo")] + [InlineData(80, "octogésimo")] + [InlineData(90, "nonagésimo")] + [InlineData(95, "nonagésimo quinto")] + [InlineData(96, "nonagésimo sexto")] + [InlineData(100, "centésimo")] + [InlineData(120, "centésimo vigésimo")] + [InlineData(121, "centésimo vigésimo primeiro")] + [InlineData(200, "ducentésimo")] + [InlineData(300, "trecentésimo")] + [InlineData(400, "quadringentésimo")] + [InlineData(500, "quingentésimo")] + [InlineData(600, "sexcentésimo")] + [InlineData(700, "septingentésimo")] + [InlineData(800, "octingentésimo")] + [InlineData(900, "noningentésimo")] + [InlineData(1000, "milésimo")] + [InlineData(1001, "milésimo primeiro")] + [InlineData(1021, "milésimo vigésimo primeiro")] + [InlineData(2021, "segundo milésimo vigésimo primeiro")] + [InlineData(10000, "décimo milésimo")] + [InlineData(10121, "décimo milésimo centésimo vigésimo primeiro")] + [InlineData(100000, "centésimo milésimo")] + [InlineData(1000000, "milionésimo")] + [InlineData(1000000000, "bilionésimo")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primeira")] + [InlineData(2, "segunda")] + [InlineData(3, "terceira")] + [InlineData(4, "quarta")] + [InlineData(5, "quinta")] + [InlineData(6, "sexta")] + [InlineData(7, "sétima")] + [InlineData(8, "oitava")] + [InlineData(9, "nona")] + [InlineData(10, "décima")] + [InlineData(11, "décima primeira")] + [InlineData(12, "décima segunda")] + [InlineData(13, "décima terceira")] + [InlineData(14, "décima quarta")] + [InlineData(15, "décima quinta")] + [InlineData(16, "décima sexta")] + [InlineData(17, "décima sétima")] + [InlineData(18, "décima oitava")] + [InlineData(19, "décima nona")] + [InlineData(20, "vigésima")] + [InlineData(21, "vigésima primeira")] + [InlineData(22, "vigésima segunda")] + [InlineData(30, "trigésima")] + [InlineData(40, "quadragésima")] + [InlineData(50, "quinquagésima")] + [InlineData(60, "sexagésima")] + [InlineData(70, "septuagésima")] + [InlineData(80, "octogésima")] + [InlineData(90, "nonagésima")] + [InlineData(95, "nonagésima quinta")] + [InlineData(96, "nonagésima sexta")] + [InlineData(100, "centésima")] + [InlineData(120, "centésima vigésima")] + [InlineData(121, "centésima vigésima primeira")] + [InlineData(200, "ducentésima")] + [InlineData(300, "trecentésima")] + [InlineData(400, "quadringentésima")] + [InlineData(500, "quingentésima")] + [InlineData(600, "sexcentésima")] + [InlineData(700, "septingentésima")] + [InlineData(800, "octingentésima")] + [InlineData(900, "noningentésima")] + [InlineData(1000, "milésima")] + [InlineData(1001, "milésima primeira")] + [InlineData(1021, "milésima vigésima primeira")] + [InlineData(2021, "segunda milésima vigésima primeira")] + [InlineData(10000, "décima milésima")] + [InlineData(10121, "décima milésima centésima vigésima primeira")] + [InlineData(100000, "centésima milésima")] + [InlineData(1000000, "milionésima")] + [InlineData(1000000000, "bilionésima")] + public void ToFeminineOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs index 01cbcdad6..0fc5f845f 100644 --- a/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs @@ -1,76 +1,75 @@ -namespace Humanizer.Tests.Localisation.ptBR +namespace Humanizer.Tests.Localisation.ptBR; + +[UseCulture("pt-BR")] +public class OrdinalizeTests { - [UseCulture("pt-BR")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0")] - [InlineData("1", "1º")] - [InlineData("2", "2º")] - [InlineData("3", "3º")] - [InlineData("4", "4º")] - [InlineData("5", "5º")] - [InlineData("6", "6º")] - [InlineData("23", "23º")] - [InlineData("100", "100º")] - [InlineData("101", "101º")] - [InlineData("102", "102º")] - [InlineData("103", "103º")] - [InlineData("1001", "1001º")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1º")] + [InlineData("2", "2º")] + [InlineData("3", "3º")] + [InlineData("4", "4º")] + [InlineData("5", "5º")] + [InlineData("6", "6º")] + [InlineData("23", "23º")] + [InlineData("100", "100º")] + [InlineData("101", "101º")] + [InlineData("102", "102º")] + [InlineData("103", "103º")] + [InlineData("1001", "1001º")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0")] - [InlineData("1", "1ª")] - [InlineData("2", "2ª")] - [InlineData("3", "3ª")] - [InlineData("4", "4ª")] - [InlineData("5", "5ª")] - [InlineData("6", "6ª")] - [InlineData("23", "23ª")] - [InlineData("100", "100ª")] - [InlineData("101", "101ª")] - [InlineData("102", "102ª")] - [InlineData("103", "103ª")] - [InlineData("1001", "1001ª")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1ª")] + [InlineData("2", "2ª")] + [InlineData("3", "3ª")] + [InlineData("4", "4ª")] + [InlineData("5", "5ª")] + [InlineData("6", "6ª")] + [InlineData("23", "23ª")] + [InlineData("100", "100ª")] + [InlineData("101", "101ª")] + [InlineData("102", "102ª")] + [InlineData("103", "103ª")] + [InlineData("1001", "1001ª")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "1º")] - [InlineData(2, "2º")] - [InlineData(3, "3º")] - [InlineData(4, "4º")] - [InlineData(5, "5º")] - [InlineData(6, "6º")] - [InlineData(10, "10º")] - [InlineData(23, "23º")] - [InlineData(100, "100º")] - [InlineData(101, "101º")] - [InlineData(102, "102º")] - [InlineData(103, "103º")] - [InlineData(1001, "1001º")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1º")] + [InlineData(2, "2º")] + [InlineData(3, "3º")] + [InlineData(4, "4º")] + [InlineData(5, "5º")] + [InlineData(6, "6º")] + [InlineData(10, "10º")] + [InlineData(23, "23º")] + [InlineData(100, "100º")] + [InlineData(101, "101º")] + [InlineData(102, "102º")] + [InlineData(103, "103º")] + [InlineData(1001, "1001º")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "1ª")] - [InlineData(2, "2ª")] - [InlineData(3, "3ª")] - [InlineData(4, "4ª")] - [InlineData(5, "5ª")] - [InlineData(6, "6ª")] - [InlineData(10, "10ª")] - [InlineData(23, "23ª")] - [InlineData(100, "100ª")] - [InlineData(101, "101ª")] - [InlineData(102, "102ª")] - [InlineData(103, "103ª")] - [InlineData(1001, "1001ª")] - public void OrdinalizeNumberFeminine(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - } -} + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1ª")] + [InlineData(2, "2ª")] + [InlineData(3, "3ª")] + [InlineData(4, "4ª")] + [InlineData(5, "5ª")] + [InlineData(6, "6ª")] + [InlineData(10, "10ª")] + [InlineData(23, "23ª")] + [InlineData(100, "100ª")] + [InlineData(101, "101ª")] + [InlineData(102, "102ª")] + [InlineData(103, "103ª")] + [InlineData(1001, "1001ª")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt-BR/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/TimeSpanHumanizeTests.cs index 02d16a87c..51967ae3d 100644 --- a/src/Humanizer.Tests/Localisation/pt-BR/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pt-BR/TimeSpanHumanizeTests.cs @@ -1,85 +1,84 @@ -namespace Humanizer.Tests.Localisation.ptBR +namespace Humanizer.Tests.Localisation.ptBR; + +[UseCulture("pt-BR")] +public class TimeSpanHumanizeTests { - [UseCulture("pt-BR")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 ano")] - [InlineData(731, "2 anos")] - [InlineData(1096, "3 anos")] - [InlineData(4018, "11 anos")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mês")] - [InlineData(61, "2 meses")] - [InlineData(92, "3 meses")] - [InlineData(335, "11 meses")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Fact] - public void TwoWeeks() => - Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); - - [Fact] - public void OneWeek() => - Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); - - [Fact] - public void SixDays() => - Assert.Equal("6 dias", TimeSpan.FromDays(6).Humanize()); - - [Fact] - public void TwoDays() => - Assert.Equal("2 dias", TimeSpan.FromDays(2).Humanize()); - - [Fact] - public void OneDay() => - Assert.Equal("1 dia", TimeSpan.FromDays(1).Humanize()); - - [Fact] - public void TwoHours() => - Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); - - [Fact] - public void OneHour() => - Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); - - [Fact] - public void TwoMinutes() => - Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); - - [Fact] - public void OneMinute() => - Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); - - [Fact] - public void TwoSeconds() => - Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); - - [Fact] - public void OneSecond() => - Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); - - [Fact] - public void TwoMilliseconds() => - Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); - - [Fact] - public void OneMillisecond() => - Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); - - [Fact] - public void NoTime() => - Assert.Equal("0 milisegundos", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("sem horário", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 ano")] + [InlineData(731, "2 anos")] + [InlineData(1096, "3 anos")] + [InlineData(4018, "11 anos")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mês")] + [InlineData(61, "2 meses")] + [InlineData(92, "3 meses")] + [InlineData(335, "11 meses")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Fact] + public void TwoWeeks() => + Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); + + [Fact] + public void OneWeek() => + Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); + + [Fact] + public void SixDays() => + Assert.Equal("6 dias", TimeSpan.FromDays(6).Humanize()); + + [Fact] + public void TwoDays() => + Assert.Equal("2 dias", TimeSpan.FromDays(2).Humanize()); + + [Fact] + public void OneDay() => + Assert.Equal("1 dia", TimeSpan.FromDays(1).Humanize()); + + [Fact] + public void TwoHours() => + Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); + + [Fact] + public void OneHour() => + Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); + + [Fact] + public void TwoMinutes() => + Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); + + [Fact] + public void OneMinute() => + Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); + + [Fact] + public void TwoSeconds() => + Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); + + [Fact] + public void OneSecond() => + Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); + + [Fact] + public void TwoMilliseconds() => + Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); + + [Fact] + public void OneMillisecond() => + Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); + + [Fact] + public void NoTime() => + Assert.Equal("0 milisegundos", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("sem horário", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/pt/NumberToWordsTests.cs index 7ae0e3fe4..9de656a8b 100644 --- a/src/Humanizer.Tests/Localisation/pt/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/pt/NumberToWordsTests.cs @@ -1,243 +1,241 @@ -namespace Humanizer.Tests.Localisation.pt -{ - [UseCulture("pt")] - public class NumberToWordsTests - { - [Theory] - [InlineData(1, "um")] - [InlineData(2, "dois")] - [InlineData(3, "três")] - [InlineData(4, "quatro")] - [InlineData(5, "cinco")] - [InlineData(6, "seis")] - [InlineData(7, "sete")] - [InlineData(8, "oito")] - [InlineData(9, "nove")] - [InlineData(10, "dez")] - [InlineData(11, "onze")] - [InlineData(12, "doze")] - [InlineData(13, "treze")] - [InlineData(14, "quatorze")] - [InlineData(15, "quinze")] - [InlineData(16, "dezesseis")] - [InlineData(17, "dezessete")] - [InlineData(18, "dezoito")] - [InlineData(19, "dezenove")] - [InlineData(20, "vinte")] - [InlineData(30, "trinta")] - [InlineData(40, "quarenta")] - [InlineData(50, "cinquenta")] - [InlineData(51, "cinquenta e um")] - [InlineData(60, "sessenta")] - [InlineData(66, "sessenta e seis")] - [InlineData(70, "setenta")] - [InlineData(80, "oitenta")] - [InlineData(90, "noventa")] - [InlineData(100, "cem")] - [InlineData(200, "duzentos")] - [InlineData(300, "trezentos")] - [InlineData(400, "quatrocentos")] - [InlineData(500, "quinhentos")] - [InlineData(600, "seiscentos")] - [InlineData(700, "setecentos")] - [InlineData(800, "oitocentos")] - [InlineData(900, "novecentos")] - [InlineData(1000, "mil")] - [InlineData(2000, "dois mil")] - [InlineData(3000, "três mil")] - [InlineData(4000, "quatro mil")] - [InlineData(5000, "cinco mil")] - [InlineData(6000, "seis mil")] - [InlineData(7000, "sete mil")] - [InlineData(8000, "oito mil")] - [InlineData(9000, "nove mil")] - [InlineData(10000, "dez mil")] - [InlineData(100000, "cem mil")] - [InlineData(1000000, "um milhão")] - [InlineData(1000000000, "mil milhões")] - [InlineData(37, "trinta e sete")] - [InlineData(637, "seiscentos e trinta e sete")] - [InlineData(1637, "mil seiscentos e trinta e sete")] - [InlineData(61637, "sessenta e um mil seiscentos e trinta e sete")] - [InlineData(961637, "novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(5961637, "cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(25961637, "vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(425961637, "quatrocentos e vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] - [InlineData(10000000, "dez milhões")] - [InlineData(100000000, "cem milhões")] - [InlineData(1101111101, "mil milhões cento e um milhões cento e onze mil cento e um")] - [InlineData(111, "cento e onze")] - [InlineData(1111, "mil cento e onze")] - [InlineData(1111101, "um milhão cento e onze mil cento e um")] - [InlineData(111111, "cento e onze mil cento e onze")] - [InlineData(1111111, "um milhão cento e onze mil cento e onze")] - [InlineData(11111111, "onze milhões cento e onze mil cento e onze")] - [InlineData(111111111, "cento e onze milhões cento e onze mil cento e onze")] - [InlineData(1111111111, "mil milhões cento e onze milhões cento e onze mil cento e onze")] - [InlineData(122, "cento e vinte e dois")] - [InlineData(123, "cento e vinte e três")] - [InlineData(1234, "mil duzentos e trinta e quatro")] - [InlineData(12345, "doze mil trezentos e quarenta e cinco")] - [InlineData(123456, "cento e vinte e três mil quatrocentos e cinquenta e seis")] - [InlineData(1234567, "um milhão duzentos e trinta e quatro mil quinhentos e sessenta e sete")] - [InlineData(12345678, "doze milhões trezentos e quarenta e cinco mil seiscentos e setenta e oito")] - [InlineData(123456789, "cento e vinte e três milhões quatrocentos e cinquenta e seis mil setecentos e oitenta e nove")] - [InlineData(1234567890, "mil milhões duzentos e trinta e quatro milhões quinhentos e sessenta e sete mil oitocentos e noventa")] - [InlineData(1999, "mil novecentos e noventa e nove")] - [InlineData(2000000, "dois milhões")] - [InlineData(2000000000, "dois mil milhões")] - [InlineData(2001000000, "dois mil milhões um milhão")] - [InlineData(2014, "dois mil e quatorze")] - [InlineData(2048, "dois mil e quarenta e oito")] - [InlineData(21, "vinte e um")] - [InlineData(211, "duzentos e onze")] - [InlineData(2111101, "dois milhões cento e onze mil cento e um")] - [InlineData(221, "duzentos e vinte e um")] - [InlineData(3501, "três mil quinhentos e um")] - [InlineData(8100, "oito mil e cem")] - [InlineData(999999999999, "novecentos e noventa e nove mil milhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] - [InlineData(-999999999999, "menos novecentos e noventa e nove mil milhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); +namespace Humanizer.Tests.Localisation.pt; - [Theory] - [InlineData(1, "uma")] - [InlineData(2, "duas")] - [InlineData(3, "três")] - [InlineData(11, "onze")] - [InlineData(21, "vinte e uma")] - [InlineData(122, "cento e vinte e duas")] - [InlineData(232, "duzentas e trinta e duas")] - [InlineData(343, "trezentas e quarenta e três")] - [InlineData(3501, "três mil quinhentas e uma")] - [InlineData(100, "cem")] - [InlineData(1000, "mil")] - [InlineData(111, "cento e onze")] - [InlineData(1111, "mil cento e onze")] - [InlineData(111111, "cento e onze mil cento e onze")] - [InlineData(1111101, "um milhão cento e onze mil cento e uma")] - [InlineData(1111111, "um milhão cento e onze mil cento e onze")] - [InlineData(2111102, "dois milhões cento e onze mil cento e duas")] - [InlineData(3111101, "três milhões cento e onze mil cento e uma")] - [InlineData(1101111101, "mil milhões cento e um milhões cento e onze mil cento e uma")] - [InlineData(2101111101, "dois mil milhões cento e um milhões cento e onze mil cento e uma")] - [InlineData(1234, "mil duzentas e trinta e quatro")] - [InlineData(8100, "oito mil e cem")] - [InlineData(12345, "doze mil trezentas e quarenta e cinco")] - public void ToFeminineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); +[UseCulture("pt")] +public class NumberToWordsTests +{ + [Theory] + [InlineData(1, "um")] + [InlineData(2, "dois")] + [InlineData(3, "três")] + [InlineData(4, "quatro")] + [InlineData(5, "cinco")] + [InlineData(6, "seis")] + [InlineData(7, "sete")] + [InlineData(8, "oito")] + [InlineData(9, "nove")] + [InlineData(10, "dez")] + [InlineData(11, "onze")] + [InlineData(12, "doze")] + [InlineData(13, "treze")] + [InlineData(14, "quatorze")] + [InlineData(15, "quinze")] + [InlineData(16, "dezesseis")] + [InlineData(17, "dezessete")] + [InlineData(18, "dezoito")] + [InlineData(19, "dezenove")] + [InlineData(20, "vinte")] + [InlineData(30, "trinta")] + [InlineData(40, "quarenta")] + [InlineData(50, "cinquenta")] + [InlineData(51, "cinquenta e um")] + [InlineData(60, "sessenta")] + [InlineData(66, "sessenta e seis")] + [InlineData(70, "setenta")] + [InlineData(80, "oitenta")] + [InlineData(90, "noventa")] + [InlineData(100, "cem")] + [InlineData(200, "duzentos")] + [InlineData(300, "trezentos")] + [InlineData(400, "quatrocentos")] + [InlineData(500, "quinhentos")] + [InlineData(600, "seiscentos")] + [InlineData(700, "setecentos")] + [InlineData(800, "oitocentos")] + [InlineData(900, "novecentos")] + [InlineData(1000, "mil")] + [InlineData(2000, "dois mil")] + [InlineData(3000, "três mil")] + [InlineData(4000, "quatro mil")] + [InlineData(5000, "cinco mil")] + [InlineData(6000, "seis mil")] + [InlineData(7000, "sete mil")] + [InlineData(8000, "oito mil")] + [InlineData(9000, "nove mil")] + [InlineData(10000, "dez mil")] + [InlineData(100000, "cem mil")] + [InlineData(1000000, "um milhão")] + [InlineData(1000000000, "mil milhões")] + [InlineData(37, "trinta e sete")] + [InlineData(637, "seiscentos e trinta e sete")] + [InlineData(1637, "mil seiscentos e trinta e sete")] + [InlineData(61637, "sessenta e um mil seiscentos e trinta e sete")] + [InlineData(961637, "novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(5961637, "cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(25961637, "vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(425961637, "quatrocentos e vinte e cinco milhões novecentos e sessenta e um mil seiscentos e trinta e sete")] + [InlineData(10000000, "dez milhões")] + [InlineData(100000000, "cem milhões")] + [InlineData(1101111101, "mil milhões cento e um milhões cento e onze mil cento e um")] + [InlineData(111, "cento e onze")] + [InlineData(1111, "mil cento e onze")] + [InlineData(1111101, "um milhão cento e onze mil cento e um")] + [InlineData(111111, "cento e onze mil cento e onze")] + [InlineData(1111111, "um milhão cento e onze mil cento e onze")] + [InlineData(11111111, "onze milhões cento e onze mil cento e onze")] + [InlineData(111111111, "cento e onze milhões cento e onze mil cento e onze")] + [InlineData(1111111111, "mil milhões cento e onze milhões cento e onze mil cento e onze")] + [InlineData(122, "cento e vinte e dois")] + [InlineData(123, "cento e vinte e três")] + [InlineData(1234, "mil duzentos e trinta e quatro")] + [InlineData(12345, "doze mil trezentos e quarenta e cinco")] + [InlineData(123456, "cento e vinte e três mil quatrocentos e cinquenta e seis")] + [InlineData(1234567, "um milhão duzentos e trinta e quatro mil quinhentos e sessenta e sete")] + [InlineData(12345678, "doze milhões trezentos e quarenta e cinco mil seiscentos e setenta e oito")] + [InlineData(123456789, "cento e vinte e três milhões quatrocentos e cinquenta e seis mil setecentos e oitenta e nove")] + [InlineData(1234567890, "mil milhões duzentos e trinta e quatro milhões quinhentos e sessenta e sete mil oitocentos e noventa")] + [InlineData(1999, "mil novecentos e noventa e nove")] + [InlineData(2000000, "dois milhões")] + [InlineData(2000000000, "dois mil milhões")] + [InlineData(2001000000, "dois mil milhões um milhão")] + [InlineData(2014, "dois mil e quatorze")] + [InlineData(2048, "dois mil e quarenta e oito")] + [InlineData(21, "vinte e um")] + [InlineData(211, "duzentos e onze")] + [InlineData(2111101, "dois milhões cento e onze mil cento e um")] + [InlineData(221, "duzentos e vinte e um")] + [InlineData(3501, "três mil quinhentos e um")] + [InlineData(8100, "oito mil e cem")] + [InlineData(999999999999, "novecentos e noventa e nove mil milhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] + [InlineData(-999999999999, "menos novecentos e noventa e nove mil milhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primeiro")] - [InlineData(2, "segundo")] - [InlineData(3, "terceiro")] - [InlineData(4, "quarto")] - [InlineData(5, "quinto")] - [InlineData(6, "sexto")] - [InlineData(7, "sétimo")] - [InlineData(8, "oitavo")] - [InlineData(9, "nono")] - [InlineData(10, "décimo")] - [InlineData(11, "décimo primeiro")] - [InlineData(12, "décimo segundo")] - [InlineData(13, "décimo terceiro")] - [InlineData(14, "décimo quarto")] - [InlineData(15, "décimo quinto")] - [InlineData(16, "décimo sexto")] - [InlineData(17, "décimo sétimo")] - [InlineData(18, "décimo oitavo")] - [InlineData(19, "décimo nono")] - [InlineData(20, "vigésimo")] - [InlineData(21, "vigésimo primeiro")] - [InlineData(22, "vigésimo segundo")] - [InlineData(30, "trigésimo")] - [InlineData(40, "quadragésimo")] - [InlineData(50, "quinquagésimo")] - [InlineData(60, "sexagésimo")] - [InlineData(70, "septuagésimo")] - [InlineData(80, "octogésimo")] - [InlineData(90, "nonagésimo")] - [InlineData(95, "nonagésimo quinto")] - [InlineData(96, "nonagésimo sexto")] - [InlineData(100, "centésimo")] - [InlineData(120, "centésimo vigésimo")] - [InlineData(121, "centésimo vigésimo primeiro")] - [InlineData(200, "ducentésimo")] - [InlineData(300, "trecentésimo")] - [InlineData(400, "quadringentésimo")] - [InlineData(500, "quingentésimo")] - [InlineData(600, "sexcentésimo")] - [InlineData(700, "septingentésimo")] - [InlineData(800, "octingentésimo")] - [InlineData(900, "noningentésimo")] - [InlineData(1000, "milésimo")] - [InlineData(1001, "milésimo primeiro")] - [InlineData(1021, "milésimo vigésimo primeiro")] - [InlineData(2021, "segundo milésimo vigésimo primeiro")] - [InlineData(10000, "décimo milésimo")] - [InlineData(10121, "décimo milésimo centésimo vigésimo primeiro")] - [InlineData(100000, "centésimo milésimo")] - [InlineData(1000000, "milionésimo")] - [InlineData(1000000000, "milésimo milionésimo")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(1, "uma")] + [InlineData(2, "duas")] + [InlineData(3, "três")] + [InlineData(11, "onze")] + [InlineData(21, "vinte e uma")] + [InlineData(122, "cento e vinte e duas")] + [InlineData(232, "duzentas e trinta e duas")] + [InlineData(343, "trezentas e quarenta e três")] + [InlineData(3501, "três mil quinhentas e uma")] + [InlineData(100, "cem")] + [InlineData(1000, "mil")] + [InlineData(111, "cento e onze")] + [InlineData(1111, "mil cento e onze")] + [InlineData(111111, "cento e onze mil cento e onze")] + [InlineData(1111101, "um milhão cento e onze mil cento e uma")] + [InlineData(1111111, "um milhão cento e onze mil cento e onze")] + [InlineData(2111102, "dois milhões cento e onze mil cento e duas")] + [InlineData(3111101, "três milhões cento e onze mil cento e uma")] + [InlineData(1101111101, "mil milhões cento e um milhões cento e onze mil cento e uma")] + [InlineData(2101111101, "dois mil milhões cento e um milhões cento e onze mil cento e uma")] + [InlineData(1234, "mil duzentas e trinta e quatro")] + [InlineData(8100, "oito mil e cem")] + [InlineData(12345, "doze mil trezentas e quarenta e cinco")] + public void ToFeminineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primeira")] - [InlineData(2, "segunda")] - [InlineData(3, "terceira")] - [InlineData(4, "quarta")] - [InlineData(5, "quinta")] - [InlineData(6, "sexta")] - [InlineData(7, "sétima")] - [InlineData(8, "oitava")] - [InlineData(9, "nona")] - [InlineData(10, "décima")] - [InlineData(11, "décima primeira")] - [InlineData(12, "décima segunda")] - [InlineData(13, "décima terceira")] - [InlineData(14, "décima quarta")] - [InlineData(15, "décima quinta")] - [InlineData(16, "décima sexta")] - [InlineData(17, "décima sétima")] - [InlineData(18, "décima oitava")] - [InlineData(19, "décima nona")] - [InlineData(20, "vigésima")] - [InlineData(21, "vigésima primeira")] - [InlineData(22, "vigésima segunda")] - [InlineData(30, "trigésima")] - [InlineData(40, "quadragésima")] - [InlineData(50, "quinquagésima")] - [InlineData(60, "sexagésima")] - [InlineData(70, "septuagésima")] - [InlineData(80, "octogésima")] - [InlineData(90, "nonagésima")] - [InlineData(95, "nonagésima quinta")] - [InlineData(96, "nonagésima sexta")] - [InlineData(100, "centésima")] - [InlineData(120, "centésima vigésima")] - [InlineData(121, "centésima vigésima primeira")] - [InlineData(200, "ducentésima")] - [InlineData(300, "trecentésima")] - [InlineData(400, "quadringentésima")] - [InlineData(500, "quingentésima")] - [InlineData(600, "sexcentésima")] - [InlineData(700, "septingentésima")] - [InlineData(800, "octingentésima")] - [InlineData(900, "noningentésima")] - [InlineData(1000, "milésima")] - [InlineData(1001, "milésima primeira")] - [InlineData(1021, "milésima vigésima primeira")] - [InlineData(2021, "segunda milésima vigésima primeira")] - [InlineData(10000, "décima milésima")] - [InlineData(10121, "décima milésima centésima vigésima primeira")] - [InlineData(100000, "centésima milésima")] - [InlineData(1000000, "milionésima")] - [InlineData(1000000000, "milésima milionésima")] - public void ToFeminineOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primeiro")] + [InlineData(2, "segundo")] + [InlineData(3, "terceiro")] + [InlineData(4, "quarto")] + [InlineData(5, "quinto")] + [InlineData(6, "sexto")] + [InlineData(7, "sétimo")] + [InlineData(8, "oitavo")] + [InlineData(9, "nono")] + [InlineData(10, "décimo")] + [InlineData(11, "décimo primeiro")] + [InlineData(12, "décimo segundo")] + [InlineData(13, "décimo terceiro")] + [InlineData(14, "décimo quarto")] + [InlineData(15, "décimo quinto")] + [InlineData(16, "décimo sexto")] + [InlineData(17, "décimo sétimo")] + [InlineData(18, "décimo oitavo")] + [InlineData(19, "décimo nono")] + [InlineData(20, "vigésimo")] + [InlineData(21, "vigésimo primeiro")] + [InlineData(22, "vigésimo segundo")] + [InlineData(30, "trigésimo")] + [InlineData(40, "quadragésimo")] + [InlineData(50, "quinquagésimo")] + [InlineData(60, "sexagésimo")] + [InlineData(70, "septuagésimo")] + [InlineData(80, "octogésimo")] + [InlineData(90, "nonagésimo")] + [InlineData(95, "nonagésimo quinto")] + [InlineData(96, "nonagésimo sexto")] + [InlineData(100, "centésimo")] + [InlineData(120, "centésimo vigésimo")] + [InlineData(121, "centésimo vigésimo primeiro")] + [InlineData(200, "ducentésimo")] + [InlineData(300, "trecentésimo")] + [InlineData(400, "quadringentésimo")] + [InlineData(500, "quingentésimo")] + [InlineData(600, "sexcentésimo")] + [InlineData(700, "septingentésimo")] + [InlineData(800, "octingentésimo")] + [InlineData(900, "noningentésimo")] + [InlineData(1000, "milésimo")] + [InlineData(1001, "milésimo primeiro")] + [InlineData(1021, "milésimo vigésimo primeiro")] + [InlineData(2021, "segundo milésimo vigésimo primeiro")] + [InlineData(10000, "décimo milésimo")] + [InlineData(10121, "décimo milésimo centésimo vigésimo primeiro")] + [InlineData(100000, "centésimo milésimo")] + [InlineData(1000000, "milionésimo")] + [InlineData(1000000000, "milésimo milionésimo")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primeira")] + [InlineData(2, "segunda")] + [InlineData(3, "terceira")] + [InlineData(4, "quarta")] + [InlineData(5, "quinta")] + [InlineData(6, "sexta")] + [InlineData(7, "sétima")] + [InlineData(8, "oitava")] + [InlineData(9, "nona")] + [InlineData(10, "décima")] + [InlineData(11, "décima primeira")] + [InlineData(12, "décima segunda")] + [InlineData(13, "décima terceira")] + [InlineData(14, "décima quarta")] + [InlineData(15, "décima quinta")] + [InlineData(16, "décima sexta")] + [InlineData(17, "décima sétima")] + [InlineData(18, "décima oitava")] + [InlineData(19, "décima nona")] + [InlineData(20, "vigésima")] + [InlineData(21, "vigésima primeira")] + [InlineData(22, "vigésima segunda")] + [InlineData(30, "trigésima")] + [InlineData(40, "quadragésima")] + [InlineData(50, "quinquagésima")] + [InlineData(60, "sexagésima")] + [InlineData(70, "septuagésima")] + [InlineData(80, "octogésima")] + [InlineData(90, "nonagésima")] + [InlineData(95, "nonagésima quinta")] + [InlineData(96, "nonagésima sexta")] + [InlineData(100, "centésima")] + [InlineData(120, "centésima vigésima")] + [InlineData(121, "centésima vigésima primeira")] + [InlineData(200, "ducentésima")] + [InlineData(300, "trecentésima")] + [InlineData(400, "quadringentésima")] + [InlineData(500, "quingentésima")] + [InlineData(600, "sexcentésima")] + [InlineData(700, "septingentésima")] + [InlineData(800, "octingentésima")] + [InlineData(900, "noningentésima")] + [InlineData(1000, "milésima")] + [InlineData(1001, "milésima primeira")] + [InlineData(1021, "milésima vigésima primeira")] + [InlineData(2021, "segunda milésima vigésima primeira")] + [InlineData(10000, "décima milésima")] + [InlineData(10121, "décima milésima centésima vigésima primeira")] + [InlineData(100000, "centésima milésima")] + [InlineData(1000000, "milionésima")] + [InlineData(1000000000, "milésima milionésima")] + public void ToFeminineOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/pt/OrdinalizeTests.cs index 82fdd7f48..c99713c49 100644 --- a/src/Humanizer.Tests/Localisation/pt/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pt/OrdinalizeTests.cs @@ -1,76 +1,75 @@ -namespace Humanizer.Tests.Localisation.pt +namespace Humanizer.Tests.Localisation.pt; + +[UseCulture("pt")] +public class OrdinalizeTests { - [UseCulture("pt")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0")] - [InlineData("1", "1º")] - [InlineData("2", "2º")] - [InlineData("3", "3º")] - [InlineData("4", "4º")] - [InlineData("5", "5º")] - [InlineData("6", "6º")] - [InlineData("23", "23º")] - [InlineData("100", "100º")] - [InlineData("101", "101º")] - [InlineData("102", "102º")] - [InlineData("103", "103º")] - [InlineData("1001", "1001º")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1º")] + [InlineData("2", "2º")] + [InlineData("3", "3º")] + [InlineData("4", "4º")] + [InlineData("5", "5º")] + [InlineData("6", "6º")] + [InlineData("23", "23º")] + [InlineData("100", "100º")] + [InlineData("101", "101º")] + [InlineData("102", "102º")] + [InlineData("103", "103º")] + [InlineData("1001", "1001º")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0")] - [InlineData("1", "1ª")] - [InlineData("2", "2ª")] - [InlineData("3", "3ª")] - [InlineData("4", "4ª")] - [InlineData("5", "5ª")] - [InlineData("6", "6ª")] - [InlineData("23", "23ª")] - [InlineData("100", "100ª")] - [InlineData("101", "101ª")] - [InlineData("102", "102ª")] - [InlineData("103", "103ª")] - [InlineData("1001", "1001ª")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0")] + [InlineData("1", "1ª")] + [InlineData("2", "2ª")] + [InlineData("3", "3ª")] + [InlineData("4", "4ª")] + [InlineData("5", "5ª")] + [InlineData("6", "6ª")] + [InlineData("23", "23ª")] + [InlineData("100", "100ª")] + [InlineData("101", "101ª")] + [InlineData("102", "102ª")] + [InlineData("103", "103ª")] + [InlineData("1001", "1001ª")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "1º")] - [InlineData(2, "2º")] - [InlineData(3, "3º")] - [InlineData(4, "4º")] - [InlineData(5, "5º")] - [InlineData(6, "6º")] - [InlineData(10, "10º")] - [InlineData(23, "23º")] - [InlineData(100, "100º")] - [InlineData(101, "101º")] - [InlineData(102, "102º")] - [InlineData(103, "103º")] - [InlineData(1001, "1001º")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1º")] + [InlineData(2, "2º")] + [InlineData(3, "3º")] + [InlineData(4, "4º")] + [InlineData(5, "5º")] + [InlineData(6, "6º")] + [InlineData(10, "10º")] + [InlineData(23, "23º")] + [InlineData(100, "100º")] + [InlineData(101, "101º")] + [InlineData(102, "102º")] + [InlineData(103, "103º")] + [InlineData(1001, "1001º")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData(0, "0")] - [InlineData(1, "1ª")] - [InlineData(2, "2ª")] - [InlineData(3, "3ª")] - [InlineData(4, "4ª")] - [InlineData(5, "5ª")] - [InlineData(6, "6ª")] - [InlineData(10, "10ª")] - [InlineData(23, "23ª")] - [InlineData(100, "100ª")] - [InlineData(101, "101ª")] - [InlineData(102, "102ª")] - [InlineData(103, "103ª")] - [InlineData(1001, "1001ª")] - public void OrdinalizeNumberFeminine(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - } -} + [Theory] + [InlineData(0, "0")] + [InlineData(1, "1ª")] + [InlineData(2, "2ª")] + [InlineData(3, "3ª")] + [InlineData(4, "4ª")] + [InlineData(5, "5ª")] + [InlineData(6, "6ª")] + [InlineData(10, "10ª")] + [InlineData(23, "23ª")] + [InlineData(100, "100ª")] + [InlineData(101, "101ª")] + [InlineData(102, "102ª")] + [InlineData(103, "103ª")] + [InlineData(1001, "1001ª")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/pt/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/pt/TimeSpanHumanizeTests.cs index 4c6f98e41..d844351d4 100644 --- a/src/Humanizer.Tests/Localisation/pt/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/pt/TimeSpanHumanizeTests.cs @@ -1,85 +1,84 @@ -namespace Humanizer.Tests.Localisation.pt +namespace Humanizer.Tests.Localisation.pt; + +[UseCulture("pt")] +public class TimeSpanHumanizeTests { - [UseCulture("pt")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 ano")] - [InlineData(731, "2 anos")] - [InlineData(1096, "3 anos")] - [InlineData(4018, "11 anos")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mês")] - [InlineData(61, "2 meses")] - [InlineData(92, "3 meses")] - [InlineData(335, "11 meses")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Fact] - public void TwoWeeks() => - Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); - - [Fact] - public void OneWeek() => - Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); - - [Fact] - public void SixDays() => - Assert.Equal("6 dias", TimeSpan.FromDays(6).Humanize()); - - [Fact] - public void TwoDays() => - Assert.Equal("2 dias", TimeSpan.FromDays(2).Humanize()); - - [Fact] - public void OneDay() => - Assert.Equal("1 dia", TimeSpan.FromDays(1).Humanize()); - - [Fact] - public void TwoHours() => - Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); - - [Fact] - public void OneHour() => - Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); - - [Fact] - public void TwoMinutes() => - Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); - - [Fact] - public void OneMinute() => - Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); - - [Fact] - public void TwoSeconds() => - Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); - - [Fact] - public void OneSecond() => - Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); - - [Fact] - public void TwoMilliseconds() => - Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); - - [Fact] - public void OneMillisecond() => - Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); - - [Fact] - public void NoTime() => - Assert.Equal("0 milisegundos", TimeSpan.Zero.Humanize()); - - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("sem horário", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 ano")] + [InlineData(731, "2 anos")] + [InlineData(1096, "3 anos")] + [InlineData(4018, "11 anos")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mês")] + [InlineData(61, "2 meses")] + [InlineData(92, "3 meses")] + [InlineData(335, "11 meses")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Fact] + public void TwoWeeks() => + Assert.Equal("2 semanas", TimeSpan.FromDays(14).Humanize()); + + [Fact] + public void OneWeek() => + Assert.Equal("1 semana", TimeSpan.FromDays(7).Humanize()); + + [Fact] + public void SixDays() => + Assert.Equal("6 dias", TimeSpan.FromDays(6).Humanize()); + + [Fact] + public void TwoDays() => + Assert.Equal("2 dias", TimeSpan.FromDays(2).Humanize()); + + [Fact] + public void OneDay() => + Assert.Equal("1 dia", TimeSpan.FromDays(1).Humanize()); + + [Fact] + public void TwoHours() => + Assert.Equal("2 horas", TimeSpan.FromHours(2).Humanize()); + + [Fact] + public void OneHour() => + Assert.Equal("1 hora", TimeSpan.FromHours(1).Humanize()); + + [Fact] + public void TwoMinutes() => + Assert.Equal("2 minutos", TimeSpan.FromMinutes(2).Humanize()); + + [Fact] + public void OneMinute() => + Assert.Equal("1 minuto", TimeSpan.FromMinutes(1).Humanize()); + + [Fact] + public void TwoSeconds() => + Assert.Equal("2 segundos", TimeSpan.FromSeconds(2).Humanize()); + + [Fact] + public void OneSecond() => + Assert.Equal("1 segundo", TimeSpan.FromSeconds(1).Humanize()); + + [Fact] + public void TwoMilliseconds() => + Assert.Equal("2 milisegundos", TimeSpan.FromMilliseconds(2).Humanize()); + + [Fact] + public void OneMillisecond() => + Assert.Equal("1 milisegundo", TimeSpan.FromMilliseconds(1).Humanize()); + + [Fact] + public void NoTime() => + Assert.Equal("0 milisegundos", TimeSpan.Zero.Humanize()); + + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("sem horário", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ro-Ro/CollectionFormatterTests.cs b/src/Humanizer.Tests/Localisation/ro-Ro/CollectionFormatterTests.cs index ba6e9c8a1..8e8aff920 100644 --- a/src/Humanizer.Tests/Localisation/ro-Ro/CollectionFormatterTests.cs +++ b/src/Humanizer.Tests/Localisation/ro-Ro/CollectionFormatterTests.cs @@ -1,30 +1,29 @@ -namespace Humanizer.Tests.Localisation.roRO +namespace Humanizer.Tests.Localisation.roRO; + +[UseCulture("ro-RO")] +public class CollectionFormatterTests { - [UseCulture("ro-RO")] - public class CollectionFormatterTests + [Fact] + public void OneItem() { - [Fact] - public void OneItem() - { var collection = new List(new[] { 1 }); var humanized = "1"; Assert.Equal(humanized, collection.Humanize()); } - [Fact] - public void TwoItems() - { + [Fact] + public void TwoItems() + { var collection = new List(new[] { 1, 2 }); var humanized = "1 și 2"; Assert.Equal(humanized, collection.Humanize()); } - [Fact] - public void MoreThanTwoItems() - { + [Fact] + public void MoreThanTwoItems() + { var collection = new List(new[] { 1, 2, 3 }); var humanized = "1, 2 și 3"; Assert.Equal(humanized, collection.Humanize()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs index 6255ac328..b5cc7f4d9 100644 --- a/src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs @@ -1,78 +1,77 @@ -namespace Humanizer.Tests.Localisation.roRO +namespace Humanizer.Tests.Localisation.roRO; + +/// +/// Test that for values bigger than 19 "de" is added between the numeral +/// and the time unit: http://ebooks.unibuc.ro/filologie/NForascu-DGLR/numerale.htm. +/// There is no test for months since there are only 12 of them in a year. +/// +[UseCulture("ro-RO")] +public class DateHumanizeTests { - /// - /// Test that for values bigger than 19 "de" is added between the numeral - /// and the time unit: http://ebooks.unibuc.ro/filologie/NForascu-DGLR/numerale.htm. - /// There is no test for months since there are only 12 of them in a year. - /// - [UseCulture("ro-RO")] - public class DateHumanizeTests - { - [Theory] - [InlineData(3, "acum 3 ore")] - [InlineData(20, "acum 20 de ore")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(3, "acum 3 ore")] + [InlineData(20, "acum 20 de ore")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(19, "acum 19 minute")] - [InlineData(60, "acum o oră")] - [InlineData(44, "acum 44 de minute")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(19, "acum 19 minute")] + [InlineData(60, "acum o oră")] + [InlineData(44, "acum 44 de minute")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "acum 2 secunde")] - [InlineData(59, "acum 59 de secunde")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(2, "acum 2 secunde")] + [InlineData(59, "acum 59 de secunde")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(10, "acum 10 zile")] - [InlineData(23, "acum 23 de zile")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(10, "acum 10 zile")] + [InlineData(23, "acum 23 de zile")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(119, "acum 119 ani")] - [InlineData(100, "acum 100 de ani")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(119, "acum 119 ani")] + [InlineData(100, "acum 100 de ani")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "acum")] - [InlineData(22, "acum")] - public void MillisecondsAgo(int milliseconds, string expected) => - DateHumanize.Verify(expected, milliseconds, TimeUnit.Millisecond, Tense.Past); + [Theory] + [InlineData(1, "acum")] + [InlineData(22, "acum")] + public void MillisecondsAgo(int milliseconds, string expected) => + DateHumanize.Verify(expected, milliseconds, TimeUnit.Millisecond, Tense.Past); - [Theory] - [InlineData(19, "peste 19 secunde")] - [InlineData(21, "peste 21 de secunde")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(19, "peste 19 secunde")] + [InlineData(21, "peste 21 de secunde")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(19, "peste 19 minute")] - [InlineData(22, "peste 22 de minute")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(19, "peste 19 minute")] + [InlineData(22, "peste 22 de minute")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(3, "peste 3 ore")] - [InlineData(23, "peste 23 de ore")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(3, "peste 3 ore")] + [InlineData(23, "peste 23 de ore")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(5, "peste 5 zile")] - [InlineData(23, "peste 23 de zile")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(5, "peste 5 zile")] + [InlineData(23, "peste 23 de zile")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(5, "peste 5 ani")] - [InlineData(21, "peste 21 de ani")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(5, "peste 5 ani")] + [InlineData(21, "peste 21 de ani")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ro-Ro/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ro-Ro/NumberToWordsTests.cs index 5418af4ac..8a6221768 100644 --- a/src/Humanizer.Tests/Localisation/ro-Ro/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ro-Ro/NumberToWordsTests.cs @@ -1,359 +1,358 @@ -namespace Humanizer.Tests.Localisation.roRO +namespace Humanizer.Tests.Localisation.roRO; + +[UseCulture("ro-RO")] +public class NumberToWordsTests { - [UseCulture("ro-RO")] - public class NumberToWordsTests - { - [Theory] - [InlineData(-1, "minus unu")] - [InlineData(0, "zero")] - [InlineData(1, "unu")] - [InlineData(2, "doi")] - [InlineData(3, "trei")] - [InlineData(4, "patru")] - [InlineData(5, "cinci")] - [InlineData(6, "șase")] - [InlineData(7, "șapte")] - [InlineData(8, "opt")] - [InlineData(9, "nouă")] - [InlineData(10, "zece")] - [InlineData(11, "unsprezece")] - [InlineData(12, "doisprezece")] - [InlineData(13, "treisprezece")] - [InlineData(14, "paisprezece")] - [InlineData(15, "cincisprezece")] - [InlineData(16, "șaisprezece")] - [InlineData(17, "șaptesprezece")] - [InlineData(18, "optsprezece")] - [InlineData(19, "nouăsprezece")] - [InlineData(20, "douăzeci")] - [InlineData(21, "douăzeci și unu")] - [InlineData(22, "douăzeci și doi")] - [InlineData(30, "treizeci")] - [InlineData(40, "patruzeci")] - [InlineData(50, "cincizeci")] - [InlineData(60, "șaizeci")] - [InlineData(70, "șaptezeci")] - [InlineData(80, "optzeci")] - [InlineData(90, "nouăzeci")] - [InlineData(100, "o sută")] - [InlineData(101, "o sută unu")] - [InlineData(102, "o sută doi")] - [InlineData(111, "o sută unsprezece")] - [InlineData(120, "o sută douăzeci")] - [InlineData(121, "o sută douăzeci și unu")] - [InlineData(122, "o sută douăzeci și doi")] - [InlineData(200, "două sute")] - [InlineData(1000, "o mie")] - [InlineData(1001, "o mie unu")] - [InlineData(1002, "o mie doi")] - [InlineData(1100, "o mie o sută")] - [InlineData(1200, "o mie două sute")] - [InlineData(2000, "două mii")] - [InlineData(10000, "zece mii")] - [InlineData(12000, "douăsprezece mii")] - [InlineData(20000, "douăzeci de mii")] - [InlineData(21000, "douăzeci și una de mii")] - [InlineData(22371, "douăzeci și două de mii trei sute șaptezeci și unu")] - [InlineData(100000, "o sută de mii")] - [InlineData(1000000, "un milion")] - [InlineData(2000000, "două milioane")] - [InlineData(1000000000, "un miliard")] - [InlineData(2000000000, "două miliarde")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(-1, "minus unu")] + [InlineData(0, "zero")] + [InlineData(1, "unu")] + [InlineData(2, "doi")] + [InlineData(3, "trei")] + [InlineData(4, "patru")] + [InlineData(5, "cinci")] + [InlineData(6, "șase")] + [InlineData(7, "șapte")] + [InlineData(8, "opt")] + [InlineData(9, "nouă")] + [InlineData(10, "zece")] + [InlineData(11, "unsprezece")] + [InlineData(12, "doisprezece")] + [InlineData(13, "treisprezece")] + [InlineData(14, "paisprezece")] + [InlineData(15, "cincisprezece")] + [InlineData(16, "șaisprezece")] + [InlineData(17, "șaptesprezece")] + [InlineData(18, "optsprezece")] + [InlineData(19, "nouăsprezece")] + [InlineData(20, "douăzeci")] + [InlineData(21, "douăzeci și unu")] + [InlineData(22, "douăzeci și doi")] + [InlineData(30, "treizeci")] + [InlineData(40, "patruzeci")] + [InlineData(50, "cincizeci")] + [InlineData(60, "șaizeci")] + [InlineData(70, "șaptezeci")] + [InlineData(80, "optzeci")] + [InlineData(90, "nouăzeci")] + [InlineData(100, "o sută")] + [InlineData(101, "o sută unu")] + [InlineData(102, "o sută doi")] + [InlineData(111, "o sută unsprezece")] + [InlineData(120, "o sută douăzeci")] + [InlineData(121, "o sută douăzeci și unu")] + [InlineData(122, "o sută douăzeci și doi")] + [InlineData(200, "două sute")] + [InlineData(1000, "o mie")] + [InlineData(1001, "o mie unu")] + [InlineData(1002, "o mie doi")] + [InlineData(1100, "o mie o sută")] + [InlineData(1200, "o mie două sute")] + [InlineData(2000, "două mii")] + [InlineData(10000, "zece mii")] + [InlineData(12000, "douăsprezece mii")] + [InlineData(20000, "douăzeci de mii")] + [InlineData(21000, "douăzeci și una de mii")] + [InlineData(22371, "douăzeci și două de mii trei sute șaptezeci și unu")] + [InlineData(100000, "o sută de mii")] + [InlineData(1000000, "un milion")] + [InlineData(2000000, "două milioane")] + [InlineData(1000000000, "un miliard")] + [InlineData(2000000000, "două miliarde")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(-1, "minus unu")] - [InlineData(0, "zero")] - [InlineData(1, "unu")] - [InlineData(2, "doi")] - [InlineData(3, "trei")] - [InlineData(4, "patru")] - [InlineData(5, "cinci")] - [InlineData(6, "șase")] - [InlineData(7, "șapte")] - [InlineData(8, "opt")] - [InlineData(9, "nouă")] - [InlineData(10, "zece")] - [InlineData(11, "unsprezece")] - [InlineData(12, "doisprezece")] - [InlineData(13, "treisprezece")] - [InlineData(14, "paisprezece")] - [InlineData(15, "cincisprezece")] - [InlineData(16, "șaisprezece")] - [InlineData(17, "șaptesprezece")] - [InlineData(18, "optsprezece")] - [InlineData(19, "nouăsprezece")] - [InlineData(20, "douăzeci")] - [InlineData(21, "douăzeci și unu")] - [InlineData(22, "douăzeci și doi")] - [InlineData(30, "treizeci")] - [InlineData(40, "patruzeci")] - [InlineData(50, "cincizeci")] - [InlineData(60, "șaizeci")] - [InlineData(70, "șaptezeci")] - [InlineData(80, "optzeci")] - [InlineData(90, "nouăzeci")] - [InlineData(100, "o sută")] - [InlineData(101, "o sută unu")] - [InlineData(102, "o sută doi")] - [InlineData(111, "o sută unsprezece")] - [InlineData(120, "o sută douăzeci")] - [InlineData(121, "o sută douăzeci și unu")] - [InlineData(122, "o sută douăzeci și doi")] - [InlineData(200, "două sute")] - [InlineData(1000, "o mie")] - [InlineData(1001, "o mie unu")] - [InlineData(1002, "o mie doi")] - [InlineData(1100, "o mie o sută")] - [InlineData(1200, "o mie două sute")] - [InlineData(2000, "două mii")] - [InlineData(10000, "zece mii")] - [InlineData(12000, "douăsprezece mii")] - [InlineData(20000, "douăzeci de mii")] - [InlineData(21000, "douăzeci și una de mii")] - [InlineData(22371, "douăzeci și două de mii trei sute șaptezeci și unu")] - [InlineData(100000, "o sută de mii")] - [InlineData(1000000, "un milion")] - [InlineData(2000000, "două milioane")] - [InlineData(1000000000, "un miliard")] - [InlineData(2000000000, "două miliarde")] - public void ToMasculineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(-1, "minus unu")] + [InlineData(0, "zero")] + [InlineData(1, "unu")] + [InlineData(2, "doi")] + [InlineData(3, "trei")] + [InlineData(4, "patru")] + [InlineData(5, "cinci")] + [InlineData(6, "șase")] + [InlineData(7, "șapte")] + [InlineData(8, "opt")] + [InlineData(9, "nouă")] + [InlineData(10, "zece")] + [InlineData(11, "unsprezece")] + [InlineData(12, "doisprezece")] + [InlineData(13, "treisprezece")] + [InlineData(14, "paisprezece")] + [InlineData(15, "cincisprezece")] + [InlineData(16, "șaisprezece")] + [InlineData(17, "șaptesprezece")] + [InlineData(18, "optsprezece")] + [InlineData(19, "nouăsprezece")] + [InlineData(20, "douăzeci")] + [InlineData(21, "douăzeci și unu")] + [InlineData(22, "douăzeci și doi")] + [InlineData(30, "treizeci")] + [InlineData(40, "patruzeci")] + [InlineData(50, "cincizeci")] + [InlineData(60, "șaizeci")] + [InlineData(70, "șaptezeci")] + [InlineData(80, "optzeci")] + [InlineData(90, "nouăzeci")] + [InlineData(100, "o sută")] + [InlineData(101, "o sută unu")] + [InlineData(102, "o sută doi")] + [InlineData(111, "o sută unsprezece")] + [InlineData(120, "o sută douăzeci")] + [InlineData(121, "o sută douăzeci și unu")] + [InlineData(122, "o sută douăzeci și doi")] + [InlineData(200, "două sute")] + [InlineData(1000, "o mie")] + [InlineData(1001, "o mie unu")] + [InlineData(1002, "o mie doi")] + [InlineData(1100, "o mie o sută")] + [InlineData(1200, "o mie două sute")] + [InlineData(2000, "două mii")] + [InlineData(10000, "zece mii")] + [InlineData(12000, "douăsprezece mii")] + [InlineData(20000, "douăzeci de mii")] + [InlineData(21000, "douăzeci și una de mii")] + [InlineData(22371, "douăzeci și două de mii trei sute șaptezeci și unu")] + [InlineData(100000, "o sută de mii")] + [InlineData(1000000, "un milion")] + [InlineData(2000000, "două milioane")] + [InlineData(1000000000, "un miliard")] + [InlineData(2000000000, "două miliarde")] + public void ToMasculineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(-1, "minus una")] - [InlineData(0, "zero")] - [InlineData(1, "una")] - [InlineData(2, "două")] - [InlineData(3, "trei")] - [InlineData(4, "patru")] - [InlineData(5, "cinci")] - [InlineData(6, "șase")] - [InlineData(7, "șapte")] - [InlineData(8, "opt")] - [InlineData(9, "nouă")] - [InlineData(10, "zece")] - [InlineData(11, "unsprezece")] - [InlineData(12, "douăsprezece")] // DOOM 2 (dicționarul ortografic, ortoepic și morfologic al limbii române) - [InlineData(13, "treisprezece")] - [InlineData(14, "paisprezece")] - [InlineData(15, "cincisprezece")] - [InlineData(16, "șaisprezece")] - [InlineData(17, "șaptesprezece")] - [InlineData(18, "optsprezece")] - [InlineData(19, "nouăsprezece")] - [InlineData(20, "douăzeci")] - [InlineData(21, "douăzeci și una")] - [InlineData(22, "douăzeci și două")] - [InlineData(30, "treizeci")] - [InlineData(40, "patruzeci")] - [InlineData(50, "cincizeci")] - [InlineData(60, "șaizeci")] - [InlineData(70, "șaptezeci")] - [InlineData(80, "optzeci")] - [InlineData(90, "nouăzeci")] - [InlineData(100, "o sută")] - [InlineData(101, "o sută una")] - [InlineData(102, "o sută două")] - [InlineData(111, "o sută unsprezece")] - [InlineData(120, "o sută douăzeci")] - [InlineData(121, "o sută douăzeci și una")] - [InlineData(122, "o sută douăzeci și două")] - [InlineData(200, "două sute")] - [InlineData(1000, "o mie")] - [InlineData(1001, "o mie una")] - [InlineData(1002, "o mie două")] - [InlineData(1100, "o mie o sută")] - [InlineData(1200, "o mie două sute")] - [InlineData(2000, "două mii")] - [InlineData(10000, "zece mii")] - [InlineData(12000, "douăsprezece mii")] - [InlineData(20000, "douăzeci de mii")] - [InlineData(21000, "douăzeci și una de mii")] - [InlineData(22371, "douăzeci și două de mii trei sute șaptezeci și una")] - [InlineData(100000, "o sută de mii")] - [InlineData(1000000, "un milion")] - [InlineData(2000000, "două milioane")] - [InlineData(1000000000, "un miliard")] - [InlineData(2000000000, "două miliarde")] - public void ToFeminineWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(-1, "minus una")] + [InlineData(0, "zero")] + [InlineData(1, "una")] + [InlineData(2, "două")] + [InlineData(3, "trei")] + [InlineData(4, "patru")] + [InlineData(5, "cinci")] + [InlineData(6, "șase")] + [InlineData(7, "șapte")] + [InlineData(8, "opt")] + [InlineData(9, "nouă")] + [InlineData(10, "zece")] + [InlineData(11, "unsprezece")] + [InlineData(12, "douăsprezece")] // DOOM 2 (dicționarul ortografic, ortoepic și morfologic al limbii române) + [InlineData(13, "treisprezece")] + [InlineData(14, "paisprezece")] + [InlineData(15, "cincisprezece")] + [InlineData(16, "șaisprezece")] + [InlineData(17, "șaptesprezece")] + [InlineData(18, "optsprezece")] + [InlineData(19, "nouăsprezece")] + [InlineData(20, "douăzeci")] + [InlineData(21, "douăzeci și una")] + [InlineData(22, "douăzeci și două")] + [InlineData(30, "treizeci")] + [InlineData(40, "patruzeci")] + [InlineData(50, "cincizeci")] + [InlineData(60, "șaizeci")] + [InlineData(70, "șaptezeci")] + [InlineData(80, "optzeci")] + [InlineData(90, "nouăzeci")] + [InlineData(100, "o sută")] + [InlineData(101, "o sută una")] + [InlineData(102, "o sută două")] + [InlineData(111, "o sută unsprezece")] + [InlineData(120, "o sută douăzeci")] + [InlineData(121, "o sută douăzeci și una")] + [InlineData(122, "o sută douăzeci și două")] + [InlineData(200, "două sute")] + [InlineData(1000, "o mie")] + [InlineData(1001, "o mie una")] + [InlineData(1002, "o mie două")] + [InlineData(1100, "o mie o sută")] + [InlineData(1200, "o mie două sute")] + [InlineData(2000, "două mii")] + [InlineData(10000, "zece mii")] + [InlineData(12000, "douăsprezece mii")] + [InlineData(20000, "douăzeci de mii")] + [InlineData(21000, "douăzeci și una de mii")] + [InlineData(22371, "douăzeci și două de mii trei sute șaptezeci și una")] + [InlineData(100000, "o sută de mii")] + [InlineData(1000000, "un milion")] + [InlineData(2000000, "două milioane")] + [InlineData(1000000000, "un miliard")] + [InlineData(2000000000, "două miliarde")] + public void ToFeminineWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(-1, "minus unu")] - [InlineData(0, "zero")] - [InlineData(1, "unu")] - [InlineData(2, "două")] - [InlineData(3, "trei")] - [InlineData(4, "patru")] - [InlineData(5, "cinci")] - public void ToNeuterWords(int number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Neuter)); + [Theory] + [InlineData(-1, "minus unu")] + [InlineData(0, "zero")] + [InlineData(1, "unu")] + [InlineData(2, "două")] + [InlineData(3, "trei")] + [InlineData(4, "patru")] + [InlineData(5, "cinci")] + public void ToNeuterWords(int number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Neuter)); - // Test cases taken from Romanian Grammar, Mika Sarlin. + // Test cases taken from Romanian Grammar, Mika Sarlin. - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primul")] - [InlineData(2, "al doilea")] - [InlineData(3, "al treilea")] - [InlineData(4, "al patrulea")] - [InlineData(5, "al cincilea")] - [InlineData(6, "al șaselea")] - [InlineData(7, "al șaptelea")] - [InlineData(8, "al optulea")] - [InlineData(9, "al nouălea")] - [InlineData(10, "al zecelea")] - [InlineData(11, "al unsprezecelea")] - [InlineData(12, "al doisprezecelea")] - [InlineData(13, "al treisprezecelea")] - [InlineData(14, "al paisprezecelea")] - [InlineData(15, "al cincisprezecelea")] - [InlineData(16, "al șaisprezecelea")] - [InlineData(17, "al șaptesprezecelea")] - [InlineData(18, "al optsprezecelea")] - [InlineData(19, "al nouăsprezecelea")] - [InlineData(20, "al douăzecilea")] - [InlineData(21, "al douăzeci și unulea")] - [InlineData(22, "al douăzeci și doilea")] - [InlineData(30, "al treizecilea")] - [InlineData(40, "al patruzecilea")] - [InlineData(50, "al cincizecilea")] - [InlineData(60, "al șaizecilea")] - [InlineData(70, "al șaptezecilea")] - [InlineData(80, "al optzecilea")] - [InlineData(90, "al nouăzecilea")] - [InlineData(100, "al o sutălea")] - [InlineData(101, "al o sută unulea")] - [InlineData(102, "al o sută doilea")] - [InlineData(199, "al o sută nouăzeci și nouălea")] - [InlineData(200, "al două sutelea")] - [InlineData(300, "al trei sutelea")] - [InlineData(1000, "al o mielea")] - [InlineData(1001, "al o mie unulea")] - [InlineData(2000, "al două miilea")] - [InlineData(10000, "al zece miilea")] - [InlineData(20000, "al douăzeci miilea")] - [InlineData(50000, "al cincizeci miilea")] - [InlineData(1000000, "al un milionulea")] - [InlineData(2000000, "al două milioanelea")] - [InlineData(20000000, "al douăzeci milioanelea")] - [InlineData(1000000000, "al un miliardulea")] - [InlineData(2000000000, "al două miliardelea")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primul")] + [InlineData(2, "al doilea")] + [InlineData(3, "al treilea")] + [InlineData(4, "al patrulea")] + [InlineData(5, "al cincilea")] + [InlineData(6, "al șaselea")] + [InlineData(7, "al șaptelea")] + [InlineData(8, "al optulea")] + [InlineData(9, "al nouălea")] + [InlineData(10, "al zecelea")] + [InlineData(11, "al unsprezecelea")] + [InlineData(12, "al doisprezecelea")] + [InlineData(13, "al treisprezecelea")] + [InlineData(14, "al paisprezecelea")] + [InlineData(15, "al cincisprezecelea")] + [InlineData(16, "al șaisprezecelea")] + [InlineData(17, "al șaptesprezecelea")] + [InlineData(18, "al optsprezecelea")] + [InlineData(19, "al nouăsprezecelea")] + [InlineData(20, "al douăzecilea")] + [InlineData(21, "al douăzeci și unulea")] + [InlineData(22, "al douăzeci și doilea")] + [InlineData(30, "al treizecilea")] + [InlineData(40, "al patruzecilea")] + [InlineData(50, "al cincizecilea")] + [InlineData(60, "al șaizecilea")] + [InlineData(70, "al șaptezecilea")] + [InlineData(80, "al optzecilea")] + [InlineData(90, "al nouăzecilea")] + [InlineData(100, "al o sutălea")] + [InlineData(101, "al o sută unulea")] + [InlineData(102, "al o sută doilea")] + [InlineData(199, "al o sută nouăzeci și nouălea")] + [InlineData(200, "al două sutelea")] + [InlineData(300, "al trei sutelea")] + [InlineData(1000, "al o mielea")] + [InlineData(1001, "al o mie unulea")] + [InlineData(2000, "al două miilea")] + [InlineData(10000, "al zece miilea")] + [InlineData(20000, "al douăzeci miilea")] + [InlineData(50000, "al cincizeci miilea")] + [InlineData(1000000, "al un milionulea")] + [InlineData(2000000, "al două milioanelea")] + [InlineData(20000000, "al douăzeci milioanelea")] + [InlineData(1000000000, "al un miliardulea")] + [InlineData(2000000000, "al două miliardelea")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primul")] - [InlineData(2, "al doilea")] - [InlineData(3, "al treilea")] - [InlineData(4, "al patrulea")] - [InlineData(5, "al cincilea")] - [InlineData(6, "al șaselea")] - [InlineData(7, "al șaptelea")] - [InlineData(8, "al optulea")] - [InlineData(9, "al nouălea")] - [InlineData(10, "al zecelea")] - [InlineData(11, "al unsprezecelea")] - [InlineData(12, "al doisprezecelea")] - [InlineData(13, "al treisprezecelea")] - [InlineData(14, "al paisprezecelea")] - [InlineData(15, "al cincisprezecelea")] - [InlineData(16, "al șaisprezecelea")] - [InlineData(17, "al șaptesprezecelea")] - [InlineData(18, "al optsprezecelea")] - [InlineData(19, "al nouăsprezecelea")] - [InlineData(20, "al douăzecilea")] - [InlineData(21, "al douăzeci și unulea")] - [InlineData(22, "al douăzeci și doilea")] - [InlineData(30, "al treizecilea")] - [InlineData(40, "al patruzecilea")] - [InlineData(50, "al cincizecilea")] - [InlineData(60, "al șaizecilea")] - [InlineData(70, "al șaptezecilea")] - [InlineData(80, "al optzecilea")] - [InlineData(90, "al nouăzecilea")] - [InlineData(100, "al o sutălea")] - [InlineData(101, "al o sută unulea")] - [InlineData(102, "al o sută doilea")] - [InlineData(199, "al o sută nouăzeci și nouălea")] - [InlineData(200, "al două sutelea")] - [InlineData(300, "al trei sutelea")] - [InlineData(1000, "al o mielea")] - [InlineData(1001, "al o mie unulea")] - [InlineData(2000, "al două miilea")] - [InlineData(10000, "al zece miilea")] - [InlineData(20000, "al douăzeci miilea")] - [InlineData(50000, "al cincizeci miilea")] - [InlineData(1000000, "al un milionulea")] - [InlineData(2000000, "al două milioanelea")] - [InlineData(20000000, "al douăzeci milioanelea")] - [InlineData(1000000000, "al un miliardulea")] - [InlineData(2000000000, "al două miliardelea")] - public void ToMasculineOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primul")] + [InlineData(2, "al doilea")] + [InlineData(3, "al treilea")] + [InlineData(4, "al patrulea")] + [InlineData(5, "al cincilea")] + [InlineData(6, "al șaselea")] + [InlineData(7, "al șaptelea")] + [InlineData(8, "al optulea")] + [InlineData(9, "al nouălea")] + [InlineData(10, "al zecelea")] + [InlineData(11, "al unsprezecelea")] + [InlineData(12, "al doisprezecelea")] + [InlineData(13, "al treisprezecelea")] + [InlineData(14, "al paisprezecelea")] + [InlineData(15, "al cincisprezecelea")] + [InlineData(16, "al șaisprezecelea")] + [InlineData(17, "al șaptesprezecelea")] + [InlineData(18, "al optsprezecelea")] + [InlineData(19, "al nouăsprezecelea")] + [InlineData(20, "al douăzecilea")] + [InlineData(21, "al douăzeci și unulea")] + [InlineData(22, "al douăzeci și doilea")] + [InlineData(30, "al treizecilea")] + [InlineData(40, "al patruzecilea")] + [InlineData(50, "al cincizecilea")] + [InlineData(60, "al șaizecilea")] + [InlineData(70, "al șaptezecilea")] + [InlineData(80, "al optzecilea")] + [InlineData(90, "al nouăzecilea")] + [InlineData(100, "al o sutălea")] + [InlineData(101, "al o sută unulea")] + [InlineData(102, "al o sută doilea")] + [InlineData(199, "al o sută nouăzeci și nouălea")] + [InlineData(200, "al două sutelea")] + [InlineData(300, "al trei sutelea")] + [InlineData(1000, "al o mielea")] + [InlineData(1001, "al o mie unulea")] + [InlineData(2000, "al două miilea")] + [InlineData(10000, "al zece miilea")] + [InlineData(20000, "al douăzeci miilea")] + [InlineData(50000, "al cincizeci miilea")] + [InlineData(1000000, "al un milionulea")] + [InlineData(2000000, "al două milioanelea")] + [InlineData(20000000, "al douăzeci milioanelea")] + [InlineData(1000000000, "al un miliardulea")] + [InlineData(2000000000, "al două miliardelea")] + public void ToMasculineOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Masculine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "prima")] - [InlineData(2, "a doua")] - [InlineData(3, "a treia")] - [InlineData(4, "a patra")] - [InlineData(5, "a cincea")] - [InlineData(6, "a șasea")] - [InlineData(7, "a șaptea")] - [InlineData(8, "a opta")] - [InlineData(9, "a noua")] - [InlineData(10, "a zecea")] - [InlineData(11, "a unsprezecea")] - [InlineData(12, "a douăsprezecea")] - [InlineData(13, "a treisprezecea")] - [InlineData(14, "a paisprezecea")] - [InlineData(15, "a cincisprezecea")] - [InlineData(16, "a șaisprezecea")] - [InlineData(17, "a șaptesprezecea")] - [InlineData(18, "a optsprezecea")] - [InlineData(19, "a nouăsprezecea")] - [InlineData(20, "a douăzecea")] - [InlineData(21, "a douăzeci și una")] - [InlineData(22, "a douăzeci și doua")] - [InlineData(30, "a treizecea")] - [InlineData(40, "a patruzecea")] - [InlineData(50, "a cincizecea")] - [InlineData(60, "a șaizecea")] - [InlineData(70, "a șaptezecea")] - [InlineData(80, "a optzecea")] - [InlineData(90, "a nouăzecea")] - [InlineData(100, "a o suta")] - [InlineData(101, "a o sută una")] - [InlineData(102, "a o sută doua")] - [InlineData(199, "a o sută nouăzeci și noua")] - [InlineData(200, "a două suta")] - [InlineData(300, "a trei suta")] - [InlineData(1000, "a o mia")] - [InlineData(1001, "a o mie una")] - [InlineData(2000, "a două mia")] - [InlineData(10000, "a zece mia")] - [InlineData(20000, "a douăzeci mia")] - [InlineData(50000, "a cincizeci mia")] - [InlineData(1000000, "a milioana")] - [InlineData(2000000, "a două milioana")] - [InlineData(20000000, "a douăzecea milioana")] - [InlineData(1000000000, "a miliarda")] - [InlineData(2000000000, "a două miliarda")] - public void ToFeminineOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "prima")] + [InlineData(2, "a doua")] + [InlineData(3, "a treia")] + [InlineData(4, "a patra")] + [InlineData(5, "a cincea")] + [InlineData(6, "a șasea")] + [InlineData(7, "a șaptea")] + [InlineData(8, "a opta")] + [InlineData(9, "a noua")] + [InlineData(10, "a zecea")] + [InlineData(11, "a unsprezecea")] + [InlineData(12, "a douăsprezecea")] + [InlineData(13, "a treisprezecea")] + [InlineData(14, "a paisprezecea")] + [InlineData(15, "a cincisprezecea")] + [InlineData(16, "a șaisprezecea")] + [InlineData(17, "a șaptesprezecea")] + [InlineData(18, "a optsprezecea")] + [InlineData(19, "a nouăsprezecea")] + [InlineData(20, "a douăzecea")] + [InlineData(21, "a douăzeci și una")] + [InlineData(22, "a douăzeci și doua")] + [InlineData(30, "a treizecea")] + [InlineData(40, "a patruzecea")] + [InlineData(50, "a cincizecea")] + [InlineData(60, "a șaizecea")] + [InlineData(70, "a șaptezecea")] + [InlineData(80, "a optzecea")] + [InlineData(90, "a nouăzecea")] + [InlineData(100, "a o suta")] + [InlineData(101, "a o sută una")] + [InlineData(102, "a o sută doua")] + [InlineData(199, "a o sută nouăzeci și noua")] + [InlineData(200, "a două suta")] + [InlineData(300, "a trei suta")] + [InlineData(1000, "a o mia")] + [InlineData(1001, "a o mie una")] + [InlineData(2000, "a două mia")] + [InlineData(10000, "a zece mia")] + [InlineData(20000, "a douăzeci mia")] + [InlineData(50000, "a cincizeci mia")] + [InlineData(1000000, "a milioana")] + [InlineData(2000000, "a două milioana")] + [InlineData(20000000, "a douăzecea milioana")] + [InlineData(1000000000, "a miliarda")] + [InlineData(2000000000, "a două miliarda")] + public void ToFeminineOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(0, "zero")] - [InlineData(1, "primul")] - [InlineData(2, "al doilea")] - [InlineData(3, "al treilea")] - [InlineData(4, "al patrulea")] - [InlineData(5, "al cincilea")] - public void ToNeuterOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(0, "zero")] + [InlineData(1, "primul")] + [InlineData(2, "al doilea")] + [InlineData(3, "al treilea")] + [InlineData(4, "al patrulea")] + [InlineData(5, "al cincilea")] + public void ToNeuterOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ro-Ro/OrdinalizerTests.cs b/src/Humanizer.Tests/Localisation/ro-Ro/OrdinalizerTests.cs index 046f3af04..c14a6c19a 100644 --- a/src/Humanizer.Tests/Localisation/ro-Ro/OrdinalizerTests.cs +++ b/src/Humanizer.Tests/Localisation/ro-Ro/OrdinalizerTests.cs @@ -1,58 +1,57 @@ -namespace Humanizer.Tests.Localisation.roRO +namespace Humanizer.Tests.Localisation.roRO; + +[UseCulture("ro-RO")] +public class OrdinalizerTests { - [UseCulture("ro-RO")] - public class OrdinalizerTests - { - [Theory] - [InlineData(0, "0")] // No ordinal for 0 (zero) in Romanian. - [InlineData(1, "primul")] - [InlineData(2, "al 2-lea")] - [InlineData(3, "al 3-lea")] - [InlineData(10, "al 10-lea")] - public void GenderlessNumber(int number, string expected) => - Assert.Equal(expected, number.Ordinalize()); + [Theory] + [InlineData(0, "0")] // No ordinal for 0 (zero) in Romanian. + [InlineData(1, "primul")] + [InlineData(2, "al 2-lea")] + [InlineData(3, "al 3-lea")] + [InlineData(10, "al 10-lea")] + public void GenderlessNumber(int number, string expected) => + Assert.Equal(expected, number.Ordinalize()); - [Theory] - [InlineData("0", "0")] // No ordinal for 0 (zero) in Romanian. - [InlineData("1", "primul")] - [InlineData("2", "al 2-lea")] - [InlineData("3", "al 3-lea")] - [InlineData("10", "al 10-lea")] - public void GenderlessText(string number, string expected) => - Assert.Equal(expected, number.Ordinalize()); + [Theory] + [InlineData("0", "0")] // No ordinal for 0 (zero) in Romanian. + [InlineData("1", "primul")] + [InlineData("2", "al 2-lea")] + [InlineData("3", "al 3-lea")] + [InlineData("10", "al 10-lea")] + public void GenderlessText(string number, string expected) => + Assert.Equal(expected, number.Ordinalize()); - [Theory] - [InlineData(0, "0")] // No ordinal for 0 (zero) in Romanian. - [InlineData(1, "primul")] - [InlineData(2, "al 2-lea")] - [InlineData(3, "al 3-lea")] - [InlineData(10, "al 10-lea")] - public void MasculineNumber(int number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); + [Theory] + [InlineData(0, "0")] // No ordinal for 0 (zero) in Romanian. + [InlineData(1, "primul")] + [InlineData(2, "al 2-lea")] + [InlineData(3, "al 3-lea")] + [InlineData(10, "al 10-lea")] + public void MasculineNumber(int number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); - [Theory] - [InlineData("0", "0")] // No ordinal for 0 (zero) in Romanian. - [InlineData("1", "primul")] - [InlineData("2", "al 2-lea")] - [InlineData("3", "al 3-lea")] - [InlineData("10", "al 10-lea")] - public void MasculineText(string number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); + [Theory] + [InlineData("0", "0")] // No ordinal for 0 (zero) in Romanian. + [InlineData("1", "primul")] + [InlineData("2", "al 2-lea")] + [InlineData("3", "al 3-lea")] + [InlineData("10", "al 10-lea")] + public void MasculineText(string number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Masculine)); - [Theory] - [InlineData(0, "0")] // No ordinal for 0 (zero) in Romanian. - [InlineData(1, "prima")] - [InlineData(2, "a 2-a")] - [InlineData(10, "a 10-a")] - public void FeminineNumber(int number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "0")] // No ordinal for 0 (zero) in Romanian. + [InlineData(1, "prima")] + [InlineData(2, "a 2-a")] + [InlineData(10, "a 10-a")] + public void FeminineNumber(int number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); - [Theory] - [InlineData("0", "0")] // No ordinal for 0 (zero) in Romanian. - [InlineData("1", "prima")] - [InlineData("2", "a 2-a")] - [InlineData("10", "a 10-a")] - public void FeminineText(string number, string expected) => - Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData("0", "0")] // No ordinal for 0 (zero) in Romanian. + [InlineData("1", "prima")] + [InlineData("2", "a 2-a")] + [InlineData("10", "a 10-a")] + public void FeminineText(string number, string expected) => + Assert.Equal(expected, number.Ordinalize(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ro-Ro/TimeSpanHumanizerTests.cs b/src/Humanizer.Tests/Localisation/ro-Ro/TimeSpanHumanizerTests.cs index 28e0694be..0df3f6a1b 100644 --- a/src/Humanizer.Tests/Localisation/ro-Ro/TimeSpanHumanizerTests.cs +++ b/src/Humanizer.Tests/Localisation/ro-Ro/TimeSpanHumanizerTests.cs @@ -1,109 +1,108 @@ -namespace Humanizer.Tests.Localisation.roRO +namespace Humanizer.Tests.Localisation.roRO; + +/// +/// Test that for values bigger than 19 "de" is added between the numeral +/// and the time unit: http://ebooks.unibuc.ro/filologie/NForascu-DGLR/numerale.htm. +/// There is no test for months since there are only 12 of them in a year. +/// +[UseCulture("ro-RO")] +public class TimeSpanHumanizerTests { - /// - /// Test that for values bigger than 19 "de" is added between the numeral - /// and the time unit: http://ebooks.unibuc.ro/filologie/NForascu-DGLR/numerale.htm. - /// There is no test for months since there are only 12 of them in a year. - /// - [UseCulture("ro-RO")] - public class TimeSpanHumanizerTests + [Theory] + [InlineData(1, "1 milisecundă")] + [InlineData(14, "14 milisecunde")] + [InlineData(21, "21 de milisecunde")] + [InlineData(3000, "3 secunde")] + public void Milliseconds(int milliseconds, string expected) { - [Theory] - [InlineData(1, "1 milisecundă")] - [InlineData(14, "14 milisecunde")] - [InlineData(21, "21 de milisecunde")] - [InlineData(3000, "3 secunde")] - public void Milliseconds(int milliseconds, string expected) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(); - Assert.Equal(expected, actual); - } + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(0, "0 secunde", true)] - [InlineData(0, "0 de secunde")] - [InlineData(1, "1 secundă")] - [InlineData(14, "14 secunde")] - [InlineData(21, "21 de secunde")] - [InlineData(156, "2 minute")] - public void Seconds(int seconds, string expected, bool toWords = false) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(minUnit: TimeUnit.Second, - toWords: toWords); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(0, "0 secunde", true)] + [InlineData(0, "0 de secunde")] + [InlineData(1, "1 secundă")] + [InlineData(14, "14 secunde")] + [InlineData(21, "21 de secunde")] + [InlineData(156, "2 minute")] + public void Seconds(int seconds, string expected, bool toWords = false) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(minUnit: TimeUnit.Second, + toWords: toWords); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(1, "1 minut")] - [InlineData(14, "14 minute")] - [InlineData(21, "21 de minute")] - [InlineData(156, "2 ore")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(1, "1 minut")] + [InlineData(14, "14 minute")] + [InlineData(21, "21 de minute")] + [InlineData(156, "2 ore")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(1, "1 oră")] - [InlineData(14, "14 ore")] - [InlineData(21, "21 de ore")] - [InlineData(48, "2 zile")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(1, "1 oră")] + [InlineData(14, "14 ore")] + [InlineData(21, "21 de ore")] + [InlineData(48, "2 zile")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(1, "1 zi")] - [InlineData(6, "6 zile")] - [InlineData(7, "1 săptămână")] - [InlineData(14, "2 săptămâni")] - [InlineData(21, "3 săptămâni")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(1, "1 zi")] + [InlineData(6, "6 zile")] + [InlineData(7, "1 săptămână")] + [InlineData(14, "2 săptămâni")] + [InlineData(21, "3 săptămâni")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(1, "1 săptămână")] - [InlineData(14, "14 săptămâni")] - [InlineData(21, "21 de săptămâni")] - public void Weeks(int weeks, string expected) - { - var actual = TimeSpan.FromDays(7 * weeks).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(1, "1 săptămână")] + [InlineData(14, "14 săptămâni")] + [InlineData(21, "21 de săptămâni")] + public void Weeks(int weeks, string expected) + { + var actual = TimeSpan.FromDays(7 * weeks).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 lună")] - [InlineData(61, "2 luni")] - [InlineData(92, "3 luni")] - [InlineData(335, "11 luni")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 lună")] + [InlineData(61, "2 luni")] + [InlineData(92, "3 luni")] + [InlineData(335, "11 luni")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 an")] - [InlineData(731, "2 ani")] - [InlineData(1096, "3 ani")] - [InlineData(4018, "11 ani")] - [InlineData(7500, "20 de ani")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 an")] + [InlineData(731, "2 ani")] + [InlineData(1096, "3 ani")] + [InlineData(4018, "11 ani")] + [InlineData(7500, "20 de ani")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Fact] - public void NoTime() => - Assert.Equal("0 de milisecunde", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 de milisecunde", TimeSpan.Zero.Humanize()); - [Fact, CustomDescription("The name of this test is confusing because has no sense. Instead should be read as an interval with duration zero and not the absence of time.")] - public void NoTimeToWords() => - // Usage in Romanian: "Timp execuție: 0 secunde." - // Should be equivalent with TimeSpan.FromSeconds(0).Humanize() - Assert.Equal("0 secunde", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact, CustomDescription("The name of this test is confusing because has no sense. Instead should be read as an interval with duration zero and not the absence of time.")] + public void NoTimeToWords() => + // Usage in Romanian: "Timp execuție: 0 secunde." + // Should be equivalent with TimeSpan.FromSeconds(0).Humanize() + Assert.Equal("0 secunde", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs index 573d98fb6..75891d8f8 100644 --- a/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs @@ -1,224 +1,223 @@ -namespace Humanizer.Tests.Localisation.ruRU +namespace Humanizer.Tests.Localisation.ruRU; + +[UseCulture("ru-RU")] +public class DateHumanizeTests { - [UseCulture("ru-RU")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "секунду назад")] - [InlineData(2, "2 секунды назад")] - [InlineData(3, "3 секунды назад")] - [InlineData(4, "4 секунды назад")] - [InlineData(5, "5 секунд назад")] - [InlineData(6, "6 секунд назад")] - [InlineData(10, "10 секунд назад")] - [InlineData(11, "11 секунд назад")] - [InlineData(19, "19 секунд назад")] - [InlineData(20, "20 секунд назад")] - [InlineData(21, "21 секунду назад")] - [InlineData(22, "22 секунды назад")] - [InlineData(23, "23 секунды назад")] - [InlineData(24, "24 секунды назад")] - [InlineData(25, "25 секунд назад")] - [InlineData(40, "40 секунд назад")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "секунду назад")] + [InlineData(2, "2 секунды назад")] + [InlineData(3, "3 секунды назад")] + [InlineData(4, "4 секунды назад")] + [InlineData(5, "5 секунд назад")] + [InlineData(6, "6 секунд назад")] + [InlineData(10, "10 секунд назад")] + [InlineData(11, "11 секунд назад")] + [InlineData(19, "19 секунд назад")] + [InlineData(20, "20 секунд назад")] + [InlineData(21, "21 секунду назад")] + [InlineData(22, "22 секунды назад")] + [InlineData(23, "23 секунды назад")] + [InlineData(24, "24 секунды назад")] + [InlineData(25, "25 секунд назад")] + [InlineData(40, "40 секунд назад")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "через секунду")] - [InlineData(2, "через 2 секунды")] - [InlineData(3, "через 3 секунды")] - [InlineData(4, "через 4 секунды")] - [InlineData(5, "через 5 секунд")] - [InlineData(6, "через 6 секунд")] - [InlineData(10, "через 10 секунд")] - [InlineData(11, "через 11 секунд")] - [InlineData(19, "через 19 секунд")] - [InlineData(20, "через 20 секунд")] - [InlineData(21, "через 21 секунду")] - [InlineData(22, "через 22 секунды")] - [InlineData(23, "через 23 секунды")] - [InlineData(24, "через 24 секунды")] - [InlineData(25, "через 25 секунд")] - [InlineData(40, "через 40 секунд")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "через секунду")] + [InlineData(2, "через 2 секунды")] + [InlineData(3, "через 3 секунды")] + [InlineData(4, "через 4 секунды")] + [InlineData(5, "через 5 секунд")] + [InlineData(6, "через 6 секунд")] + [InlineData(10, "через 10 секунд")] + [InlineData(11, "через 11 секунд")] + [InlineData(19, "через 19 секунд")] + [InlineData(20, "через 20 секунд")] + [InlineData(21, "через 21 секунду")] + [InlineData(22, "через 22 секунды")] + [InlineData(23, "через 23 секунды")] + [InlineData(24, "через 24 секунды")] + [InlineData(25, "через 25 секунд")] + [InlineData(40, "через 40 секунд")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "минуту назад")] - [InlineData(2, "2 минуты назад")] - [InlineData(3, "3 минуты назад")] - [InlineData(4, "4 минуты назад")] - [InlineData(5, "5 минут назад")] - [InlineData(6, "6 минут назад")] - [InlineData(10, "10 минут назад")] - [InlineData(11, "11 минут назад")] - [InlineData(19, "19 минут назад")] - [InlineData(20, "20 минут назад")] - [InlineData(21, "21 минуту назад")] - [InlineData(22, "22 минуты назад")] - [InlineData(23, "23 минуты назад")] - [InlineData(24, "24 минуты назад")] - [InlineData(25, "25 минут назад")] - [InlineData(40, "40 минут назад")] - [InlineData(60, "час назад")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "минуту назад")] + [InlineData(2, "2 минуты назад")] + [InlineData(3, "3 минуты назад")] + [InlineData(4, "4 минуты назад")] + [InlineData(5, "5 минут назад")] + [InlineData(6, "6 минут назад")] + [InlineData(10, "10 минут назад")] + [InlineData(11, "11 минут назад")] + [InlineData(19, "19 минут назад")] + [InlineData(20, "20 минут назад")] + [InlineData(21, "21 минуту назад")] + [InlineData(22, "22 минуты назад")] + [InlineData(23, "23 минуты назад")] + [InlineData(24, "24 минуты назад")] + [InlineData(25, "25 минут назад")] + [InlineData(40, "40 минут назад")] + [InlineData(60, "час назад")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "через минуту")] - [InlineData(2, "через 2 минуты")] - [InlineData(3, "через 3 минуты")] - [InlineData(4, "через 4 минуты")] - [InlineData(5, "через 5 минут")] - [InlineData(6, "через 6 минут")] - [InlineData(10, "через 10 минут")] - [InlineData(11, "через 11 минут")] - [InlineData(19, "через 19 минут")] - [InlineData(20, "через 20 минут")] - [InlineData(21, "через 21 минуту")] - [InlineData(22, "через 22 минуты")] - [InlineData(23, "через 23 минуты")] - [InlineData(24, "через 24 минуты")] - [InlineData(25, "через 25 минут")] - [InlineData(40, "через 40 минут")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "через минуту")] + [InlineData(2, "через 2 минуты")] + [InlineData(3, "через 3 минуты")] + [InlineData(4, "через 4 минуты")] + [InlineData(5, "через 5 минут")] + [InlineData(6, "через 6 минут")] + [InlineData(10, "через 10 минут")] + [InlineData(11, "через 11 минут")] + [InlineData(19, "через 19 минут")] + [InlineData(20, "через 20 минут")] + [InlineData(21, "через 21 минуту")] + [InlineData(22, "через 22 минуты")] + [InlineData(23, "через 23 минуты")] + [InlineData(24, "через 24 минуты")] + [InlineData(25, "через 25 минут")] + [InlineData(40, "через 40 минут")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "час назад")] - [InlineData(2, "2 часа назад")] - [InlineData(3, "3 часа назад")] - [InlineData(4, "4 часа назад")] - [InlineData(5, "5 часов назад")] - [InlineData(6, "6 часов назад")] - [InlineData(10, "10 часов назад")] - [InlineData(11, "11 часов назад")] - [InlineData(19, "19 часов назад")] - [InlineData(20, "20 часов назад")] - [InlineData(21, "21 час назад")] - [InlineData(22, "22 часа назад")] - [InlineData(23, "23 часа назад")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "час назад")] + [InlineData(2, "2 часа назад")] + [InlineData(3, "3 часа назад")] + [InlineData(4, "4 часа назад")] + [InlineData(5, "5 часов назад")] + [InlineData(6, "6 часов назад")] + [InlineData(10, "10 часов назад")] + [InlineData(11, "11 часов назад")] + [InlineData(19, "19 часов назад")] + [InlineData(20, "20 часов назад")] + [InlineData(21, "21 час назад")] + [InlineData(22, "22 часа назад")] + [InlineData(23, "23 часа назад")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "через час")] - [InlineData(2, "через 2 часа")] - [InlineData(3, "через 3 часа")] - [InlineData(4, "через 4 часа")] - [InlineData(5, "через 5 часов")] - [InlineData(6, "через 6 часов")] - [InlineData(10, "через 10 часов")] - [InlineData(11, "через 11 часов")] - [InlineData(19, "через 19 часов")] - [InlineData(20, "через 20 часов")] - [InlineData(21, "через 21 час")] - [InlineData(22, "через 22 часа")] - [InlineData(23, "через 23 часа")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "через час")] + [InlineData(2, "через 2 часа")] + [InlineData(3, "через 3 часа")] + [InlineData(4, "через 4 часа")] + [InlineData(5, "через 5 часов")] + [InlineData(6, "через 6 часов")] + [InlineData(10, "через 10 часов")] + [InlineData(11, "через 11 часов")] + [InlineData(19, "через 19 часов")] + [InlineData(20, "через 20 часов")] + [InlineData(21, "через 21 час")] + [InlineData(22, "через 22 часа")] + [InlineData(23, "через 23 часа")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "вчера")] - [InlineData(2, "2 дня назад")] - [InlineData(3, "3 дня назад")] - [InlineData(4, "4 дня назад")] - [InlineData(5, "5 дней назад")] - [InlineData(6, "6 дней назад")] - [InlineData(10, "10 дней назад")] - [InlineData(11, "11 дней назад")] - [InlineData(19, "19 дней назад")] - [InlineData(20, "20 дней назад")] - [InlineData(21, "21 день назад")] - [InlineData(22, "22 дня назад")] - [InlineData(23, "23 дня назад")] - [InlineData(24, "24 дня назад")] - [InlineData(25, "25 дней назад")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "вчера")] + [InlineData(2, "2 дня назад")] + [InlineData(3, "3 дня назад")] + [InlineData(4, "4 дня назад")] + [InlineData(5, "5 дней назад")] + [InlineData(6, "6 дней назад")] + [InlineData(10, "10 дней назад")] + [InlineData(11, "11 дней назад")] + [InlineData(19, "19 дней назад")] + [InlineData(20, "20 дней назад")] + [InlineData(21, "21 день назад")] + [InlineData(22, "22 дня назад")] + [InlineData(23, "23 дня назад")] + [InlineData(24, "24 дня назад")] + [InlineData(25, "25 дней назад")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "завтра")] - [InlineData(2, "через 2 дня")] - [InlineData(3, "через 3 дня")] - [InlineData(4, "через 4 дня")] - [InlineData(5, "через 5 дней")] - [InlineData(6, "через 6 дней")] - [InlineData(10, "через 10 дней")] - [InlineData(11, "через 11 дней")] - [InlineData(19, "через 19 дней")] - [InlineData(20, "через 20 дней")] - [InlineData(21, "через 21 день")] - [InlineData(22, "через 22 дня")] - [InlineData(23, "через 23 дня")] - [InlineData(24, "через 24 дня")] - [InlineData(25, "через 25 дней")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "завтра")] + [InlineData(2, "через 2 дня")] + [InlineData(3, "через 3 дня")] + [InlineData(4, "через 4 дня")] + [InlineData(5, "через 5 дней")] + [InlineData(6, "через 6 дней")] + [InlineData(10, "через 10 дней")] + [InlineData(11, "через 11 дней")] + [InlineData(19, "через 19 дней")] + [InlineData(20, "через 20 дней")] + [InlineData(21, "через 21 день")] + [InlineData(22, "через 22 дня")] + [InlineData(23, "через 23 дня")] + [InlineData(24, "через 24 дня")] + [InlineData(25, "через 25 дней")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "месяц назад")] - [InlineData(2, "2 месяца назад")] - [InlineData(3, "3 месяца назад")] - [InlineData(4, "4 месяца назад")] - [InlineData(5, "5 месяцев назад")] - [InlineData(6, "6 месяцев назад")] - [InlineData(10, "10 месяцев назад")] - [InlineData(11, "11 месяцев назад")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "месяц назад")] + [InlineData(2, "2 месяца назад")] + [InlineData(3, "3 месяца назад")] + [InlineData(4, "4 месяца назад")] + [InlineData(5, "5 месяцев назад")] + [InlineData(6, "6 месяцев назад")] + [InlineData(10, "10 месяцев назад")] + [InlineData(11, "11 месяцев назад")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "через месяц")] - [InlineData(2, "через 2 месяца")] - [InlineData(3, "через 3 месяца")] - [InlineData(4, "через 4 месяца")] - [InlineData(5, "через 5 месяцев")] - [InlineData(6, "через 6 месяцев")] - [InlineData(10, "через 10 месяцев")] - [InlineData(11, "через 11 месяцев")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "через месяц")] + [InlineData(2, "через 2 месяца")] + [InlineData(3, "через 3 месяца")] + [InlineData(4, "через 4 месяца")] + [InlineData(5, "через 5 месяцев")] + [InlineData(6, "через 6 месяцев")] + [InlineData(10, "через 10 месяцев")] + [InlineData(11, "через 11 месяцев")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "год назад")] - [InlineData(2, "2 года назад")] - [InlineData(3, "3 года назад")] - [InlineData(4, "4 года назад")] - [InlineData(5, "5 лет назад")] - [InlineData(6, "6 лет назад")] - [InlineData(10, "10 лет назад")] - [InlineData(11, "11 лет назад")] - [InlineData(19, "19 лет назад")] - [InlineData(21, "21 год назад")] - [InlineData(111, "111 лет назад")] - [InlineData(121, "121 год назад")] - [InlineData(222, "222 года назад")] - [InlineData(325, "325 лет назад")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "год назад")] + [InlineData(2, "2 года назад")] + [InlineData(3, "3 года назад")] + [InlineData(4, "4 года назад")] + [InlineData(5, "5 лет назад")] + [InlineData(6, "6 лет назад")] + [InlineData(10, "10 лет назад")] + [InlineData(11, "11 лет назад")] + [InlineData(19, "19 лет назад")] + [InlineData(21, "21 год назад")] + [InlineData(111, "111 лет назад")] + [InlineData(121, "121 год назад")] + [InlineData(222, "222 года назад")] + [InlineData(325, "325 лет назад")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "через год")] - [InlineData(2, "через 2 года")] - [InlineData(3, "через 3 года")] - [InlineData(4, "через 4 года")] - [InlineData(5, "через 5 лет")] - [InlineData(6, "через 6 лет")] - [InlineData(10, "через 10 лет")] - [InlineData(11, "через 11 лет")] - [InlineData(19, "через 19 лет")] - [InlineData(20, "через 20 лет")] - [InlineData(21, "через 21 год")] - [InlineData(111, "через 111 лет")] - [InlineData(121, "через 121 год")] - [InlineData(222, "через 222 года")] - [InlineData(325, "через 325 лет")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "через год")] + [InlineData(2, "через 2 года")] + [InlineData(3, "через 3 года")] + [InlineData(4, "через 4 года")] + [InlineData(5, "через 5 лет")] + [InlineData(6, "через 6 лет")] + [InlineData(10, "через 10 лет")] + [InlineData(11, "через 11 лет")] + [InlineData(19, "через 19 лет")] + [InlineData(20, "через 20 лет")] + [InlineData(21, "через 21 год")] + [InlineData(111, "через 111 лет")] + [InlineData(121, "через 121 год")] + [InlineData(222, "через 222 года")] + [InlineData(325, "через 325 лет")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("сейчас", 0, TimeUnit.Day, Tense.Past); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("сейчас", 0, TimeUnit.Day, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ru-RU/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/NumberToWordsTests.cs index 729b9773e..576721bab 100644 --- a/src/Humanizer.Tests/Localisation/ru-RU/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ru-RU/NumberToWordsTests.cs @@ -1,247 +1,246 @@ -namespace Humanizer.Tests.Localisation.ruRU +namespace Humanizer.Tests.Localisation.ruRU; + +[UseCulture("ru-RU")] +public class NumberToWordsTests { - [UseCulture("ru-RU")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "ноль")] - [InlineData(1, "один")] - [InlineData(10, "десять")] - [InlineData(11, "одиннадцать")] - [InlineData(12, "двенадцать")] - [InlineData(13, "тринадцать")] - [InlineData(14, "четырнадцать")] - [InlineData(15, "пятнадцать")] - [InlineData(16, "шестнадцать")] - [InlineData(17, "семнадцать")] - [InlineData(18, "восемнадцать")] - [InlineData(19, "девятнадцать")] - [InlineData(20, "двадцать")] - [InlineData(30, "тридцать")] - [InlineData(40, "сорок")] - [InlineData(50, "пятьдесят")] - [InlineData(60, "шестьдесят")] - [InlineData(70, "семьдесят")] - [InlineData(80, "восемьдесят")] - [InlineData(90, "девяносто")] - [InlineData(100, "сто")] - [InlineData(200, "двести")] - [InlineData(300, "триста")] - [InlineData(400, "четыреста")] - [InlineData(500, "пятьсот")] - [InlineData(600, "шестьсот")] - [InlineData(700, "семьсот")] - [InlineData(800, "восемьсот")] - [InlineData(900, "девятьсот")] - [InlineData(1000, "одна тысяча")] - [InlineData(2000, "две тысячи")] - [InlineData(3000, "три тысячи")] - [InlineData(4000, "четыре тысячи")] - [InlineData(5000, "пять тысяч")] - [InlineData(10000, "десять тысяч")] - [InlineData(100000, "сто тысяч")] - [InlineData(1000000, "один миллион")] - [InlineData(2000000, "два миллиона")] - [InlineData(10000000, "десять миллионов")] - [InlineData(100000000, "сто миллионов")] - [InlineData(1000000000, "один миллиард")] - [InlineData(2000000000, "два миллиарда")] - [InlineData(3000000000, "три миллиарда")] - [InlineData(4000000000, "четыре миллиарда")] - [InlineData(122, "сто двадцать два")] - [InlineData(3501, "три тысячи пятьсот один")] - [InlineData(111, "сто одиннадцать")] - [InlineData(1112, "одна тысяча сто двенадцать")] - [InlineData(11213, "одиннадцать тысяч двести тринадцать")] - [InlineData(121314, "сто двадцать одна тысяча триста четырнадцать")] - [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцать")] - [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцать")] - [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцать")] - [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцать")] - [InlineData(4111111118, "четыре миллиарда сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцать")] - [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцать")] - [InlineData(999999999999, "девятьсот девяносто девять миллиардов девятьсот девяносто девять миллионов девятьсот девяносто девять тысяч девятьсот девяносто девять")] - [InlineData(1_000_000_000_000, "один триллион")] - [InlineData(3_000_000_000_000, "три триллиона")] - [InlineData(5_000_000_000_000, "пять триллионов")] - [InlineData(999_000_000_000_000, "девятьсот девяносто девять триллионов")] - [InlineData( - long.MaxValue, - "девять квинтиллионов " + - "двести двадцать три квадриллиона " + - "триста семьдесят два триллиона " + - "тридцать шесть миллиардов " + - "восемьсот пятьдесят четыре миллиона " + - "семьсот семьдесят пять тысяч " + - "восемьсот семь")] - [InlineData( - long.MinValue, - "минус девять квинтиллионов " + - "двести двадцать три квадриллиона " + - "триста семьдесят два триллиона " + - "тридцать шесть миллиардов " + - "восемьсот пятьдесят четыре миллиона " + - "семьсот семьдесят пять тысяч " + - "восемьсот восемь")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "ноль")] + [InlineData(1, "один")] + [InlineData(10, "десять")] + [InlineData(11, "одиннадцать")] + [InlineData(12, "двенадцать")] + [InlineData(13, "тринадцать")] + [InlineData(14, "четырнадцать")] + [InlineData(15, "пятнадцать")] + [InlineData(16, "шестнадцать")] + [InlineData(17, "семнадцать")] + [InlineData(18, "восемнадцать")] + [InlineData(19, "девятнадцать")] + [InlineData(20, "двадцать")] + [InlineData(30, "тридцать")] + [InlineData(40, "сорок")] + [InlineData(50, "пятьдесят")] + [InlineData(60, "шестьдесят")] + [InlineData(70, "семьдесят")] + [InlineData(80, "восемьдесят")] + [InlineData(90, "девяносто")] + [InlineData(100, "сто")] + [InlineData(200, "двести")] + [InlineData(300, "триста")] + [InlineData(400, "четыреста")] + [InlineData(500, "пятьсот")] + [InlineData(600, "шестьсот")] + [InlineData(700, "семьсот")] + [InlineData(800, "восемьсот")] + [InlineData(900, "девятьсот")] + [InlineData(1000, "одна тысяча")] + [InlineData(2000, "две тысячи")] + [InlineData(3000, "три тысячи")] + [InlineData(4000, "четыре тысячи")] + [InlineData(5000, "пять тысяч")] + [InlineData(10000, "десять тысяч")] + [InlineData(100000, "сто тысяч")] + [InlineData(1000000, "один миллион")] + [InlineData(2000000, "два миллиона")] + [InlineData(10000000, "десять миллионов")] + [InlineData(100000000, "сто миллионов")] + [InlineData(1000000000, "один миллиард")] + [InlineData(2000000000, "два миллиарда")] + [InlineData(3000000000, "три миллиарда")] + [InlineData(4000000000, "четыре миллиарда")] + [InlineData(122, "сто двадцать два")] + [InlineData(3501, "три тысячи пятьсот один")] + [InlineData(111, "сто одиннадцать")] + [InlineData(1112, "одна тысяча сто двенадцать")] + [InlineData(11213, "одиннадцать тысяч двести тринадцать")] + [InlineData(121314, "сто двадцать одна тысяча триста четырнадцать")] + [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцать")] + [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцать")] + [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцать")] + [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцать")] + [InlineData(4111111118, "четыре миллиарда сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцать")] + [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцать")] + [InlineData(999999999999, "девятьсот девяносто девять миллиардов девятьсот девяносто девять миллионов девятьсот девяносто девять тысяч девятьсот девяносто девять")] + [InlineData(1_000_000_000_000, "один триллион")] + [InlineData(3_000_000_000_000, "три триллиона")] + [InlineData(5_000_000_000_000, "пять триллионов")] + [InlineData(999_000_000_000_000, "девятьсот девяносто девять триллионов")] + [InlineData( + long.MaxValue, + "девять квинтиллионов " + + "двести двадцать три квадриллиона " + + "триста семьдесят два триллиона " + + "тридцать шесть миллиардов " + + "восемьсот пятьдесят четыре миллиона " + + "семьсот семьдесят пять тысяч " + + "восемьсот семь")] + [InlineData( + long.MinValue, + "минус девять квинтиллионов " + + "двести двадцать три квадриллиона " + + "триста семьдесят два триллиона " + + "тридцать шесть миллиардов " + + "восемьсот пятьдесят четыре миллиона " + + "семьсот семьдесят пять тысяч " + + "восемьсот восемь")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(122, "сто двадцать две", GrammaticalGender.Feminine)] - [InlineData(3501, "три тысячи пятьсот одна", GrammaticalGender.Feminine)] - [InlineData(3501, "три тысячи пятьсот одно", GrammaticalGender.Neuter)] - public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(122, "сто двадцать две", GrammaticalGender.Feminine)] + [InlineData(3501, "три тысячи пятьсот одна", GrammaticalGender.Feminine)] + [InlineData(3501, "три тысячи пятьсот одно", GrammaticalGender.Neuter)] + public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(0, "нулевой")] - [InlineData(1, "первый")] - [InlineData(2, "второй")] - [InlineData(3, "третий")] - [InlineData(10, "десятый")] - [InlineData(11, "одиннадцатый")] - [InlineData(12, "двенадцатый")] - [InlineData(13, "тринадцатый")] - [InlineData(14, "четырнадцатый")] - [InlineData(15, "пятнадцатый")] - [InlineData(16, "шестнадцатый")] - [InlineData(17, "семнадцатый")] - [InlineData(18, "восемнадцатый")] - [InlineData(19, "девятнадцатый")] - [InlineData(20, "двадцатый")] - [InlineData(30, "тридцатый")] - [InlineData(40, "сороковой")] - [InlineData(50, "пятидесятый")] - [InlineData(60, "шестидесятый")] - [InlineData(70, "семидесятый")] - [InlineData(80, "восьмидесятый")] - [InlineData(90, "девяностый")] - [InlineData(100, "сотый")] - [InlineData(101, "сто первый")] - [InlineData(140, "сто сороковой")] - [InlineData(200, "двухсотый")] - [InlineData(300, "трёхсотый")] - [InlineData(400, "четырёхсотый")] - [InlineData(500, "пятисотый")] - [InlineData(600, "шестисотый")] - [InlineData(700, "семисотый")] - [InlineData(800, "восьмисотый")] - [InlineData(900, "девятисотый")] - [InlineData(1000, "тысячный")] - [InlineData(1001, "одна тысяча первый")] - [InlineData(1040, "одна тысяча сороковой")] - [InlineData(2000, "двухтысячный")] - [InlineData(3000, "трёхтысячный")] - [InlineData(4000, "четырёхтысячный")] - [InlineData(5000, "пятитысячный")] - [InlineData(10000, "десятитысячный")] - [InlineData(21000, "двадцатиоднотысячный")] - [InlineData(100000, "стотысячный")] - [InlineData(101000, "стооднотысячный")] - [InlineData(121000, "стодвадцатиоднотысячный")] - [InlineData(200000, "двухсоттысячный")] - [InlineData(1000000, "миллионный")] - [InlineData(2000000, "двухмиллионный")] - [InlineData(10000000, "десятимиллионный")] - [InlineData(21000000, "двадцатиодномиллионный")] - [InlineData(100000000, "стомиллионный")] - [InlineData(230000000, "двухсоттридцатимиллионный")] - [InlineData(1000000000, "миллиардный")] - [InlineData(2000000000, "двухмиллиардный")] - [InlineData(122, "сто двадцать второй")] - [InlineData(3501, "три тысячи пятьсот первый")] - [InlineData(111, "сто одиннадцатый")] - [InlineData(1112, "одна тысяча сто двенадцатый")] - [InlineData(11213, "одиннадцать тысяч двести тринадцатый")] - [InlineData(121314, "сто двадцать одна тысяча триста четырнадцатый")] - [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцатый")] - [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцатый")] - [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатый")] - [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцатый")] - [InlineData(1111111000, "один миллиард сто одиннадцать миллионов стоодиннадцатитысячный")] - [InlineData(1234567000, "один миллиард двести тридцать четыре миллиона пятисотшестидесятисемитысячный")] - [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатый")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "нулевой")] + [InlineData(1, "первый")] + [InlineData(2, "второй")] + [InlineData(3, "третий")] + [InlineData(10, "десятый")] + [InlineData(11, "одиннадцатый")] + [InlineData(12, "двенадцатый")] + [InlineData(13, "тринадцатый")] + [InlineData(14, "четырнадцатый")] + [InlineData(15, "пятнадцатый")] + [InlineData(16, "шестнадцатый")] + [InlineData(17, "семнадцатый")] + [InlineData(18, "восемнадцатый")] + [InlineData(19, "девятнадцатый")] + [InlineData(20, "двадцатый")] + [InlineData(30, "тридцатый")] + [InlineData(40, "сороковой")] + [InlineData(50, "пятидесятый")] + [InlineData(60, "шестидесятый")] + [InlineData(70, "семидесятый")] + [InlineData(80, "восьмидесятый")] + [InlineData(90, "девяностый")] + [InlineData(100, "сотый")] + [InlineData(101, "сто первый")] + [InlineData(140, "сто сороковой")] + [InlineData(200, "двухсотый")] + [InlineData(300, "трёхсотый")] + [InlineData(400, "четырёхсотый")] + [InlineData(500, "пятисотый")] + [InlineData(600, "шестисотый")] + [InlineData(700, "семисотый")] + [InlineData(800, "восьмисотый")] + [InlineData(900, "девятисотый")] + [InlineData(1000, "тысячный")] + [InlineData(1001, "одна тысяча первый")] + [InlineData(1040, "одна тысяча сороковой")] + [InlineData(2000, "двухтысячный")] + [InlineData(3000, "трёхтысячный")] + [InlineData(4000, "четырёхтысячный")] + [InlineData(5000, "пятитысячный")] + [InlineData(10000, "десятитысячный")] + [InlineData(21000, "двадцатиоднотысячный")] + [InlineData(100000, "стотысячный")] + [InlineData(101000, "стооднотысячный")] + [InlineData(121000, "стодвадцатиоднотысячный")] + [InlineData(200000, "двухсоттысячный")] + [InlineData(1000000, "миллионный")] + [InlineData(2000000, "двухмиллионный")] + [InlineData(10000000, "десятимиллионный")] + [InlineData(21000000, "двадцатиодномиллионный")] + [InlineData(100000000, "стомиллионный")] + [InlineData(230000000, "двухсоттридцатимиллионный")] + [InlineData(1000000000, "миллиардный")] + [InlineData(2000000000, "двухмиллиардный")] + [InlineData(122, "сто двадцать второй")] + [InlineData(3501, "три тысячи пятьсот первый")] + [InlineData(111, "сто одиннадцатый")] + [InlineData(1112, "одна тысяча сто двенадцатый")] + [InlineData(11213, "одиннадцать тысяч двести тринадцатый")] + [InlineData(121314, "сто двадцать одна тысяча триста четырнадцатый")] + [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцатый")] + [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцатый")] + [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатый")] + [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцатый")] + [InlineData(1111111000, "один миллиард сто одиннадцать миллионов стоодиннадцатитысячный")] + [InlineData(1234567000, "один миллиард двести тридцать четыре миллиона пятисотшестидесятисемитысячный")] + [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатый")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "нулевая")] - [InlineData(1, "первая")] - [InlineData(2, "вторая")] - [InlineData(3, "третья")] - [InlineData(10, "десятая")] - [InlineData(11, "одиннадцатая")] - [InlineData(12, "двенадцатая")] - [InlineData(13, "тринадцатая")] - [InlineData(14, "четырнадцатая")] - [InlineData(15, "пятнадцатая")] - [InlineData(16, "шестнадцатая")] - [InlineData(17, "семнадцатая")] - [InlineData(18, "восемнадцатая")] - [InlineData(19, "девятнадцатая")] - [InlineData(20, "двадцатая")] - [InlineData(30, "тридцатая")] - [InlineData(40, "сороковая")] - [InlineData(50, "пятидесятая")] - [InlineData(60, "шестидесятая")] - [InlineData(70, "семидесятая")] - [InlineData(80, "восьмидесятая")] - [InlineData(90, "девяностая")] - [InlineData(100, "сотая")] - [InlineData(200, "двухсотая")] - [InlineData(300, "трёхсотая")] - [InlineData(400, "четырёхсотая")] - [InlineData(500, "пятисотая")] - [InlineData(600, "шестисотая")] - [InlineData(700, "семисотая")] - [InlineData(800, "восьмисотая")] - [InlineData(900, "девятисотая")] - [InlineData(1000, "тысячная")] - [InlineData(2000, "двухтысячная")] - [InlineData(3000, "трёхтысячная")] - [InlineData(4000, "четырёхтысячная")] - [InlineData(5000, "пятитысячная")] - [InlineData(10000, "десятитысячная")] - [InlineData(90000, "девяностотысячная")] - [InlineData(100000, "стотысячная")] - [InlineData(990000, "девятисотдевяностотысячная")] - [InlineData(990001, "девятьсот девяносто тысяч первая")] - [InlineData(1000000, "миллионная")] - [InlineData(2000000, "двухмиллионная")] - [InlineData(10000000, "десятимиллионная")] - [InlineData(100000000, "стомиллионная")] - [InlineData(1000000000, "миллиардная")] - [InlineData(2000000000, "двухмиллиардная")] - [InlineData(122, "сто двадцать вторая")] - [InlineData(3501, "три тысячи пятьсот первая")] - [InlineData(111, "сто одиннадцатая")] - [InlineData(1112, "одна тысяча сто двенадцатая")] - [InlineData(11000, "одиннадцатитысячная")] - [InlineData(11001, "одиннадцать тысяч первая")] - [InlineData(11213, "одиннадцать тысяч двести тринадцатая")] - [InlineData(15000, "пятнадцатитысячная")] - [InlineData(20000, "двадцатитысячная")] - [InlineData(121314, "сто двадцать одна тысяча триста четырнадцатая")] - [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцатая")] - [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцатая")] - [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатая")] - [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцатая")] - [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатая")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "нулевая")] + [InlineData(1, "первая")] + [InlineData(2, "вторая")] + [InlineData(3, "третья")] + [InlineData(10, "десятая")] + [InlineData(11, "одиннадцатая")] + [InlineData(12, "двенадцатая")] + [InlineData(13, "тринадцатая")] + [InlineData(14, "четырнадцатая")] + [InlineData(15, "пятнадцатая")] + [InlineData(16, "шестнадцатая")] + [InlineData(17, "семнадцатая")] + [InlineData(18, "восемнадцатая")] + [InlineData(19, "девятнадцатая")] + [InlineData(20, "двадцатая")] + [InlineData(30, "тридцатая")] + [InlineData(40, "сороковая")] + [InlineData(50, "пятидесятая")] + [InlineData(60, "шестидесятая")] + [InlineData(70, "семидесятая")] + [InlineData(80, "восьмидесятая")] + [InlineData(90, "девяностая")] + [InlineData(100, "сотая")] + [InlineData(200, "двухсотая")] + [InlineData(300, "трёхсотая")] + [InlineData(400, "четырёхсотая")] + [InlineData(500, "пятисотая")] + [InlineData(600, "шестисотая")] + [InlineData(700, "семисотая")] + [InlineData(800, "восьмисотая")] + [InlineData(900, "девятисотая")] + [InlineData(1000, "тысячная")] + [InlineData(2000, "двухтысячная")] + [InlineData(3000, "трёхтысячная")] + [InlineData(4000, "четырёхтысячная")] + [InlineData(5000, "пятитысячная")] + [InlineData(10000, "десятитысячная")] + [InlineData(90000, "девяностотысячная")] + [InlineData(100000, "стотысячная")] + [InlineData(990000, "девятисотдевяностотысячная")] + [InlineData(990001, "девятьсот девяносто тысяч первая")] + [InlineData(1000000, "миллионная")] + [InlineData(2000000, "двухмиллионная")] + [InlineData(10000000, "десятимиллионная")] + [InlineData(100000000, "стомиллионная")] + [InlineData(1000000000, "миллиардная")] + [InlineData(2000000000, "двухмиллиардная")] + [InlineData(122, "сто двадцать вторая")] + [InlineData(3501, "три тысячи пятьсот первая")] + [InlineData(111, "сто одиннадцатая")] + [InlineData(1112, "одна тысяча сто двенадцатая")] + [InlineData(11000, "одиннадцатитысячная")] + [InlineData(11001, "одиннадцать тысяч первая")] + [InlineData(11213, "одиннадцать тысяч двести тринадцатая")] + [InlineData(15000, "пятнадцатитысячная")] + [InlineData(20000, "двадцатитысячная")] + [InlineData(121314, "сто двадцать одна тысяча триста четырнадцатая")] + [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцатая")] + [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцатая")] + [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатая")] + [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцатая")] + [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатая")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(3, "третье")] - [InlineData(111, "сто одиннадцатое")] - [InlineData(1112, "одна тысяча сто двенадцатое")] - [InlineData(11213, "одиннадцать тысяч двести тринадцатое")] - [InlineData(121314, "сто двадцать одна тысяча триста четырнадцатое")] - [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцатое")] - [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцатое")] - [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатое")] - [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцатое")] - [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатое")] - public void ToOrdinalWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(3, "третье")] + [InlineData(111, "сто одиннадцатое")] + [InlineData(1112, "одна тысяча сто двенадцатое")] + [InlineData(11213, "одиннадцать тысяч двести тринадцатое")] + [InlineData(121314, "сто двадцать одна тысяча триста четырнадцатое")] + [InlineData(2132415, "два миллиона сто тридцать две тысячи четыреста пятнадцатое")] + [InlineData(12345516, "двенадцать миллионов триста сорок пять тысяч пятьсот шестнадцатое")] + [InlineData(751633617, "семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатое")] + [InlineData(1111111118, "один миллиард сто одиннадцать миллионов сто одиннадцать тысяч сто восемнадцатое")] + [InlineData(-751633617, "минус семьсот пятьдесят один миллион шестьсот тридцать три тысячи шестьсот семнадцатое")] + public void ToOrdinalWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ru-RU/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/OrdinalizeTests.cs index 897a9355b..352631e1b 100644 --- a/src/Humanizer.Tests/Localisation/ru-RU/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ru-RU/OrdinalizeTests.cs @@ -1,110 +1,109 @@ -namespace Humanizer.Tests.Localisation.ruRU +namespace Humanizer.Tests.Localisation.ruRU; + +[UseCulture("ru-RU")] +public class OrdinalizeTests { - [UseCulture("ru-RU")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0-й")] - [InlineData("1", "1-й")] - [InlineData("2", "2-й")] - [InlineData("3", "3-й")] - [InlineData("4", "4-й")] - [InlineData("5", "5-й")] - [InlineData("6", "6-й")] - [InlineData("23", "23-й")] - [InlineData("100", "100-й")] - [InlineData("101", "101-й")] - [InlineData("102", "102-й")] - [InlineData("103", "103-й")] - [InlineData("1001", "1001-й")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("0", "0-й")] + [InlineData("1", "1-й")] + [InlineData("2", "2-й")] + [InlineData("3", "3-й")] + [InlineData("4", "4-й")] + [InlineData("5", "5-й")] + [InlineData("6", "6-й")] + [InlineData("23", "23-й")] + [InlineData("100", "100-й")] + [InlineData("101", "101-й")] + [InlineData("102", "102-й")] + [InlineData("103", "103-й")] + [InlineData("1001", "1001-й")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0-я")] - [InlineData("1", "1-я")] - [InlineData("2", "2-я")] - [InlineData("3", "3-я")] - [InlineData("4", "4-я")] - [InlineData("5", "5-я")] - [InlineData("6", "6-я")] - [InlineData("23", "23-я")] - [InlineData("100", "100-я")] - [InlineData("101", "101-я")] - [InlineData("102", "102-я")] - [InlineData("103", "103-я")] - [InlineData("1001", "1001-я")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0-я")] + [InlineData("1", "1-я")] + [InlineData("2", "2-я")] + [InlineData("3", "3-я")] + [InlineData("4", "4-я")] + [InlineData("5", "5-я")] + [InlineData("6", "6-я")] + [InlineData("23", "23-я")] + [InlineData("100", "100-я")] + [InlineData("101", "101-я")] + [InlineData("102", "102-я")] + [InlineData("103", "103-я")] + [InlineData("1001", "1001-я")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData("0", "0-е")] - [InlineData("1", "1-е")] - [InlineData("2", "2-е")] - [InlineData("3", "3-е")] - [InlineData("4", "4-е")] - [InlineData("5", "5-е")] - [InlineData("6", "6-е")] - [InlineData("23", "23-е")] - [InlineData("100", "100-е")] - [InlineData("101", "101-е")] - [InlineData("102", "102-е")] - [InlineData("103", "103-е")] - [InlineData("1001", "1001-е")] - public void OrdinalizeStringNeuter(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); + [Theory] + [InlineData("0", "0-е")] + [InlineData("1", "1-е")] + [InlineData("2", "2-е")] + [InlineData("3", "3-е")] + [InlineData("4", "4-е")] + [InlineData("5", "5-е")] + [InlineData("6", "6-е")] + [InlineData("23", "23-е")] + [InlineData("100", "100-е")] + [InlineData("101", "101-е")] + [InlineData("102", "102-е")] + [InlineData("103", "103-е")] + [InlineData("1001", "1001-е")] + public void OrdinalizeStringNeuter(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - [Theory] - [InlineData(0, "0-й")] - [InlineData(1, "1-й")] - [InlineData(2, "2-й")] - [InlineData(3, "3-й")] - [InlineData(4, "4-й")] - [InlineData(5, "5-й")] - [InlineData(6, "6-й")] - [InlineData(10, "10-й")] - [InlineData(23, "23-й")] - [InlineData(100, "100-й")] - [InlineData(101, "101-й")] - [InlineData(102, "102-й")] - [InlineData(103, "103-й")] - [InlineData(1001, "1001-й")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData(0, "0-й")] + [InlineData(1, "1-й")] + [InlineData(2, "2-й")] + [InlineData(3, "3-й")] + [InlineData(4, "4-й")] + [InlineData(5, "5-й")] + [InlineData(6, "6-й")] + [InlineData(10, "10-й")] + [InlineData(23, "23-й")] + [InlineData(100, "100-й")] + [InlineData(101, "101-й")] + [InlineData(102, "102-й")] + [InlineData(103, "103-й")] + [InlineData(1001, "1001-й")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData(0, "0-я")] - [InlineData(1, "1-я")] - [InlineData(2, "2-я")] - [InlineData(3, "3-я")] - [InlineData(4, "4-я")] - [InlineData(5, "5-я")] - [InlineData(6, "6-я")] - [InlineData(10, "10-я")] - [InlineData(23, "23-я")] - [InlineData(100, "100-я")] - [InlineData(101, "101-я")] - [InlineData(102, "102-я")] - [InlineData(103, "103-я")] - [InlineData(1001, "1001-я")] - public void OrdinalizeNumberFeminine(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData(0, "0-я")] + [InlineData(1, "1-я")] + [InlineData(2, "2-я")] + [InlineData(3, "3-я")] + [InlineData(4, "4-я")] + [InlineData(5, "5-я")] + [InlineData(6, "6-я")] + [InlineData(10, "10-я")] + [InlineData(23, "23-я")] + [InlineData(100, "100-я")] + [InlineData(101, "101-я")] + [InlineData(102, "102-я")] + [InlineData(103, "103-я")] + [InlineData(1001, "1001-я")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData(0, "0-е")] - [InlineData(1, "1-е")] - [InlineData(2, "2-е")] - [InlineData(3, "3-е")] - [InlineData(4, "4-е")] - [InlineData(5, "5-е")] - [InlineData(6, "6-е")] - [InlineData(23, "23-е")] - [InlineData(100, "100-е")] - [InlineData(101, "101-е")] - [InlineData(102, "102-е")] - [InlineData(103, "103-е")] - [InlineData(1001, "1001-е")] - public void OrdinalizeNumberNeuter(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - } -} + [Theory] + [InlineData(0, "0-е")] + [InlineData(1, "1-е")] + [InlineData(2, "2-е")] + [InlineData(3, "3-е")] + [InlineData(4, "4-е")] + [InlineData(5, "5-е")] + [InlineData(6, "6-е")] + [InlineData(23, "23-е")] + [InlineData(100, "100-е")] + [InlineData(101, "101-е")] + [InlineData(102, "102-е")] + [InlineData(103, "103-е")] + [InlineData(1001, "1001-е")] + public void OrdinalizeNumberNeuter(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs index 2106e7efe..6e58c8405 100644 --- a/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/ru-RU/TimeSpanHumanizeTests.cs @@ -1,138 +1,137 @@ -namespace Humanizer.Tests.Localisation.ruRU +namespace Humanizer.Tests.Localisation.ruRU; + +[UseCulture("ru-RU")] +public class TimeSpanHumanizeTests { - [UseCulture("ru-RU")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "один год", true)] - [InlineData(366, "1 год")] - [InlineData(731, "2 года")] - [InlineData(1096, "3 года")] - [InlineData(4018, "11 лет")] - public void Years(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "один год", true)] + [InlineData(366, "1 год")] + [InlineData(731, "2 года")] + [InlineData(1096, "3 года")] + [InlineData(4018, "11 лет")] + public void Years(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "один месяц", true)] - [InlineData(31, "1 месяц")] - [InlineData(61, "2 месяца")] - [InlineData(92, "3 месяца")] - [InlineData(335, "11 месяцев")] - public void Months(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "один месяц", true)] + [InlineData(31, "1 месяц")] + [InlineData(61, "2 месяца")] + [InlineData(92, "3 месяца")] + [InlineData(335, "11 месяцев")] + public void Months(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year, toWords: toWords)); - [Theory] - [InlineData(7, "одна неделя", true)] - [InlineData(7, "1 неделя")] - [InlineData(14, "2 недели")] - [InlineData(21, "3 недели")] - [InlineData(28, "4 недели")] - [InlineData(35, "5 недель")] - [InlineData(77, "11 недель")] - public void Weeks(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); + [Theory] + [InlineData(7, "одна неделя", true)] + [InlineData(7, "1 неделя")] + [InlineData(14, "2 недели")] + [InlineData(21, "3 недели")] + [InlineData(28, "4 недели")] + [InlineData(35, "5 недель")] + [InlineData(77, "11 недель")] + public void Weeks(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "один день", true)] - [InlineData(1, "1 день")] - [InlineData(2, "2 дня")] - [InlineData(3, "3 дня")] - [InlineData(4, "4 дня")] - [InlineData(5, "5 дней")] - [InlineData(6, "6 дней")] - public void Days(int days, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "один день", true)] + [InlineData(1, "1 день")] + [InlineData(2, "2 дня")] + [InlineData(3, "3 дня")] + [InlineData(4, "4 дня")] + [InlineData(5, "5 дней")] + [InlineData(6, "6 дней")] + public void Days(int days, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "один час", true)] - [InlineData(1, "1 час")] - [InlineData(2, "2 часа")] - [InlineData(3, "3 часа")] - [InlineData(4, "4 часа")] - [InlineData(5, "5 часов")] - [InlineData(6, "6 часов")] - [InlineData(10, "10 часов")] - [InlineData(11, "11 часов")] - [InlineData(19, "19 часов")] - [InlineData(20, "20 часов")] - [InlineData(21, "21 час")] - [InlineData(22, "22 часа")] - [InlineData(23, "23 часа")] - public void Hours(int hours, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "один час", true)] + [InlineData(1, "1 час")] + [InlineData(2, "2 часа")] + [InlineData(3, "3 часа")] + [InlineData(4, "4 часа")] + [InlineData(5, "5 часов")] + [InlineData(6, "6 часов")] + [InlineData(10, "10 часов")] + [InlineData(11, "11 часов")] + [InlineData(19, "19 часов")] + [InlineData(20, "20 часов")] + [InlineData(21, "21 час")] + [InlineData(22, "22 часа")] + [InlineData(23, "23 часа")] + public void Hours(int hours, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "одна минута", true)] - [InlineData(1, "1 минута")] - [InlineData(2, "2 минуты")] - [InlineData(3, "3 минуты")] - [InlineData(4, "4 минуты")] - [InlineData(5, "5 минут")] - [InlineData(6, "6 минут")] - [InlineData(10, "10 минут")] - [InlineData(11, "11 минут")] - [InlineData(19, "19 минут")] - [InlineData(20, "20 минут")] - [InlineData(21, "21 минута")] - [InlineData(22, "22 минуты")] - [InlineData(23, "23 минуты")] - [InlineData(24, "24 минуты")] - [InlineData(25, "25 минут")] - [InlineData(40, "40 минут")] - public void Minutes(int minutes, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "одна минута", true)] + [InlineData(1, "1 минута")] + [InlineData(2, "2 минуты")] + [InlineData(3, "3 минуты")] + [InlineData(4, "4 минуты")] + [InlineData(5, "5 минут")] + [InlineData(6, "6 минут")] + [InlineData(10, "10 минут")] + [InlineData(11, "11 минут")] + [InlineData(19, "19 минут")] + [InlineData(20, "20 минут")] + [InlineData(21, "21 минута")] + [InlineData(22, "22 минуты")] + [InlineData(23, "23 минуты")] + [InlineData(24, "24 минуты")] + [InlineData(25, "25 минут")] + [InlineData(40, "40 минут")] + public void Minutes(int minutes, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "одна секунда", true)] - [InlineData(1, "1 секунда")] - [InlineData(2, "2 секунды")] - [InlineData(3, "3 секунды")] - [InlineData(4, "4 секунды")] - [InlineData(5, "5 секунд")] - [InlineData(6, "6 секунд")] - [InlineData(10, "10 секунд")] - [InlineData(11, "11 секунд")] - [InlineData(19, "19 секунд")] - [InlineData(20, "20 секунд")] - [InlineData(21, "21 секунда")] - [InlineData(22, "22 секунды")] - [InlineData(23, "23 секунды")] - [InlineData(24, "24 секунды")] - [InlineData(25, "25 секунд")] - [InlineData(40, "40 секунд")] - public void Seconds(int seconds, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "одна секунда", true)] + [InlineData(1, "1 секунда")] + [InlineData(2, "2 секунды")] + [InlineData(3, "3 секунды")] + [InlineData(4, "4 секунды")] + [InlineData(5, "5 секунд")] + [InlineData(6, "6 секунд")] + [InlineData(10, "10 секунд")] + [InlineData(11, "11 секунд")] + [InlineData(19, "19 секунд")] + [InlineData(20, "20 секунд")] + [InlineData(21, "21 секунда")] + [InlineData(22, "22 секунды")] + [InlineData(23, "23 секунды")] + [InlineData(24, "24 секунды")] + [InlineData(25, "25 секунд")] + [InlineData(40, "40 секунд")] + public void Seconds(int seconds, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize(toWords: toWords)); - [Theory] - [InlineData(1, "одна миллисекунда", true)] - [InlineData(1, "1 миллисекунда")] - [InlineData(2, "2 миллисекунды")] - [InlineData(3, "3 миллисекунды")] - [InlineData(4, "4 миллисекунды")] - [InlineData(5, "5 миллисекунд")] - [InlineData(6, "6 миллисекунд")] - [InlineData(10, "10 миллисекунд")] - [InlineData(11, "11 миллисекунд")] - [InlineData(19, "19 миллисекунд")] - [InlineData(20, "20 миллисекунд")] - [InlineData(21, "21 миллисекунда")] - [InlineData(22, "22 миллисекунды")] - [InlineData(23, "23 миллисекунды")] - [InlineData(24, "24 миллисекунды")] - [InlineData(25, "25 миллисекунд")] - [InlineData(40, "40 миллисекунд")] - public void Milliseconds(int milliseconds, string expected, bool toWords = false) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: toWords)); + [Theory] + [InlineData(1, "одна миллисекунда", true)] + [InlineData(1, "1 миллисекунда")] + [InlineData(2, "2 миллисекунды")] + [InlineData(3, "3 миллисекунды")] + [InlineData(4, "4 миллисекунды")] + [InlineData(5, "5 миллисекунд")] + [InlineData(6, "6 миллисекунд")] + [InlineData(10, "10 миллисекунд")] + [InlineData(11, "11 миллисекунд")] + [InlineData(19, "19 миллисекунд")] + [InlineData(20, "20 миллисекунд")] + [InlineData(21, "21 миллисекунда")] + [InlineData(22, "22 миллисекунды")] + [InlineData(23, "23 миллисекунды")] + [InlineData(24, "24 миллисекунды")] + [InlineData(25, "25 миллисекунд")] + [InlineData(40, "40 миллисекунд")] + public void Milliseconds(int milliseconds, string expected, bool toWords = false) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize(toWords: toWords)); - [Fact] - public void NoTime() => - Assert.Equal("0 миллисекунд", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 миллисекунд", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("нет времени", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("нет времени", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs index 8e2242f9f..e09d64816 100644 --- a/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs @@ -1,137 +1,136 @@ -namespace Humanizer.Tests.Localisation.sk +namespace Humanizer.Tests.Localisation.sk; + +[UseCulture("sk-SK")] +public class DateHumanizeTests { - [UseCulture("sk-SK")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "o sekundu")] - [InlineData(2, "o 2 sekundy")] - [InlineData(3, "o 3 sekundy")] - [InlineData(4, "o 4 sekundy")] - [InlineData(5, "o 5 sekúnd")] - [InlineData(6, "o 6 sekúnd")] - [InlineData(10, "o 10 sekúnd")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "o sekundu")] + [InlineData(2, "o 2 sekundy")] + [InlineData(3, "o 3 sekundy")] + [InlineData(4, "o 4 sekundy")] + [InlineData(5, "o 5 sekúnd")] + [InlineData(6, "o 6 sekúnd")] + [InlineData(10, "o 10 sekúnd")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "o minútu")] - [InlineData(2, "o 2 minúty")] - [InlineData(3, "o 3 minúty")] - [InlineData(4, "o 4 minúty")] - [InlineData(5, "o 5 minút")] - [InlineData(6, "o 6 minút")] - [InlineData(10, "o 10 minút")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "o minútu")] + [InlineData(2, "o 2 minúty")] + [InlineData(3, "o 3 minúty")] + [InlineData(4, "o 4 minúty")] + [InlineData(5, "o 5 minút")] + [InlineData(6, "o 6 minút")] + [InlineData(10, "o 10 minút")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "o hodinu")] - [InlineData(2, "o 2 hodiny")] - [InlineData(3, "o 3 hodiny")] - [InlineData(4, "o 4 hodiny")] - [InlineData(5, "o 5 hodín")] - [InlineData(6, "o 6 hodín")] - [InlineData(10, "o 10 hodín")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "o hodinu")] + [InlineData(2, "o 2 hodiny")] + [InlineData(3, "o 3 hodiny")] + [InlineData(4, "o 4 hodiny")] + [InlineData(5, "o 5 hodín")] + [InlineData(6, "o 6 hodín")] + [InlineData(10, "o 10 hodín")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "zajtra")] - [InlineData(2, "o 2 dni")] - [InlineData(3, "o 3 dni")] - [InlineData(4, "o 4 dni")] - [InlineData(9, "o 9 dní")] - [InlineData(10, "o 10 dní")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "zajtra")] + [InlineData(2, "o 2 dni")] + [InlineData(3, "o 3 dni")] + [InlineData(4, "o 4 dni")] + [InlineData(9, "o 9 dní")] + [InlineData(10, "o 10 dní")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "o mesiac")] - [InlineData(2, "o 2 mesiace")] - [InlineData(3, "o 3 mesiace")] - [InlineData(4, "o 4 mesiace")] - [InlineData(5, "o 5 mesiacov")] - [InlineData(6, "o 6 mesiacov")] - [InlineData(10, "o 10 mesiacov")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "o mesiac")] + [InlineData(2, "o 2 mesiace")] + [InlineData(3, "o 3 mesiace")] + [InlineData(4, "o 4 mesiace")] + [InlineData(5, "o 5 mesiacov")] + [InlineData(6, "o 6 mesiacov")] + [InlineData(10, "o 10 mesiacov")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "o rok")] - [InlineData(2, "o 2 roky")] - [InlineData(3, "o 3 roky")] - [InlineData(4, "o 4 roky")] - [InlineData(5, "o 5 rokov")] - [InlineData(6, "o 6 rokov")] - [InlineData(10, "o 10 rokov")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "o rok")] + [InlineData(2, "o 2 roky")] + [InlineData(3, "o 3 roky")] + [InlineData(4, "o 4 roky")] + [InlineData(5, "o 5 rokov")] + [InlineData(6, "o 6 rokov")] + [InlineData(10, "o 10 rokov")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(1, "pred sekundou")] - [InlineData(2, "pred 2 sekundami")] - [InlineData(3, "pred 3 sekundami")] - [InlineData(4, "pred 4 sekundami")] - [InlineData(5, "pred 5 sekundami")] - [InlineData(6, "pred 6 sekundami")] - [InlineData(10, "pred 10 sekundami")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "pred sekundou")] + [InlineData(2, "pred 2 sekundami")] + [InlineData(3, "pred 3 sekundami")] + [InlineData(4, "pred 4 sekundami")] + [InlineData(5, "pred 5 sekundami")] + [InlineData(6, "pred 6 sekundami")] + [InlineData(10, "pred 10 sekundami")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "pred minútou")] - [InlineData(2, "pred 2 minútami")] - [InlineData(3, "pred 3 minútami")] - [InlineData(4, "pred 4 minútami")] - [InlineData(5, "pred 5 minútami")] - [InlineData(6, "pred 6 minútami")] - [InlineData(10, "pred 10 minútami")] - [InlineData(60, "pred hodinou")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "pred minútou")] + [InlineData(2, "pred 2 minútami")] + [InlineData(3, "pred 3 minútami")] + [InlineData(4, "pred 4 minútami")] + [InlineData(5, "pred 5 minútami")] + [InlineData(6, "pred 6 minútami")] + [InlineData(10, "pred 10 minútami")] + [InlineData(60, "pred hodinou")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "pred hodinou")] - [InlineData(2, "pred 2 hodinami")] - [InlineData(3, "pred 3 hodinami")] - [InlineData(4, "pred 4 hodinami")] - [InlineData(5, "pred 5 hodinami")] - [InlineData(6, "pred 6 hodinami")] - [InlineData(10, "pred 10 hodinami")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "pred hodinou")] + [InlineData(2, "pred 2 hodinami")] + [InlineData(3, "pred 3 hodinami")] + [InlineData(4, "pred 4 hodinami")] + [InlineData(5, "pred 5 hodinami")] + [InlineData(6, "pred 6 hodinami")] + [InlineData(10, "pred 10 hodinami")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "včera")] - [InlineData(2, "pred 2 dňami")] - [InlineData(3, "pred 3 dňami")] - [InlineData(4, "pred 4 dňami")] - [InlineData(9, "pred 9 dňami")] - [InlineData(10, "pred 10 dňami")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "včera")] + [InlineData(2, "pred 2 dňami")] + [InlineData(3, "pred 3 dňami")] + [InlineData(4, "pred 4 dňami")] + [InlineData(9, "pred 9 dňami")] + [InlineData(10, "pred 10 dňami")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "pred mesiacom")] - [InlineData(2, "pred 2 mesiacmi")] - [InlineData(3, "pred 3 mesiacmi")] - [InlineData(4, "pred 4 mesiacmi")] - [InlineData(5, "pred 5 mesiacmi")] - [InlineData(6, "pred 6 mesiacmi")] - [InlineData(10, "pred 10 mesiacmi")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "pred mesiacom")] + [InlineData(2, "pred 2 mesiacmi")] + [InlineData(3, "pred 3 mesiacmi")] + [InlineData(4, "pred 4 mesiacmi")] + [InlineData(5, "pred 5 mesiacmi")] + [InlineData(6, "pred 6 mesiacmi")] + [InlineData(10, "pred 10 mesiacmi")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "pred rokom")] - [InlineData(2, "pred 2 rokmi")] - [InlineData(3, "pred 3 rokmi")] - [InlineData(4, "pred 4 rokmi")] - [InlineData(5, "pred 5 rokmi")] - [InlineData(6, "pred 6 rokmi")] - [InlineData(10, "pred 10 rokmi")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - } -} + [Theory] + [InlineData(1, "pred rokom")] + [InlineData(2, "pred 2 rokmi")] + [InlineData(3, "pred 3 rokmi")] + [InlineData(4, "pred 4 rokmi")] + [InlineData(5, "pred 5 rokmi")] + [InlineData(6, "pred 6 rokmi")] + [InlineData(10, "pred 10 rokmi")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sk/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sk/TimeSpanHumanizeTests.cs index 52f95a9b7..e6e1001ee 100644 --- a/src/Humanizer.Tests/Localisation/sk/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sk/TimeSpanHumanizeTests.cs @@ -1,88 +1,87 @@ -namespace Humanizer.Tests.Localisation.sk +namespace Humanizer.Tests.Localisation.sk; + +[UseCulture("sk-SK")] +public class TimeSpanHumanizeTests { - [UseCulture("sk-SK")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 rok")] - [InlineData(731, "2 roky")] - [InlineData(1096, "3 roky")] - [InlineData(4018, "11 rokov")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 rok")] + [InlineData(731, "2 roky")] + [InlineData(1096, "3 roky")] + [InlineData(4018, "11 rokov")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mesiac")] - [InlineData(61, "2 mesiace")] - [InlineData(92, "3 mesiace")] - [InlineData(335, "11 mesiacov")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mesiac")] + [InlineData(61, "2 mesiace")] + [InlineData(92, "3 mesiace")] + [InlineData(335, "11 mesiacov")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(1, "1 milisekunda")] - [InlineData(2, "2 milisekundy")] - [InlineData(3, "3 milisekundy")] - [InlineData(4, "4 milisekundy")] - [InlineData(5, "5 milisekúnd")] - [InlineData(6, "6 milisekúnd")] - [InlineData(10, "10 milisekúnd")] - public void Milliseconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); + [Theory] + [InlineData(1, "1 milisekunda")] + [InlineData(2, "2 milisekundy")] + [InlineData(3, "3 milisekundy")] + [InlineData(4, "4 milisekundy")] + [InlineData(5, "5 milisekúnd")] + [InlineData(6, "6 milisekúnd")] + [InlineData(10, "10 milisekúnd")] + public void Milliseconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); - [Theory] - [InlineData(1, "1 sekunda")] - [InlineData(2, "2 sekundy")] - [InlineData(3, "3 sekundy")] - [InlineData(4, "4 sekundy")] - [InlineData(5, "5 sekúnd")] - [InlineData(6, "6 sekúnd")] - [InlineData(10, "10 sekúnd")] - public void Seconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); + [Theory] + [InlineData(1, "1 sekunda")] + [InlineData(2, "2 sekundy")] + [InlineData(3, "3 sekundy")] + [InlineData(4, "4 sekundy")] + [InlineData(5, "5 sekúnd")] + [InlineData(6, "6 sekúnd")] + [InlineData(10, "10 sekúnd")] + public void Seconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); - [Theory] - [InlineData(1, "1 minúta")] - [InlineData(2, "2 minúty")] - [InlineData(3, "3 minúty")] - [InlineData(4, "4 minúty")] - [InlineData(5, "5 minút")] - [InlineData(6, "6 minút")] - [InlineData(10, "10 minút")] - public void Minutes(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); + [Theory] + [InlineData(1, "1 minúta")] + [InlineData(2, "2 minúty")] + [InlineData(3, "3 minúty")] + [InlineData(4, "4 minúty")] + [InlineData(5, "5 minút")] + [InlineData(6, "6 minút")] + [InlineData(10, "10 minút")] + public void Minutes(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); - [Theory] - [InlineData(1, "1 hodina")] - [InlineData(2, "2 hodiny")] - [InlineData(3, "3 hodiny")] - [InlineData(4, "4 hodiny")] - [InlineData(5, "5 hodín")] - [InlineData(6, "6 hodín")] - [InlineData(10, "10 hodín")] - public void Hours(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); + [Theory] + [InlineData(1, "1 hodina")] + [InlineData(2, "2 hodiny")] + [InlineData(3, "3 hodiny")] + [InlineData(4, "4 hodiny")] + [InlineData(5, "5 hodín")] + [InlineData(6, "6 hodín")] + [InlineData(10, "10 hodín")] + public void Hours(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); - [Theory] - [InlineData(1, "1 deň")] - [InlineData(2, "2 dni")] - [InlineData(3, "3 dni")] - [InlineData(4, "4 dni")] - [InlineData(5, "5 dní")] - [InlineData(6, "6 dní")] - public void Days(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); + [Theory] + [InlineData(1, "1 deň")] + [InlineData(2, "2 dni")] + [InlineData(3, "3 dni")] + [InlineData(4, "4 dni")] + [InlineData(5, "5 dní")] + [InlineData(6, "6 dní")] + public void Days(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); - [Theory] - [InlineData(1, "1 týždeň")] - [InlineData(2, "2 týždne")] - [InlineData(3, "3 týždne")] - [InlineData(4, "4 týždne")] - [InlineData(5, "5 týždňov")] - [InlineData(6, "6 týždňov")] - public void Weeks(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); - } -} + [Theory] + [InlineData(1, "1 týždeň")] + [InlineData(2, "2 týždne")] + [InlineData(3, "3 týždne")] + [InlineData(4, "4 týždne")] + [InlineData(5, "5 týždňov")] + [InlineData(6, "6 týždňov")] + public void Weeks(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sl/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sl/DateHumanizeTests.cs index 816a21314..daddc5bc2 100644 --- a/src/Humanizer.Tests/Localisation/sl/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sl/DateHumanizeTests.cs @@ -1,122 +1,121 @@ -namespace Humanizer.Tests.Localisation.sl +namespace Humanizer.Tests.Localisation.sl; + +[UseCulture("sl-SI")] +public class DateHumanizeTests { - [UseCulture("sl-SI")] - public class DateHumanizeTests - { - [Theory] - [InlineData(-10, "pred 10 leti")] - [InlineData(-5, "pred 5 leti")] - [InlineData(-4, "pred 4 leti")] - [InlineData(-3, "pred 3 leti")] - [InlineData(-2, "pred 2 letoma")] - [InlineData(-1, "pred enim letom")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-10, "pred 10 leti")] + [InlineData(-5, "pred 5 leti")] + [InlineData(-4, "pred 4 leti")] + [InlineData(-3, "pred 3 leti")] + [InlineData(-2, "pred 2 letoma")] + [InlineData(-1, "pred enim letom")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(5, "čez 5 let")] - [InlineData(4, "čez 4 leta")] - [InlineData(3, "čez 3 leta")] - [InlineData(2, "čez 2 leti")] - [InlineData(1, "čez eno leto")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(5, "čez 5 let")] + [InlineData(4, "čez 4 leta")] + [InlineData(3, "čez 3 leta")] + [InlineData(2, "čez 2 leti")] + [InlineData(1, "čez eno leto")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(-10, "pred 10 meseci")] - [InlineData(-5, "pred 5 meseci")] - [InlineData(-4, "pred 4 meseci")] - [InlineData(-3, "pred 3 meseci")] - [InlineData(-2, "pred 2 mesecema")] - [InlineData(-1, "pred enim mesecem")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-10, "pred 10 meseci")] + [InlineData(-5, "pred 5 meseci")] + [InlineData(-4, "pred 4 meseci")] + [InlineData(-3, "pred 3 meseci")] + [InlineData(-2, "pred 2 mesecema")] + [InlineData(-1, "pred enim mesecem")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(5, "čez 5 mesecev")] - [InlineData(4, "čez 4 mesece")] - [InlineData(3, "čez 3 mesece")] - [InlineData(2, "čez 2 meseca")] - [InlineData(1, "čez en mesec")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(5, "čez 5 mesecev")] + [InlineData(4, "čez 4 mesece")] + [InlineData(3, "čez 3 mesece")] + [InlineData(2, "čez 2 meseca")] + [InlineData(1, "čez en mesec")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-10, "pred 10 dnevi")] - [InlineData(-5, "pred 5 dnevi")] - [InlineData(-4, "pred 4 dnevi")] - [InlineData(-3, "pred 3 dnevi")] - [InlineData(-2, "pred 2 dnevoma")] - [InlineData(-1, "včeraj")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(-10, "pred 10 dnevi")] + [InlineData(-5, "pred 5 dnevi")] + [InlineData(-4, "pred 4 dnevi")] + [InlineData(-3, "pred 3 dnevi")] + [InlineData(-2, "pred 2 dnevoma")] + [InlineData(-1, "včeraj")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(5, "čez 5 dni")] - [InlineData(4, "čez 4 dni")] - [InlineData(3, "čez 3 dni")] - [InlineData(2, "čez 2 dni")] - [InlineData(1, "jutri")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(5, "čez 5 dni")] + [InlineData(4, "čez 4 dni")] + [InlineData(3, "čez 3 dni")] + [InlineData(2, "čez 2 dni")] + [InlineData(1, "jutri")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(-10, "pred 10 urami")] - [InlineData(-5, "pred 5 urami")] - [InlineData(-4, "pred 4 urami")] - [InlineData(-3, "pred 3 urami")] - [InlineData(-2, "pred 2 urama")] - [InlineData(-1, "pred eno uro")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(-10, "pred 10 urami")] + [InlineData(-5, "pred 5 urami")] + [InlineData(-4, "pred 4 urami")] + [InlineData(-3, "pred 3 urami")] + [InlineData(-2, "pred 2 urama")] + [InlineData(-1, "pred eno uro")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(5, "čez 5 ur")] - [InlineData(4, "čez 4 ure")] - [InlineData(3, "čez 3 ure")] - [InlineData(2, "čez 2 uri")] - [InlineData(1, "čez eno uro")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(5, "čez 5 ur")] + [InlineData(4, "čez 4 ure")] + [InlineData(3, "čez 3 ure")] + [InlineData(2, "čez 2 uri")] + [InlineData(1, "čez eno uro")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-10, "pred 10 minutami")] - [InlineData(-5, "pred 5 minutami")] - [InlineData(-4, "pred 4 minutami")] - [InlineData(-3, "pred 3 minutami")] - [InlineData(-2, "pred 2 minutama")] - [InlineData(-1, "pred eno minuto")] - [InlineData(60, "pred eno uro")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-10, "pred 10 minutami")] + [InlineData(-5, "pred 5 minutami")] + [InlineData(-4, "pred 4 minutami")] + [InlineData(-3, "pred 3 minutami")] + [InlineData(-2, "pred 2 minutama")] + [InlineData(-1, "pred eno minuto")] + [InlineData(60, "pred eno uro")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(5, "čez 5 minut")] - [InlineData(4, "čez 4 minute")] - [InlineData(3, "čez 3 minute")] - [InlineData(2, "čez 2 minuti")] - [InlineData(1, "čez eno minuto")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(5, "čez 5 minut")] + [InlineData(4, "čez 4 minute")] + [InlineData(3, "čez 3 minute")] + [InlineData(2, "čez 2 minuti")] + [InlineData(1, "čez eno minuto")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-10, "pred 10 sekundami")] - [InlineData(-5, "pred 5 sekundami")] - [InlineData(-4, "pred 4 sekundami")] - [InlineData(-3, "pred 3 sekundami")] - [InlineData(-2, "pred 2 sekundama")] - [InlineData(-1, "pred eno sekundo")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-10, "pred 10 sekundami")] + [InlineData(-5, "pred 5 sekundami")] + [InlineData(-4, "pred 4 sekundami")] + [InlineData(-3, "pred 3 sekundami")] + [InlineData(-2, "pred 2 sekundama")] + [InlineData(-1, "pred eno sekundo")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(10, "čez 10 sekund")] - [InlineData(5, "čez 5 sekund")] - [InlineData(4, "čez 4 sekunde")] - [InlineData(3, "čez 3 sekunde")] - [InlineData(2, "čez 2 sekundi")] - [InlineData(1, "čez eno sekundo")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - } -} + [Theory] + [InlineData(10, "čez 10 sekund")] + [InlineData(5, "čez 5 sekund")] + [InlineData(4, "čez 4 sekunde")] + [InlineData(3, "čez 3 sekunde")] + [InlineData(2, "čez 2 sekundi")] + [InlineData(1, "čez eno sekundo")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sl/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/sl/NumberToWordsTests.cs index ec63ea8aa..1750161bf 100644 --- a/src/Humanizer.Tests/Localisation/sl/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/sl/NumberToWordsTests.cs @@ -1,50 +1,49 @@ -namespace Humanizer.Tests.Localisation.sl +namespace Humanizer.Tests.Localisation.sl; + +[UseCulture("sl-SI")] +public class NumberToWordsTests { - [UseCulture("sl-SI")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "nič")] - [InlineData(1, "ena")] - [InlineData(2, "dva")] - [InlineData(3, "tri")] - [InlineData(4, "štiri")] - [InlineData(5, "pet")] - [InlineData(6, "šest")] - [InlineData(7, "sedem")] - [InlineData(8, "osem")] - [InlineData(9, "devet")] - [InlineData(10, "deset")] - [InlineData(20, "dvajset")] - [InlineData(30, "trideset")] - [InlineData(40, "štirideset")] - [InlineData(50, "petdeset")] - [InlineData(60, "šestdeset")] - [InlineData(70, "sedemdeset")] - [InlineData(80, "osemdeset")] - [InlineData(90, "devetdeset")] - [InlineData(100, "sto")] - [InlineData(200, "dvesto")] - [InlineData(1000, "tisoč")] - [InlineData(10000, "deset tisoč")] - [InlineData(100000, "sto tisoč")] - [InlineData(1000000, "milijon")] - [InlineData(10000000, "deset milijonov")] - [InlineData(100000000, "sto milijonov")] - [InlineData(1000000000, "milijarda")] - [InlineData(2000000000, "dve milijardi")] - [InlineData(122, "sto dvaindvajset")] - [InlineData(3501, "tri tisoč petsto ena")] - [InlineData(111, "sto enajst")] - [InlineData(1112, "tisoč sto dvanajst")] - [InlineData(11213, "enajst tisoč dvesto trinajst")] - [InlineData(121314, "sto enaindvajset tisoč tristo štirinajst")] - [InlineData(2132415, "dva milijona sto dvaintrideset tisoč štiristo petnajst")] - [InlineData(12345516, "dvanajst milijonov tristo petinštirideset tisoč petsto šestnajst")] - [InlineData(751633617, "sedemsto enainpetdeset milijonov šeststo triintrideset tisoč šeststo sedemnajst")] - [InlineData(1111111118, "milijarda sto enajst milijonov sto enajst tisoč sto osemnajst")] - [InlineData(-751633619, "minus sedemsto enainpetdeset milijonov šeststo triintrideset tisoč šeststo devetnajst")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [Theory] + [InlineData(0, "nič")] + [InlineData(1, "ena")] + [InlineData(2, "dva")] + [InlineData(3, "tri")] + [InlineData(4, "štiri")] + [InlineData(5, "pet")] + [InlineData(6, "šest")] + [InlineData(7, "sedem")] + [InlineData(8, "osem")] + [InlineData(9, "devet")] + [InlineData(10, "deset")] + [InlineData(20, "dvajset")] + [InlineData(30, "trideset")] + [InlineData(40, "štirideset")] + [InlineData(50, "petdeset")] + [InlineData(60, "šestdeset")] + [InlineData(70, "sedemdeset")] + [InlineData(80, "osemdeset")] + [InlineData(90, "devetdeset")] + [InlineData(100, "sto")] + [InlineData(200, "dvesto")] + [InlineData(1000, "tisoč")] + [InlineData(10000, "deset tisoč")] + [InlineData(100000, "sto tisoč")] + [InlineData(1000000, "milijon")] + [InlineData(10000000, "deset milijonov")] + [InlineData(100000000, "sto milijonov")] + [InlineData(1000000000, "milijarda")] + [InlineData(2000000000, "dve milijardi")] + [InlineData(122, "sto dvaindvajset")] + [InlineData(3501, "tri tisoč petsto ena")] + [InlineData(111, "sto enajst")] + [InlineData(1112, "tisoč sto dvanajst")] + [InlineData(11213, "enajst tisoč dvesto trinajst")] + [InlineData(121314, "sto enaindvajset tisoč tristo štirinajst")] + [InlineData(2132415, "dva milijona sto dvaintrideset tisoč štiristo petnajst")] + [InlineData(12345516, "dvanajst milijonov tristo petinštirideset tisoč petsto šestnajst")] + [InlineData(751633617, "sedemsto enainpetdeset milijonov šeststo triintrideset tisoč šeststo sedemnajst")] + [InlineData(1111111118, "milijarda sto enajst milijonov sto enajst tisoč sto osemnajst")] + [InlineData(-751633619, "minus sedemsto enainpetdeset milijonov šeststo triintrideset tisoč šeststo devetnajst")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sl/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sl/TimeSpanHumanizeTests.cs index 025ccde62..c6f41880f 100644 --- a/src/Humanizer.Tests/Localisation/sl/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sl/TimeSpanHumanizeTests.cs @@ -1,87 +1,86 @@ -namespace Humanizer.Tests.Localisation.sl +namespace Humanizer.Tests.Localisation.sl; + +[UseCulture("sl-SI")] +public class TimeSpanHumanizeTests { - [UseCulture("sl-SI")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 leto")] - [InlineData(731, "2 leti")] - [InlineData(1096, "3 leta")] - [InlineData(4018, "11 let")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 leto")] + [InlineData(731, "2 leti")] + [InlineData(1096, "3 leta")] + [InlineData(4018, "11 let")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mesec")] - [InlineData(61, "2 meseca")] - [InlineData(92, "3 mesece")] - [InlineData(335, "11 mesecev")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mesec")] + [InlineData(61, "2 meseca")] + [InlineData(92, "3 mesece")] + [InlineData(335, "11 mesecev")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 teden")] - [InlineData(14, "2 tedna")] - [InlineData(21, "3 tedne")] - [InlineData(28, "4 tedne")] - [InlineData(35, "5 tednov")] - [InlineData(77, "11 tednov")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 teden")] + [InlineData(14, "2 tedna")] + [InlineData(21, "3 tedne")] + [InlineData(28, "4 tedne")] + [InlineData(35, "5 tednov")] + [InlineData(77, "11 tednov")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 dan")] - [InlineData(2, "2 dneva")] - [InlineData(3, "3 dni")] - [InlineData(4, "4 dni")] - [InlineData(5, "5 dni")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 dan")] + [InlineData(2, "2 dneva")] + [InlineData(3, "3 dni")] + [InlineData(4, "4 dni")] + [InlineData(5, "5 dni")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 ura")] - [InlineData(2, "2 uri")] - [InlineData(3, "3 ure")] - [InlineData(4, "4 ure")] - [InlineData(5, "5 ur")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 ura")] + [InlineData(2, "2 uri")] + [InlineData(3, "3 ure")] + [InlineData(4, "4 ure")] + [InlineData(5, "5 ur")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 minuta")] - [InlineData(2, "2 minuti")] - [InlineData(3, "3 minute")] - [InlineData(4, "4 minute")] - [InlineData(5, "5 minut")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 minuta")] + [InlineData(2, "2 minuti")] + [InlineData(3, "3 minute")] + [InlineData(4, "4 minute")] + [InlineData(5, "5 minut")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 sekunda")] - [InlineData(2, "2 sekundi")] - [InlineData(3, "3 sekunde")] - [InlineData(4, "4 sekunde")] - [InlineData(5, "5 sekund")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 sekunda")] + [InlineData(2, "2 sekundi")] + [InlineData(3, "3 sekunde")] + [InlineData(4, "4 sekunde")] + [InlineData(5, "5 sekund")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 milisekunda")] - [InlineData(2, "2 milisekundi")] - [InlineData(3, "3 milisekunde")] - [InlineData(4, "4 milisekunde")] - [InlineData(5, "5 milisekund")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 milisekunda")] + [InlineData(2, "2 milisekundi")] + [InlineData(3, "3 milisekunde")] + [InlineData(4, "4 milisekunde")] + [InlineData(5, "5 milisekund")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 milisekund", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 milisekund", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("nič časa", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("nič časa", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sr-Latn/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sr-Latn/DateHumanizeTests.cs index c4dd892bc..addef9be1 100644 --- a/src/Humanizer.Tests/Localisation/sr-Latn/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sr-Latn/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.srLatn +namespace Humanizer.Tests.Localisation.srLatn; + +[UseCulture("sr-Latn")] +public class DateHumanizeDefaultStrategyTests { - [UseCulture("sr-Latn")] - public class DateHumanizeDefaultStrategyTests - { - [Theory] - [InlineData(1, "pre sekund")] - [InlineData(10, "pre 10 sekundi")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "pre sekund")] + [InlineData(10, "pre 10 sekundi")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "za sekund")] - [InlineData(10, "za 10 sekundi")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "za sekund")] + [InlineData(10, "za 10 sekundi")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "pre minut")] - [InlineData(10, "pre 10 minuta")] - [InlineData(60, "pre sat vremena")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "pre minut")] + [InlineData(10, "pre 10 minuta")] + [InlineData(60, "pre sat vremena")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "za minut")] - [InlineData(10, "za 10 minuta")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "za minut")] + [InlineData(10, "za 10 minuta")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "pre sat vremena")] - [InlineData(10, "pre 10 sati")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "pre sat vremena")] + [InlineData(10, "pre 10 sati")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "za sat vremena")] - [InlineData(10, "za 10 sati")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "za sat vremena")] + [InlineData(10, "za 10 sati")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "juče")] - [InlineData(10, "pre 10 dana")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "juče")] + [InlineData(10, "pre 10 dana")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "sutra")] - [InlineData(10, "za 10 dana")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "sutra")] + [InlineData(10, "za 10 dana")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "pre mesec dana")] - [InlineData(10, "pre 10 meseci")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "pre mesec dana")] + [InlineData(10, "pre 10 meseci")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "za mesec dana")] - [InlineData(10, "za 10 meseci")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "za mesec dana")] + [InlineData(10, "za 10 meseci")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "pre godinu dana")] - [InlineData(2, "pre 2 godine")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "pre godinu dana")] + [InlineData(2, "pre 2 godine")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "za godinu dana")] - [InlineData(2, "za 2 godine")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "za godinu dana")] + [InlineData(2, "za 2 godine")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("sada", 0, TimeUnit.Year, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("sada", 0, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sr-Latn/NumberToWordsTest.cs b/src/Humanizer.Tests/Localisation/sr-Latn/NumberToWordsTest.cs index bbc6116e9..94f538169 100644 --- a/src/Humanizer.Tests/Localisation/sr-Latn/NumberToWordsTest.cs +++ b/src/Humanizer.Tests/Localisation/sr-Latn/NumberToWordsTest.cs @@ -1,44 +1,43 @@ -namespace Humanizer.Tests.Localisation.sr_Latn +namespace Humanizer.Tests.Localisation.sr_Latn; + +[UseCulture("sr-Latn")] +public class NumberToWordsTest { - [UseCulture("sr-Latn")] - public class NumberToWordsTest - { - [Theory] - [InlineData(0, "nula")] - [InlineData(1, "jedan")] - [InlineData(2, "dva")] - [InlineData(3, "tri")] - [InlineData(4, "četiri")] - [InlineData(5, "pet")] - [InlineData(6, "šest")] - [InlineData(7, "sedam")] - [InlineData(8, "osam")] - [InlineData(9, "devet")] - [InlineData(10, "deset")] - [InlineData(20, "dvadeset")] - [InlineData(30, "trideset")] - [InlineData(40, "četrdeset")] - [InlineData(50, "petdeset")] - [InlineData(60, "šestdeset")] - [InlineData(70, "sedamdeset")] - [InlineData(80, "osamdeset")] - [InlineData(90, "devetdeset")] - [InlineData(100, "sto")] - [InlineData(200, "dvesto")] - [InlineData(1000, "hiljadu")] - [InlineData(10000, "deset hiljada")] - [InlineData(100000, "sto hiljada")] - [InlineData(1000000, "milion")] - [InlineData(10000000, "deset miliona")] - [InlineData(100000000, "sto miliona")] - [InlineData(1000000000, "milijarda")] - [InlineData(2000000000, "dve milijarde")] - [InlineData(15, "petnaest")] - [InlineData(43, "četrdeset tri")] - [InlineData(81, "osamdeset jedan")] - [InlineData(213, "dvesto trinaest")] - [InlineData(547, "petsto četrdeset sedam")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [Theory] + [InlineData(0, "nula")] + [InlineData(1, "jedan")] + [InlineData(2, "dva")] + [InlineData(3, "tri")] + [InlineData(4, "četiri")] + [InlineData(5, "pet")] + [InlineData(6, "šest")] + [InlineData(7, "sedam")] + [InlineData(8, "osam")] + [InlineData(9, "devet")] + [InlineData(10, "deset")] + [InlineData(20, "dvadeset")] + [InlineData(30, "trideset")] + [InlineData(40, "četrdeset")] + [InlineData(50, "petdeset")] + [InlineData(60, "šestdeset")] + [InlineData(70, "sedamdeset")] + [InlineData(80, "osamdeset")] + [InlineData(90, "devetdeset")] + [InlineData(100, "sto")] + [InlineData(200, "dvesto")] + [InlineData(1000, "hiljadu")] + [InlineData(10000, "deset hiljada")] + [InlineData(100000, "sto hiljada")] + [InlineData(1000000, "milion")] + [InlineData(10000000, "deset miliona")] + [InlineData(100000000, "sto miliona")] + [InlineData(1000000000, "milijarda")] + [InlineData(2000000000, "dve milijarde")] + [InlineData(15, "petnaest")] + [InlineData(43, "četrdeset tri")] + [InlineData(81, "osamdeset jedan")] + [InlineData(213, "dvesto trinaest")] + [InlineData(547, "petsto četrdeset sedam")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sr-Latn/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sr-Latn/TimeSpanHumanizeTests.cs index 85edb7a8d..190336743 100644 --- a/src/Humanizer.Tests/Localisation/sr-Latn/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sr-Latn/TimeSpanHumanizeTests.cs @@ -1,95 +1,94 @@ -namespace Humanizer.Tests.Localisation.srLatn +namespace Humanizer.Tests.Localisation.srLatn; + +[UseCulture("sr-Latn")] +public class TimeSpanHumanizeTests { - [UseCulture("sr-Latn")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 godina")] - [InlineData(731, "2 godine")] - [InlineData(1096, "3 godine")] - [InlineData(4018, "11 godina")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 godina")] + [InlineData(731, "2 godine")] + [InlineData(1096, "3 godine")] + [InlineData(4018, "11 godina")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 mesec")] - [InlineData(61, "2 meseca")] - [InlineData(92, "3 meseca")] - [InlineData(335, "11 meseci")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 mesec")] + [InlineData(61, "2 meseca")] + [InlineData(92, "3 meseca")] + [InlineData(335, "11 meseci")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(35, "5 nedelja")] - [InlineData(14, "2 nedelje")] - [InlineData(7, "1 nedelja")] - public void Weeks(int days, string expected) - { + [Theory] + [InlineData(35, "5 nedelja")] + [InlineData(14, "2 nedelje")] + [InlineData(7, "1 nedelja")] + public void Weeks(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 dana")] - [InlineData(1, "1 dan")] - public void Days(int days, string expected) - { + [Theory] + [InlineData(2, "2 dana")] + [InlineData(1, "1 dan")] + public void Days(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 sata")] - [InlineData(1, "1 sat")] - public void Hours(int hours, string expected) - { + [Theory] + [InlineData(2, "2 sata")] + [InlineData(1, "1 sat")] + public void Hours(int hours, string expected) + { var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 minuta")] - [InlineData(1, "1 minut")] - public void Minutes(int minutes, string expected) - { + [Theory] + [InlineData(2, "2 minuta")] + [InlineData(1, "1 minut")] + public void Minutes(int minutes, string expected) + { var actual = TimeSpan.FromMinutes(minutes).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 sekunde")] - [InlineData(1, "1 sekunda")] - public void Seconds(int seconds, string expected) - { + [Theory] + [InlineData(2, "2 sekunde")] + [InlineData(1, "1 sekunda")] + public void Seconds(int seconds, string expected) + { var actual = TimeSpan.FromSeconds(seconds).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 milisekunde")] - [InlineData(1, "1 milisekunda")] - public void Milliseconds(int ms, string expected) - { + [Theory] + [InlineData(2, "2 milisekunde")] + [InlineData(1, "1 milisekunda")] + public void Milliseconds(int ms, string expected) + { var actual = TimeSpan.FromMilliseconds(ms).Humanize(); Assert.Equal(expected, actual); } - [Fact] - public void NoTime() - { + [Fact] + public void NoTime() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(); Assert.Equal("0 milisekundi", actual); } - [Fact] - public void NoTimeToWords() - { + [Fact] + public void NoTimeToWords() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(toWords: true); Assert.Equal("bez proteklog vremena", actual); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sr/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sr/DateHumanizeTests.cs index 992b50d83..c08f620f4 100644 --- a/src/Humanizer.Tests/Localisation/sr/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sr/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.sr +namespace Humanizer.Tests.Localisation.sr; + +[UseCulture("sr")] +public class DateHumanizeDefaultStrategyTests { - [UseCulture("sr")] - public class DateHumanizeDefaultStrategyTests - { - [Theory] - [InlineData(1, "пре секунд")] - [InlineData(10, "пре 10 секунди")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "пре секунд")] + [InlineData(10, "пре 10 секунди")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "за секунд")] - [InlineData(10, "за 10 секунди")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "за секунд")] + [InlineData(10, "за 10 секунди")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "пре минут")] - [InlineData(10, "пре 10 минута")] - [InlineData(60, "пре сат времена")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "пре минут")] + [InlineData(10, "пре 10 минута")] + [InlineData(60, "пре сат времена")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "за минут")] - [InlineData(10, "за 10 минута")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "за минут")] + [InlineData(10, "за 10 минута")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "пре сат времена")] - [InlineData(10, "пре 10 сати")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "пре сат времена")] + [InlineData(10, "пре 10 сати")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "за сат времена")] - [InlineData(10, "за 10 сати")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "за сат времена")] + [InlineData(10, "за 10 сати")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "јуче")] - [InlineData(10, "пре 10 дана")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "јуче")] + [InlineData(10, "пре 10 дана")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "сутра")] - [InlineData(10, "за 10 дана")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "сутра")] + [InlineData(10, "за 10 дана")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "пре месец дана")] - [InlineData(10, "пре 10 месеци")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "пре месец дана")] + [InlineData(10, "пре 10 месеци")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "за месец дана")] - [InlineData(10, "за 10 месеци")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "за месец дана")] + [InlineData(10, "за 10 месеци")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "пре годину дана")] - [InlineData(2, "пре 2 године")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "пре годину дана")] + [InlineData(2, "пре 2 године")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "за годину дана")] - [InlineData(2, "за 2 године")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "за годину дана")] + [InlineData(2, "за 2 године")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("сада", 0, TimeUnit.Year, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("сада", 0, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sr/NumberToWordsTest.cs b/src/Humanizer.Tests/Localisation/sr/NumberToWordsTest.cs index f94252202..f24847cfd 100644 --- a/src/Humanizer.Tests/Localisation/sr/NumberToWordsTest.cs +++ b/src/Humanizer.Tests/Localisation/sr/NumberToWordsTest.cs @@ -1,44 +1,43 @@ -namespace Humanizer.Tests.Localisation.sr +namespace Humanizer.Tests.Localisation.sr; + +[UseCulture("sr")] +public class NumberToWordsTest { - [UseCulture("sr")] - public class NumberToWordsTest - { - [Theory] - [InlineData(0, "нула")] - [InlineData(1, "један")] - [InlineData(2, "два")] - [InlineData(3, "три")] - [InlineData(4, "четири")] - [InlineData(5, "пет")] - [InlineData(6, "шест")] - [InlineData(7, "седам")] - [InlineData(8, "осам")] - [InlineData(9, "девет")] - [InlineData(10, "десет")] - [InlineData(20, "двадесет")] - [InlineData(30, "тридесет")] - [InlineData(40, "четрдесет")] - [InlineData(50, "петдесет")] - [InlineData(60, "шестдесет")] - [InlineData(70, "седамдесет")] - [InlineData(80, "осамдесет")] - [InlineData(90, "деветдесет")] - [InlineData(100, "сто")] - [InlineData(200, "двесто")] - [InlineData(1000, "хиљаду")] - [InlineData(10000, "десет хиљада")] - [InlineData(100000, "сто хиљада")] - [InlineData(1000000, "милион")] - [InlineData(10000000, "десет милиона")] - [InlineData(100000000, "сто милиона")] - [InlineData(1000000000, "милијарда")] - [InlineData(2000000000, "две милијарде")] - [InlineData(15, "петнаест")] - [InlineData(43, "четрдесет три")] - [InlineData(81, "осамдесет један")] - [InlineData(213, "двесто тринаест")] - [InlineData(547, "петсто четрдесет седам")] - public void ToWordsSr(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [Theory] + [InlineData(0, "нула")] + [InlineData(1, "један")] + [InlineData(2, "два")] + [InlineData(3, "три")] + [InlineData(4, "четири")] + [InlineData(5, "пет")] + [InlineData(6, "шест")] + [InlineData(7, "седам")] + [InlineData(8, "осам")] + [InlineData(9, "девет")] + [InlineData(10, "десет")] + [InlineData(20, "двадесет")] + [InlineData(30, "тридесет")] + [InlineData(40, "четрдесет")] + [InlineData(50, "петдесет")] + [InlineData(60, "шестдесет")] + [InlineData(70, "седамдесет")] + [InlineData(80, "осамдесет")] + [InlineData(90, "деветдесет")] + [InlineData(100, "сто")] + [InlineData(200, "двесто")] + [InlineData(1000, "хиљаду")] + [InlineData(10000, "десет хиљада")] + [InlineData(100000, "сто хиљада")] + [InlineData(1000000, "милион")] + [InlineData(10000000, "десет милиона")] + [InlineData(100000000, "сто милиона")] + [InlineData(1000000000, "милијарда")] + [InlineData(2000000000, "две милијарде")] + [InlineData(15, "петнаест")] + [InlineData(43, "четрдесет три")] + [InlineData(81, "осамдесет један")] + [InlineData(213, "двесто тринаест")] + [InlineData(547, "петсто четрдесет седам")] + public void ToWordsSr(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sr/TimeSpanHumanizeTests.cs index 6246dace8..a83966021 100644 --- a/src/Humanizer.Tests/Localisation/sr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sr/TimeSpanHumanizeTests.cs @@ -1,97 +1,96 @@ -namespace Humanizer.Tests.Localisation.sr +namespace Humanizer.Tests.Localisation.sr; + +[UseCulture("sr")] +public class TimeSpanHumanizeTests { - [UseCulture("sr")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 година")] - [InlineData(731, "2 године")] - [InlineData(1096, "3 године")] - [InlineData(4018, "11 година")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 година")] + [InlineData(731, "2 године")] + [InlineData(1096, "3 године")] + [InlineData(4018, "11 година")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 месец")] - [InlineData(61, "2 месеца")] - [InlineData(92, "3 месеца")] - [InlineData(335, "11 месеци")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 месец")] + [InlineData(61, "2 месеца")] + [InlineData(92, "3 месеца")] + [InlineData(335, "11 месеци")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(35, "5 недеља")] - [InlineData(14, "2 недеље")] - [InlineData(7, "1 недеља")] - public void Weeks(int days, string expected) - { + [Theory] + [InlineData(35, "5 недеља")] + [InlineData(14, "2 недеље")] + [InlineData(7, "1 недеља")] + public void Weeks(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(6, "6 дана")] - [InlineData(2, "2 дана")] - [InlineData(1, "1 дан")] - public void Days(int days, string expected) - { + [Theory] + [InlineData(6, "6 дана")] + [InlineData(2, "2 дана")] + [InlineData(1, "1 дан")] + public void Days(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(5, "5 сати")] - [InlineData(2, "2 сата")] - [InlineData(1, "1 сат")] - public void Hours(int hours, string expected) - { + [Theory] + [InlineData(5, "5 сати")] + [InlineData(2, "2 сата")] + [InlineData(1, "1 сат")] + public void Hours(int hours, string expected) + { var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 минута")] - [InlineData(1, "1 минут")] - public void Minutes(int minutes, string expected) - { + [Theory] + [InlineData(2, "2 минута")] + [InlineData(1, "1 минут")] + public void Minutes(int minutes, string expected) + { var actual = TimeSpan.FromMinutes(minutes).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 секунде")] - [InlineData(1, "1 секунда")] - public void Seconds(int seconds, string expected) - { + [Theory] + [InlineData(2, "2 секунде")] + [InlineData(1, "1 секунда")] + public void Seconds(int seconds, string expected) + { var actual = TimeSpan.FromSeconds(seconds).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 милисекунде")] - [InlineData(1, "1 милисекунда")] - public void Milliseconds(int ms, string expected) - { + [Theory] + [InlineData(2, "2 милисекунде")] + [InlineData(1, "1 милисекунда")] + public void Milliseconds(int ms, string expected) + { var actual = TimeSpan.FromMilliseconds(ms).Humanize(); Assert.Equal(expected, actual); } - [Fact] - public void NoTime() - { + [Fact] + public void NoTime() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(); Assert.Equal("0 милисекунди", actual); } - [Fact] - public void NoTimeToWords() - { + [Fact] + public void NoTimeToWords() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(toWords: true); Assert.Equal("без протеклог времена", actual); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sv/CollectionFormatterTests.cs b/src/Humanizer.Tests/Localisation/sv/CollectionFormatterTests.cs index a5b7e3ec1..aeab5b000 100644 --- a/src/Humanizer.Tests/Localisation/sv/CollectionFormatterTests.cs +++ b/src/Humanizer.Tests/Localisation/sv/CollectionFormatterTests.cs @@ -1,30 +1,29 @@ -namespace Humanizer.Tests.Localisation.sv +namespace Humanizer.Tests.Localisation.sv; + +[UseCulture("sv-SE")] +public class CollectionFormatterTests { - [UseCulture("sv-SE")] - public class CollectionFormatterTests + [Fact] + public void MoreThanTwoItems() { - [Fact] - public void MoreThanTwoItems() - { - var collection = new List(new[] { 1, 2, 3 }); - var humanized = "1, 2 och 3"; - Assert.Equal(humanized, collection.Humanize()); - } + var collection = new List(new[] { 1, 2, 3 }); + var humanized = "1, 2 och 3"; + Assert.Equal(humanized, collection.Humanize()); + } - [Fact] - public void OneItem() - { - var collection = new List(new[] { 1 }); - var humanized = "1"; - Assert.Equal(humanized, collection.Humanize()); - } + [Fact] + public void OneItem() + { + var collection = new List(new[] { 1 }); + var humanized = "1"; + Assert.Equal(humanized, collection.Humanize()); + } - [Fact] - public void TwoItems() - { - var collection = new List(new[] { 1, 2 }); - var humanized = "1 och 2"; - Assert.Equal(humanized, collection.Humanize()); - } + [Fact] + public void TwoItems() + { + var collection = new List(new[] { 1, 2 }); + var humanized = "1 och 2"; + Assert.Equal(humanized, collection.Humanize()); } } \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs index 75f4df20c..d3dd74668 100644 --- a/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sv/DateHumanizeTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.sv +namespace Humanizer.Tests.Localisation.sv; + +[UseCulture("sv-SE")] +public class DateHumanizeTests { - [UseCulture("sv-SE")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "om en sekund")] - [InlineData(2, "om 2 sekunder")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "om en sekund")] + [InlineData(2, "om 2 sekunder")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "om en minut")] - [InlineData(2, "om 2 minuter")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "om en minut")] + [InlineData(2, "om 2 minuter")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "om en timme")] - [InlineData(2, "om 2 timmar")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "om en timme")] + [InlineData(2, "om 2 timmar")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "i morgon")] - [InlineData(2, "om 2 dagar")] - public void DayFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "i morgon")] + [InlineData(2, "om 2 dagar")] + public void DayFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "om en månad")] - [InlineData(2, "om 2 månader")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "om en månad")] + [InlineData(2, "om 2 månader")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "om ett år")] - [InlineData(2, "om 2 år")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "om ett år")] + [InlineData(2, "om 2 år")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Theory] - [InlineData(1, "en sekund sedan")] - [InlineData(2, "för 2 sekunder sedan")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "en sekund sedan")] + [InlineData(2, "för 2 sekunder sedan")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "en minut sedan")] - [InlineData(2, "för 2 minuter sedan")] - [InlineData(60, "en timme sedan")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "en minut sedan")] + [InlineData(2, "för 2 minuter sedan")] + [InlineData(60, "en timme sedan")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "en timme sedan")] - [InlineData(2, "för 2 timmar sedan")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "en timme sedan")] + [InlineData(2, "för 2 timmar sedan")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "igår")] - [InlineData(2, "för 2 dagar sedan")] - public void DayAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "igår")] + [InlineData(2, "för 2 dagar sedan")] + public void DayAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "en månad sedan")] - [InlineData(2, "för 2 månader sedan")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "en månad sedan")] + [InlineData(2, "för 2 månader sedan")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "ett år sedan")] - [InlineData(2, "för 2 år sedan")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - } -} + [Theory] + [InlineData(1, "ett år sedan")] + [InlineData(2, "för 2 år sedan")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sv/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/sv/NumberToWordsTests.cs index 73a0c104c..86a8e5f48 100644 --- a/src/Humanizer.Tests/Localisation/sv/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/sv/NumberToWordsTests.cs @@ -1,79 +1,78 @@ -namespace Humanizer.Tests.Localisation.sv +namespace Humanizer.Tests.Localisation.sv; + +[UseCulture("sv-SE")] +public class NumberToWordsTests { - [UseCulture("sv-SE")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "noll")] - [InlineData(1, "ett")] - [InlineData(2, "två")] - [InlineData(3, "tre")] - [InlineData(4, "fyra")] - [InlineData(5, "fem")] - [InlineData(6, "sex")] - [InlineData(7, "sju")] - [InlineData(8, "åtta")] - [InlineData(9, "nio")] - [InlineData(10, "tio")] - [InlineData(20, "tjugo")] - [InlineData(30, "trettio")] - [InlineData(40, "fyrtio")] - [InlineData(50, "femtio")] - [InlineData(60, "sextio")] - [InlineData(70, "sjuttio")] - [InlineData(80, "åttio")] - [InlineData(90, "nittio")] - [InlineData(100, "hundra")] - [InlineData(200, "tvåhundra")] - [InlineData(201, "tvåhundraett")] - [InlineData(211, "tvåhundraelva")] - [InlineData(221, "tvåhundratjugoett")] - [InlineData(1000, "ett tusen")] - [InlineData(10000, "tio tusen")] - [InlineData(100000, "hundra tusen")] - [InlineData(1000000, "en miljon")] - [InlineData(10000000, "tio miljoner")] - [InlineData(100000000, "hundra miljoner")] - [InlineData(1000000000, "en miljard")] - [InlineData(2000000000, "två miljarder")] - [InlineData(122, "hundratjugotvå")] - [InlineData(3501, "tre tusen femhundraett")] - [InlineData(111, "hundraelva")] - [InlineData(1112, "ett tusen hundratolv")] - [InlineData(11213, "elva tusen tvåhundratretton")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "noll")] + [InlineData(1, "ett")] + [InlineData(2, "två")] + [InlineData(3, "tre")] + [InlineData(4, "fyra")] + [InlineData(5, "fem")] + [InlineData(6, "sex")] + [InlineData(7, "sju")] + [InlineData(8, "åtta")] + [InlineData(9, "nio")] + [InlineData(10, "tio")] + [InlineData(20, "tjugo")] + [InlineData(30, "trettio")] + [InlineData(40, "fyrtio")] + [InlineData(50, "femtio")] + [InlineData(60, "sextio")] + [InlineData(70, "sjuttio")] + [InlineData(80, "åttio")] + [InlineData(90, "nittio")] + [InlineData(100, "hundra")] + [InlineData(200, "tvåhundra")] + [InlineData(201, "tvåhundraett")] + [InlineData(211, "tvåhundraelva")] + [InlineData(221, "tvåhundratjugoett")] + [InlineData(1000, "ett tusen")] + [InlineData(10000, "tio tusen")] + [InlineData(100000, "hundra tusen")] + [InlineData(1000000, "en miljon")] + [InlineData(10000000, "tio miljoner")] + [InlineData(100000000, "hundra miljoner")] + [InlineData(1000000000, "en miljard")] + [InlineData(2000000000, "två miljarder")] + [InlineData(122, "hundratjugotvå")] + [InlineData(3501, "tre tusen femhundraett")] + [InlineData(111, "hundraelva")] + [InlineData(1112, "ett tusen hundratolv")] + [InlineData(11213, "elva tusen tvåhundratretton")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nollte")] - [InlineData(1, "första")] - [InlineData(2, "andra")] - [InlineData(3, "tredje")] - [InlineData(4, "fjärde")] - [InlineData(5, "femte")] - [InlineData(6, "sjätte")] - [InlineData(7, "sjunde")] - [InlineData(8, "åttonde")] - [InlineData(9, "nionde")] - [InlineData(10, "tionde")] - [InlineData(20, "tjugonde")] - [InlineData(30, "trettionde")] - [InlineData(40, "fyrtionde")] - [InlineData(50, "femtionde")] - [InlineData(60, "sextionde")] - [InlineData(70, "sjuttionde")] - [InlineData(80, "åttionde")] - [InlineData(90, "nittionde")] - [InlineData(100, "hundrade")] - [InlineData(200, "tvåhundrade")] - [InlineData(201, "tvåhundraförsta")] - [InlineData(211, "tvåhundraelfte")] - [InlineData(221, "tvåhundratjugoförsta")] - [InlineData(1000, "ett tusende")] - [InlineData(10000, "tio tusende")] - [InlineData(100000, "hundra tusende")] - [InlineData(1000000, "en miljonte")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "nollte")] + [InlineData(1, "första")] + [InlineData(2, "andra")] + [InlineData(3, "tredje")] + [InlineData(4, "fjärde")] + [InlineData(5, "femte")] + [InlineData(6, "sjätte")] + [InlineData(7, "sjunde")] + [InlineData(8, "åttonde")] + [InlineData(9, "nionde")] + [InlineData(10, "tionde")] + [InlineData(20, "tjugonde")] + [InlineData(30, "trettionde")] + [InlineData(40, "fyrtionde")] + [InlineData(50, "femtionde")] + [InlineData(60, "sextionde")] + [InlineData(70, "sjuttionde")] + [InlineData(80, "åttionde")] + [InlineData(90, "nittionde")] + [InlineData(100, "hundrade")] + [InlineData(200, "tvåhundrade")] + [InlineData(201, "tvåhundraförsta")] + [InlineData(211, "tvåhundraelfte")] + [InlineData(221, "tvåhundratjugoförsta")] + [InlineData(1000, "ett tusende")] + [InlineData(10000, "tio tusende")] + [InlineData(100000, "hundra tusende")] + [InlineData(1000000, "en miljonte")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs index b88580827..7372e5b89 100644 --- a/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/sv/TimeSpanHumanizeTests.cs @@ -1,60 +1,59 @@ -namespace Humanizer.Tests.Localisation.sv +namespace Humanizer.Tests.Localisation.sv; + +[UseCulture("sv-SE")] +public class TimeSpanHumanizeTests { - [UseCulture("sv-SE")] - public class TimeSpanHumanizeTests - { - [Theory] - [InlineData(1, "1 millisekund")] - [InlineData(2, "2 millisekunder")] - public void Milliseconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); - - [Theory] - [InlineData(1, "1 sekund")] - [InlineData(2, "2 sekunder")] - public void Seconds(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); - - [Theory] - [InlineData(1, "1 minut")] - [InlineData(2, "2 minuter")] - public void Minutes(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); - - [Theory] - [InlineData(1, "1 timma")] - [InlineData(2, "2 timmar")] - public void Hours(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); - - [Theory] - [InlineData(1, "1 dag")] - [InlineData(2, "2 dagar")] - public void Days(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); - - [Theory] - [InlineData(1, "1 vecka")] - [InlineData(2, "2 veckor")] - public void Weeks(int number, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "en månad")] - [InlineData(61, "2 månader")] - [InlineData(92, "3 månader")] - [InlineData(335, "11 månader")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "ett år")] - [InlineData(731, "2 år")] - [InlineData(1096, "3 år")] - [InlineData(4018, "11 år")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - } -} + [Theory] + [InlineData(1, "1 millisekund")] + [InlineData(2, "2 millisekunder")] + public void Milliseconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(number).Humanize()); + + [Theory] + [InlineData(1, "1 sekund")] + [InlineData(2, "2 sekunder")] + public void Seconds(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(number).Humanize()); + + [Theory] + [InlineData(1, "1 minut")] + [InlineData(2, "2 minuter")] + public void Minutes(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(number).Humanize()); + + [Theory] + [InlineData(1, "1 timma")] + [InlineData(2, "2 timmar")] + public void Hours(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(number).Humanize()); + + [Theory] + [InlineData(1, "1 dag")] + [InlineData(2, "2 dagar")] + public void Days(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number).Humanize()); + + [Theory] + [InlineData(1, "1 vecka")] + [InlineData(2, "2 veckor")] + public void Weeks(int number, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(number * 7).Humanize()); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "en månad")] + [InlineData(61, "2 månader")] + [InlineData(92, "3 månader")] + [InlineData(335, "11 månader")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "ett år")] + [InlineData(731, "2 år")] + [InlineData(1096, "3 år")] + [InlineData(4018, "11 år")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/ta/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/ta/NumberToWordsTests.cs index 0b957d5c0..e5e8b57cc 100644 --- a/src/Humanizer.Tests/Localisation/ta/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/ta/NumberToWordsTests.cs @@ -1,99 +1,98 @@ -namespace Humanizer.Tests.Localisation.ta +namespace Humanizer.Tests.Localisation.ta; + +[UseCulture("ta")] +public class NumberToWordsTests { - [UseCulture("ta")] - public class NumberToWordsTests - { - //http://tnschools.gov.in/media/textbooks/3rd_Maths_Science_and_Social_science_TM_Combine_pd_Full_Book.pdf page 12 - [Theory] - [InlineData(0, "சுழியம்")] - [InlineData(1, "ஒன்று")] - [InlineData(2, "இரண்டு")] - [InlineData(3, "மூன்று")] - [InlineData(4, "நான்கு")] - [InlineData(5, "ஐந்து")] - [InlineData(6, "ஆறு")] - [InlineData(7, "ஏழு")] - [InlineData(8, "எட்டு")] - [InlineData(9, "ஒன்பது")] - [InlineData(10, "பத்து")] - [InlineData(11, "பதினொன்று")] - [InlineData(12, "பனிரெண்டு")] - [InlineData(13, "பதிமூன்று")] - [InlineData(14, "பதினான்கு")] - [InlineData(15, "பதினைந்து")] - [InlineData(16, "பதினாறு")] - [InlineData(17, "பதினேழு")] - [InlineData(18, "பதினெட்டு")] - [InlineData(19, "பத்தொன்பது")] - [InlineData(20, "இருபது")] - [InlineData(21, "இருபத்து ஒன்று")] - [InlineData(30, "முப்பது")] - [InlineData(31, "முப்பத்து ஒன்று")] - [InlineData(40, "நாற்பது")] - [InlineData(41, "நாற்பத்தி ஒன்று")] - [InlineData(50, "ஐம்பது")] - [InlineData(60, "அறுபது")] - [InlineData(64, "அறுபத்து நான்கு")] + //http://tnschools.gov.in/media/textbooks/3rd_Maths_Science_and_Social_science_TM_Combine_pd_Full_Book.pdf page 12 + [Theory] + [InlineData(0, "சுழியம்")] + [InlineData(1, "ஒன்று")] + [InlineData(2, "இரண்டு")] + [InlineData(3, "மூன்று")] + [InlineData(4, "நான்கு")] + [InlineData(5, "ஐந்து")] + [InlineData(6, "ஆறு")] + [InlineData(7, "ஏழு")] + [InlineData(8, "எட்டு")] + [InlineData(9, "ஒன்பது")] + [InlineData(10, "பத்து")] + [InlineData(11, "பதினொன்று")] + [InlineData(12, "பனிரெண்டு")] + [InlineData(13, "பதிமூன்று")] + [InlineData(14, "பதினான்கு")] + [InlineData(15, "பதினைந்து")] + [InlineData(16, "பதினாறு")] + [InlineData(17, "பதினேழு")] + [InlineData(18, "பதினெட்டு")] + [InlineData(19, "பத்தொன்பது")] + [InlineData(20, "இருபது")] + [InlineData(21, "இருபத்து ஒன்று")] + [InlineData(30, "முப்பது")] + [InlineData(31, "முப்பத்து ஒன்று")] + [InlineData(40, "நாற்பது")] + [InlineData(41, "நாற்பத்தி ஒன்று")] + [InlineData(50, "ஐம்பது")] + [InlineData(60, "அறுபது")] + [InlineData(64, "அறுபத்து நான்கு")] - [InlineData(70, "எழுபது")] - [InlineData(80, "எண்பது")] - [InlineData(89, "எண்பத்தி ஒன்பது")] - [InlineData(90, "தொண்ணூறு")] - [InlineData(95, "தொண்ணூற்றி ஐந்து")] - [InlineData(100, "நூறு")] - [InlineData(101, "நூற்று ஒன்று")] - [InlineData(121, "நூற்று இருபத்து ஒன்று")] - [InlineData(191, "நூற்று தொண்ணூற்றி ஒன்று")] - [InlineData(200, "இருநூறு")] - [InlineData(201, "இருநூற்று ஒன்று")] - [InlineData(411, "நானூற்று பதினொன்று")] - [InlineData(535, "ஐந்நூற்று முப்பத்து ஐந்து")] - [InlineData(985, "தொள்ளாயிரத்து எண்பத்தி ஐந்து")] - [InlineData(1000, "ஆயிரம்")] - [InlineData(1535, "ஆயிரத்து ஐந்நூற்று முப்பத்து ஐந்து")] - [InlineData(2000, "இரண்டாயிரம்")] - [InlineData(3000, "மூன்றாயிரம்")] - [InlineData(4000, "நான்காயிரம்")] - [InlineData(5000, "ஐந்தாயிரம்")] - [InlineData(6000, "ஆறாயிரம்")] - [InlineData(7000, "ஏழாயிரம்")] - [InlineData(8000, "எட்டாயிரம்")] - [InlineData(8888, "எட்டாயிரத்து எண்ணூற்று எண்பத்தி எட்டு")] - [InlineData(9000, "ஒன்பதாயிரம்")] - [InlineData(9999, "ஒன்பதாயிரத்து தொள்ளாயிரத்து தொண்ணூற்றி ஒன்பது")] - [InlineData(10000, "பத்தாயிரம்")] - [InlineData(20000, "இருபதாயிரம்")] - [InlineData(20005, "இருபதாயிரத்து ஐந்து")] - [InlineData(20205, "இருபதாயிரத்து இருநூற்று ஐந்து")] - [InlineData(25435, "இருபத்து ஐந்தாயிரத்து நானூற்று முப்பத்து ஐந்து")] - [InlineData(90995, "தொண்ணூறாயிரத்து தொள்ளாயிரத்து தொண்ணூற்றி ஐந்து")] - [InlineData(100000, "ஒரு இலட்சம்")] - [InlineData(1000000, "பத்து இலட்சம்")] - [InlineData(10000000, "ஒரு கோடி")] - [InlineData(100000000, "பத்து கோடி")] - [InlineData(1000000000, "நூறு கோடி")] - [InlineData(2000000000, "இருநூறு கோடி")] - [InlineData(122, "நூற்று இருபத்து இரண்டு")] - [InlineData(3501, "மூன்றாயிரத்து ஐந்நூற்று ஒன்று")] - [InlineData(111, "நூற்று பதினொன்று")] - [InlineData(1112, "ஆயிரத்து நூற்று பனிரெண்டு")] - [InlineData(11213, "பதினொன்றாயிரத்து இருநூற்று பதிமூன்று")] - [InlineData(121314, "ஒரு இலட்சத்து இருபத்து ஓராயிரத்து முன்னூற்று பதினான்கு")] - [InlineData(2132415, "இருபத்து ஒன்று இலட்சத்து முப்பத்து இரண்டாயிரத்து நானூற்று பதினைந்து")] - [InlineData(12345516, "ஒரு கோடியே இருபத்து மூன்று இலட்சத்து நாற்பத்தி ஐந்தாயிரத்து ஐந்நூற்று பதினாறு")] - [InlineData(751633617, "எழுபத்தி ஐந்து கோடியே பதினாறு இலட்சத்து முப்பத்து மூன்றாயிரத்து அறுநூற்று பதினேழு")] - [InlineData(1111111118, "நூற்று பதினொன்று கோடியே பதினொன்று இலட்சத்து பதினொன்றாயிரத்து நூற்று பதினெட்டு")] - [InlineData(35484694489515, "முப்பத்து ஐந்து இலட்சத்து நாற்பத்தி எட்டாயிரத்து நானூற்று அறுபத்து ஒன்பது கோடியே நாற்பத்தி நான்கு இலட்சத்து எண்பத்தி ஒன்பதாயிரத்து ஐந்நூற்று பதினைந்து")] - //[InlineData(8183162164626926, "எட்டு quadrillion கோடியே நாற்பத்தி ஆறு இலட்சத்து இருபத்து ஆறாயிரத்து தொள்ளாயிரத்து இருபத்து ஆறு")] - //[InlineData(4564121926659524672, "நான்கு quintillion ஐந்நூற்று அறுபத்து நான்கு quadrillion கோடியே தொண்ணூற்றி ஐந்து இலட்சத்து இருபத்து நான்காயிரத்து அறுநூற்று எழுபத்தி இரண்டு")] - [InlineData(-751633619, "கழித்தல் எழுபத்தி ஐந்து கோடியே பதினாறு இலட்சத்து முப்பத்து மூன்றாயிரத்து அறுநூற்று பத்தொன்பது")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [InlineData(70, "எழுபது")] + [InlineData(80, "எண்பது")] + [InlineData(89, "எண்பத்தி ஒன்பது")] + [InlineData(90, "தொண்ணூறு")] + [InlineData(95, "தொண்ணூற்றி ஐந்து")] + [InlineData(100, "நூறு")] + [InlineData(101, "நூற்று ஒன்று")] + [InlineData(121, "நூற்று இருபத்து ஒன்று")] + [InlineData(191, "நூற்று தொண்ணூற்றி ஒன்று")] + [InlineData(200, "இருநூறு")] + [InlineData(201, "இருநூற்று ஒன்று")] + [InlineData(411, "நானூற்று பதினொன்று")] + [InlineData(535, "ஐந்நூற்று முப்பத்து ஐந்து")] + [InlineData(985, "தொள்ளாயிரத்து எண்பத்தி ஐந்து")] + [InlineData(1000, "ஆயிரம்")] + [InlineData(1535, "ஆயிரத்து ஐந்நூற்று முப்பத்து ஐந்து")] + [InlineData(2000, "இரண்டாயிரம்")] + [InlineData(3000, "மூன்றாயிரம்")] + [InlineData(4000, "நான்காயிரம்")] + [InlineData(5000, "ஐந்தாயிரம்")] + [InlineData(6000, "ஆறாயிரம்")] + [InlineData(7000, "ஏழாயிரம்")] + [InlineData(8000, "எட்டாயிரம்")] + [InlineData(8888, "எட்டாயிரத்து எண்ணூற்று எண்பத்தி எட்டு")] + [InlineData(9000, "ஒன்பதாயிரம்")] + [InlineData(9999, "ஒன்பதாயிரத்து தொள்ளாயிரத்து தொண்ணூற்றி ஒன்பது")] + [InlineData(10000, "பத்தாயிரம்")] + [InlineData(20000, "இருபதாயிரம்")] + [InlineData(20005, "இருபதாயிரத்து ஐந்து")] + [InlineData(20205, "இருபதாயிரத்து இருநூற்று ஐந்து")] + [InlineData(25435, "இருபத்து ஐந்தாயிரத்து நானூற்று முப்பத்து ஐந்து")] + [InlineData(90995, "தொண்ணூறாயிரத்து தொள்ளாயிரத்து தொண்ணூற்றி ஐந்து")] + [InlineData(100000, "ஒரு இலட்சம்")] + [InlineData(1000000, "பத்து இலட்சம்")] + [InlineData(10000000, "ஒரு கோடி")] + [InlineData(100000000, "பத்து கோடி")] + [InlineData(1000000000, "நூறு கோடி")] + [InlineData(2000000000, "இருநூறு கோடி")] + [InlineData(122, "நூற்று இருபத்து இரண்டு")] + [InlineData(3501, "மூன்றாயிரத்து ஐந்நூற்று ஒன்று")] + [InlineData(111, "நூற்று பதினொன்று")] + [InlineData(1112, "ஆயிரத்து நூற்று பனிரெண்டு")] + [InlineData(11213, "பதினொன்றாயிரத்து இருநூற்று பதிமூன்று")] + [InlineData(121314, "ஒரு இலட்சத்து இருபத்து ஓராயிரத்து முன்னூற்று பதினான்கு")] + [InlineData(2132415, "இருபத்து ஒன்று இலட்சத்து முப்பத்து இரண்டாயிரத்து நானூற்று பதினைந்து")] + [InlineData(12345516, "ஒரு கோடியே இருபத்து மூன்று இலட்சத்து நாற்பத்தி ஐந்தாயிரத்து ஐந்நூற்று பதினாறு")] + [InlineData(751633617, "எழுபத்தி ஐந்து கோடியே பதினாறு இலட்சத்து முப்பத்து மூன்றாயிரத்து அறுநூற்று பதினேழு")] + [InlineData(1111111118, "நூற்று பதினொன்று கோடியே பதினொன்று இலட்சத்து பதினொன்றாயிரத்து நூற்று பதினெட்டு")] + [InlineData(35484694489515, "முப்பத்து ஐந்து இலட்சத்து நாற்பத்தி எட்டாயிரத்து நானூற்று அறுபத்து ஒன்பது கோடியே நாற்பத்தி நான்கு இலட்சத்து எண்பத்தி ஒன்பதாயிரத்து ஐந்நூற்று பதினைந்து")] + //[InlineData(8183162164626926, "எட்டு quadrillion கோடியே நாற்பத்தி ஆறு இலட்சத்து இருபத்து ஆறாயிரத்து தொள்ளாயிரத்து இருபத்து ஆறு")] + //[InlineData(4564121926659524672, "நான்கு quintillion ஐந்நூற்று அறுபத்து நான்கு quadrillion கோடியே தொண்ணூற்றி ஐந்து இலட்சத்து இருபத்து நான்காயிரத்து அறுநூற்று எழுபத்தி இரண்டு")] + [InlineData(-751633619, "கழித்தல் எழுபத்தி ஐந்து கோடியே பதினாறு இலட்சத்து முப்பத்து மூன்றாயிரத்து அறுநூற்று பத்தொன்பது")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "ஒன்று")] - [InlineData(3501, "மூன்றாயிரத்து ஐந்நூற்று ஒன்று")] - public void ToWordsFeminine(long number, string expected) => - Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); - } -} + [Theory] + [InlineData(1, "ஒன்று")] + [InlineData(3501, "மூன்றாயிரத்து ஐந்நூற்று ஒன்று")] + public void ToWordsFeminine(long number, string expected) => + Assert.Equal(expected, number.ToWords(GrammaticalGender.Feminine)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs index 079de20f5..6552b9647 100644 --- a/src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/th-TH/DateHumanizeTests.cs @@ -1,14 +1,13 @@ -namespace Humanizer.Tests.Localisation.thTH +namespace Humanizer.Tests.Localisation.thTH; + +[UseCulture("th-TH")] +public class DateHumanizeTests { - [UseCulture("th-TH")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "หนึ่งวินาทีที่แล้ว")] - [InlineData(10, "10 วินาทีที่แล้ว")] - [InlineData(59, "59 วินาทีที่แล้ว")] - [InlineData(60, "หนึ่งนาทีที่แล้ว")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - } -} + [Theory] + [InlineData(1, "หนึ่งวินาทีที่แล้ว")] + [InlineData(10, "10 วินาทีที่แล้ว")] + [InlineData(59, "59 วินาทีที่แล้ว")] + [InlineData(60, "หนึ่งนาทีที่แล้ว")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs index e22efbdb9..b66e30704 100644 --- a/src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/th-TH/NumberToWordsTests.cs @@ -1,31 +1,30 @@ -namespace Humanizer.Tests.Localisation.thTH +namespace Humanizer.Tests.Localisation.thTH; + +[UseCulture("th-TH")] +public class NumberToWordsTests { - [UseCulture("th-TH")] - public class NumberToWordsTests - { - [InlineData(1, "หนึ่ง")] - [InlineData(10, "สิบ")] - [InlineData(11, "สิบเอ็ด")] - [InlineData(20, "ยี่สิบ")] - [InlineData(-122, "ลบหนึ่งร้อยยี่สิบสอง")] - [InlineData(3501, "สามพันห้าร้อยหนึ่ง")] - [InlineData(100, "หนึ่งร้อย")] - [InlineData(1000, "หนึ่งพัน")] - [InlineData(10000, "หนึ่งหมื่น")] - [InlineData(-100000, "ลบหนึ่งแสน")] - [InlineData(1000000, "หนึ่งล้าน")] - [InlineData(10000000, "สิบล้าน")] - [InlineData(100000000, "หนึ่งร้อยล้าน")] - [InlineData(1000000000, "หนึ่งพันล้าน")] - [InlineData(111, "หนึ่งร้อยสิบเอ็ด")] - [InlineData(1111, "หนึ่งพันหนึ่งร้อยสิบเอ็ด")] - [InlineData(-111111, "ลบหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] - [InlineData(1111111, "หนึ่งล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] - [InlineData(11111111, "สิบเอ็ดล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] - [InlineData(111111111, "หนึ่งร้อยสิบเอ็ดล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] - [InlineData(1111111111, "หนึ่งพันหนึ่งร้อยสิบเอ็ดล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] - [Theory] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - } -} + [InlineData(1, "หนึ่ง")] + [InlineData(10, "สิบ")] + [InlineData(11, "สิบเอ็ด")] + [InlineData(20, "ยี่สิบ")] + [InlineData(-122, "ลบหนึ่งร้อยยี่สิบสอง")] + [InlineData(3501, "สามพันห้าร้อยหนึ่ง")] + [InlineData(100, "หนึ่งร้อย")] + [InlineData(1000, "หนึ่งพัน")] + [InlineData(10000, "หนึ่งหมื่น")] + [InlineData(-100000, "ลบหนึ่งแสน")] + [InlineData(1000000, "หนึ่งล้าน")] + [InlineData(10000000, "สิบล้าน")] + [InlineData(100000000, "หนึ่งร้อยล้าน")] + [InlineData(1000000000, "หนึ่งพันล้าน")] + [InlineData(111, "หนึ่งร้อยสิบเอ็ด")] + [InlineData(1111, "หนึ่งพันหนึ่งร้อยสิบเอ็ด")] + [InlineData(-111111, "ลบหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] + [InlineData(1111111, "หนึ่งล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] + [InlineData(11111111, "สิบเอ็ดล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] + [InlineData(111111111, "หนึ่งร้อยสิบเอ็ดล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] + [InlineData(1111111111, "หนึ่งพันหนึ่งร้อยสิบเอ็ดล้านหนึ่งแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบเอ็ด")] + [Theory] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/tr/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/tr/DateHumanizeTests.cs index e81afebde..0f6f3ede8 100644 --- a/src/Humanizer.Tests/Localisation/tr/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/tr/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.tr +namespace Humanizer.Tests.Localisation.tr; + +[UseCulture("tr")] +public class DateHumanizeTests { - [UseCulture("tr")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "bir saniye önce")] - [InlineData(10, "10 saniye önce")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "bir saniye önce")] + [InlineData(10, "10 saniye önce")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "bir saniye sonra")] - [InlineData(10, "10 saniye sonra")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "bir saniye sonra")] + [InlineData(10, "10 saniye sonra")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "bir dakika önce")] - [InlineData(10, "10 dakika önce")] - [InlineData(60, "bir saat önce")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "bir dakika önce")] + [InlineData(10, "10 dakika önce")] + [InlineData(60, "bir saat önce")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "bir dakika sonra")] - [InlineData(10, "10 dakika sonra")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "bir dakika sonra")] + [InlineData(10, "10 dakika sonra")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "bir saat önce")] - [InlineData(10, "10 saat önce")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "bir saat önce")] + [InlineData(10, "10 saat önce")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "bir saat sonra")] - [InlineData(10, "10 saat sonra")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "bir saat sonra")] + [InlineData(10, "10 saat sonra")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "dün")] - [InlineData(10, "10 gün önce")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "dün")] + [InlineData(10, "10 gün önce")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "yarın")] - [InlineData(10, "10 gün sonra")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "yarın")] + [InlineData(10, "10 gün sonra")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "bir ay önce")] - [InlineData(10, "10 ay önce")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "bir ay önce")] + [InlineData(10, "10 ay önce")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "bir ay sonra")] - [InlineData(10, "10 ay sonra")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "bir ay sonra")] + [InlineData(10, "10 ay sonra")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "bir yıl önce")] - [InlineData(2, "2 yıl önce")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "bir yıl önce")] + [InlineData(2, "2 yıl önce")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "bir yıl sonra")] - [InlineData(2, "2 yıl sonra")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "bir yıl sonra")] + [InlineData(2, "2 yıl sonra")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("şimdi", 0, TimeUnit.Year, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("şimdi", 0, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/tr/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/tr/NumberToWordsTests.cs index 2b5e07cd6..e44b1a893 100644 --- a/src/Humanizer.Tests/Localisation/tr/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/tr/NumberToWordsTests.cs @@ -1,68 +1,67 @@ -namespace Humanizer.Tests.Localisation.tr +namespace Humanizer.Tests.Localisation.tr; + +[UseCulture("tr")] +public class NumberToWordsTests { - [UseCulture("tr")] - public class NumberToWordsTests - { - [Theory] - [InlineData("sıfır", 0)] - [InlineData("bir", 1)] - [InlineData("iki", 2)] - [InlineData("on", 10)] - [InlineData("yüz on iki", 112)] - [InlineData("bin dört yüz kırk", 1440)] - [InlineData("yirmi iki", 22)] - [InlineData("on bir", 11)] - [InlineData("üç bin beş yüz bir", 3501)] - [InlineData("bir milyon bir", 1000001)] - [InlineData("eksi bir milyon üç yüz kırk altı bin yedi yüz on bir", -1346711)] - [InlineData("dokuz kentilyon iki yüz yirmi üç katrilyon üç yüz yetmiş iki trilyon otuz altı milyar sekiz yüz elli dört milyon yedi yüz yetmiş beş bin sekiz yüz yedi", 9223372036854775807)] - public void ToWords(string expected, long number) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData("sıfır", 0)] + [InlineData("bir", 1)] + [InlineData("iki", 2)] + [InlineData("on", 10)] + [InlineData("yüz on iki", 112)] + [InlineData("bin dört yüz kırk", 1440)] + [InlineData("yirmi iki", 22)] + [InlineData("on bir", 11)] + [InlineData("üç bin beş yüz bir", 3501)] + [InlineData("bir milyon bir", 1000001)] + [InlineData("eksi bir milyon üç yüz kırk altı bin yedi yüz on bir", -1346711)] + [InlineData("dokuz kentilyon iki yüz yirmi üç katrilyon üç yüz yetmiş iki trilyon otuz altı milyar sekiz yüz elli dört milyon yedi yüz yetmiş beş bin sekiz yüz yedi", 9223372036854775807)] + public void ToWords(string expected, long number) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "sıfırıncı")] - [InlineData(1, "birinci")] - [InlineData(2, "ikinci")] - [InlineData(3, "üçüncü")] - [InlineData(4, "dördüncü")] - [InlineData(5, "beşinci")] - [InlineData(6, "altıncı")] - [InlineData(7, "yedinci")] - [InlineData(8, "sekizinci")] - [InlineData(9, "dokuzuncu")] - [InlineData(10, "onuncu")] - [InlineData(11, "on birinci")] - [InlineData(12, "on ikinci")] - [InlineData(13, "on üçüncü")] - [InlineData(14, "on dördüncü")] - [InlineData(15, "on beşinci")] - [InlineData(16, "on altıncı")] - [InlineData(17, "on yedinci")] - [InlineData(18, "on sekizinci")] - [InlineData(19, "on dokuzuncu")] - [InlineData(20, "yirminci")] - [InlineData(21, "yirmi birinci")] - [InlineData(30, "otuzuncu")] - [InlineData(40, "kırkıncı")] - [InlineData(50, "ellinci")] - [InlineData(60, "altmışıncı")] - [InlineData(70, "yetmişinci")] - [InlineData(80, "sekseninci")] - [InlineData(90, "doksanıncı")] - [InlineData(100, "yüzüncü")] - [InlineData(120, "yüz yirminci")] - [InlineData(121, "yüz yirmi birinci")] - [InlineData(200, "iki yüzüncü")] - [InlineData(221, "iki yüz yirmi birinci")] - [InlineData(300, "üç yüzüncü")] - [InlineData(321, "üç yüz yirmi birinci")] - [InlineData(1000, "bininci")] - [InlineData(1001, "bin birinci")] - [InlineData(10000, "on bininci")] - [InlineData(100000, "yüz bininci")] - [InlineData(1000000, "bir milyonuncu")] - [InlineData(1022135, "bir milyon yirmi iki bin yüz otuz beşinci")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "sıfırıncı")] + [InlineData(1, "birinci")] + [InlineData(2, "ikinci")] + [InlineData(3, "üçüncü")] + [InlineData(4, "dördüncü")] + [InlineData(5, "beşinci")] + [InlineData(6, "altıncı")] + [InlineData(7, "yedinci")] + [InlineData(8, "sekizinci")] + [InlineData(9, "dokuzuncu")] + [InlineData(10, "onuncu")] + [InlineData(11, "on birinci")] + [InlineData(12, "on ikinci")] + [InlineData(13, "on üçüncü")] + [InlineData(14, "on dördüncü")] + [InlineData(15, "on beşinci")] + [InlineData(16, "on altıncı")] + [InlineData(17, "on yedinci")] + [InlineData(18, "on sekizinci")] + [InlineData(19, "on dokuzuncu")] + [InlineData(20, "yirminci")] + [InlineData(21, "yirmi birinci")] + [InlineData(30, "otuzuncu")] + [InlineData(40, "kırkıncı")] + [InlineData(50, "ellinci")] + [InlineData(60, "altmışıncı")] + [InlineData(70, "yetmişinci")] + [InlineData(80, "sekseninci")] + [InlineData(90, "doksanıncı")] + [InlineData(100, "yüzüncü")] + [InlineData(120, "yüz yirminci")] + [InlineData(121, "yüz yirmi birinci")] + [InlineData(200, "iki yüzüncü")] + [InlineData(221, "iki yüz yirmi birinci")] + [InlineData(300, "üç yüzüncü")] + [InlineData(321, "üç yüz yirmi birinci")] + [InlineData(1000, "bininci")] + [InlineData(1001, "bin birinci")] + [InlineData(10000, "on bininci")] + [InlineData(100000, "yüz bininci")] + [InlineData(1000000, "bir milyonuncu")] + [InlineData(1022135, "bir milyon yirmi iki bin yüz otuz beşinci")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/tr/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/tr/TimeSpanHumanizeTests.cs index 36d5cc521..f25200223 100644 --- a/src/Humanizer.Tests/Localisation/tr/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/tr/TimeSpanHumanizeTests.cs @@ -1,94 +1,93 @@ -namespace Humanizer.Tests.Localisation.tr +namespace Humanizer.Tests.Localisation.tr; + +[UseCulture("tr")] +public class TimeSpanHumanizeTests { - [UseCulture("tr")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 yıl")] - [InlineData(731, "2 yıl")] - [InlineData(1096, "3 yıl")] - [InlineData(4018, "11 yıl")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 yıl")] + [InlineData(731, "2 yıl")] + [InlineData(1096, "3 yıl")] + [InlineData(4018, "11 yıl")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 ay")] - [InlineData(61, "2 ay")] - [InlineData(92, "3 ay")] - [InlineData(335, "11 ay")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ay")] + [InlineData(61, "2 ay")] + [InlineData(92, "3 ay")] + [InlineData(335, "11 ay")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 hafta")] - [InlineData(7, "1 hafta")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(14, "2 hafta")] + [InlineData(7, "1 hafta")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(6, "6 gün")] - [InlineData(2, "2 gün")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(6, "6 gün")] + [InlineData(2, "2 gün")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 saat")] - [InlineData(1, "1 saat")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 saat")] + [InlineData(1, "1 saat")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 dakika")] - [InlineData(1, "1 dakika")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 dakika")] + [InlineData(1, "1 dakika")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 saniye")] - [InlineData(1, "1 saniye")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 saniye")] + [InlineData(1, "1 saniye")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 milisaniye")] - [InlineData(1, "1 milisaniye")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 milisaniye")] + [InlineData(1, "1 milisaniye")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } - [Fact] - public void NoTime() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(); - Assert.Equal("0 milisaniye", actual); - } + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("0 milisaniye", actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("zaman farkı yok", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("zaman farkı yok", actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uk-UA/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/uk-UA/DateHumanizeTests.cs index fcac9a2ae..44a54b4ed 100644 --- a/src/Humanizer.Tests/Localisation/uk-UA/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uk-UA/DateHumanizeTests.cs @@ -1,224 +1,223 @@ -namespace Humanizer.Tests.Localisation.ukUA +namespace Humanizer.Tests.Localisation.ukUA; + +[UseCulture("uk-UA")] +public class DateHumanizeTests { - [UseCulture("uk-UA")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "секунду тому")] - [InlineData(2, "2 секунди тому")] - [InlineData(3, "3 секунди тому")] - [InlineData(4, "4 секунди тому")] - [InlineData(5, "5 секунд тому")] - [InlineData(6, "6 секунд тому")] - [InlineData(10, "10 секунд тому")] - [InlineData(11, "11 секунд тому")] - [InlineData(19, "19 секунд тому")] - [InlineData(20, "20 секунд тому")] - [InlineData(21, "21 секунду тому")] - [InlineData(22, "22 секунди тому")] - [InlineData(23, "23 секунди тому")] - [InlineData(24, "24 секунди тому")] - [InlineData(25, "25 секунд тому")] - [InlineData(40, "40 секунд тому")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "секунду тому")] + [InlineData(2, "2 секунди тому")] + [InlineData(3, "3 секунди тому")] + [InlineData(4, "4 секунди тому")] + [InlineData(5, "5 секунд тому")] + [InlineData(6, "6 секунд тому")] + [InlineData(10, "10 секунд тому")] + [InlineData(11, "11 секунд тому")] + [InlineData(19, "19 секунд тому")] + [InlineData(20, "20 секунд тому")] + [InlineData(21, "21 секунду тому")] + [InlineData(22, "22 секунди тому")] + [InlineData(23, "23 секунди тому")] + [InlineData(24, "24 секунди тому")] + [InlineData(25, "25 секунд тому")] + [InlineData(40, "40 секунд тому")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "через секунду")] - [InlineData(2, "через 2 секунди")] - [InlineData(3, "через 3 секунди")] - [InlineData(4, "через 4 секунди")] - [InlineData(5, "через 5 секунд")] - [InlineData(6, "через 6 секунд")] - [InlineData(10, "через 10 секунд")] - [InlineData(11, "через 11 секунд")] - [InlineData(19, "через 19 секунд")] - [InlineData(20, "через 20 секунд")] - [InlineData(21, "через 21 секунду")] - [InlineData(22, "через 22 секунди")] - [InlineData(23, "через 23 секунди")] - [InlineData(24, "через 24 секунди")] - [InlineData(25, "через 25 секунд")] - [InlineData(40, "через 40 секунд")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "через секунду")] + [InlineData(2, "через 2 секунди")] + [InlineData(3, "через 3 секунди")] + [InlineData(4, "через 4 секунди")] + [InlineData(5, "через 5 секунд")] + [InlineData(6, "через 6 секунд")] + [InlineData(10, "через 10 секунд")] + [InlineData(11, "через 11 секунд")] + [InlineData(19, "через 19 секунд")] + [InlineData(20, "через 20 секунд")] + [InlineData(21, "через 21 секунду")] + [InlineData(22, "через 22 секунди")] + [InlineData(23, "через 23 секунди")] + [InlineData(24, "через 24 секунди")] + [InlineData(25, "через 25 секунд")] + [InlineData(40, "через 40 секунд")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "хвилину тому")] - [InlineData(2, "2 хвилини тому")] - [InlineData(3, "3 хвилини тому")] - [InlineData(4, "4 хвилини тому")] - [InlineData(5, "5 хвилин тому")] - [InlineData(6, "6 хвилин тому")] - [InlineData(10, "10 хвилин тому")] - [InlineData(11, "11 хвилин тому")] - [InlineData(19, "19 хвилин тому")] - [InlineData(20, "20 хвилин тому")] - [InlineData(21, "21 хвилину тому")] - [InlineData(22, "22 хвилини тому")] - [InlineData(23, "23 хвилини тому")] - [InlineData(24, "24 хвилини тому")] - [InlineData(25, "25 хвилин тому")] - [InlineData(40, "40 хвилин тому")] - [InlineData(60, "годину тому")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "хвилину тому")] + [InlineData(2, "2 хвилини тому")] + [InlineData(3, "3 хвилини тому")] + [InlineData(4, "4 хвилини тому")] + [InlineData(5, "5 хвилин тому")] + [InlineData(6, "6 хвилин тому")] + [InlineData(10, "10 хвилин тому")] + [InlineData(11, "11 хвилин тому")] + [InlineData(19, "19 хвилин тому")] + [InlineData(20, "20 хвилин тому")] + [InlineData(21, "21 хвилину тому")] + [InlineData(22, "22 хвилини тому")] + [InlineData(23, "23 хвилини тому")] + [InlineData(24, "24 хвилини тому")] + [InlineData(25, "25 хвилин тому")] + [InlineData(40, "40 хвилин тому")] + [InlineData(60, "годину тому")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "через хвилину")] - [InlineData(2, "через 2 хвилини")] - [InlineData(3, "через 3 хвилини")] - [InlineData(4, "через 4 хвилини")] - [InlineData(5, "через 5 хвилин")] - [InlineData(6, "через 6 хвилин")] - [InlineData(10, "через 10 хвилин")] - [InlineData(11, "через 11 хвилин")] - [InlineData(19, "через 19 хвилин")] - [InlineData(20, "через 20 хвилин")] - [InlineData(21, "через 21 хвилину")] - [InlineData(22, "через 22 хвилини")] - [InlineData(23, "через 23 хвилини")] - [InlineData(24, "через 24 хвилини")] - [InlineData(25, "через 25 хвилин")] - [InlineData(40, "через 40 хвилин")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "через хвилину")] + [InlineData(2, "через 2 хвилини")] + [InlineData(3, "через 3 хвилини")] + [InlineData(4, "через 4 хвилини")] + [InlineData(5, "через 5 хвилин")] + [InlineData(6, "через 6 хвилин")] + [InlineData(10, "через 10 хвилин")] + [InlineData(11, "через 11 хвилин")] + [InlineData(19, "через 19 хвилин")] + [InlineData(20, "через 20 хвилин")] + [InlineData(21, "через 21 хвилину")] + [InlineData(22, "через 22 хвилини")] + [InlineData(23, "через 23 хвилини")] + [InlineData(24, "через 24 хвилини")] + [InlineData(25, "через 25 хвилин")] + [InlineData(40, "через 40 хвилин")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "годину тому")] - [InlineData(2, "2 години тому")] - [InlineData(3, "3 години тому")] - [InlineData(4, "4 години тому")] - [InlineData(5, "5 годин тому")] - [InlineData(6, "6 годин тому")] - [InlineData(10, "10 годин тому")] - [InlineData(11, "11 годин тому")] - [InlineData(19, "19 годин тому")] - [InlineData(20, "20 годин тому")] - [InlineData(21, "21 годину тому")] - [InlineData(22, "22 години тому")] - [InlineData(23, "23 години тому")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "годину тому")] + [InlineData(2, "2 години тому")] + [InlineData(3, "3 години тому")] + [InlineData(4, "4 години тому")] + [InlineData(5, "5 годин тому")] + [InlineData(6, "6 годин тому")] + [InlineData(10, "10 годин тому")] + [InlineData(11, "11 годин тому")] + [InlineData(19, "19 годин тому")] + [InlineData(20, "20 годин тому")] + [InlineData(21, "21 годину тому")] + [InlineData(22, "22 години тому")] + [InlineData(23, "23 години тому")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "через годину")] - [InlineData(2, "через 2 години")] - [InlineData(3, "через 3 години")] - [InlineData(4, "через 4 години")] - [InlineData(5, "через 5 годин")] - [InlineData(6, "через 6 годин")] - [InlineData(10, "через 10 годин")] - [InlineData(11, "через 11 годин")] - [InlineData(19, "через 19 годин")] - [InlineData(20, "через 20 годин")] - [InlineData(21, "через 21 годину")] - [InlineData(22, "через 22 години")] - [InlineData(23, "через 23 години")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "через годину")] + [InlineData(2, "через 2 години")] + [InlineData(3, "через 3 години")] + [InlineData(4, "через 4 години")] + [InlineData(5, "через 5 годин")] + [InlineData(6, "через 6 годин")] + [InlineData(10, "через 10 годин")] + [InlineData(11, "через 11 годин")] + [InlineData(19, "через 19 годин")] + [InlineData(20, "через 20 годин")] + [InlineData(21, "через 21 годину")] + [InlineData(22, "через 22 години")] + [InlineData(23, "через 23 години")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "вчора")] - [InlineData(2, "2 дні тому")] - [InlineData(3, "3 дні тому")] - [InlineData(4, "4 дні тому")] - [InlineData(5, "5 днів тому")] - [InlineData(6, "6 днів тому")] - [InlineData(10, "10 днів тому")] - [InlineData(11, "11 днів тому")] - [InlineData(19, "19 днів тому")] - [InlineData(20, "20 днів тому")] - [InlineData(21, "21 день тому")] - [InlineData(22, "22 дні тому")] - [InlineData(23, "23 дні тому")] - [InlineData(24, "24 дні тому")] - [InlineData(25, "25 днів тому")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "вчора")] + [InlineData(2, "2 дні тому")] + [InlineData(3, "3 дні тому")] + [InlineData(4, "4 дні тому")] + [InlineData(5, "5 днів тому")] + [InlineData(6, "6 днів тому")] + [InlineData(10, "10 днів тому")] + [InlineData(11, "11 днів тому")] + [InlineData(19, "19 днів тому")] + [InlineData(20, "20 днів тому")] + [InlineData(21, "21 день тому")] + [InlineData(22, "22 дні тому")] + [InlineData(23, "23 дні тому")] + [InlineData(24, "24 дні тому")] + [InlineData(25, "25 днів тому")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "завтра")] - [InlineData(2, "через 2 дні")] - [InlineData(3, "через 3 дні")] - [InlineData(4, "через 4 дні")] - [InlineData(5, "через 5 днів")] - [InlineData(6, "через 6 днів")] - [InlineData(10, "через 10 днів")] - [InlineData(11, "через 11 днів")] - [InlineData(19, "через 19 днів")] - [InlineData(20, "через 20 днів")] - [InlineData(21, "через 21 день")] - [InlineData(22, "через 22 дні")] - [InlineData(23, "через 23 дні")] - [InlineData(24, "через 24 дні")] - [InlineData(25, "через 25 днів")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "завтра")] + [InlineData(2, "через 2 дні")] + [InlineData(3, "через 3 дні")] + [InlineData(4, "через 4 дні")] + [InlineData(5, "через 5 днів")] + [InlineData(6, "через 6 днів")] + [InlineData(10, "через 10 днів")] + [InlineData(11, "через 11 днів")] + [InlineData(19, "через 19 днів")] + [InlineData(20, "через 20 днів")] + [InlineData(21, "через 21 день")] + [InlineData(22, "через 22 дні")] + [InlineData(23, "через 23 дні")] + [InlineData(24, "через 24 дні")] + [InlineData(25, "через 25 днів")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "місяць тому")] - [InlineData(2, "2 місяці тому")] - [InlineData(3, "3 місяці тому")] - [InlineData(4, "4 місяці тому")] - [InlineData(5, "5 місяців тому")] - [InlineData(6, "6 місяців тому")] - [InlineData(10, "10 місяців тому")] - [InlineData(11, "11 місяців тому")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "місяць тому")] + [InlineData(2, "2 місяці тому")] + [InlineData(3, "3 місяці тому")] + [InlineData(4, "4 місяці тому")] + [InlineData(5, "5 місяців тому")] + [InlineData(6, "6 місяців тому")] + [InlineData(10, "10 місяців тому")] + [InlineData(11, "11 місяців тому")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "через місяць")] - [InlineData(2, "через 2 місяці")] - [InlineData(3, "через 3 місяці")] - [InlineData(4, "через 4 місяці")] - [InlineData(5, "через 5 місяців")] - [InlineData(6, "через 6 місяців")] - [InlineData(10, "через 10 місяців")] - [InlineData(11, "через 11 місяців")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "через місяць")] + [InlineData(2, "через 2 місяці")] + [InlineData(3, "через 3 місяці")] + [InlineData(4, "через 4 місяці")] + [InlineData(5, "через 5 місяців")] + [InlineData(6, "через 6 місяців")] + [InlineData(10, "через 10 місяців")] + [InlineData(11, "через 11 місяців")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "рік тому")] - [InlineData(2, "2 роки тому")] - [InlineData(3, "3 роки тому")] - [InlineData(4, "4 роки тому")] - [InlineData(5, "5 років тому")] - [InlineData(6, "6 років тому")] - [InlineData(10, "10 років тому")] - [InlineData(11, "11 років тому")] - [InlineData(19, "19 років тому")] - [InlineData(21, "21 рік тому")] - [InlineData(111, "111 років тому")] - [InlineData(121, "121 рік тому")] - [InlineData(222, "222 роки тому")] - [InlineData(325, "325 років тому")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "рік тому")] + [InlineData(2, "2 роки тому")] + [InlineData(3, "3 роки тому")] + [InlineData(4, "4 роки тому")] + [InlineData(5, "5 років тому")] + [InlineData(6, "6 років тому")] + [InlineData(10, "10 років тому")] + [InlineData(11, "11 років тому")] + [InlineData(19, "19 років тому")] + [InlineData(21, "21 рік тому")] + [InlineData(111, "111 років тому")] + [InlineData(121, "121 рік тому")] + [InlineData(222, "222 роки тому")] + [InlineData(325, "325 років тому")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "через рік")] - [InlineData(2, "через 2 роки")] - [InlineData(3, "через 3 роки")] - [InlineData(4, "через 4 роки")] - [InlineData(5, "через 5 років")] - [InlineData(6, "через 6 років")] - [InlineData(10, "через 10 років")] - [InlineData(11, "через 11 років")] - [InlineData(19, "через 19 років")] - [InlineData(20, "через 20 років")] - [InlineData(21, "через 21 рік")] - [InlineData(111, "через 111 років")] - [InlineData(121, "через 121 рік")] - [InlineData(222, "через 222 роки")] - [InlineData(325, "через 325 років")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "через рік")] + [InlineData(2, "через 2 роки")] + [InlineData(3, "через 3 роки")] + [InlineData(4, "через 4 роки")] + [InlineData(5, "через 5 років")] + [InlineData(6, "через 6 років")] + [InlineData(10, "через 10 років")] + [InlineData(11, "через 11 років")] + [InlineData(19, "через 19 років")] + [InlineData(20, "через 20 років")] + [InlineData(21, "через 21 рік")] + [InlineData(111, "через 111 років")] + [InlineData(121, "через 121 рік")] + [InlineData(222, "через 222 роки")] + [InlineData(325, "через 325 років")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("зараз", 0, TimeUnit.Day, Tense.Past); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("зараз", 0, TimeUnit.Day, Tense.Past); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uk-UA/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/uk-UA/NumberToWordsTests.cs index 1dfd5afdf..fc2f9d0fb 100644 --- a/src/Humanizer.Tests/Localisation/uk-UA/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/uk-UA/NumberToWordsTests.cs @@ -1,245 +1,244 @@ -namespace Humanizer.Tests.Localisation.ukUA +namespace Humanizer.Tests.Localisation.ukUA; + +[UseCulture("uk-UA")] +public class NumberToWordsTests { - [UseCulture("uk-UA")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "нуль")] - [InlineData(1, "один")] - [InlineData(10, "десять")] - [InlineData(11, "одинадцять")] - [InlineData(12, "дванадцять")] - [InlineData(13, "тринадцять")] - [InlineData(14, "чотирнадцять")] - [InlineData(15, "п'ятнадцять")] - [InlineData(16, "шістнадцять")] - [InlineData(17, "сімнадцять")] - [InlineData(18, "вісімнадцять")] - [InlineData(19, "дев'ятнадцять")] - [InlineData(20, "двадцять")] - [InlineData(30, "тридцять")] - [InlineData(40, "сорок")] - [InlineData(50, "п'ятдесят")] - [InlineData(60, "шістдесят")] - [InlineData(70, "сімдесят")] - [InlineData(80, "вісімдесят")] - [InlineData(90, "дев'яносто")] - [InlineData(100, "сто")] - [InlineData(200, "двісті")] - [InlineData(300, "триста")] - [InlineData(400, "чотириста")] - [InlineData(500, "п'ятсот")] - [InlineData(600, "шістсот")] - [InlineData(700, "сімсот")] - [InlineData(800, "вісімсот")] - [InlineData(900, "дев'ятсот")] - [InlineData(1000, "одна тисяча")] - [InlineData(2000, "дві тисячі")] - [InlineData(3000, "три тисячі")] - [InlineData(4000, "чотири тисячі")] - [InlineData(5000, "п'ять тисяч")] - [InlineData(10000, "десять тисяч")] - [InlineData(100000, "сто тисяч")] - [InlineData(1000000, "один мільйон")] - [InlineData(2000000, "два мільйона")] - [InlineData(10000000, "десять мільйонів")] - [InlineData(100000000, "сто мільйонів")] - [InlineData(1000000000, "один мільярд")] - [InlineData(2000000000, "два мільярда")] - [InlineData(122, "сто двадцять два")] - [InlineData(3501, "три тисячі п'ятсот один")] - [InlineData(111, "сто одинадцять")] - [InlineData(1112, "одна тисяча сто дванадцять")] - [InlineData(11213, "одинадцять тисяч двісті тринадцять")] - [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцять")] - [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцять")] - [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцять")] - [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцять")] - [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцять")] - [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцять")] - [InlineData(1_000_000_000_000, "один трильйон")] - [InlineData(3_000_000_000_000, "три трильйона")] - [InlineData(5_000_000_000_000, "п'ять трильйонів")] - [InlineData(999_000_000_000_000, "дев'ятсот дев'яносто дев'ять трильйонів")] - [InlineData( - long.MaxValue, - "дев'ять квінтильйонів " + - "двісті двадцять три квадрильйона " + - "триста сімдесят два трильйона " + - "тридцять шість мільярдів " + - "вісімсот п'ятдесят чотири мільйона " + - "сімсот сімдесят п'ять тисяч " + - "вісімсот сім")] - [InlineData( - long.MinValue, - "мінус дев'ять квінтильйонів " + - "двісті двадцять три квадрильйона " + - "триста сімдесят два трильйона " + - "тридцять шість мільярдів " + - "вісімсот п'ятдесят чотири мільйона " + - "сімсот сімдесят п'ять тисяч " + - "вісімсот вісім")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "нуль")] + [InlineData(1, "один")] + [InlineData(10, "десять")] + [InlineData(11, "одинадцять")] + [InlineData(12, "дванадцять")] + [InlineData(13, "тринадцять")] + [InlineData(14, "чотирнадцять")] + [InlineData(15, "п'ятнадцять")] + [InlineData(16, "шістнадцять")] + [InlineData(17, "сімнадцять")] + [InlineData(18, "вісімнадцять")] + [InlineData(19, "дев'ятнадцять")] + [InlineData(20, "двадцять")] + [InlineData(30, "тридцять")] + [InlineData(40, "сорок")] + [InlineData(50, "п'ятдесят")] + [InlineData(60, "шістдесят")] + [InlineData(70, "сімдесят")] + [InlineData(80, "вісімдесят")] + [InlineData(90, "дев'яносто")] + [InlineData(100, "сто")] + [InlineData(200, "двісті")] + [InlineData(300, "триста")] + [InlineData(400, "чотириста")] + [InlineData(500, "п'ятсот")] + [InlineData(600, "шістсот")] + [InlineData(700, "сімсот")] + [InlineData(800, "вісімсот")] + [InlineData(900, "дев'ятсот")] + [InlineData(1000, "одна тисяча")] + [InlineData(2000, "дві тисячі")] + [InlineData(3000, "три тисячі")] + [InlineData(4000, "чотири тисячі")] + [InlineData(5000, "п'ять тисяч")] + [InlineData(10000, "десять тисяч")] + [InlineData(100000, "сто тисяч")] + [InlineData(1000000, "один мільйон")] + [InlineData(2000000, "два мільйона")] + [InlineData(10000000, "десять мільйонів")] + [InlineData(100000000, "сто мільйонів")] + [InlineData(1000000000, "один мільярд")] + [InlineData(2000000000, "два мільярда")] + [InlineData(122, "сто двадцять два")] + [InlineData(3501, "три тисячі п'ятсот один")] + [InlineData(111, "сто одинадцять")] + [InlineData(1112, "одна тисяча сто дванадцять")] + [InlineData(11213, "одинадцять тисяч двісті тринадцять")] + [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцять")] + [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцять")] + [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцять")] + [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцять")] + [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцять")] + [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцять")] + [InlineData(1_000_000_000_000, "один трильйон")] + [InlineData(3_000_000_000_000, "три трильйона")] + [InlineData(5_000_000_000_000, "п'ять трильйонів")] + [InlineData(999_000_000_000_000, "дев'ятсот дев'яносто дев'ять трильйонів")] + [InlineData( + long.MaxValue, + "дев'ять квінтильйонів " + + "двісті двадцять три квадрильйона " + + "триста сімдесят два трильйона " + + "тридцять шість мільярдів " + + "вісімсот п'ятдесят чотири мільйона " + + "сімсот сімдесят п'ять тисяч " + + "вісімсот сім")] + [InlineData( + long.MinValue, + "мінус дев'ять квінтильйонів " + + "двісті двадцять три квадрильйона " + + "триста сімдесят два трильйона " + + "тридцять шість мільярдів " + + "вісімсот п'ятдесят чотири мільйона " + + "сімсот сімдесят п'ять тисяч " + + "вісімсот вісім")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(122, "сто двадцять дві", GrammaticalGender.Feminine)] - [InlineData(3501, "три тисячі п'ятсот одна", GrammaticalGender.Feminine)] - [InlineData(3501, "три тисячі п'ятсот одне", GrammaticalGender.Neuter)] - public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => - Assert.Equal(expected, number.ToWords(gender)); + [Theory] + [InlineData(122, "сто двадцять дві", GrammaticalGender.Feminine)] + [InlineData(3501, "три тисячі п'ятсот одна", GrammaticalGender.Feminine)] + [InlineData(3501, "три тисячі п'ятсот одне", GrammaticalGender.Neuter)] + public void ToWordsWithGender(int number, string expected, GrammaticalGender gender) => + Assert.Equal(expected, number.ToWords(gender)); - [Theory] - [InlineData(0, "нульовий")] - [InlineData(1, "перший")] - [InlineData(2, "другий")] - [InlineData(3, "третій")] - [InlineData(4, "четвертий")] - [InlineData(10, "десятий")] - [InlineData(11, "одинадцятий")] - [InlineData(12, "дванадцятий")] - [InlineData(13, "тринадцятий")] - [InlineData(14, "чотирнадцятий")] - [InlineData(15, "п'ятнадцятий")] - [InlineData(16, "шістнадцятий")] - [InlineData(17, "сімнадцятий")] - [InlineData(18, "вісімнадцятий")] - [InlineData(19, "дев'ятнадцятий")] - [InlineData(20, "двадцятий")] - [InlineData(30, "тридцятий")] - [InlineData(40, "сороковий")] - [InlineData(50, "п'ятдесятий")] - [InlineData(60, "шістдесятий")] - [InlineData(70, "сімдесятий")] - [InlineData(80, "вісімдесятий")] - [InlineData(90, "дев'яностий")] - [InlineData(100, "сотий")] - [InlineData(101, "сто перший")] - [InlineData(140, "сто сороковий")] - [InlineData(200, "двохсотий")] - [InlineData(300, "трьохсотий")] - [InlineData(400, "чотирьохсотий")] - [InlineData(500, "п'ятисотий")] - [InlineData(600, "шестисотий")] - [InlineData(700, "семисотий")] - [InlineData(800, "восьмисотий")] - [InlineData(900, "дев'ятисотий")] - [InlineData(1000, "тисячний")] - [InlineData(1001, "одна тисяча перший")] - [InlineData(1040, "одна тисяча сороковий")] - [InlineData(2000, "двохтисячний")] - [InlineData(3000, "трьохтисячний")] - [InlineData(4000, "чотирьохтисячний")] - [InlineData(5000, "п'ятитисячний")] - [InlineData(10000, "десятитисячний")] - [InlineData(21000, "двадцятиоднотисячний")] - [InlineData(100000, "стотисячний")] - [InlineData(101000, "стооднотисячний")] - [InlineData(121000, "стодвадцятиоднотисячний")] - [InlineData(200000, "двохсоттисячний")] - [InlineData(1000000, "мільйонний")] - [InlineData(2000000, "двохмільйонний")] - [InlineData(10000000, "десятимільйонний")] - [InlineData(21000000, "двадцятиодномільйонний")] - [InlineData(100000000, "стомільйонний")] - [InlineData(230000000, "двохсоттридцятимільйонний")] - [InlineData(1000000000, "мільярдний")] - [InlineData(2000000000, "двохмільярдний")] - [InlineData(122, "сто двадцять другий")] - [InlineData(3501, "три тисячі п'ятсот перший")] - [InlineData(111, "сто одинадцятий")] - [InlineData(1112, "одна тисяча сто дванадцятий")] - [InlineData(11213, "одинадцять тисяч двісті тринадцятий")] - [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцятий")] - [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцятий")] - [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцятий")] - [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцятий")] - [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцятий")] - [InlineData(1111111000, "один мільярд сто одинадцять мільйонів стоодинадцятитисячний")] - [InlineData(1234567000, "один мільярд двісті тридцять чотири мільйона п'ятисотшістдесятисемитисячний")] - [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцятий")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); + [Theory] + [InlineData(0, "нульовий")] + [InlineData(1, "перший")] + [InlineData(2, "другий")] + [InlineData(3, "третій")] + [InlineData(4, "четвертий")] + [InlineData(10, "десятий")] + [InlineData(11, "одинадцятий")] + [InlineData(12, "дванадцятий")] + [InlineData(13, "тринадцятий")] + [InlineData(14, "чотирнадцятий")] + [InlineData(15, "п'ятнадцятий")] + [InlineData(16, "шістнадцятий")] + [InlineData(17, "сімнадцятий")] + [InlineData(18, "вісімнадцятий")] + [InlineData(19, "дев'ятнадцятий")] + [InlineData(20, "двадцятий")] + [InlineData(30, "тридцятий")] + [InlineData(40, "сороковий")] + [InlineData(50, "п'ятдесятий")] + [InlineData(60, "шістдесятий")] + [InlineData(70, "сімдесятий")] + [InlineData(80, "вісімдесятий")] + [InlineData(90, "дев'яностий")] + [InlineData(100, "сотий")] + [InlineData(101, "сто перший")] + [InlineData(140, "сто сороковий")] + [InlineData(200, "двохсотий")] + [InlineData(300, "трьохсотий")] + [InlineData(400, "чотирьохсотий")] + [InlineData(500, "п'ятисотий")] + [InlineData(600, "шестисотий")] + [InlineData(700, "семисотий")] + [InlineData(800, "восьмисотий")] + [InlineData(900, "дев'ятисотий")] + [InlineData(1000, "тисячний")] + [InlineData(1001, "одна тисяча перший")] + [InlineData(1040, "одна тисяча сороковий")] + [InlineData(2000, "двохтисячний")] + [InlineData(3000, "трьохтисячний")] + [InlineData(4000, "чотирьохтисячний")] + [InlineData(5000, "п'ятитисячний")] + [InlineData(10000, "десятитисячний")] + [InlineData(21000, "двадцятиоднотисячний")] + [InlineData(100000, "стотисячний")] + [InlineData(101000, "стооднотисячний")] + [InlineData(121000, "стодвадцятиоднотисячний")] + [InlineData(200000, "двохсоттисячний")] + [InlineData(1000000, "мільйонний")] + [InlineData(2000000, "двохмільйонний")] + [InlineData(10000000, "десятимільйонний")] + [InlineData(21000000, "двадцятиодномільйонний")] + [InlineData(100000000, "стомільйонний")] + [InlineData(230000000, "двохсоттридцятимільйонний")] + [InlineData(1000000000, "мільярдний")] + [InlineData(2000000000, "двохмільярдний")] + [InlineData(122, "сто двадцять другий")] + [InlineData(3501, "три тисячі п'ятсот перший")] + [InlineData(111, "сто одинадцятий")] + [InlineData(1112, "одна тисяча сто дванадцятий")] + [InlineData(11213, "одинадцять тисяч двісті тринадцятий")] + [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцятий")] + [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцятий")] + [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцятий")] + [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцятий")] + [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцятий")] + [InlineData(1111111000, "один мільярд сто одинадцять мільйонів стоодинадцятитисячний")] + [InlineData(1234567000, "один мільярд двісті тридцять чотири мільйона п'ятисотшістдесятисемитисячний")] + [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцятий")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); - [Theory] - [InlineData(0, "нульова")] - [InlineData(1, "перша")] - [InlineData(2, "друга")] - [InlineData(3, "третя")] - [InlineData(4, "четверта")] - [InlineData(10, "десята")] - [InlineData(11, "одинадцята")] - [InlineData(12, "дванадцята")] - [InlineData(13, "тринадцята")] - [InlineData(14, "чотирнадцята")] - [InlineData(15, "п'ятнадцята")] - [InlineData(16, "шістнадцята")] - [InlineData(17, "сімнадцята")] - [InlineData(18, "вісімнадцята")] - [InlineData(19, "дев'ятнадцята")] - [InlineData(20, "двадцята")] - [InlineData(30, "тридцята")] - [InlineData(40, "сорокова")] - [InlineData(50, "п'ятдесята")] - [InlineData(60, "шістдесята")] - [InlineData(70, "сімдесята")] - [InlineData(80, "вісімдесята")] - [InlineData(90, "дев'яноста")] - [InlineData(100, "сота")] - [InlineData(200, "двохсота")] - [InlineData(300, "трьохсота")] - [InlineData(400, "чотирьохсота")] - [InlineData(500, "п'ятисота")] - [InlineData(600, "шестисота")] - [InlineData(700, "семисота")] - [InlineData(800, "восьмисота")] - [InlineData(900, "дев'ятисота")] - [InlineData(1000, "тисячна")] - [InlineData(2000, "двохтисячна")] - [InlineData(3000, "трьохтисячна")] - [InlineData(4000, "чотирьохтисячна")] - [InlineData(5000, "п'ятитисячна")] - [InlineData(10000, "десятитисячна")] - [InlineData(90000, "дев'яностотисячна")] - [InlineData(100000, "стотисячна")] - [InlineData(990000, "дев'ятисотдев'яностотисячна")] - [InlineData(990001, "дев'ятсот дев'яносто тисяч перша")] - [InlineData(1000000, "мільйонна")] - [InlineData(2000000, "двохмільйонна")] - [InlineData(10000000, "десятимільйонна")] - [InlineData(100000000, "стомільйонна")] - [InlineData(1000000000, "мільярдна")] - [InlineData(2000000000, "двохмільярдна")] - [InlineData(122, "сто двадцять друга")] - [InlineData(3501, "три тисячі п'ятсот перша")] - [InlineData(111, "сто одинадцята")] - [InlineData(1112, "одна тисяча сто дванадцята")] - [InlineData(11000, "одинадцятитисячна")] - [InlineData(11001, "одинадцять тисяч перша")] - [InlineData(11213, "одинадцять тисяч двісті тринадцята")] - [InlineData(15000, "п'ятнадцятитисячна")] - [InlineData(20000, "двадцятитисячна")] - [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцята")] - [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцята")] - [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцята")] - [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцята")] - [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцята")] - [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцята")] - public void ToOrdinalWordsFeminine(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); + [Theory] + [InlineData(0, "нульова")] + [InlineData(1, "перша")] + [InlineData(2, "друга")] + [InlineData(3, "третя")] + [InlineData(4, "четверта")] + [InlineData(10, "десята")] + [InlineData(11, "одинадцята")] + [InlineData(12, "дванадцята")] + [InlineData(13, "тринадцята")] + [InlineData(14, "чотирнадцята")] + [InlineData(15, "п'ятнадцята")] + [InlineData(16, "шістнадцята")] + [InlineData(17, "сімнадцята")] + [InlineData(18, "вісімнадцята")] + [InlineData(19, "дев'ятнадцята")] + [InlineData(20, "двадцята")] + [InlineData(30, "тридцята")] + [InlineData(40, "сорокова")] + [InlineData(50, "п'ятдесята")] + [InlineData(60, "шістдесята")] + [InlineData(70, "сімдесята")] + [InlineData(80, "вісімдесята")] + [InlineData(90, "дев'яноста")] + [InlineData(100, "сота")] + [InlineData(200, "двохсота")] + [InlineData(300, "трьохсота")] + [InlineData(400, "чотирьохсота")] + [InlineData(500, "п'ятисота")] + [InlineData(600, "шестисота")] + [InlineData(700, "семисота")] + [InlineData(800, "восьмисота")] + [InlineData(900, "дев'ятисота")] + [InlineData(1000, "тисячна")] + [InlineData(2000, "двохтисячна")] + [InlineData(3000, "трьохтисячна")] + [InlineData(4000, "чотирьохтисячна")] + [InlineData(5000, "п'ятитисячна")] + [InlineData(10000, "десятитисячна")] + [InlineData(90000, "дев'яностотисячна")] + [InlineData(100000, "стотисячна")] + [InlineData(990000, "дев'ятисотдев'яностотисячна")] + [InlineData(990001, "дев'ятсот дев'яносто тисяч перша")] + [InlineData(1000000, "мільйонна")] + [InlineData(2000000, "двохмільйонна")] + [InlineData(10000000, "десятимільйонна")] + [InlineData(100000000, "стомільйонна")] + [InlineData(1000000000, "мільярдна")] + [InlineData(2000000000, "двохмільярдна")] + [InlineData(122, "сто двадцять друга")] + [InlineData(3501, "три тисячі п'ятсот перша")] + [InlineData(111, "сто одинадцята")] + [InlineData(1112, "одна тисяча сто дванадцята")] + [InlineData(11000, "одинадцятитисячна")] + [InlineData(11001, "одинадцять тисяч перша")] + [InlineData(11213, "одинадцять тисяч двісті тринадцята")] + [InlineData(15000, "п'ятнадцятитисячна")] + [InlineData(20000, "двадцятитисячна")] + [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцята")] + [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцята")] + [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцята")] + [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцята")] + [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцята")] + [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцята")] + public void ToOrdinalWordsFeminine(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Feminine)); - [Theory] - [InlineData(3, "третє")] - [InlineData(111, "сто одинадцяте")] - [InlineData(1112, "одна тисяча сто дванадцяте")] - [InlineData(11213, "одинадцять тисяч двісті тринадцяте")] - [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцяте")] - [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцяте")] - [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцяте")] - [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцяте")] - [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцяте")] - [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцяте")] - public void ToOrdinalWordsNeuter(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); - } -} + [Theory] + [InlineData(3, "третє")] + [InlineData(111, "сто одинадцяте")] + [InlineData(1112, "одна тисяча сто дванадцяте")] + [InlineData(11213, "одинадцять тисяч двісті тринадцяте")] + [InlineData(121314, "сто двадцять одна тисяча триста чотирнадцяте")] + [InlineData(2132415, "два мільйона сто тридцять дві тисячі чотириста п'ятнадцяте")] + [InlineData(12345516, "дванадцять мільйонів триста сорок п'ять тисяч п'ятсот шістнадцяте")] + [InlineData(751633617, "сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцяте")] + [InlineData(1111111118, "один мільярд сто одинадцять мільйонів сто одинадцять тисяч сто вісімнадцяте")] + [InlineData(-751633617, "мінус сімсот п'ятдесят один мільйон шістсот тридцять три тисячі шістсот сімнадцяте")] + public void ToOrdinalWordsNeuter(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(GrammaticalGender.Neuter)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uk-UA/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/uk-UA/OrdinalizeTests.cs index f533dce02..84a7c4db5 100644 --- a/src/Humanizer.Tests/Localisation/uk-UA/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uk-UA/OrdinalizeTests.cs @@ -1,110 +1,109 @@ -namespace Humanizer.Tests.Localisation.ukUA +namespace Humanizer.Tests.Localisation.ukUA; + +[UseCulture("uk-UA")] +public class OrdinalizeTests { - [UseCulture("uk-UA")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0-й")] - [InlineData("1", "1-й")] - [InlineData("2", "2-й")] - [InlineData("3", "3-й")] - [InlineData("4", "4-й")] - [InlineData("5", "5-й")] - [InlineData("6", "6-й")] - [InlineData("23", "23-й")] - [InlineData("100", "100-й")] - [InlineData("101", "101-й")] - [InlineData("102", "102-й")] - [InlineData("103", "103-й")] - [InlineData("1001", "1001-й")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData("0", "0-й")] + [InlineData("1", "1-й")] + [InlineData("2", "2-й")] + [InlineData("3", "3-й")] + [InlineData("4", "4-й")] + [InlineData("5", "5-й")] + [InlineData("6", "6-й")] + [InlineData("23", "23-й")] + [InlineData("100", "100-й")] + [InlineData("101", "101-й")] + [InlineData("102", "102-й")] + [InlineData("103", "103-й")] + [InlineData("1001", "1001-й")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData("0", "0-а")] - [InlineData("1", "1-а")] - [InlineData("2", "2-а")] - [InlineData("3", "3-я")] - [InlineData("4", "4-а")] - [InlineData("5", "5-а")] - [InlineData("6", "6-а")] - [InlineData("23", "23-я")] - [InlineData("100", "100-а")] - [InlineData("101", "101-а")] - [InlineData("102", "102-а")] - [InlineData("103", "103-я")] - [InlineData("1001", "1001-а")] - public void OrdinalizeStringFeminine(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData("0", "0-а")] + [InlineData("1", "1-а")] + [InlineData("2", "2-а")] + [InlineData("3", "3-я")] + [InlineData("4", "4-а")] + [InlineData("5", "5-а")] + [InlineData("6", "6-а")] + [InlineData("23", "23-я")] + [InlineData("100", "100-а")] + [InlineData("101", "101-а")] + [InlineData("102", "102-а")] + [InlineData("103", "103-я")] + [InlineData("1001", "1001-а")] + public void OrdinalizeStringFeminine(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData("0", "0-е")] - [InlineData("1", "1-е")] - [InlineData("2", "2-е")] - [InlineData("3", "3-є")] - [InlineData("4", "4-е")] - [InlineData("5", "5-е")] - [InlineData("6", "6-е")] - [InlineData("23", "23-є")] - [InlineData("100", "100-е")] - [InlineData("101", "101-е")] - [InlineData("102", "102-е")] - [InlineData("103", "103-є")] - [InlineData("1001", "1001-е")] - public void OrdinalizeStringNeuter(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); + [Theory] + [InlineData("0", "0-е")] + [InlineData("1", "1-е")] + [InlineData("2", "2-е")] + [InlineData("3", "3-є")] + [InlineData("4", "4-е")] + [InlineData("5", "5-е")] + [InlineData("6", "6-е")] + [InlineData("23", "23-є")] + [InlineData("100", "100-е")] + [InlineData("101", "101-е")] + [InlineData("102", "102-е")] + [InlineData("103", "103-є")] + [InlineData("1001", "1001-е")] + public void OrdinalizeStringNeuter(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - [Theory] - [InlineData(0, "0-й")] - [InlineData(1, "1-й")] - [InlineData(2, "2-й")] - [InlineData(3, "3-й")] - [InlineData(4, "4-й")] - [InlineData(5, "5-й")] - [InlineData(6, "6-й")] - [InlineData(10, "10-й")] - [InlineData(23, "23-й")] - [InlineData(100, "100-й")] - [InlineData(101, "101-й")] - [InlineData(102, "102-й")] - [InlineData(103, "103-й")] - [InlineData(1001, "1001-й")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); + [Theory] + [InlineData(0, "0-й")] + [InlineData(1, "1-й")] + [InlineData(2, "2-й")] + [InlineData(3, "3-й")] + [InlineData(4, "4-й")] + [InlineData(5, "5-й")] + [InlineData(6, "6-й")] + [InlineData(10, "10-й")] + [InlineData(23, "23-й")] + [InlineData(100, "100-й")] + [InlineData(101, "101-й")] + [InlineData(102, "102-й")] + [InlineData(103, "103-й")] + [InlineData(1001, "1001-й")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized); - [Theory] - [InlineData(0, "0-а")] - [InlineData(1, "1-а")] - [InlineData(2, "2-а")] - [InlineData(3, "3-я")] - [InlineData(4, "4-а")] - [InlineData(5, "5-а")] - [InlineData(6, "6-а")] - [InlineData(10, "10-а")] - [InlineData(23, "23-я")] - [InlineData(100, "100-а")] - [InlineData(101, "101-а")] - [InlineData(102, "102-а")] - [InlineData(103, "103-я")] - [InlineData(1001, "1001-а")] - public void OrdinalizeNumberFeminine(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); + [Theory] + [InlineData(0, "0-а")] + [InlineData(1, "1-а")] + [InlineData(2, "2-а")] + [InlineData(3, "3-я")] + [InlineData(4, "4-а")] + [InlineData(5, "5-а")] + [InlineData(6, "6-а")] + [InlineData(10, "10-а")] + [InlineData(23, "23-я")] + [InlineData(100, "100-а")] + [InlineData(101, "101-а")] + [InlineData(102, "102-а")] + [InlineData(103, "103-я")] + [InlineData(1001, "1001-а")] + public void OrdinalizeNumberFeminine(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); - [Theory] - [InlineData(0, "0-е")] - [InlineData(1, "1-е")] - [InlineData(2, "2-е")] - [InlineData(3, "3-є")] - [InlineData(4, "4-е")] - [InlineData(5, "5-е")] - [InlineData(6, "6-е")] - [InlineData(23, "23-є")] - [InlineData(100, "100-е")] - [InlineData(101, "101-е")] - [InlineData(102, "102-е")] - [InlineData(103, "103-є")] - [InlineData(1001, "1001-е")] - public void OrdinalizeNumberNeuter(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); - } -} + [Theory] + [InlineData(0, "0-е")] + [InlineData(1, "1-е")] + [InlineData(2, "2-е")] + [InlineData(3, "3-є")] + [InlineData(4, "4-е")] + [InlineData(5, "5-е")] + [InlineData(6, "6-е")] + [InlineData(23, "23-є")] + [InlineData(100, "100-е")] + [InlineData(101, "101-е")] + [InlineData(102, "102-е")] + [InlineData(103, "103-є")] + [InlineData(1001, "1001-е")] + public void OrdinalizeNumberNeuter(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(GrammaticalGender.Neuter), ordinalized); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uk-UA/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/uk-UA/TimeSpanHumanizeTests.cs index ca20d4bd4..06f361b82 100644 --- a/src/Humanizer.Tests/Localisation/uk-UA/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uk-UA/TimeSpanHumanizeTests.cs @@ -1,129 +1,128 @@ -namespace Humanizer.Tests.Localisation.ukUA +namespace Humanizer.Tests.Localisation.ukUA; + +[UseCulture("uk-UA")] +public class TimeSpanHumanizeTests { - [UseCulture("uk-UA")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "один рік")] - [InlineData(731, "2 роки")] - [InlineData(1096, "3 роки")] - [InlineData(4018, "11 років")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "один рік")] + [InlineData(731, "2 роки")] + [InlineData(1096, "3 роки")] + [InlineData(4018, "11 років")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "один місяць")] - [InlineData(61, "2 місяці")] - [InlineData(92, "3 місяці")] - [InlineData(335, "11 місяців")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "один місяць")] + [InlineData(61, "2 місяці")] + [InlineData(92, "3 місяці")] + [InlineData(335, "11 місяців")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "один тиждень")] - [InlineData(14, "2 тижні")] - [InlineData(21, "3 тижні")] - [InlineData(28, "4 тижні")] - [InlineData(35, "5 тижнів")] - [InlineData(77, "11 тижнів")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "один тиждень")] + [InlineData(14, "2 тижні")] + [InlineData(21, "3 тижні")] + [InlineData(28, "4 тижні")] + [InlineData(35, "5 тижнів")] + [InlineData(77, "11 тижнів")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "один день")] - [InlineData(2, "2 дні")] - [InlineData(3, "3 дні")] - [InlineData(4, "4 дні")] - [InlineData(5, "5 днів")] - [InlineData(6, "6 днів")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "один день")] + [InlineData(2, "2 дні")] + [InlineData(3, "3 дні")] + [InlineData(4, "4 дні")] + [InlineData(5, "5 днів")] + [InlineData(6, "6 днів")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "одна година")] - [InlineData(2, "2 години")] - [InlineData(3, "3 години")] - [InlineData(4, "4 години")] - [InlineData(5, "5 годин")] - [InlineData(6, "6 годин")] - [InlineData(10, "10 годин")] - [InlineData(11, "11 годин")] - [InlineData(19, "19 годин")] - [InlineData(20, "20 годин")] - [InlineData(21, "21 година")] - [InlineData(22, "22 години")] - [InlineData(23, "23 години")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "одна година")] + [InlineData(2, "2 години")] + [InlineData(3, "3 години")] + [InlineData(4, "4 години")] + [InlineData(5, "5 годин")] + [InlineData(6, "6 годин")] + [InlineData(10, "10 годин")] + [InlineData(11, "11 годин")] + [InlineData(19, "19 годин")] + [InlineData(20, "20 годин")] + [InlineData(21, "21 година")] + [InlineData(22, "22 години")] + [InlineData(23, "23 години")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "одна хвилина")] - [InlineData(2, "2 хвилини")] - [InlineData(3, "3 хвилини")] - [InlineData(4, "4 хвилини")] - [InlineData(5, "5 хвилин")] - [InlineData(6, "6 хвилин")] - [InlineData(10, "10 хвилин")] - [InlineData(11, "11 хвилин")] - [InlineData(19, "19 хвилин")] - [InlineData(20, "20 хвилин")] - [InlineData(21, "21 хвилина")] - [InlineData(22, "22 хвилини")] - [InlineData(23, "23 хвилини")] - [InlineData(24, "24 хвилини")] - [InlineData(25, "25 хвилин")] - [InlineData(40, "40 хвилин")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "одна хвилина")] + [InlineData(2, "2 хвилини")] + [InlineData(3, "3 хвилини")] + [InlineData(4, "4 хвилини")] + [InlineData(5, "5 хвилин")] + [InlineData(6, "6 хвилин")] + [InlineData(10, "10 хвилин")] + [InlineData(11, "11 хвилин")] + [InlineData(19, "19 хвилин")] + [InlineData(20, "20 хвилин")] + [InlineData(21, "21 хвилина")] + [InlineData(22, "22 хвилини")] + [InlineData(23, "23 хвилини")] + [InlineData(24, "24 хвилини")] + [InlineData(25, "25 хвилин")] + [InlineData(40, "40 хвилин")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "одна секунда")] - [InlineData(2, "2 секунди")] - [InlineData(3, "3 секунди")] - [InlineData(4, "4 секунди")] - [InlineData(5, "5 секунд")] - [InlineData(6, "6 секунд")] - [InlineData(10, "10 секунд")] - [InlineData(11, "11 секунд")] - [InlineData(19, "19 секунд")] - [InlineData(20, "20 секунд")] - [InlineData(21, "21 секунда")] - [InlineData(22, "22 секунди")] - [InlineData(23, "23 секунди")] - [InlineData(24, "24 секунди")] - [InlineData(25, "25 секунд")] - [InlineData(40, "40 секунд")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "одна секунда")] + [InlineData(2, "2 секунди")] + [InlineData(3, "3 секунди")] + [InlineData(4, "4 секунди")] + [InlineData(5, "5 секунд")] + [InlineData(6, "6 секунд")] + [InlineData(10, "10 секунд")] + [InlineData(11, "11 секунд")] + [InlineData(19, "19 секунд")] + [InlineData(20, "20 секунд")] + [InlineData(21, "21 секунда")] + [InlineData(22, "22 секунди")] + [InlineData(23, "23 секунди")] + [InlineData(24, "24 секунди")] + [InlineData(25, "25 секунд")] + [InlineData(40, "40 секунд")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "одна мілісекунда")] - [InlineData(2, "2 мілісекунди")] - [InlineData(3, "3 мілісекунди")] - [InlineData(4, "4 мілісекунди")] - [InlineData(5, "5 мілісекунд")] - [InlineData(6, "6 мілісекунд")] - [InlineData(10, "10 мілісекунд")] - [InlineData(11, "11 мілісекунд")] - [InlineData(19, "19 мілісекунд")] - [InlineData(20, "20 мілісекунд")] - [InlineData(21, "21 мілісекунда")] - [InlineData(22, "22 мілісекунди")] - [InlineData(23, "23 мілісекунди")] - [InlineData(24, "24 мілісекунди")] - [InlineData(25, "25 мілісекунд")] - [InlineData(40, "40 мілісекунд")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "одна мілісекунда")] + [InlineData(2, "2 мілісекунди")] + [InlineData(3, "3 мілісекунди")] + [InlineData(4, "4 мілісекунди")] + [InlineData(5, "5 мілісекунд")] + [InlineData(6, "6 мілісекунд")] + [InlineData(10, "10 мілісекунд")] + [InlineData(11, "11 мілісекунд")] + [InlineData(19, "19 мілісекунд")] + [InlineData(20, "20 мілісекунд")] + [InlineData(21, "21 мілісекунда")] + [InlineData(22, "22 мілісекунди")] + [InlineData(23, "23 мілісекунди")] + [InlineData(24, "24 мілісекунди")] + [InlineData(25, "25 мілісекунд")] + [InlineData(40, "40 мілісекунд")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 мілісекунд", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 мілісекунд", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - Assert.Equal("без часу", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + Assert.Equal("без часу", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/DateHumanizeTests.cs index c72785300..7733d2e58 100644 --- a/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.uzCyrl +namespace Humanizer.Tests.Localisation.uzCyrl; + +[UseCulture("uz-Cyrl-UZ")] +public class DateHumanizeTests { - [UseCulture("uz-Cyrl-UZ")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "бир сония аввал")] - [InlineData(10, "10 секунд аввал")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "бир сония аввал")] + [InlineData(10, "10 секунд аввал")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "бир сониядан сўнг")] - [InlineData(10, "10 секунддан сўнг")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "бир сониядан сўнг")] + [InlineData(10, "10 секунддан сўнг")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "бир дақиқа аввал")] - [InlineData(10, "10 минут аввал")] - [InlineData(60, "бир соат аввал")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "бир дақиқа аввал")] + [InlineData(10, "10 минут аввал")] + [InlineData(60, "бир соат аввал")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "бир дақиқадан сўнг")] - [InlineData(10, "10 минутдан сўнг")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "бир дақиқадан сўнг")] + [InlineData(10, "10 минутдан сўнг")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "бир соат аввал")] - [InlineData(10, "10 соат аввал")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "бир соат аввал")] + [InlineData(10, "10 соат аввал")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "бир соатдан сўнг")] - [InlineData(10, "10 соатдан сўнг")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "бир соатдан сўнг")] + [InlineData(10, "10 соатдан сўнг")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "кеча")] - [InlineData(10, "10 кун аввал")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "кеча")] + [InlineData(10, "10 кун аввал")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "эртага")] - [InlineData(10, "10 кундан сўнг")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "эртага")] + [InlineData(10, "10 кундан сўнг")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "бир ой аввал")] - [InlineData(10, "10 ой аввал")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "бир ой аввал")] + [InlineData(10, "10 ой аввал")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "бир ойдан сўнг")] - [InlineData(10, "10 ойдан сўнг")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "бир ойдан сўнг")] + [InlineData(10, "10 ойдан сўнг")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "бир йил аввал")] - [InlineData(2, "2 йил аввал")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "бир йил аввал")] + [InlineData(2, "2 йил аввал")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "бир йилдан сўнг")] - [InlineData(2, "2 йилдан сўнг")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "бир йилдан сўнг")] + [InlineData(2, "2 йилдан сўнг")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("ҳозир", 0, TimeUnit.Year, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("ҳозир", 0, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/NumberToWordsTests.cs index 20391ebf1..fae808b7f 100644 --- a/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/NumberToWordsTests.cs @@ -1,101 +1,100 @@ -namespace Humanizer.Tests.Localisation.uzCyrl +namespace Humanizer.Tests.Localisation.uzCyrl; + +[UseCulture("uz-Cyrl-UZ")] +public class NumberToWordsTests { - [UseCulture("uz-Cyrl-UZ")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "нол")] - [InlineData(1, "бир")] - [InlineData(10, "ўн")] - [InlineData(11, "ўн бир")] - [InlineData(12, "ўн икки")] - [InlineData(13, "ўн уч")] - [InlineData(14, "ўн тўрт")] - [InlineData(15, "ўн беш")] - [InlineData(16, "ўн олти")] - [InlineData(17, "ўн етти")] - [InlineData(18, "ўн саккиз")] - [InlineData(19, "ўн тўққиз")] - [InlineData(20, "йигирма")] - [InlineData(30, "ўттиз")] - [InlineData(40, "қирқ")] - [InlineData(50, "эллик")] - [InlineData(60, "олтмиш")] - [InlineData(70, "етмиш")] - [InlineData(80, "саксон")] - [InlineData(90, "тўқсон")] - [InlineData(100, "юз")] - [InlineData(200, "икки юз")] - [InlineData(300, "уч юз")] - [InlineData(400, "тўрт юз")] - [InlineData(500, "беш юз")] - [InlineData(600, "олти юз")] - [InlineData(700, "етти юз")] - [InlineData(800, "саккиз юз")] - [InlineData(900, "тўққиз юз")] - [InlineData(1000, "бир минг")] - [InlineData(2000, "икки минг")] - [InlineData(3000, "уч минг")] - [InlineData(10000, "ўн минг")] - [InlineData(100000, "юз минг")] - [InlineData(100100, "юз минг бир юз")] - [InlineData(200100, "икки юз минг бир юз")] - [InlineData(1000000, "бир миллион")] - [InlineData(1001000, "бир миллион бир минг")] - [InlineData(1000100, "бир миллион бир юз")] - [InlineData(2000000, "икки миллион")] - [InlineData(10000000, "ўн миллион")] - [InlineData(100000000, "юз миллион")] - [InlineData(100001000, "юз миллион бир минг")] - [InlineData(1000000000, "бир миллиард")] - [InlineData(2000000000, "икки миллиард")] - [InlineData(122, "бир юз йигирма икки")] - [InlineData(3501, "уч минг беш юз бир")] - [InlineData(111, "бир юз ўн бир")] - [InlineData(1112, "бир минг бир юз ўн икки")] - [InlineData(11213, "ўн бир минг икки юз ўн уч")] - [InlineData(121314, "бир юз йигирма бир минг уч юз ўн тўрт")] - [InlineData(2132415, "икки миллион бир юз ўттиз икки минг тўрт юз ўн беш")] - [InlineData(12345516, "ўн икки миллион уч юз қирқ беш минг беш юз ўн олти")] - [InlineData(751633617, "етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн етти")] - [InlineData(1111111118, "бир миллиард бир юз ўн бир миллион бир юз ўн бир минг бир юз ўн саккиз")] - [InlineData(-751633617, "минус етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн етти")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "нол")] + [InlineData(1, "бир")] + [InlineData(10, "ўн")] + [InlineData(11, "ўн бир")] + [InlineData(12, "ўн икки")] + [InlineData(13, "ўн уч")] + [InlineData(14, "ўн тўрт")] + [InlineData(15, "ўн беш")] + [InlineData(16, "ўн олти")] + [InlineData(17, "ўн етти")] + [InlineData(18, "ўн саккиз")] + [InlineData(19, "ўн тўққиз")] + [InlineData(20, "йигирма")] + [InlineData(30, "ўттиз")] + [InlineData(40, "қирқ")] + [InlineData(50, "эллик")] + [InlineData(60, "олтмиш")] + [InlineData(70, "етмиш")] + [InlineData(80, "саксон")] + [InlineData(90, "тўқсон")] + [InlineData(100, "юз")] + [InlineData(200, "икки юз")] + [InlineData(300, "уч юз")] + [InlineData(400, "тўрт юз")] + [InlineData(500, "беш юз")] + [InlineData(600, "олти юз")] + [InlineData(700, "етти юз")] + [InlineData(800, "саккиз юз")] + [InlineData(900, "тўққиз юз")] + [InlineData(1000, "бир минг")] + [InlineData(2000, "икки минг")] + [InlineData(3000, "уч минг")] + [InlineData(10000, "ўн минг")] + [InlineData(100000, "юз минг")] + [InlineData(100100, "юз минг бир юз")] + [InlineData(200100, "икки юз минг бир юз")] + [InlineData(1000000, "бир миллион")] + [InlineData(1001000, "бир миллион бир минг")] + [InlineData(1000100, "бир миллион бир юз")] + [InlineData(2000000, "икки миллион")] + [InlineData(10000000, "ўн миллион")] + [InlineData(100000000, "юз миллион")] + [InlineData(100001000, "юз миллион бир минг")] + [InlineData(1000000000, "бир миллиард")] + [InlineData(2000000000, "икки миллиард")] + [InlineData(122, "бир юз йигирма икки")] + [InlineData(3501, "уч минг беш юз бир")] + [InlineData(111, "бир юз ўн бир")] + [InlineData(1112, "бир минг бир юз ўн икки")] + [InlineData(11213, "ўн бир минг икки юз ўн уч")] + [InlineData(121314, "бир юз йигирма бир минг уч юз ўн тўрт")] + [InlineData(2132415, "икки миллион бир юз ўттиз икки минг тўрт юз ўн беш")] + [InlineData(12345516, "ўн икки миллион уч юз қирқ беш минг беш юз ўн олти")] + [InlineData(751633617, "етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн етти")] + [InlineData(1111111118, "бир миллиард бир юз ўн бир миллион бир юз ўн бир минг бир юз ўн саккиз")] + [InlineData(-751633617, "минус етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн етти")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "нолинчи")] - [InlineData(1, "биринчи")] - [InlineData(10, "ўнинчи")] - [InlineData(11, "ўн биринчи")] - [InlineData(12, "ўн иккинчи")] - [InlineData(13, "ўн учинчи")] - [InlineData(14, "ўн тўртинчи")] - [InlineData(15, "ўн бешинчи")] - [InlineData(16, "ўн олтинчи")] - [InlineData(17, "ўн еттинчи")] - [InlineData(18, "ўн саккизинчи")] - [InlineData(19, "ўн тўққизинчи")] - [InlineData(20, "йигирманчи")] - [InlineData(30, "ўттизинчи")] - [InlineData(40, "қирқинчи")] - [InlineData(50, "элликинчи")] - [InlineData(60, "олтмишинчи")] - [InlineData(70, "етмишинчи")] - [InlineData(80, "саксонинчи")] - [InlineData(90, "тўқсонинчи")] - [InlineData(100, "юзинчи")] - [InlineData(200, "икки юзинчи")] - [InlineData(1000, "бир мингинчи")] - [InlineData(2000000, "икки миллионинчи")] - [InlineData(1000000000, "бир миллиардинчи")] - [InlineData(122, "бир юз йигирма иккинчи")] - [InlineData(3501, "уч минг беш юз биринчи")] - [InlineData(111, "бир юз ўн биринчи")] - [InlineData(751633617, "етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн еттинчи")] - [InlineData(1111111118, "бир миллиард бир юз ўн бир миллион бир юз ўн бир минг бир юз ўн саккизинчи")] - [InlineData(-751633617, "минус етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн еттинчи")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "нолинчи")] + [InlineData(1, "биринчи")] + [InlineData(10, "ўнинчи")] + [InlineData(11, "ўн биринчи")] + [InlineData(12, "ўн иккинчи")] + [InlineData(13, "ўн учинчи")] + [InlineData(14, "ўн тўртинчи")] + [InlineData(15, "ўн бешинчи")] + [InlineData(16, "ўн олтинчи")] + [InlineData(17, "ўн еттинчи")] + [InlineData(18, "ўн саккизинчи")] + [InlineData(19, "ўн тўққизинчи")] + [InlineData(20, "йигирманчи")] + [InlineData(30, "ўттизинчи")] + [InlineData(40, "қирқинчи")] + [InlineData(50, "элликинчи")] + [InlineData(60, "олтмишинчи")] + [InlineData(70, "етмишинчи")] + [InlineData(80, "саксонинчи")] + [InlineData(90, "тўқсонинчи")] + [InlineData(100, "юзинчи")] + [InlineData(200, "икки юзинчи")] + [InlineData(1000, "бир мингинчи")] + [InlineData(2000000, "икки миллионинчи")] + [InlineData(1000000000, "бир миллиардинчи")] + [InlineData(122, "бир юз йигирма иккинчи")] + [InlineData(3501, "уч минг беш юз биринчи")] + [InlineData(111, "бир юз ўн биринчи")] + [InlineData(751633617, "етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн еттинчи")] + [InlineData(1111111118, "бир миллиард бир юз ўн бир миллион бир юз ўн бир минг бир юз ўн саккизинчи")] + [InlineData(-751633617, "минус етти юз эллик бир миллион олти юз ўттиз уч минг олти юз ўн еттинчи")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs index 017c7cd33..e2d74b947 100644 --- a/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uz-Cyrl-UZ/TimeSpanHumanizeTests.cs @@ -1,94 +1,93 @@ -namespace Humanizer.Tests.Localisation.uzCyrl +namespace Humanizer.Tests.Localisation.uzCyrl; + +[UseCulture("uz-Cyrl-UZ")] +public class TimeSpanHumanizeTests { - [UseCulture("uz-Cyrl-UZ")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 йил")] - [InlineData(731, "2 йил")] - [InlineData(1096, "3 йил")] - [InlineData(4018, "11 йил")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 йил")] + [InlineData(731, "2 йил")] + [InlineData(1096, "3 йил")] + [InlineData(4018, "11 йил")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 ой")] - [InlineData(61, "2 ой")] - [InlineData(92, "3 ой")] - [InlineData(335, "11 ой")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 ой")] + [InlineData(61, "2 ой")] + [InlineData(92, "3 ой")] + [InlineData(335, "11 ой")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 ҳафта")] - [InlineData(7, "1 ҳафта")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(14, "2 ҳафта")] + [InlineData(7, "1 ҳафта")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(6, "6 кун")] - [InlineData(2, "2 кун")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(6, "6 кун")] + [InlineData(2, "2 кун")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 соат")] - [InlineData(1, "1 соат")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 соат")] + [InlineData(1, "1 соат")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 минут")] - [InlineData(1, "1 минут")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 минут")] + [InlineData(1, "1 минут")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 секунд")] - [InlineData(1, "1 секунд")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 секунд")] + [InlineData(1, "1 секунд")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 миллисекунд")] - [InlineData(1, "1 миллисекунд")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 миллисекунд")] + [InlineData(1, "1 миллисекунд")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } - [Fact] - public void NoTime() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(); - Assert.Equal("0 миллисекунд", actual); - } + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("0 миллисекунд", actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("вақт йўқ", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("вақт йўқ", actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uz-Latn-UZ/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/uz-Latn-UZ/DateHumanizeTests.cs index 2f7ed6a2f..b7ed5ee55 100644 --- a/src/Humanizer.Tests/Localisation/uz-Latn-UZ/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uz-Latn-UZ/DateHumanizeTests.cs @@ -1,83 +1,82 @@ -namespace Humanizer.Tests.Localisation.uzLatn +namespace Humanizer.Tests.Localisation.uzLatn; + +[UseCulture("uz-Latn-UZ")] +public class DateHumanizeTests { - [UseCulture("uz-Latn-UZ")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "bir soniya avval")] - [InlineData(10, "10 sekund avval")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "bir soniya avval")] + [InlineData(10, "10 sekund avval")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "bir soniyadan so`ng")] - [InlineData(10, "10 sekunddan so`ng")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "bir soniyadan so`ng")] + [InlineData(10, "10 sekunddan so`ng")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "bir daqiqa avval")] - [InlineData(10, "10 minut avval")] - [InlineData(60, "bir soat avval")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "bir daqiqa avval")] + [InlineData(10, "10 minut avval")] + [InlineData(60, "bir soat avval")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "bir daqiqadan so`ng")] - [InlineData(10, "10 minutdan so`ng")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "bir daqiqadan so`ng")] + [InlineData(10, "10 minutdan so`ng")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "bir soat avval")] - [InlineData(10, "10 soat avval")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "bir soat avval")] + [InlineData(10, "10 soat avval")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "bir soatdan so`ng")] - [InlineData(10, "10 soatdan so`ng")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "bir soatdan so`ng")] + [InlineData(10, "10 soatdan so`ng")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "kecha")] - [InlineData(10, "10 kun avval")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "kecha")] + [InlineData(10, "10 kun avval")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "ertaga")] - [InlineData(10, "10 kundan so`ng")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "ertaga")] + [InlineData(10, "10 kundan so`ng")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "bir oy avval")] - [InlineData(10, "10 oy avval")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "bir oy avval")] + [InlineData(10, "10 oy avval")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "bir oydan so`ng")] - [InlineData(10, "10 oydan so`ng")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "bir oydan so`ng")] + [InlineData(10, "10 oydan so`ng")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "bir yil avval")] - [InlineData(2, "2 yil avval")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "bir yil avval")] + [InlineData(2, "2 yil avval")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "bir yildan so`ng")] - [InlineData(2, "2 yildan so`ng")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + [Theory] + [InlineData(1, "bir yildan so`ng")] + [InlineData(2, "2 yildan so`ng")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - [Fact] - public void Now() => - DateHumanize.Verify("hozir", 0, TimeUnit.Year, Tense.Future); - } -} + [Fact] + public void Now() => + DateHumanize.Verify("hozir", 0, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uz-Latn-UZ/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/uz-Latn-UZ/NumberToWordsTests.cs index c4fa635a6..dcbf99556 100644 --- a/src/Humanizer.Tests/Localisation/uz-Latn-UZ/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/uz-Latn-UZ/NumberToWordsTests.cs @@ -1,101 +1,100 @@ -namespace Humanizer.Tests.Localisation.uzLatn +namespace Humanizer.Tests.Localisation.uzLatn; + +[UseCulture("uz-Latn-UZ")] +public class NumberToWordsTests { - [UseCulture("uz-Latn-UZ")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "nol")] - [InlineData(1, "bir")] - [InlineData(10, "o`n")] - [InlineData(11, "o`n bir")] - [InlineData(12, "o`n ikki")] - [InlineData(13, "o`n uch")] - [InlineData(14, "o`n to`rt")] - [InlineData(15, "o`n besh")] - [InlineData(16, "o`n olti")] - [InlineData(17, "o`n yetti")] - [InlineData(18, "o`n sakkiz")] - [InlineData(19, "o`n to`qqiz")] - [InlineData(20, "yigirma")] - [InlineData(30, "o`ttiz")] - [InlineData(40, "qirq")] - [InlineData(50, "ellik")] - [InlineData(60, "oltmish")] - [InlineData(70, "yetmish")] - [InlineData(80, "sakson")] - [InlineData(90, "to`qson")] - [InlineData(100, "yuz")] - [InlineData(200, "ikki yuz")] - [InlineData(300, "uch yuz")] - [InlineData(400, "to`rt yuz")] - [InlineData(500, "besh yuz")] - [InlineData(600, "olti yuz")] - [InlineData(700, "yetti yuz")] - [InlineData(800, "sakkiz yuz")] - [InlineData(900, "to`qqiz yuz")] - [InlineData(1000, "bir ming")] - [InlineData(2000, "ikki ming")] - [InlineData(3000, "uch ming")] - [InlineData(10000, "o`n ming")] - [InlineData(100000, "yuz ming")] - [InlineData(100100, "yuz ming bir yuz")] - [InlineData(200100, "ikki yuz ming bir yuz")] - [InlineData(1000000, "bir million")] - [InlineData(1001000, "bir million bir ming")] - [InlineData(1000100, "bir million bir yuz")] - [InlineData(2000000, "ikki million")] - [InlineData(10000000, "o`n million")] - [InlineData(100000000, "yuz million")] - [InlineData(100001000, "yuz million bir ming")] - [InlineData(1000000000, "bir milliard")] - [InlineData(2000000000, "ikki milliard")] - [InlineData(122, "bir yuz yigirma ikki")] - [InlineData(3501, "uch ming besh yuz bir")] - [InlineData(111, "bir yuz o`n bir")] - [InlineData(1112, "bir ming bir yuz o`n ikki")] - [InlineData(11213, "o`n bir ming ikki yuz o`n uch")] - [InlineData(121314, "bir yuz yigirma bir ming uch yuz o`n to`rt")] - [InlineData(2132415, "ikki million bir yuz o`ttiz ikki ming to`rt yuz o`n besh")] - [InlineData(12345516, "o`n ikki million uch yuz qirq besh ming besh yuz o`n olti")] - [InlineData(751633617, "yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yetti")] - [InlineData(1111111118, "bir milliard bir yuz o`n bir million bir yuz o`n bir ming bir yuz o`n sakkiz")] - [InlineData(-751633617, "minus yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yetti")] - public void ToWords(int number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "nol")] + [InlineData(1, "bir")] + [InlineData(10, "o`n")] + [InlineData(11, "o`n bir")] + [InlineData(12, "o`n ikki")] + [InlineData(13, "o`n uch")] + [InlineData(14, "o`n to`rt")] + [InlineData(15, "o`n besh")] + [InlineData(16, "o`n olti")] + [InlineData(17, "o`n yetti")] + [InlineData(18, "o`n sakkiz")] + [InlineData(19, "o`n to`qqiz")] + [InlineData(20, "yigirma")] + [InlineData(30, "o`ttiz")] + [InlineData(40, "qirq")] + [InlineData(50, "ellik")] + [InlineData(60, "oltmish")] + [InlineData(70, "yetmish")] + [InlineData(80, "sakson")] + [InlineData(90, "to`qson")] + [InlineData(100, "yuz")] + [InlineData(200, "ikki yuz")] + [InlineData(300, "uch yuz")] + [InlineData(400, "to`rt yuz")] + [InlineData(500, "besh yuz")] + [InlineData(600, "olti yuz")] + [InlineData(700, "yetti yuz")] + [InlineData(800, "sakkiz yuz")] + [InlineData(900, "to`qqiz yuz")] + [InlineData(1000, "bir ming")] + [InlineData(2000, "ikki ming")] + [InlineData(3000, "uch ming")] + [InlineData(10000, "o`n ming")] + [InlineData(100000, "yuz ming")] + [InlineData(100100, "yuz ming bir yuz")] + [InlineData(200100, "ikki yuz ming bir yuz")] + [InlineData(1000000, "bir million")] + [InlineData(1001000, "bir million bir ming")] + [InlineData(1000100, "bir million bir yuz")] + [InlineData(2000000, "ikki million")] + [InlineData(10000000, "o`n million")] + [InlineData(100000000, "yuz million")] + [InlineData(100001000, "yuz million bir ming")] + [InlineData(1000000000, "bir milliard")] + [InlineData(2000000000, "ikki milliard")] + [InlineData(122, "bir yuz yigirma ikki")] + [InlineData(3501, "uch ming besh yuz bir")] + [InlineData(111, "bir yuz o`n bir")] + [InlineData(1112, "bir ming bir yuz o`n ikki")] + [InlineData(11213, "o`n bir ming ikki yuz o`n uch")] + [InlineData(121314, "bir yuz yigirma bir ming uch yuz o`n to`rt")] + [InlineData(2132415, "ikki million bir yuz o`ttiz ikki ming to`rt yuz o`n besh")] + [InlineData(12345516, "o`n ikki million uch yuz qirq besh ming besh yuz o`n olti")] + [InlineData(751633617, "yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yetti")] + [InlineData(1111111118, "bir milliard bir yuz o`n bir million bir yuz o`n bir ming bir yuz o`n sakkiz")] + [InlineData(-751633617, "minus yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yetti")] + public void ToWords(int number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "nolinchi")] - [InlineData(1, "birinchi")] - [InlineData(10, "o`ninchi")] - [InlineData(11, "o`n birinchi")] - [InlineData(12, "o`n ikkinchi")] - [InlineData(13, "o`n uchinchi")] - [InlineData(14, "o`n to`rtinchi")] - [InlineData(15, "o`n beshinchi")] - [InlineData(16, "o`n oltinchi")] - [InlineData(17, "o`n yettinchi")] - [InlineData(18, "o`n sakkizinchi")] - [InlineData(19, "o`n to`qqizinchi")] - [InlineData(20, "yigirmanchi")] - [InlineData(30, "o`ttizinchi")] - [InlineData(40, "qirqinchi")] - [InlineData(50, "ellikinchi")] - [InlineData(60, "oltmishinchi")] - [InlineData(70, "yetmishinchi")] - [InlineData(80, "saksoninchi")] - [InlineData(90, "to`qsoninchi")] - [InlineData(100, "yuzinchi")] - [InlineData(200, "ikki yuzinchi")] - [InlineData(1000, "bir minginchi")] - [InlineData(2000000, "ikki millioninchi")] - [InlineData(1000000000, "bir milliardinchi")] - [InlineData(122, "bir yuz yigirma ikkinchi")] - [InlineData(3501, "uch ming besh yuz birinchi")] - [InlineData(111, "bir yuz o`n birinchi")] - [InlineData(751633617, "yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yettinchi")] - [InlineData(1111111118, "bir milliard bir yuz o`n bir million bir yuz o`n bir ming bir yuz o`n sakkizinchi")] - [InlineData(-751633617, "minus yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yettinchi")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "nolinchi")] + [InlineData(1, "birinchi")] + [InlineData(10, "o`ninchi")] + [InlineData(11, "o`n birinchi")] + [InlineData(12, "o`n ikkinchi")] + [InlineData(13, "o`n uchinchi")] + [InlineData(14, "o`n to`rtinchi")] + [InlineData(15, "o`n beshinchi")] + [InlineData(16, "o`n oltinchi")] + [InlineData(17, "o`n yettinchi")] + [InlineData(18, "o`n sakkizinchi")] + [InlineData(19, "o`n to`qqizinchi")] + [InlineData(20, "yigirmanchi")] + [InlineData(30, "o`ttizinchi")] + [InlineData(40, "qirqinchi")] + [InlineData(50, "ellikinchi")] + [InlineData(60, "oltmishinchi")] + [InlineData(70, "yetmishinchi")] + [InlineData(80, "saksoninchi")] + [InlineData(90, "to`qsoninchi")] + [InlineData(100, "yuzinchi")] + [InlineData(200, "ikki yuzinchi")] + [InlineData(1000, "bir minginchi")] + [InlineData(2000000, "ikki millioninchi")] + [InlineData(1000000000, "bir milliardinchi")] + [InlineData(122, "bir yuz yigirma ikkinchi")] + [InlineData(3501, "uch ming besh yuz birinchi")] + [InlineData(111, "bir yuz o`n birinchi")] + [InlineData(751633617, "yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yettinchi")] + [InlineData(1111111118, "bir milliard bir yuz o`n bir million bir yuz o`n bir ming bir yuz o`n sakkizinchi")] + [InlineData(-751633617, "minus yetti yuz ellik bir million olti yuz o`ttiz uch ming olti yuz o`n yettinchi")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs index ba73644a4..301836934 100644 --- a/src/Humanizer.Tests/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/uz-Latn-UZ/TimeSpanHumanizeTests.cs @@ -1,94 +1,93 @@ -namespace Humanizer.Tests.Localisation.uzLatn +namespace Humanizer.Tests.Localisation.uzLatn; + +[UseCulture("uz-Latn-UZ")] +public class TimeSpanHumanizeTests { - [UseCulture("uz-Latn-UZ")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 yil")] - [InlineData(731, "2 yil")] - [InlineData(1096, "3 yil")] - [InlineData(4018, "11 yil")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 yil")] + [InlineData(731, "2 yil")] + [InlineData(1096, "3 yil")] + [InlineData(4018, "11 yil")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 oy")] - [InlineData(61, "2 oy")] - [InlineData(92, "3 oy")] - [InlineData(335, "11 oy")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 oy")] + [InlineData(61, "2 oy")] + [InlineData(92, "3 oy")] + [InlineData(335, "11 oy")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 hafta")] - [InlineData(7, "1 hafta")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(14, "2 hafta")] + [InlineData(7, "1 hafta")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(6, "6 kun")] - [InlineData(2, "2 kun")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(6, "6 kun")] + [InlineData(2, "2 kun")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 soat")] - [InlineData(1, "1 soat")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 soat")] + [InlineData(1, "1 soat")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 minut")] - [InlineData(1, "1 minut")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 minut")] + [InlineData(1, "1 minut")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 sekund")] - [InlineData(1, "1 sekund")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 sekund")] + [InlineData(1, "1 sekund")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 millisekund")] - [InlineData(1, "1 millisekund")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 millisekund")] + [InlineData(1, "1 millisekund")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } - [Fact] - public void NoTime() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(); - Assert.Equal("0 millisekund", actual); - } + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("0 millisekund", actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("vaqt yo`q", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("vaqt yo`q", actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/vi/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/vi/DateHumanizeTests.cs index 5920603fa..eb87c75f6 100644 --- a/src/Humanizer.Tests/Localisation/vi/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/vi/DateHumanizeTests.cs @@ -1,78 +1,77 @@ -namespace Humanizer.Tests.Localisation.vi +namespace Humanizer.Tests.Localisation.vi; + +[UseCulture("vi")] +public class DateHumanizeTests { - [UseCulture("vi")] - public class DateHumanizeTests - { - [Theory] - [InlineData(1, "cách đây một giây")] - [InlineData(10, "cách đây 10 giây")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(1, "cách đây một giây")] + [InlineData(10, "cách đây 10 giây")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(1, "một giây nữa")] - [InlineData(10, "10 giây nữa")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(1, "một giây nữa")] + [InlineData(10, "10 giây nữa")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(1, "cách đây một phút")] - [InlineData(10, "cách đây 10 phút")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(1, "cách đây một phút")] + [InlineData(10, "cách đây 10 phút")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(1, "một phút nữa")] - [InlineData(10, "10 phút nữa")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(1, "một phút nữa")] + [InlineData(10, "10 phút nữa")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(1, "cách đây một tiếng")] - [InlineData(10, "cách đây 10 tiếng")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(1, "cách đây một tiếng")] + [InlineData(10, "cách đây 10 tiếng")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(1, "một tiếng nữa")] - [InlineData(10, "10 tiếng nữa")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(1, "một tiếng nữa")] + [InlineData(10, "10 tiếng nữa")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(1, "hôm qua")] - [InlineData(10, "cách đây 10 ngày")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(1, "hôm qua")] + [InlineData(10, "cách đây 10 ngày")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(1, "ngày mai")] - [InlineData(10, "10 ngày nữa")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(1, "ngày mai")] + [InlineData(10, "10 ngày nữa")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(1, "cách đây một tháng")] - [InlineData(10, "cách đây 10 tháng")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(1, "cách đây một tháng")] + [InlineData(10, "cách đây 10 tháng")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(1, "một tháng nữa")] - [InlineData(10, "10 tháng nữa")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(1, "một tháng nữa")] + [InlineData(10, "10 tháng nữa")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(1, "cách đây một năm")] - [InlineData(2, "cách đây 2 năm")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(1, "cách đây một năm")] + [InlineData(2, "cách đây 2 năm")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(1, "một năm nữa")] - [InlineData(2, "2 năm nữa")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(1, "một năm nữa")] + [InlineData(2, "2 năm nữa")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/vi/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/vi/NumberToWordsTests.cs index c98c4119a..18699a039 100644 --- a/src/Humanizer.Tests/Localisation/vi/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/vi/NumberToWordsTests.cs @@ -1,72 +1,71 @@ -namespace Humanizer.Tests.vi +namespace Humanizer.Tests.vi; + +[UseCulture("vi")] +public class NumberToWordsTests { - [UseCulture("vi")] - public class NumberToWordsTests - { - [Theory] - [InlineData(0, "không")] - [InlineData(1, "một")] - [InlineData(2, "hai")] - [InlineData(3, "ba")] - [InlineData(4, "bốn")] - [InlineData(5, "năm")] - [InlineData(6, "sáu")] - [InlineData(7, "bảy")] - [InlineData(8, "tám")] - [InlineData(9, "chín")] - [InlineData(10, "mười")] - [InlineData(11, "mười một")] - [InlineData(14, "mười bốn")] - [InlineData(15, "mười lăm")] - [InlineData(21, "hai mươi mốt")] - [InlineData(24, "hai mươi tư")] - [InlineData(25, "hai mươi lăm")] - [InlineData(50, "năm mươi")] - [InlineData(55, "năm mươi lăm")] - [InlineData(100, "một trăm")] - [InlineData(105, "một trăm linh năm")] - [InlineData(110, "một trăm mười")] - [InlineData(114, "một trăm mười bốn")] - [InlineData(115, "một trăm mười lăm")] - [InlineData(134, "một trăm ba mươi tư")] - [InlineData(500, "năm trăm")] - [InlineData(505, "năm trăm linh năm")] - [InlineData(555, "năm trăm năm mươi lăm")] - [InlineData(1000, "một nghìn")] - [InlineData(1005, "một nghìn linh năm")] - [InlineData(1115, "một nghìn một trăm mười lăm")] - [InlineData(10005, "mười nghìn linh năm")] - [InlineData(10115, "mười nghìn một trăm mười lăm")] - [InlineData(11115, "mười một nghìn một trăm mười lăm")] - [InlineData(30005, "ba mươi nghìn linh năm")] - [InlineData(100005, "một trăm nghìn linh năm")] - [InlineData(1000000, "một triệu")] - [InlineData(100001005, "một trăm triệu một nghìn linh năm")] - [InlineData(1000000000, "một tỉ")] - [InlineData(1111111111111111, "một triệu một trăm mười một nghìn một trăm mười một tỉ một trăm mười một triệu một trăm mười một nghìn một trăm mười một")] - [InlineData(5101101101101151101, "năm tỉ một trăm linh một triệu một trăm linh một nghìn một trăm linh một tỉ một trăm linh một triệu một trăm năm mươi mốt nghìn một trăm linh một")] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [Theory] + [InlineData(0, "không")] + [InlineData(1, "một")] + [InlineData(2, "hai")] + [InlineData(3, "ba")] + [InlineData(4, "bốn")] + [InlineData(5, "năm")] + [InlineData(6, "sáu")] + [InlineData(7, "bảy")] + [InlineData(8, "tám")] + [InlineData(9, "chín")] + [InlineData(10, "mười")] + [InlineData(11, "mười một")] + [InlineData(14, "mười bốn")] + [InlineData(15, "mười lăm")] + [InlineData(21, "hai mươi mốt")] + [InlineData(24, "hai mươi tư")] + [InlineData(25, "hai mươi lăm")] + [InlineData(50, "năm mươi")] + [InlineData(55, "năm mươi lăm")] + [InlineData(100, "một trăm")] + [InlineData(105, "một trăm linh năm")] + [InlineData(110, "một trăm mười")] + [InlineData(114, "một trăm mười bốn")] + [InlineData(115, "một trăm mười lăm")] + [InlineData(134, "một trăm ba mươi tư")] + [InlineData(500, "năm trăm")] + [InlineData(505, "năm trăm linh năm")] + [InlineData(555, "năm trăm năm mươi lăm")] + [InlineData(1000, "một nghìn")] + [InlineData(1005, "một nghìn linh năm")] + [InlineData(1115, "một nghìn một trăm mười lăm")] + [InlineData(10005, "mười nghìn linh năm")] + [InlineData(10115, "mười nghìn một trăm mười lăm")] + [InlineData(11115, "mười một nghìn một trăm mười lăm")] + [InlineData(30005, "ba mươi nghìn linh năm")] + [InlineData(100005, "một trăm nghìn linh năm")] + [InlineData(1000000, "một triệu")] + [InlineData(100001005, "một trăm triệu một nghìn linh năm")] + [InlineData(1000000000, "một tỉ")] + [InlineData(1111111111111111, "một triệu một trăm mười một nghìn một trăm mười một tỉ một trăm mười một triệu một trăm mười một nghìn một trăm mười một")] + [InlineData(5101101101101151101, "năm tỉ một trăm linh một triệu một trăm linh một nghìn một trăm linh một tỉ một trăm linh một triệu một trăm năm mươi mốt nghìn một trăm linh một")] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(0, "thứ không")] - [InlineData(1, "thứ nhất")] - [InlineData(2, "thứ nhì")] - [InlineData(3, "thứ ba")] - [InlineData(4, "thứ tư")] - [InlineData(5, "thứ năm")] - [InlineData(6, "thứ sáu")] - [InlineData(7, "thứ bảy")] - [InlineData(8, "thứ tám")] - [InlineData(9, "thứ chín")] - [InlineData(10, "thứ mười")] - [InlineData(11, "thứ mười một")] - [InlineData(14, "thứ mười bốn")] - [InlineData(15, "thứ mười lăm")] - [InlineData(21, "thứ hai mươi mốt")] - [InlineData(24, "thứ hai mươi tư")] - [InlineData(25, "thứ hai mươi lăm")] - public void ToOrdinalWords(int number, string expected) => - Assert.Equal(expected, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(0, "thứ không")] + [InlineData(1, "thứ nhất")] + [InlineData(2, "thứ nhì")] + [InlineData(3, "thứ ba")] + [InlineData(4, "thứ tư")] + [InlineData(5, "thứ năm")] + [InlineData(6, "thứ sáu")] + [InlineData(7, "thứ bảy")] + [InlineData(8, "thứ tám")] + [InlineData(9, "thứ chín")] + [InlineData(10, "thứ mười")] + [InlineData(11, "thứ mười một")] + [InlineData(14, "thứ mười bốn")] + [InlineData(15, "thứ mười lăm")] + [InlineData(21, "thứ hai mươi mốt")] + [InlineData(24, "thứ hai mươi tư")] + [InlineData(25, "thứ hai mươi lăm")] + public void ToOrdinalWords(int number, string expected) => + Assert.Equal(expected, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/vi/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/vi/TimeSpanHumanizeTests.cs index 97ca5bcc1..4af882eab 100644 --- a/src/Humanizer.Tests/Localisation/vi/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/vi/TimeSpanHumanizeTests.cs @@ -1,94 +1,93 @@ -namespace Humanizer.Tests.Localisation.vi +namespace Humanizer.Tests.Localisation.vi; + +[UseCulture("vi")] +public class TimeSpanHumanizeTests { - [UseCulture("vi")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Google")] - [InlineData(366, "1 năm")] - [InlineData(731, "2 năm")] - [InlineData(1096, "3 năm")] - [InlineData(4018, "11 năm")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(366, "1 năm")] + [InlineData(731, "2 năm")] + [InlineData(1096, "3 năm")] + [InlineData(4018, "11 năm")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Google")] - [InlineData(31, "1 tháng")] - [InlineData(61, "2 tháng")] - [InlineData(92, "3 tháng")] - [InlineData(335, "11 tháng")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Google")] + [InlineData(31, "1 tháng")] + [InlineData(61, "2 tháng")] + [InlineData(92, "3 tháng")] + [InlineData(335, "11 tháng")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(14, "2 tuần")] - [InlineData(7, "1 tuần")] - public void Weeks(int days, string expected) - { + [Theory] + [InlineData(14, "2 tuần")] + [InlineData(7, "1 tuần")] + public void Weeks(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 ngày")] - [InlineData(1, "1 ngày")] - public void Days(int days, string expected) - { + [Theory] + [InlineData(2, "2 ngày")] + [InlineData(1, "1 ngày")] + public void Days(int days, string expected) + { var actual = TimeSpan.FromDays(days).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 giờ")] - [InlineData(1, "1 giờ")] - public void Hours(int hours, string expected) - { + [Theory] + [InlineData(2, "2 giờ")] + [InlineData(1, "1 giờ")] + public void Hours(int hours, string expected) + { var actual = TimeSpan.FromHours(hours).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 phút")] - [InlineData(1, "1 phút")] - public void Minutes(int minutes, string expected) - { + [Theory] + [InlineData(2, "2 phút")] + [InlineData(1, "1 phút")] + public void Minutes(int minutes, string expected) + { var actual = TimeSpan.FromMinutes(minutes).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 giây")] - [InlineData(1, "1 giây")] - public void Seconds(int seconds, string expected) - { + [Theory] + [InlineData(2, "2 giây")] + [InlineData(1, "1 giây")] + public void Seconds(int seconds, string expected) + { var actual = TimeSpan.FromSeconds(seconds).Humanize(); Assert.Equal(expected, actual); } - [Theory] - [InlineData(2, "2 phần ngàn giây")] - [InlineData(1, "1 phần ngàn giây")] - public void Milliseconds(int ms, string expected) - { + [Theory] + [InlineData(2, "2 phần ngàn giây")] + [InlineData(1, "1 phần ngàn giây")] + public void Milliseconds(int ms, string expected) + { var actual = TimeSpan.FromMilliseconds(ms).Humanize(); Assert.Equal(expected, actual); } - [Fact] - public void NoTime() - { + [Fact] + public void NoTime() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(); Assert.Equal("0 phần ngàn giây", actual); } - [Fact] - public void NoTimeToWords() - { + [Fact] + public void NoTimeToWords() + { var noTime = TimeSpan.Zero; var actual = noTime.Humanize(toWords: true); Assert.Equal("không giờ", actual); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-CN/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-CN/DateHumanizeTests.cs index dadb55320..4f272fb88 100644 --- a/src/Humanizer.Tests/Localisation/zh-CN/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-CN/DateHumanizeTests.cs @@ -1,81 +1,80 @@ -namespace Humanizer.Tests.Localisation.zhCN +namespace Humanizer.Tests.Localisation.zhCN; + +[UseCulture("zh-CN")] +public class DateHumanizeTests { - [UseCulture("zh-CN")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 天前")] - [InlineData(1, "昨天")] - [InlineData(0, "现在")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 天前")] + [InlineData(1, "昨天")] + [InlineData(0, "现在")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 天后")] - [InlineData(1, "明天")] - [InlineData(0, "现在")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "2 天后")] + [InlineData(1, "明天")] + [InlineData(0, "现在")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "2 小时前")] - [InlineData(1, "1 小时前")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 小时前")] + [InlineData(1, "1 小时前")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 小时后")] - [InlineData(1, "1 小时后")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "2 小时后")] + [InlineData(1, "1 小时后")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 分钟前")] - [InlineData(-1, "1 分钟前")] - [InlineData(60, "1 小时前")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 分钟前")] + [InlineData(-1, "1 分钟前")] + [InlineData(60, "1 小时前")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 分钟后")] - [InlineData(1, "1 分钟后")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "2 分钟后")] + [InlineData(1, "1 分钟后")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 个月前")] - [InlineData(-1, "1 个月前")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 个月前")] + [InlineData(-1, "1 个月前")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 个月后")] - [InlineData(1, "1 个月后")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "2 个月后")] + [InlineData(1, "1 个月后")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 秒钟前")] - [InlineData(-1, "1 秒钟前")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 秒钟前")] + [InlineData(-1, "1 秒钟前")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 秒钟后")] - [InlineData(1, "1 秒钟后")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "2 秒钟后")] + [InlineData(1, "1 秒钟后")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 年前")] - [InlineData(-1, "去年")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 年前")] + [InlineData(-1, "去年")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "2 年后")] - [InlineData(1, "明年")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(2, "2 年后")] + [InlineData(1, "明年")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-CN/NumberToWordsTests.cs b/src/Humanizer.Tests/Localisation/zh-CN/NumberToWordsTests.cs index ba6b0fa4f..1de309184 100644 --- a/src/Humanizer.Tests/Localisation/zh-CN/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-CN/NumberToWordsTests.cs @@ -1,55 +1,54 @@ -namespace Humanizer.Tests.Localisation.zhCN +namespace Humanizer.Tests.Localisation.zhCN; + +[UseCulture("zh-CN")] +public class NumberToWordsTests { - [UseCulture("zh-CN")] - public class NumberToWordsTests - { - [InlineData(1, "一")] - [InlineData(2, "二")] - [InlineData(3, "三")] - [InlineData(4, "四")] - [InlineData(-5, "负 五")] - [InlineData(6, "六")] - [InlineData(7, "七")] - [InlineData(8, "八")] - [InlineData(9, "九")] - [InlineData(10, "十")] - [InlineData(13, "十三")] - [InlineData(15, "十五")] - [InlineData(19, "十九")] - [InlineData(28, "二十八")] - [InlineData(37, "三十七")] - [InlineData(46, "四十六")] - [InlineData(55, "五十五")] - [InlineData(64, "六十四")] - [InlineData(73, "七十三")] - [InlineData(82, "八十二")] - [InlineData(-91, "负 九十一")] - [InlineData(100, "一百")] - [InlineData(507, "五百零七")] - [InlineData(719, "七百一十九")] - [InlineData(1356, "一千三百五十六")] - [InlineData(20089, "二万零八十九")] - [InlineData(335478, "三十三万五千四百七十八")] - [InlineData(4214599, "四百二十一万四千五百九十九")] - [InlineData(-54367865, "负 五千四百三十六万七千八百六十五")] - [InlineData(650004076, "六亿五千万四千零七十六")] - [InlineData(7156404367L, "七十一亿五千六百四十万四千三百六十七")] - [InlineData(89043267890L, "八百九十亿四千三百二十六万七千八百九十")] - [InlineData(500007893401L, "五千亿零七百八十九万三千四百零一")] - [InlineData(500000003401L, "五千亿零三千四百零一")] - [InlineData(500000000001L, "五千亿零一")] - [InlineData(500000000000L, "五千亿")] - [InlineData(6067823149088L, "六兆零六百七十八亿二千三百一十四万九千零八十八")] - [Theory] - public void ToWords(long number, string expected) => - Assert.Equal(expected, number.ToWords()); + [InlineData(1, "一")] + [InlineData(2, "二")] + [InlineData(3, "三")] + [InlineData(4, "四")] + [InlineData(-5, "负 五")] + [InlineData(6, "六")] + [InlineData(7, "七")] + [InlineData(8, "八")] + [InlineData(9, "九")] + [InlineData(10, "十")] + [InlineData(13, "十三")] + [InlineData(15, "十五")] + [InlineData(19, "十九")] + [InlineData(28, "二十八")] + [InlineData(37, "三十七")] + [InlineData(46, "四十六")] + [InlineData(55, "五十五")] + [InlineData(64, "六十四")] + [InlineData(73, "七十三")] + [InlineData(82, "八十二")] + [InlineData(-91, "负 九十一")] + [InlineData(100, "一百")] + [InlineData(507, "五百零七")] + [InlineData(719, "七百一十九")] + [InlineData(1356, "一千三百五十六")] + [InlineData(20089, "二万零八十九")] + [InlineData(335478, "三十三万五千四百七十八")] + [InlineData(4214599, "四百二十一万四千五百九十九")] + [InlineData(-54367865, "负 五千四百三十六万七千八百六十五")] + [InlineData(650004076, "六亿五千万四千零七十六")] + [InlineData(7156404367L, "七十一亿五千六百四十万四千三百六十七")] + [InlineData(89043267890L, "八百九十亿四千三百二十六万七千八百九十")] + [InlineData(500007893401L, "五千亿零七百八十九万三千四百零一")] + [InlineData(500000003401L, "五千亿零三千四百零一")] + [InlineData(500000000001L, "五千亿零一")] + [InlineData(500000000000L, "五千亿")] + [InlineData(6067823149088L, "六兆零六百七十八亿二千三百一十四万九千零八十八")] + [Theory] + public void ToWords(long number, string expected) => + Assert.Equal(expected, number.ToWords()); - [Theory] - [InlineData(1, "第 一")] - [InlineData(15, "第 十五")] - [InlineData(10000, "第 一万")] - [InlineData(31234, "第 三万一千二百三十四")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - } -} + [Theory] + [InlineData(1, "第 一")] + [InlineData(15, "第 十五")] + [InlineData(10000, "第 一万")] + [InlineData(31234, "第 三万一千二百三十四")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-CN/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-CN/TimeSpanHumanizeTests.cs index 806a8a608..3a43188df 100644 --- a/src/Humanizer.Tests/Localisation/zh-CN/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-CN/TimeSpanHumanizeTests.cs @@ -1,71 +1,70 @@ -namespace Humanizer.Tests.Localisation.zhCN +namespace Humanizer.Tests.Localisation.zhCN; + +[UseCulture("zh-CN")] +public class TimeSpanHumanizeTests { - [UseCulture("zh-CN")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 年")] - [InlineData(731, "2 年")] - [InlineData(1096, "3 年")] - [InlineData(4018, "11 年")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 个月")] - [InlineData(61, "2 个月")] - [InlineData(92, "3 个月")] - [InlineData(335, "11 个月")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 个月")] + [InlineData(61, "2 个月")] + [InlineData(92, "3 个月")] + [InlineData(335, "11 个月")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 周")] - [InlineData(14, "2 周")] - [InlineData(21, "3 周")] - [InlineData(77, "11 周")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 周")] + [InlineData(14, "2 周")] + [InlineData(21, "3 周")] + [InlineData(77, "11 周")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 天")] - [InlineData(2, "2 天")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 天")] + [InlineData(2, "2 天")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 小时")] - [InlineData(2, "2 小时")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 小时")] + [InlineData(2, "2 小时")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 分")] - [InlineData(2, "2 分")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 分")] + [InlineData(2, "2 分")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 秒")] - [InlineData(2, "2 秒")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 秒")] + [InlineData(2, "2 秒")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 毫秒")] - [InlineData(2, "2 毫秒")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 毫秒")] + [InlineData(2, "2 毫秒")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("没有时间", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("没有时间", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-HK/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-HK/DateHumanizeTests.cs index 60dd8eaa6..bb4360bab 100644 --- a/src/Humanizer.Tests/Localisation/zh-HK/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-HK/DateHumanizeTests.cs @@ -1,81 +1,80 @@ -namespace Humanizer.Tests.Localisation.zhHK +namespace Humanizer.Tests.Localisation.zhHK; + +[UseCulture("zh-HK")] +public class DateHumanizeTests { - [UseCulture("zh-HK")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 天前")] - [InlineData(1, "昨天")] - [InlineData(0, "現在")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 天前")] + [InlineData(1, "昨天")] + [InlineData(0, "現在")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 天後")] - [InlineData(1, "明天")] - [InlineData(0, "現在")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "2 天後")] + [InlineData(1, "明天")] + [InlineData(0, "現在")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "2 小時前")] - [InlineData(1, "1 小時前")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 小時前")] + [InlineData(1, "1 小時前")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 小時後")] - [InlineData(1, "1 小時後")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "2 小時後")] + [InlineData(1, "1 小時後")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 分鐘前")] - [InlineData(-1, "1 分鐘前")] - [InlineData(60, "1 小時前")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 分鐘前")] + [InlineData(-1, "1 分鐘前")] + [InlineData(60, "1 小時前")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 分鐘後")] - [InlineData(1, "1 分鐘後")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "2 分鐘後")] + [InlineData(1, "1 分鐘後")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 個月前")] - [InlineData(-1, "1 個月前")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 個月前")] + [InlineData(-1, "1 個月前")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 個月後")] - [InlineData(1, "1 個月後")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "2 個月後")] + [InlineData(1, "1 個月後")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 秒鐘前")] - [InlineData(-1, "1 秒鐘前")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 秒鐘前")] + [InlineData(-1, "1 秒鐘前")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 秒鐘後")] - [InlineData(1, "1 秒鐘後")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "2 秒鐘後")] + [InlineData(1, "1 秒鐘後")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 年前")] - [InlineData(-1, "去年")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 年前")] + [InlineData(-1, "去年")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "2 年後")] - [InlineData(1, "明年")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(2, "2 年後")] + [InlineData(1, "明年")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-HK/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-HK/TimeSpanHumanizeTests.cs index e34410126..8ae1abe91 100644 --- a/src/Humanizer.Tests/Localisation/zh-HK/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-HK/TimeSpanHumanizeTests.cs @@ -1,72 +1,71 @@ -namespace Humanizer.Tests.Localisation.zhHK +namespace Humanizer.Tests.Localisation.zhHK; + +[UseCulture("zh-HK")] +public class TimeSpanHumanizeTests { - [UseCulture("zh-HK")] - public class TimeSpanHumanizeTests + [Theory] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) { - [Theory] - [InlineData(366, "1 年")] - [InlineData(731, "2 年")] - [InlineData(1096, "3 年")] - [InlineData(4018, "11 年")] - public void Years(int days, string expected) - { - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - } + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + } - [Theory] - [InlineData(31, "1 個月")] - [InlineData(61, "2 個月")] - [InlineData(92, "3 個月")] - [InlineData(335, "11 個月")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [InlineData(31, "1 個月")] + [InlineData(61, "2 個月")] + [InlineData(92, "3 個月")] + [InlineData(335, "11 個月")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 周")] - [InlineData(14, "2 周")] - [InlineData(21, "3 周")] - [InlineData(77, "11 周")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 周")] + [InlineData(14, "2 周")] + [InlineData(21, "3 周")] + [InlineData(77, "11 周")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 天")] - [InlineData(2, "2 天")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 天")] + [InlineData(2, "2 天")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 小時")] - [InlineData(2, "2 小時")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 小時")] + [InlineData(2, "2 小時")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 分")] - [InlineData(2, "2 分")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 分")] + [InlineData(2, "2 分")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 秒")] - [InlineData(2, "2 秒")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 秒")] + [InlineData(2, "2 秒")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 毫秒")] - [InlineData(2, "2 毫秒")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 毫秒")] + [InlineData(2, "2 毫秒")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("沒有時間", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("沒有時間", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-Hans/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-Hans/DateHumanizeTests.cs index 06be28c17..577212e37 100644 --- a/src/Humanizer.Tests/Localisation/zh-Hans/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-Hans/DateHumanizeTests.cs @@ -1,81 +1,80 @@ -namespace Humanizer.Tests.Localisation.zhHans +namespace Humanizer.Tests.Localisation.zhHans; + +[UseCulture("zh-Hans")] +public class DateHumanizeTests { - [UseCulture("zh-Hans")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 天前")] - [InlineData(1, "昨天")] - [InlineData(0, "现在")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 天前")] + [InlineData(1, "昨天")] + [InlineData(0, "现在")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 天后")] - [InlineData(1, "明天")] - [InlineData(0, "现在")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "2 天后")] + [InlineData(1, "明天")] + [InlineData(0, "现在")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "2 小时前")] - [InlineData(1, "1 小时前")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 小时前")] + [InlineData(1, "1 小时前")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 小时后")] - [InlineData(1, "1 小时后")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "2 小时后")] + [InlineData(1, "1 小时后")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 分钟前")] - [InlineData(-1, "1 分钟前")] - [InlineData(60, "1 小时前")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 分钟前")] + [InlineData(-1, "1 分钟前")] + [InlineData(60, "1 小时前")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 分钟后")] - [InlineData(1, "1 分钟后")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "2 分钟后")] + [InlineData(1, "1 分钟后")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 个月前")] - [InlineData(-1, "1 个月前")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 个月前")] + [InlineData(-1, "1 个月前")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 个月后")] - [InlineData(1, "1 个月后")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "2 个月后")] + [InlineData(1, "1 个月后")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 秒钟前")] - [InlineData(-1, "1 秒钟前")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 秒钟前")] + [InlineData(-1, "1 秒钟前")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 秒钟后")] - [InlineData(1, "1 秒钟后")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "2 秒钟后")] + [InlineData(1, "1 秒钟后")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 年前")] - [InlineData(-1, "去年")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 年前")] + [InlineData(-1, "去年")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "2 年后")] - [InlineData(1, "明年")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(2, "2 年后")] + [InlineData(1, "明年")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-Hans/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-Hans/TimeSpanHumanizeTests.cs index df3911a0f..0d33b1830 100644 --- a/src/Humanizer.Tests/Localisation/zh-Hans/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-Hans/TimeSpanHumanizeTests.cs @@ -1,71 +1,70 @@ -namespace Humanizer.Tests.Localisation.zhHans +namespace Humanizer.Tests.Localisation.zhHans; + +[UseCulture("zh-Hans")] +public class TimeSpanHumanizeTests { - [UseCulture("zh-Hans")] - public class TimeSpanHumanizeTests - { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 年")] - [InlineData(731, "2 年")] - [InlineData(1096, "3 年")] - [InlineData(4018, "11 年")] - public void Years(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 个月")] - [InlineData(61, "2 个月")] - [InlineData(92, "3 个月")] - [InlineData(335, "11 个月")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 个月")] + [InlineData(61, "2 个月")] + [InlineData(92, "3 个月")] + [InlineData(335, "11 个月")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 周")] - [InlineData(14, "2 周")] - [InlineData(21, "3 周")] - [InlineData(77, "11 周")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 周")] + [InlineData(14, "2 周")] + [InlineData(21, "3 周")] + [InlineData(77, "11 周")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 天")] - [InlineData(2, "2 天")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 天")] + [InlineData(2, "2 天")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 小时")] - [InlineData(2, "2 小时")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 小时")] + [InlineData(2, "2 小时")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 分")] - [InlineData(2, "2 分")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 分")] + [InlineData(2, "2 分")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 秒")] - [InlineData(2, "2 秒")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 秒")] + [InlineData(2, "2 秒")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 毫秒")] - [InlineData(2, "2 毫秒")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 毫秒")] + [InlineData(2, "2 毫秒")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("没有时间", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("没有时间", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-Hant/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-Hant/DateHumanizeTests.cs index 182c12561..c1d90271a 100644 --- a/src/Humanizer.Tests/Localisation/zh-Hant/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-Hant/DateHumanizeTests.cs @@ -1,81 +1,80 @@ -namespace Humanizer.Tests.Localisation.zhHant +namespace Humanizer.Tests.Localisation.zhHant; + +[UseCulture("zh-Hant")] +public class DateHumanizeTests { - [UseCulture("zh-Hant")] - public class DateHumanizeTests - { - [Theory] - [InlineData(2, "2 天前")] - [InlineData(1, "昨天")] - [InlineData(0, "現在")] - public void DaysAgo(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + [Theory] + [InlineData(2, "2 天前")] + [InlineData(1, "昨天")] + [InlineData(0, "現在")] + public void DaysAgo(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); - [Theory] - [InlineData(2, "2 天後")] - [InlineData(1, "明天")] - [InlineData(0, "現在")] - public void DaysFromNow(int days, string expected) => - DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + [Theory] + [InlineData(2, "2 天後")] + [InlineData(1, "明天")] + [InlineData(0, "現在")] + public void DaysFromNow(int days, string expected) => + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); - [Theory] - [InlineData(2, "2 小時前")] - [InlineData(1, "1 小時前")] - public void HoursAgo(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + [Theory] + [InlineData(2, "2 小時前")] + [InlineData(1, "1 小時前")] + public void HoursAgo(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); - [Theory] - [InlineData(2, "2 小時後")] - [InlineData(1, "1 小時後")] - public void HoursFromNow(int hours, string expected) => - DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + [Theory] + [InlineData(2, "2 小時後")] + [InlineData(1, "1 小時後")] + public void HoursFromNow(int hours, string expected) => + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); - [Theory] - [InlineData(-2, "2 分鐘前")] - [InlineData(-1, "1 分鐘前")] - [InlineData(60, "1 小時前")] - public void MinutesAgo(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + [Theory] + [InlineData(-2, "2 分鐘前")] + [InlineData(-1, "1 分鐘前")] + [InlineData(60, "1 小時前")] + public void MinutesAgo(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); - [Theory] - [InlineData(2, "2 分鐘後")] - [InlineData(1, "1 分鐘後")] - public void MinutesFromNow(int minutes, string expected) => - DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + [Theory] + [InlineData(2, "2 分鐘後")] + [InlineData(1, "1 分鐘後")] + public void MinutesFromNow(int minutes, string expected) => + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); - [Theory] - [InlineData(-2, "2 個月前")] - [InlineData(-1, "1 個月前")] - public void MonthsAgo(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + [Theory] + [InlineData(-2, "2 個月前")] + [InlineData(-1, "1 個月前")] + public void MonthsAgo(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); - [Theory] - [InlineData(2, "2 個月後")] - [InlineData(1, "1 個月後")] - public void MonthsFromNow(int months, string expected) => - DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + [Theory] + [InlineData(2, "2 個月後")] + [InlineData(1, "1 個月後")] + public void MonthsFromNow(int months, string expected) => + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); - [Theory] - [InlineData(-2, "2 秒鐘前")] - [InlineData(-1, "1 秒鐘前")] - public void SecondsAgo(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + [Theory] + [InlineData(-2, "2 秒鐘前")] + [InlineData(-1, "1 秒鐘前")] + public void SecondsAgo(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); - [Theory] - [InlineData(2, "2 秒鐘後")] - [InlineData(1, "1 秒鐘後")] - public void SecondsFromNow(int seconds, string expected) => - DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + [Theory] + [InlineData(2, "2 秒鐘後")] + [InlineData(1, "1 秒鐘後")] + public void SecondsFromNow(int seconds, string expected) => + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); - [Theory] - [InlineData(-2, "2 年前")] - [InlineData(-1, "去年")] - public void YearsAgo(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + [Theory] + [InlineData(-2, "2 年前")] + [InlineData(-1, "去年")] + public void YearsAgo(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); - [Theory] - [InlineData(2, "2 年後")] - [InlineData(1, "明年")] - public void YearsFromNow(int years, string expected) => - DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); - } -} + [Theory] + [InlineData(2, "2 年後")] + [InlineData(1, "明年")] + public void YearsFromNow(int years, string expected) => + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/zh-Hant/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/zh-Hant/TimeSpanHumanizeTests.cs index 8aa2bfa53..29a1b5c89 100644 --- a/src/Humanizer.Tests/Localisation/zh-Hant/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/zh-Hant/TimeSpanHumanizeTests.cs @@ -1,74 +1,73 @@ -namespace Humanizer.Tests.Localisation.zhHant +namespace Humanizer.Tests.Localisation.zhHant; + +[UseCulture("zh-Hant")] +public class TimeSpanHumanizeTests { - [UseCulture("zh-Hant")] - public class TimeSpanHumanizeTests + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(366, "1 年")] + [InlineData(731, "2 年")] + [InlineData(1096, "3 年")] + [InlineData(4018, "11 年")] + public void Years(int days, string expected) { - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(366, "1 年")] - [InlineData(731, "2 年")] - [InlineData(1096, "3 年")] - [InlineData(4018, "11 年")] - public void Years(int days, string expected) - { - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - } + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + } - [Theory] - [Trait("Translation", "Native speaker")] - [InlineData(31, "1 個月")] - [InlineData(61, "2 個月")] - [InlineData(92, "3 個月")] - [InlineData(335, "11 個月")] - public void Months(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); + [Theory] + [Trait("Translation", "Native speaker")] + [InlineData(31, "1 個月")] + [InlineData(61, "2 個月")] + [InlineData(92, "3 個月")] + [InlineData(335, "11 個月")] + public void Months(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize(maxUnit: TimeUnit.Year)); - [Theory] - [InlineData(7, "1 周")] - [InlineData(14, "2 周")] - [InlineData(21, "3 周")] - [InlineData(77, "11 周")] - public void Weeks(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(7, "1 周")] + [InlineData(14, "2 周")] + [InlineData(21, "3 周")] + [InlineData(77, "11 周")] + public void Weeks(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 天")] - [InlineData(2, "2 天")] - public void Days(int days, string expected) => - Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + [Theory] + [InlineData(1, "1 天")] + [InlineData(2, "2 天")] + public void Days(int days, string expected) => + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); - [Theory] - [InlineData(1, "1 小時")] - [InlineData(2, "2 小時")] - public void Hours(int hours, string expected) => - Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + [Theory] + [InlineData(1, "1 小時")] + [InlineData(2, "2 小時")] + public void Hours(int hours, string expected) => + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); - [Theory] - [InlineData(1, "1 分")] - [InlineData(2, "2 分")] - public void Minutes(int minutes, string expected) => - Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + [Theory] + [InlineData(1, "1 分")] + [InlineData(2, "2 分")] + public void Minutes(int minutes, string expected) => + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); - [Theory] - [InlineData(1, "1 秒")] - [InlineData(2, "2 秒")] - public void Seconds(int seconds, string expected) => - Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + [Theory] + [InlineData(1, "1 秒")] + [InlineData(2, "2 秒")] + public void Seconds(int seconds, string expected) => + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); - [Theory] - [InlineData(1, "1 毫秒")] - [InlineData(2, "2 毫秒")] - public void Milliseconds(int milliseconds, string expected) => - Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + [Theory] + [InlineData(1, "1 毫秒")] + [InlineData(2, "2 毫秒")] + public void Milliseconds(int milliseconds, string expected) => + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); - [Fact] - public void NoTime() => - Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); + [Fact] + public void NoTime() => + Assert.Equal("0 毫秒", TimeSpan.Zero.Humanize()); - [Fact] - public void NoTimeToWords() => - // This one doesn't make a lot of sense but ... w/e - Assert.Equal("沒有時間", TimeSpan.Zero.Humanize(toWords: true)); - } -} + [Fact] + public void NoTimeToWords() => + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("沒有時間", TimeSpan.Zero.Humanize(toWords: true)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/MetricNumeralTests.cs b/src/Humanizer.Tests/MetricNumeralTests.cs index c85130419..ffda65ee4 100644 --- a/src/Humanizer.Tests/MetricNumeralTests.cs +++ b/src/Humanizer.Tests/MetricNumeralTests.cs @@ -1,44 +1,44 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class MetricNumeralTests { - [UseCulture("en-US")] - public class MetricNumeralTests - { - // Return a sequence of -24 -> 26 - public static IEnumerable SymbolRange => Enumerable.Range(-24, 51).Select(e => new object[] { e }); + // Return a sequence of -24 -> 26 + public static IEnumerable SymbolRange => Enumerable.Range(-24, 51).Select(e => new object[] { e }); - [Theory] - [InlineData(0, "0")] - [InlineData(123d, "123")] - [InlineData(-123d, "-123")] - [InlineData(1230d, "1.23k")] - [InlineData(1000d, "1 k")] - [InlineData(1000d, "1 kilo")] - [InlineData(1E-3, "1milli")] - public void FromMetric(double expected, string input) => - Assert.Equal(expected, input.FromMetric()); + [Theory] + [InlineData(0, "0")] + [InlineData(123d, "123")] + [InlineData(-123d, "-123")] + [InlineData(1230d, "1.23k")] + [InlineData(1000d, "1 k")] + [InlineData(1000d, "1 kilo")] + [InlineData(1E-3, "1milli")] + public void FromMetric(double expected, string input) => + Assert.Equal(expected, input.FromMetric()); - [Theory] - [InlineData("")] - [InlineData(" ")] - [InlineData("\t")] - [InlineData("12yy")] - [InlineData("-8e")] - [InlineData("0.12c")] - [InlineData("0.02l")] - [InlineData("0.12kilkilo")] - [InlineData("0.02alois")] - public void FromMetricOnInvalid(string input) => - Assert.Throws(() => input.FromMetric()); + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData("\t")] + [InlineData("12yy")] + [InlineData("-8e")] + [InlineData("0.12c")] + [InlineData("0.02l")] + [InlineData("0.12kilkilo")] + [InlineData("0.02alois")] + public void FromMetricOnInvalid(string input) => + Assert.Throws(() => input.FromMetric()); - [Fact] - public void FromMetricOnNull() => - Assert.Throws(() => - MetricNumeralExtensions.FromMetric(null!)); + [Fact] + public void FromMetricOnNull() => + Assert.Throws(() => + MetricNumeralExtensions.FromMetric(null!)); - [Theory] - [MemberData(nameof(SymbolRange))] - public void TestAllSymbols(int e) - { + [Theory] + [MemberData(nameof(SymbolRange))] + public void TestAllSymbols(int e) + { var origin = Math.Pow(10, e); var to = origin.ToMetric(); var from = to.FromMetric(); @@ -50,18 +50,18 @@ public void TestAllSymbols(int e) Assert.True(c); } - [Theory] - [InlineData(-9)] - [InlineData(-3)] - [InlineData(-2)] - [InlineData(-1)] - [InlineData(0)] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(9)] - public void TestAllSymbolsAsInt(int exponent) - { + [Theory] + [InlineData(-9)] + [InlineData(-3)] + [InlineData(-2)] + [InlineData(-1)] + [InlineData(0)] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + [InlineData(9)] + public void TestAllSymbolsAsInt(int exponent) + { var origin = Convert.ToInt32(Math.Pow(10, exponent)); var isEquals = Equals( origin.ToString("0.##E+0", CultureInfo.InvariantCulture), @@ -76,98 +76,97 @@ public void TestAllSymbolsAsInt(int exponent) Assert.True(isEquals); } - [Theory] - [InlineData("1.3M", 1300000, null, null)] - [InlineData("1.3million", 1300000, MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1.3 million", 1300000, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1.3 million", 1300000, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("0", 0d, null, null)] - [InlineData("123", 123d, null, null)] - [InlineData("-123", -123d, null, null)] - [InlineData("1.23k", 1230d, null, null)] - [InlineData("1 k", 1000d, MetricNumeralFormats.WithSpace, null)] - [InlineData("1milli", 1E-3, MetricNumeralFormats.UseName, null)] - [InlineData("1.23milli", 1.234E-3, MetricNumeralFormats.UseName, 2)] - [InlineData("12.34k", 12345, null, 2)] - [InlineData("12k", 12345, null, 0)] - [InlineData("-3.9m", -3.91e-3, null, 1)] - [InlineData("10 ", 10, MetricNumeralFormats.WithSpace, 0)] - [InlineData("1.2", 1.23, null, 1)] - [InlineData("1thousand", 1000d, MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1.23 thousand", 1230d, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1Y", 1E24, null, null)] - [InlineData("1 yotta", 1E24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 septillion", 1E24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 quadrillion", 1E24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1Z", 1E21, null, null)] - [InlineData("1 zetta", 1E21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 sextillion", 1E21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 trilliard", 1E21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1E", 1E18, null, null)] - [InlineData("1 exa", 1E18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 quintillion", 1E18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 trillion", 1E18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1P", 1E15, null, null)] - [InlineData("1 peta", 1E15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 quadrillion", 1E15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 billiard", 1E15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1T", 1E12, null, null)] - [InlineData("1 tera", 1E12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 trillion", 1E12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 billion", 1E12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1G", 1E9, null, null)] - [InlineData("1 giga", 1E9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 billion", 1E9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 milliard", 1E9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1M", 1E6, null, null)] - [InlineData("1 mega", 1E6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 million", 1E6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 million", 1E6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1k", 1E3, null, null)] - [InlineData("1 kilo", 1E3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 thousand", 1E3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 thousand", 1E3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1y", 1E-24, null, null)] - [InlineData("1 yocto", 1E-24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 septillionth", 1E-24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 quadrillionth", 1E-24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1z", 1E-21, null, null)] - [InlineData("1 zepto", 1E-21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 sextillionth", 1E-21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 trilliardth", 1E-21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1a", 1E-18, null, null)] - [InlineData("1 atto", 1E-18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 quintillionth", 1E-18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 trillionth", 1E-18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1f", 1E-15, null, null)] - [InlineData("1 femto", 1E-15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 quadrillionth", 1E-15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 billiardth", 1E-15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1p", 1E-12, null, null)] - [InlineData("1 pico", 1E-12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 trillionth", 1E-12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 billionth", 1E-12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1n", 1E-9, null, null)] - [InlineData("1 nano", 1E-9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 billionth", 1E-9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 milliardth", 1E-9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1μ", 1E-6, null, null)] - [InlineData("1 micro", 1E-6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 millionth", 1E-6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 millionth", 1E-6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - [InlineData("1m", 1E-3, null, null)] - [InlineData("1 milli", 1E-3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] - [InlineData("1 thousandth", 1E-3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] - [InlineData("1 thousandth", 1E-3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] - public void ToMetric(string expected, double input, MetricNumeralFormats? format, int? decimals) => - Assert.Equal(expected, input.ToMetric(format, decimals)); + [Theory] + [InlineData("1.3M", 1300000, null, null)] + [InlineData("1.3million", 1300000, MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1.3 million", 1300000, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1.3 million", 1300000, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("0", 0d, null, null)] + [InlineData("123", 123d, null, null)] + [InlineData("-123", -123d, null, null)] + [InlineData("1.23k", 1230d, null, null)] + [InlineData("1 k", 1000d, MetricNumeralFormats.WithSpace, null)] + [InlineData("1milli", 1E-3, MetricNumeralFormats.UseName, null)] + [InlineData("1.23milli", 1.234E-3, MetricNumeralFormats.UseName, 2)] + [InlineData("12.34k", 12345, null, 2)] + [InlineData("12k", 12345, null, 0)] + [InlineData("-3.9m", -3.91e-3, null, 1)] + [InlineData("10 ", 10, MetricNumeralFormats.WithSpace, 0)] + [InlineData("1.2", 1.23, null, 1)] + [InlineData("1thousand", 1000d, MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1.23 thousand", 1230d, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1Y", 1E24, null, null)] + [InlineData("1 yotta", 1E24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 septillion", 1E24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 quadrillion", 1E24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1Z", 1E21, null, null)] + [InlineData("1 zetta", 1E21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 sextillion", 1E21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 trilliard", 1E21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1E", 1E18, null, null)] + [InlineData("1 exa", 1E18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 quintillion", 1E18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 trillion", 1E18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1P", 1E15, null, null)] + [InlineData("1 peta", 1E15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 quadrillion", 1E15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 billiard", 1E15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1T", 1E12, null, null)] + [InlineData("1 tera", 1E12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 trillion", 1E12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 billion", 1E12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1G", 1E9, null, null)] + [InlineData("1 giga", 1E9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 billion", 1E9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 milliard", 1E9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1M", 1E6, null, null)] + [InlineData("1 mega", 1E6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 million", 1E6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 million", 1E6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1k", 1E3, null, null)] + [InlineData("1 kilo", 1E3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 thousand", 1E3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 thousand", 1E3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1y", 1E-24, null, null)] + [InlineData("1 yocto", 1E-24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 septillionth", 1E-24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 quadrillionth", 1E-24, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1z", 1E-21, null, null)] + [InlineData("1 zepto", 1E-21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 sextillionth", 1E-21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 trilliardth", 1E-21, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1a", 1E-18, null, null)] + [InlineData("1 atto", 1E-18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 quintillionth", 1E-18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 trillionth", 1E-18, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1f", 1E-15, null, null)] + [InlineData("1 femto", 1E-15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 quadrillionth", 1E-15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 billiardth", 1E-15, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1p", 1E-12, null, null)] + [InlineData("1 pico", 1E-12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 trillionth", 1E-12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 billionth", 1E-12, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1n", 1E-9, null, null)] + [InlineData("1 nano", 1E-9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 billionth", 1E-9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 milliardth", 1E-9, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1μ", 1E-6, null, null)] + [InlineData("1 micro", 1E-6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 millionth", 1E-6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 millionth", 1E-6, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + [InlineData("1m", 1E-3, null, null)] + [InlineData("1 milli", 1E-3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseName, null)] + [InlineData("1 thousandth", 1E-3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseShortScaleWord, null)] + [InlineData("1 thousandth", 1E-3, MetricNumeralFormats.WithSpace | MetricNumeralFormats.UseLongScaleWord, null)] + public void ToMetric(string expected, double input, MetricNumeralFormats? format, int? decimals) => + Assert.Equal(expected, input.ToMetric(format, decimals)); - [Theory] - [InlineData(1E+27)] - [InlineData(1E-27)] - [InlineData(-1E+27)] - [InlineData(-1E-27)] - public void ToMetricOnInvalid(double input) => - Assert.Throws(() => input.ToMetric()); - } -} + [Theory] + [InlineData(1E+27)] + [InlineData(1E-27)] + [InlineData(-1E+27)] + [InlineData(-1E-27)] + public void ToMetricOnInvalid(double input) => + Assert.Throws(() => input.ToMetric()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/NumberToNumberTests.cs b/src/Humanizer.Tests/NumberToNumberTests.cs index 94e602cbe..091515738 100644 --- a/src/Humanizer.Tests/NumberToNumberTests.cs +++ b/src/Humanizer.Tests/NumberToNumberTests.cs @@ -1,180 +1,179 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class NumberToNumberTests { - public class NumberToNumberTests + [Fact] + public void IntToTens() { - [Fact] - public void IntToTens() - { const int number = 1; Assert.Equal(10, number.Tens()); } - [Fact] - public void UintToTens() - { + [Fact] + public void UintToTens() + { const uint number = 1; Assert.Equal(10U, number.Tens()); } - [Fact] - public void LongToTens() - { + [Fact] + public void LongToTens() + { const long number = 1; Assert.Equal(10L, number.Tens()); } - [Fact] - public void UlongToTens() - { + [Fact] + public void UlongToTens() + { const ulong number = 1; Assert.Equal(10UL, number.Tens()); } - [Fact] - public void DoubleToTens() - { + [Fact] + public void DoubleToTens() + { const double number = 1; Assert.Equal(10d, number.Tens()); } - [Fact] - public void IntToHundreds() - { + [Fact] + public void IntToHundreds() + { const int number = 2; Assert.Equal(200, number.Hundreds()); } - [Fact] - public void UintToHundreds() - { + [Fact] + public void UintToHundreds() + { const uint number = 2; Assert.Equal(200U, number.Hundreds()); } - [Fact] - public void LongToHundreds() - { + [Fact] + public void LongToHundreds() + { const long number = 2; Assert.Equal(200L, number.Hundreds()); } - [Fact] - public void UlongToHundreds() - { + [Fact] + public void UlongToHundreds() + { const ulong number = 2; Assert.Equal(200UL, number.Hundreds()); } - [Fact] - public void DoubleToHundreds() - { + [Fact] + public void DoubleToHundreds() + { const double number = 2; Assert.Equal(200d, number.Hundreds()); } - [Fact] - public void IntToThousands() - { + [Fact] + public void IntToThousands() + { const int number = 3; Assert.Equal(3000, number.Thousands()); } - [Fact] - public void UintToThousands() - { + [Fact] + public void UintToThousands() + { const uint number = 3; Assert.Equal(3000U, number.Thousands()); } - [Fact] - public void LongToThousands() - { + [Fact] + public void LongToThousands() + { const long number = 3; Assert.Equal(3000L, number.Thousands()); } - [Fact] - public void UlongToThousands() - { + [Fact] + public void UlongToThousands() + { const ulong number = 3; Assert.Equal(3000UL, number.Thousands()); } - [Fact] - public void DoubleToThousands() - { + [Fact] + public void DoubleToThousands() + { const double number = 3; Assert.Equal(3000d, number.Thousands()); } - [Fact] - public void IntToMillions() - { + [Fact] + public void IntToMillions() + { const int number = 4; Assert.Equal(4000000, number.Millions()); } - [Fact] - public void UintToMillions() - { + [Fact] + public void UintToMillions() + { const uint number = 4; Assert.Equal(4000000U, number.Millions()); } - [Fact] - public void LongToMillions() - { + [Fact] + public void LongToMillions() + { const long number = 4; Assert.Equal(4000000L, number.Millions()); } - [Fact] - public void UlongToMillions() - { + [Fact] + public void UlongToMillions() + { const ulong number = 4; Assert.Equal(4000000UL, number.Millions()); } - [Fact] - public void DoubleToMillions() - { + [Fact] + public void DoubleToMillions() + { const double number = 4; Assert.Equal(4000000d, number.Millions()); } - [Fact] - public void IntToBillions() - { + [Fact] + public void IntToBillions() + { const int number = 1; Assert.Equal(1000000000, number.Billions()); } - [Fact] - public void UintToBillions() - { + [Fact] + public void UintToBillions() + { const uint number = 1; Assert.Equal(1000000000U, number.Billions()); } - [Fact] - public void LongToBillions() - { + [Fact] + public void LongToBillions() + { const long number = 1; Assert.Equal(1000000000L, number.Billions()); } - [Fact] - public void UlongToBillions() - { + [Fact] + public void UlongToBillions() + { const ulong number = 1; Assert.Equal(1000000000UL, number.Billions()); } - [Fact] - public void DoubleToBillions() - { + [Fact] + public void DoubleToBillions() + { const double number = 1; Assert.Equal(1000000000d, number.Billions()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/NumberToTimeSpanTests.cs b/src/Humanizer.Tests/NumberToTimeSpanTests.cs index 3bdfdd061..a24508c2d 100644 --- a/src/Humanizer.Tests/NumberToTimeSpanTests.cs +++ b/src/Humanizer.Tests/NumberToTimeSpanTests.cs @@ -1,349 +1,348 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class NumberToTimeSpanTests { - public class NumberToTimeSpanTests + [Fact] + public void ByteToMilliseconds() { - [Fact] - public void ByteToMilliseconds() - { const byte number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void SbyteToMilliseconds() - { + [Fact] + public void SbyteToMilliseconds() + { const sbyte number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void ShortToMilliseconds() - { + [Fact] + public void ShortToMilliseconds() + { const short number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void UshortToMilliseconds() - { + [Fact] + public void UshortToMilliseconds() + { const ushort number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void IntToMilliseconds() - { + [Fact] + public void IntToMilliseconds() + { const int number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void UintToMilliseconds() - { + [Fact] + public void UintToMilliseconds() + { const uint number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void LongToMilliseconds() - { + [Fact] + public void LongToMilliseconds() + { const long number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void UlongToMilliseconds() - { + [Fact] + public void UlongToMilliseconds() + { const ulong number = 1; Assert.Equal(new(0, 0, 0, 0, 1), number.Milliseconds()); } - [Fact] - public void ByteToMinutes() - { + [Fact] + public void ByteToMinutes() + { const byte number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void SbyteToMinutes() - { + [Fact] + public void SbyteToMinutes() + { const sbyte number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void ShortToMinutes() - { + [Fact] + public void ShortToMinutes() + { const short number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void UshortToMinutes() - { + [Fact] + public void UshortToMinutes() + { const ushort number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void IntToMinutes() - { + [Fact] + public void IntToMinutes() + { const int number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void UintToMinutes() - { + [Fact] + public void UintToMinutes() + { const uint number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void LongToMinutes() - { + [Fact] + public void LongToMinutes() + { const long number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void UlongToMinutes() - { + [Fact] + public void UlongToMinutes() + { const ulong number = 2; Assert.Equal(new(0, 0, 2, 0), number.Minutes()); } - [Fact] - public void ByteToSeconds() - { + [Fact] + public void ByteToSeconds() + { const byte number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void SbyteToSeconds() - { + [Fact] + public void SbyteToSeconds() + { const sbyte number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void ShortToSeconds() - { + [Fact] + public void ShortToSeconds() + { const short number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void UshortToSeconds() - { + [Fact] + public void UshortToSeconds() + { const ushort number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void IntToSeconds() - { + [Fact] + public void IntToSeconds() + { const int number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void UintToSeconds() - { + [Fact] + public void UintToSeconds() + { const uint number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void LongToSeconds() - { + [Fact] + public void LongToSeconds() + { const long number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void UlongToSeconds() - { + [Fact] + public void UlongToSeconds() + { const ulong number = 3; Assert.Equal(new(0, 0, 0, 3), number.Seconds()); } - [Fact] - public void ByteToHours() - { + [Fact] + public void ByteToHours() + { const byte number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void SbyteToHours() - { + [Fact] + public void SbyteToHours() + { const sbyte number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void ShortToHours() - { + [Fact] + public void ShortToHours() + { const short number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void UshortToHours() - { + [Fact] + public void UshortToHours() + { const ushort number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void IntToHours() - { + [Fact] + public void IntToHours() + { const int number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void UintToHours() - { + [Fact] + public void UintToHours() + { const uint number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void LongToHours() - { + [Fact] + public void LongToHours() + { const long number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void UlongToHours() - { + [Fact] + public void UlongToHours() + { const ulong number = 4; Assert.Equal(new(0, 4, 0, 0), number.Hours()); } - [Fact] - public void ByteToDays() - { + [Fact] + public void ByteToDays() + { const byte number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void SbyteToDays() - { + [Fact] + public void SbyteToDays() + { const sbyte number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void ShortToDays() - { + [Fact] + public void ShortToDays() + { const short number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void UshortToDays() - { + [Fact] + public void UshortToDays() + { const ushort number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void IntToDays() - { + [Fact] + public void IntToDays() + { const int number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void UintToDays() - { + [Fact] + public void UintToDays() + { const uint number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void LongToDays() - { + [Fact] + public void LongToDays() + { const long number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void UlongToDays() - { + [Fact] + public void UlongToDays() + { const ulong number = 5; Assert.Equal(new(5, 0, 0, 0), number.Days()); } - [Fact] - public void ByteToWeeks() - { + [Fact] + public void ByteToWeeks() + { const byte number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void SbyteToWeeks() - { + [Fact] + public void SbyteToWeeks() + { const sbyte number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void ShortToWeeks() - { + [Fact] + public void ShortToWeeks() + { const short number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void UshortToWeeks() - { + [Fact] + public void UshortToWeeks() + { const ushort number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void IntToWeeks() - { + [Fact] + public void IntToWeeks() + { const int number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void UintToWeeks() - { + [Fact] + public void UintToWeeks() + { const uint number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void LongToWeeks() - { + [Fact] + public void LongToWeeks() + { const long number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - [Fact] - public void UlongToWeeks() - { + [Fact] + public void UlongToWeeks() + { const ulong number = 6; var now = DateTime.Now; Assert.Equal(now.AddDays(42), now.Add(number.Weeks())); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/NumberToWordsTests.cs b/src/Humanizer.Tests/NumberToWordsTests.cs index ce32ad1b4..f67690625 100644 --- a/src/Humanizer.Tests/NumberToWordsTests.cs +++ b/src/Humanizer.Tests/NumberToWordsTests.cs @@ -1,68 +1,68 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class NumberToWordsTests { - [UseCulture("en-US")] - public class NumberToWordsTests + [Theory] + [InlineData(0, "zeroth")] + [InlineData(1, "first")] + [InlineData(2, "second")] + [InlineData(3, "third")] + [InlineData(4, "fourth")] + [InlineData(5, "fifth")] + [InlineData(6, "sixth")] + [InlineData(7, "seventh")] + [InlineData(8, "eighth")] + [InlineData(9, "ninth")] + [InlineData(10, "tenth")] + [InlineData(11, "eleventh")] + [InlineData(12, "twelfth")] + [InlineData(13, "thirteenth")] + [InlineData(14, "fourteenth")] + [InlineData(15, "fifteenth")] + [InlineData(16, "sixteenth")] + [InlineData(17, "seventeenth")] + [InlineData(18, "eighteenth")] + [InlineData(19, "nineteenth")] + [InlineData(20, "twentieth")] + [InlineData(21, "twenty-first")] + [InlineData(22, "twenty-second")] + [InlineData(30, "thirtieth")] + [InlineData(40, "fortieth")] + [InlineData(50, "fiftieth")] + [InlineData(60, "sixtieth")] + [InlineData(70, "seventieth")] + [InlineData(80, "eightieth")] + [InlineData(90, "ninetieth")] + [InlineData(95, "ninety-fifth")] + [InlineData(96, "ninety-sixth")] + [InlineData(100, "hundredth")] + [InlineData(112, "hundred and twelfth")] + [InlineData(120, "hundred and twentieth")] + [InlineData(121, "hundred and twenty-first")] + [InlineData(1000, "thousandth")] + [InlineData(1001, "thousand and first")] + [InlineData(1021, "thousand and twenty-first")] + [InlineData(10000, "ten thousandth")] + [InlineData(10121, "ten thousand one hundred and twenty-first")] + [InlineData(100000, "hundred thousandth")] + [InlineData(1000000, "millionth")] + public void ToOrdinalWords(int number, string words) => + Assert.Equal(words, number.ToOrdinalWords()); + + [Theory] + [InlineData(1021, "en-US", "thousand and twenty-first")] + [InlineData(21, "ar", "الحادي و العشرون")] + [InlineData(1112, "ru", "одна тысяча сто двенадцатый")] + public void ToOrdinalWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => + Assert.Equal(expected, number.ToOrdinalWords(new(culture))); + + [Theory] + [InlineData(1, "first")] + [InlineData(2, "second")] + [InlineData(3, "third")] + public void ToOrdinalWords_WordFormIsIgnored(int number, string expected) { - [Theory] - [InlineData(0, "zeroth")] - [InlineData(1, "first")] - [InlineData(2, "second")] - [InlineData(3, "third")] - [InlineData(4, "fourth")] - [InlineData(5, "fifth")] - [InlineData(6, "sixth")] - [InlineData(7, "seventh")] - [InlineData(8, "eighth")] - [InlineData(9, "ninth")] - [InlineData(10, "tenth")] - [InlineData(11, "eleventh")] - [InlineData(12, "twelfth")] - [InlineData(13, "thirteenth")] - [InlineData(14, "fourteenth")] - [InlineData(15, "fifteenth")] - [InlineData(16, "sixteenth")] - [InlineData(17, "seventeenth")] - [InlineData(18, "eighteenth")] - [InlineData(19, "nineteenth")] - [InlineData(20, "twentieth")] - [InlineData(21, "twenty-first")] - [InlineData(22, "twenty-second")] - [InlineData(30, "thirtieth")] - [InlineData(40, "fortieth")] - [InlineData(50, "fiftieth")] - [InlineData(60, "sixtieth")] - [InlineData(70, "seventieth")] - [InlineData(80, "eightieth")] - [InlineData(90, "ninetieth")] - [InlineData(95, "ninety-fifth")] - [InlineData(96, "ninety-sixth")] - [InlineData(100, "hundredth")] - [InlineData(112, "hundred and twelfth")] - [InlineData(120, "hundred and twentieth")] - [InlineData(121, "hundred and twenty-first")] - [InlineData(1000, "thousandth")] - [InlineData(1001, "thousand and first")] - [InlineData(1021, "thousand and twenty-first")] - [InlineData(10000, "ten thousandth")] - [InlineData(10121, "ten thousand one hundred and twenty-first")] - [InlineData(100000, "hundred thousandth")] - [InlineData(1000000, "millionth")] - public void ToOrdinalWords(int number, string words) => - Assert.Equal(words, number.ToOrdinalWords()); - - [Theory] - [InlineData(1021, "en-US", "thousand and twenty-first")] - [InlineData(21, "ar", "الحادي و العشرون")] - [InlineData(1112, "ru", "одна тысяча сто двенадцатый")] - public void ToOrdinalWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => - Assert.Equal(expected, number.ToOrdinalWords(new(culture))); - - [Theory] - [InlineData(1, "first")] - [InlineData(2, "second")] - [InlineData(3, "third")] - public void ToOrdinalWords_WordFormIsIgnored(int number, string expected) - { var normalForm1 = number.ToOrdinalWords(WordForm.Normal); var abbrForm1 = number.ToOrdinalWords(WordForm.Abbreviation); var normalForm2 = number.ToOrdinalWords(default, WordForm.Normal); @@ -73,15 +73,15 @@ public void ToOrdinalWords_WordFormIsIgnored(int number, string expected) item => Assert.Equal(expected, item)); } - [Theory] - [InlineData(1, "en-US", "first")] - [InlineData(3, "en-US", "third")] - [InlineData(1, "sv-SE", "första")] - [InlineData(3, "sv-SE", "tredje")] - [InlineData(1, "ko-KR", "첫번째")] - [InlineData(3, "ko-KR", "세번째")] - public void ToOrdinalWords_WordFormIsIgnoredWithSpecificCulture(int number, string culture, string expected) - { + [Theory] + [InlineData(1, "en-US", "first")] + [InlineData(3, "en-US", "third")] + [InlineData(1, "sv-SE", "första")] + [InlineData(3, "sv-SE", "tredje")] + [InlineData(1, "ko-KR", "첫번째")] + [InlineData(3, "ko-KR", "세번째")] + public void ToOrdinalWords_WordFormIsIgnoredWithSpecificCulture(int number, string culture, string expected) + { var cultureInfo = new CultureInfo(culture); var cultureSpecificNumber = number.ToOrdinalWords(cultureInfo); @@ -95,39 +95,39 @@ public void ToOrdinalWords_WordFormIsIgnoredWithSpecificCulture(int number, stri item => Assert.Equal(expected, item)); } - [Theory] - [InlineData(0, "0-tuple")] - [InlineData(1, "single")] - [InlineData(2, "double")] - [InlineData(3, "triple")] - [InlineData(4, "quadruple")] - [InlineData(5, "quintuple")] - [InlineData(6, "sextuple")] - [InlineData(7, "septuple")] - [InlineData(8, "octuple")] - [InlineData(9, "nonuple")] - [InlineData(10, "decuple")] - [InlineData(100, "centuple")] - [InlineData(1000, "milluple")] - public void ToTuple(int number, string expected) => - Assert.Equal(expected, number.ToTuple()); - - [Theory] - [InlineData(11, "en-US", "eleven")] - [InlineData(22, "ar", "اثنان و عشرون")] - [InlineData(40, "ru", "сорок")] - [InlineData(1021, "hr", "tisuću dvadeset jedan")] - [InlineData(11, "ta", "பதினொன்று")] - [InlineData(12, "ta", "பனிரெண்டு")] - [InlineData(555, "ta", "ஐந்நூற்று ஐம்பத்து ஐந்து")] - public void ToWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => - Assert.Equal(expected, number.ToWords(new(culture))); - - [Theory] - [InlineData(1, "one")] - [InlineData(3, "three")] - public void ToWords_WordFormIsIgnored(int number, string expected) - { + [Theory] + [InlineData(0, "0-tuple")] + [InlineData(1, "single")] + [InlineData(2, "double")] + [InlineData(3, "triple")] + [InlineData(4, "quadruple")] + [InlineData(5, "quintuple")] + [InlineData(6, "sextuple")] + [InlineData(7, "septuple")] + [InlineData(8, "octuple")] + [InlineData(9, "nonuple")] + [InlineData(10, "decuple")] + [InlineData(100, "centuple")] + [InlineData(1000, "milluple")] + public void ToTuple(int number, string expected) => + Assert.Equal(expected, number.ToTuple()); + + [Theory] + [InlineData(11, "en-US", "eleven")] + [InlineData(22, "ar", "اثنان و عشرون")] + [InlineData(40, "ru", "сорок")] + [InlineData(1021, "hr", "tisuću dvadeset jedan")] + [InlineData(11, "ta", "பதினொன்று")] + [InlineData(12, "ta", "பனிரெண்டு")] + [InlineData(555, "ta", "ஐந்நூற்று ஐம்பத்து ஐந்து")] + public void ToWords_CanSpecifyCultureExplicitly(int number, string culture, string expected) => + Assert.Equal(expected, number.ToWords(new(culture))); + + [Theory] + [InlineData(1, "one")] + [InlineData(3, "three")] + public void ToWords_WordFormIsIgnored(int number, string expected) + { var normalForm1 = number.ToWords(WordForm.Normal); var abbrForm1 = number.ToWords(WordForm.Abbreviation); var normalForm2 = number.ToWords(addAnd: true, WordForm.Normal); @@ -140,15 +140,15 @@ public void ToWords_WordFormIsIgnored(int number, string expected) item => Assert.Equal(expected, item)); } - [Theory] - [InlineData(1, "en-US", "one")] - [InlineData(3, "en-US", "three")] - [InlineData(1, "sv-SE", "ett")] - [InlineData(3, "sv-SE", "tre")] - [InlineData(1, "ko-KR", "일")] - [InlineData(3, "ko-KR", "삼")] - public void ToWords_WordFormIsIgnoredWithSpecificCulture(int number, string culture, string expected) - { + [Theory] + [InlineData(1, "en-US", "one")] + [InlineData(3, "en-US", "three")] + [InlineData(1, "sv-SE", "ett")] + [InlineData(3, "sv-SE", "tre")] + [InlineData(1, "ko-KR", "일")] + [InlineData(3, "ko-KR", "삼")] + public void ToWords_WordFormIsIgnoredWithSpecificCulture(int number, string culture, string expected) + { var cultureInfo = new CultureInfo(culture); var cultureSpecificNumber = number.ToWords(cultureInfo); @@ -162,66 +162,65 @@ public void ToWords_WordFormIsIgnoredWithSpecificCulture(int number, string cult item => Assert.Equal(expected, item)); } - [Theory] - [InlineData(-1, "minus one")] - [InlineData(1, "one")] - [InlineData(10, "ten")] - [InlineData(11, "eleven")] - [InlineData(20, "twenty")] - [InlineData(122, "one hundred and twenty-two")] - [InlineData(3501, "three thousand five hundred and one")] - [InlineData(100, "one hundred")] - [InlineData(1000, "one thousand")] - [InlineData(100000, "one hundred thousand")] - [InlineData(1000000, "one million")] - [InlineData(10000000, "ten million")] - [InlineData(100000000, "one hundred million")] - [InlineData(1000000000, "one billion")] - [InlineData(111, "one hundred and eleven")] - [InlineData(1111, "one thousand one hundred and eleven")] - [InlineData(111111, "one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111, "one million one hundred and eleven thousand one hundred and eleven")] - [InlineData(11111111, "eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(111111111, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111111, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(123, "one hundred and twenty-three")] - [InlineData(1234, "one thousand two hundred and thirty-four")] - [InlineData(12345, "twelve thousand three hundred and forty-five")] - [InlineData(123456, "one hundred and twenty-three thousand four hundred and fifty-six")] - [InlineData(1234567, "one million two hundred and thirty-four thousand five hundred and sixty-seven")] - [InlineData(12345678, "twelve million three hundred and forty-five thousand six hundred and seventy-eight")] - [InlineData(123456789, "one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine")] - [InlineData(1234567890, "one billion two hundred and thirty-four million five hundred and sixty-seven thousand eight hundred and ninety")] - public void ToWordsInt(int number, string expected) => - Assert.Equal(expected, number.ToWords()); - - [Theory] - [InlineData(-1L, "minus one")] - [InlineData(1L, "one")] - [InlineData(11L, "eleven")] - [InlineData(111L, "one hundred and eleven")] - [InlineData(1111L, "one thousand one hundred and eleven")] - [InlineData(11111L, "eleven thousand one hundred and eleven")] - [InlineData(111111L, "one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111L, "one million one hundred and eleven thousand one hundred and eleven")] - [InlineData(11111111L, "eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(111111111L, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111111L, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(11111111111L, "eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(111111111111L, "one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111111111L, "one trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(11111111111111L, "eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(111111111111111L, "one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111111111111L, "one quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(11111111111111111L, "eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(111111111111111111L, "one hundred and eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - [InlineData(1111111111111111111L, "one quintillion one hundred and eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] - public void ToWordsLong(long number, string expected) => - Assert.Equal(expected, number.ToWords()); - - [Theory] - [InlineData(3501L, "three thousand five hundred one", false)] - public void ToWordsWithoutAnd(int number, string expected, bool addAnd) => - Assert.Equal(expected, number.ToWords(addAnd)); - } -} + [Theory] + [InlineData(-1, "minus one")] + [InlineData(1, "one")] + [InlineData(10, "ten")] + [InlineData(11, "eleven")] + [InlineData(20, "twenty")] + [InlineData(122, "one hundred and twenty-two")] + [InlineData(3501, "three thousand five hundred and one")] + [InlineData(100, "one hundred")] + [InlineData(1000, "one thousand")] + [InlineData(100000, "one hundred thousand")] + [InlineData(1000000, "one million")] + [InlineData(10000000, "ten million")] + [InlineData(100000000, "one hundred million")] + [InlineData(1000000000, "one billion")] + [InlineData(111, "one hundred and eleven")] + [InlineData(1111, "one thousand one hundred and eleven")] + [InlineData(111111, "one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111, "one million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111, "eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(123, "one hundred and twenty-three")] + [InlineData(1234, "one thousand two hundred and thirty-four")] + [InlineData(12345, "twelve thousand three hundred and forty-five")] + [InlineData(123456, "one hundred and twenty-three thousand four hundred and fifty-six")] + [InlineData(1234567, "one million two hundred and thirty-four thousand five hundred and sixty-seven")] + [InlineData(12345678, "twelve million three hundred and forty-five thousand six hundred and seventy-eight")] + [InlineData(123456789, "one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine")] + [InlineData(1234567890, "one billion two hundred and thirty-four million five hundred and sixty-seven thousand eight hundred and ninety")] + public void ToWordsInt(int number, string expected) => + Assert.Equal(expected, number.ToWords()); + + [Theory] + [InlineData(-1L, "minus one")] + [InlineData(1L, "one")] + [InlineData(11L, "eleven")] + [InlineData(111L, "one hundred and eleven")] + [InlineData(1111L, "one thousand one hundred and eleven")] + [InlineData(11111L, "eleven thousand one hundred and eleven")] + [InlineData(111111L, "one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111L, "one million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111L, "eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111L, "one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111L, "one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111111L, "eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111111L, "one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111111L, "one trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111111111L, "eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111111111L, "one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111111111L, "one quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(11111111111111111L, "eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(111111111111111111L, "one hundred and eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + [InlineData(1111111111111111111L, "one quintillion one hundred and eleven quadrillion one hundred and eleven trillion one hundred and eleven billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven")] + public void ToWordsLong(long number, string expected) => + Assert.Equal(expected, number.ToWords()); + + [Theory] + [InlineData(3501L, "three thousand five hundred one", false)] + public void ToWordsWithoutAnd(int number, string expected, bool addAnd) => + Assert.Equal(expected, number.ToWords(addAnd)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/OrdinalizeTests.cs b/src/Humanizer.Tests/OrdinalizeTests.cs index d707bba9c..be789535e 100644 --- a/src/Humanizer.Tests/OrdinalizeTests.cs +++ b/src/Humanizer.Tests/OrdinalizeTests.cs @@ -1,165 +1,164 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class OrdinalizeTests { - [UseCulture("en-US")] - public class OrdinalizeTests - { - [Theory] - [InlineData("0", "0th")] - [InlineData("1", "1st")] - [InlineData("2", "2nd")] - [InlineData("3", "3rd")] - [InlineData("4", "4th")] - [InlineData("5", "5th")] - [InlineData("6", "6th")] - [InlineData("7", "7th")] - [InlineData("8", "8th")] - [InlineData("9", "9th")] - [InlineData("10", "10th")] - [InlineData("11", "11th")] - [InlineData("12", "12th")] - [InlineData("13", "13th")] - [InlineData("14", "14th")] - [InlineData("20", "20th")] - [InlineData("21", "21st")] - [InlineData("22", "22nd")] - [InlineData("23", "23rd")] - [InlineData("24", "24th")] - [InlineData("100", "100th")] - [InlineData("101", "101st")] - [InlineData("102", "102nd")] - [InlineData("103", "103rd")] - [InlineData("104", "104th")] - [InlineData("110", "110th")] - [InlineData("1000", "1000th")] - [InlineData("1001", "1001st")] - public void OrdinalizeString(string number, string ordinalized) => - Assert.Equal(number.Ordinalize(), ordinalized); + [Theory] + [InlineData("0", "0th")] + [InlineData("1", "1st")] + [InlineData("2", "2nd")] + [InlineData("3", "3rd")] + [InlineData("4", "4th")] + [InlineData("5", "5th")] + [InlineData("6", "6th")] + [InlineData("7", "7th")] + [InlineData("8", "8th")] + [InlineData("9", "9th")] + [InlineData("10", "10th")] + [InlineData("11", "11th")] + [InlineData("12", "12th")] + [InlineData("13", "13th")] + [InlineData("14", "14th")] + [InlineData("20", "20th")] + [InlineData("21", "21st")] + [InlineData("22", "22nd")] + [InlineData("23", "23rd")] + [InlineData("24", "24th")] + [InlineData("100", "100th")] + [InlineData("101", "101st")] + [InlineData("102", "102nd")] + [InlineData("103", "103rd")] + [InlineData("104", "104th")] + [InlineData("110", "110th")] + [InlineData("1000", "1000th")] + [InlineData("1001", "1001st")] + public void OrdinalizeString(string number, string ordinalized) => + Assert.Equal(number.Ordinalize(), ordinalized); - [Theory] - [InlineData(0, "0th")] - [InlineData(1, "1st")] - [InlineData(2, "2nd")] - [InlineData(3, "3rd")] - [InlineData(4, "4th")] - [InlineData(5, "5th")] - [InlineData(6, "6th")] - [InlineData(7, "7th")] - [InlineData(8, "8th")] - [InlineData(9, "9th")] - [InlineData(10, "10th")] - [InlineData(11, "11th")] - [InlineData(12, "12th")] - [InlineData(13, "13th")] - [InlineData(14, "14th")] - [InlineData(20, "20th")] - [InlineData(21, "21st")] - [InlineData(22, "22nd")] - [InlineData(23, "23rd")] - [InlineData(24, "24th")] - [InlineData(100, "100th")] - [InlineData(101, "101st")] - [InlineData(102, "102nd")] - [InlineData(103, "103rd")] - [InlineData(104, "104th")] - [InlineData(110, "110th")] - [InlineData(1000, "1000th")] - [InlineData(1001, "1001st")] - public void OrdinalizeNumber(int number, string ordinalized) => - Assert.Equal(number.Ordinalize(), ordinalized); + [Theory] + [InlineData(0, "0th")] + [InlineData(1, "1st")] + [InlineData(2, "2nd")] + [InlineData(3, "3rd")] + [InlineData(4, "4th")] + [InlineData(5, "5th")] + [InlineData(6, "6th")] + [InlineData(7, "7th")] + [InlineData(8, "8th")] + [InlineData(9, "9th")] + [InlineData(10, "10th")] + [InlineData(11, "11th")] + [InlineData(12, "12th")] + [InlineData(13, "13th")] + [InlineData(14, "14th")] + [InlineData(20, "20th")] + [InlineData(21, "21st")] + [InlineData(22, "22nd")] + [InlineData(23, "23rd")] + [InlineData(24, "24th")] + [InlineData(100, "100th")] + [InlineData(101, "101st")] + [InlineData(102, "102nd")] + [InlineData(103, "103rd")] + [InlineData(104, "104th")] + [InlineData(110, "110th")] + [InlineData(1000, "1000th")] + [InlineData(1001, "1001st")] + public void OrdinalizeNumber(int number, string ordinalized) => + Assert.Equal(number.Ordinalize(), ordinalized); - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(8)] - public void OrdinalizeNumberGenderIsImmaterial(int number) - { + [Theory] + [InlineData(0)] + [InlineData(1)] + [InlineData(8)] + public void OrdinalizeNumberGenderIsImmaterial(int number) + { var masculineOrdinalized = number.Ordinalize(GrammaticalGender.Masculine); var feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine); Assert.Equal(masculineOrdinalized, feminineOrdinalized); } - [Theory] - [InlineData("0")] - [InlineData("1")] - [InlineData("8")] - public void OrdinalizeStringGenderIsImmaterial(string number) - { + [Theory] + [InlineData("0")] + [InlineData("1")] + [InlineData("8")] + public void OrdinalizeStringGenderIsImmaterial(string number) + { var masculineOrdinalized = number.Ordinalize(GrammaticalGender.Masculine); var feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine); Assert.Equal(masculineOrdinalized, feminineOrdinalized); } - [Theory] - [InlineData("en-US", "1", "1st")] - [InlineData("nl-NL", "1", "1e")] - public void OrdinalizeStringWithCultureOverridesCurrentCulture(string cultureName, string number, string ordinalized) - { + [Theory] + [InlineData("en-US", "1", "1st")] + [InlineData("nl-NL", "1", "1e")] + public void OrdinalizeStringWithCultureOverridesCurrentCulture(string cultureName, string number, string ordinalized) + { var culture = new CultureInfo(cultureName); Assert.Equal(number.Ordinalize(culture), ordinalized); } - [Theory] - [InlineData("en-US", 1, "1st")] - [InlineData("nl-NL", 1, "1e")] - public void OrdinalizeNumberWithCultureOverridesCurrentCulture(string cultureName, int number, string ordinalized) - { + [Theory] + [InlineData("en-US", 1, "1st")] + [InlineData("nl-NL", 1, "1e")] + public void OrdinalizeNumberWithCultureOverridesCurrentCulture(string cultureName, int number, string ordinalized) + { var culture = new CultureInfo(cultureName); Assert.Equal(number.Ordinalize(culture), ordinalized); } - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(8)] - public void OrdinalizeNumberWithOverridenCultureGenderIsImmaterial(int number) - { + [Theory] + [InlineData(0)] + [InlineData(1)] + [InlineData(8)] + public void OrdinalizeNumberWithOverridenCultureGenderIsImmaterial(int number) + { var culture = new CultureInfo("nl-NL"); var masculineOrdinalized = number.Ordinalize(GrammaticalGender.Masculine, culture); var feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine, culture); Assert.Equal(masculineOrdinalized, feminineOrdinalized); } - [Theory] - [InlineData("0")] - [InlineData("1")] - [InlineData("8")] - public void OrdinalizeStringWithOverridenGenderIsImmaterial(string number) - { + [Theory] + [InlineData("0")] + [InlineData("1")] + [InlineData("8")] + public void OrdinalizeStringWithOverridenGenderIsImmaterial(string number) + { var culture = new CultureInfo("nl-NL"); var masculineOrdinalized = number.Ordinalize(GrammaticalGender.Masculine, culture); var feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine, culture); Assert.Equal(masculineOrdinalized, feminineOrdinalized); } - [Theory] - [InlineData(1, WordForm.Normal, "es-ES", "1.º")] - [InlineData(1, WordForm.Abbreviation, "es-ES", "1.er")] - [InlineData(1, WordForm.Normal, "en-US", "1st")] - [InlineData(1, WordForm.Abbreviation, "en-US", "1st")] - public void OrdinalizeNumberWithOverridenCultureAndSpecificForm(int number, WordForm wordForm, string cultureName, string expected) - { + [Theory] + [InlineData(1, WordForm.Normal, "es-ES", "1.º")] + [InlineData(1, WordForm.Abbreviation, "es-ES", "1.er")] + [InlineData(1, WordForm.Normal, "en-US", "1st")] + [InlineData(1, WordForm.Abbreviation, "en-US", "1st")] + public void OrdinalizeNumberWithOverridenCultureAndSpecificForm(int number, WordForm wordForm, string cultureName, string expected) + { var culture = new CultureInfo(cultureName); Assert.Equal(expected, number.Ordinalize(culture, wordForm)); Assert.Equal(expected, number.ToString(culture).Ordinalize(culture, wordForm)); } - [Theory] - [InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "es-ES", "1.º")] - [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "es-ES", "1.er")] - [InlineData(1, WordForm.Normal, GrammaticalGender.Feminine, "es-ES", "1.ª")] - [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "es-ES", "1.ª")] - [InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "en-US", "1st")] - [InlineData(1, WordForm.Normal, GrammaticalGender.Feminine, "en-US", "1st")] - public void OrdinalizeNumberWithOverridenCultureAndGenderAndForm( - int number, - WordForm wordForm, - GrammaticalGender gender, - string cultureName, - string expected) - { + [Theory] + [InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "es-ES", "1.º")] + [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "es-ES", "1.er")] + [InlineData(1, WordForm.Normal, GrammaticalGender.Feminine, "es-ES", "1.ª")] + [InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "es-ES", "1.ª")] + [InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "en-US", "1st")] + [InlineData(1, WordForm.Normal, GrammaticalGender.Feminine, "en-US", "1st")] + public void OrdinalizeNumberWithOverridenCultureAndGenderAndForm( + int number, + WordForm wordForm, + GrammaticalGender gender, + string cultureName, + string expected) + { var culture = new CultureInfo(cultureName); Assert.Equal(expected, number.Ordinalize(gender, culture, wordForm)); Assert.Equal(expected, number.ToString(culture).Ordinalize(gender, culture, wordForm)); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/ResourceKeyTests.cs b/src/Humanizer.Tests/ResourceKeyTests.cs index 95a4ac396..ae32f5f44 100644 --- a/src/Humanizer.Tests/ResourceKeyTests.cs +++ b/src/Humanizer.Tests/ResourceKeyTests.cs @@ -1,100 +1,98 @@ -namespace Humanizer.Tests -{ +namespace Humanizer.Tests; #pragma warning disable xUnit1026 // Theory methods should use all of their parameters - public class ResourceKeyTests - { - [Theory] - [MemberData(nameof(DateHumanizeResourceKeys))] - public void DateHumanizeKeysGeneration(int instance, string expected, string actual) => - Assert.Equal(expected, actual); +public class ResourceKeyTests +{ + [Theory] + [MemberData(nameof(DateHumanizeResourceKeys))] + public void DateHumanizeKeysGeneration(int instance, string expected, string actual) => + Assert.Equal(expected, actual); - [Theory] - [MemberData(nameof(TimeSpanHumanizeResourceKeys))] - public void TimeSpanHumanizeKeysGeneration(int instance, string expected, string actual) => - Assert.Equal(expected, actual); + [Theory] + [MemberData(nameof(TimeSpanHumanizeResourceKeys))] + public void TimeSpanHumanizeKeysGeneration(int instance, string expected, string actual) => + Assert.Equal(expected, actual); - [Theory] - [MemberData(nameof(DateHumanizeResourceKeys))] - public void DateHumanizeKeysExistence(int instance, string expectedResourceKey, string generatedResourceKey) => - Assert.NotNull(Resources.GetResource(generatedResourceKey)); + [Theory] + [MemberData(nameof(DateHumanizeResourceKeys))] + public void DateHumanizeKeysExistence(int instance, string expectedResourceKey, string generatedResourceKey) => + Assert.NotNull(Resources.GetResource(generatedResourceKey)); - [Theory] - [MemberData(nameof(TimeSpanHumanizeResourceKeys))] - public void TimeSpanHumanizeKeysExistence(int instance, string expectedResourceKey, string generatedResourceKey) => - Assert.NotNull(Resources.GetResource(generatedResourceKey)); + [Theory] + [MemberData(nameof(TimeSpanHumanizeResourceKeys))] + public void TimeSpanHumanizeKeysExistence(int instance, string expectedResourceKey, string generatedResourceKey) => + Assert.NotNull(Resources.GetResource(generatedResourceKey)); - public static IEnumerable DateHumanizeResourceKeys => - new[] { - [0, "DateHumanize_SingleSecondAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, Tense.Past)], - [0, "DateHumanize_SingleMinuteAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, Tense.Past)], - [0, "DateHumanize_SingleHourAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, Tense.Past)], - [0, "DateHumanize_SingleDayAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, Tense.Past)], - [0, "DateHumanize_SingleMonthAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, Tense.Past)], - [0, "DateHumanize_SingleYearAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, Tense.Past)], - [0, "DateHumanize_MultipleSecondsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, Tense.Past, count: 10)], - [0, "DateHumanize_MultipleMinutesAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, Tense.Past, count: 10)], - [0, "DateHumanize_MultipleHoursAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, Tense.Past, count: 10)], - [0, "DateHumanize_MultipleDaysAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, Tense.Past, count: 10)], - [0, "DateHumanize_MultipleMonthsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, Tense.Past, count: 10)], - [0, "DateHumanize_MultipleYearsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, Tense.Past, count: 10)], - [0, "DateHumanize_SingleSecondFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, timeUnitTense: Tense.Future, count: 1)], - [0, "DateHumanize_SingleMinuteFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, timeUnitTense: Tense.Future, count: 1)], - [0, "DateHumanize_SingleHourFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, timeUnitTense: Tense.Future, count: 1)], - [0, "DateHumanize_SingleDayFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, timeUnitTense: Tense.Future, count: 1)], - [0, "DateHumanize_SingleMonthFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, timeUnitTense: Tense.Future, count: 1)], - [0, "DateHumanize_SingleYearFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, timeUnitTense: Tense.Future, count: 1)], - [0, "DateHumanize_MultipleSecondsFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, timeUnitTense: Tense.Future, count: 10)], - [0, "DateHumanize_MultipleMinutesFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, timeUnitTense: Tense.Future, count: 10)], - [0, "DateHumanize_MultipleHoursFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, timeUnitTense: Tense.Future, count: 10)], - [0, "DateHumanize_MultipleDaysFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, timeUnitTense: Tense.Future, count: 10)], - [0, "DateHumanize_MultipleMonthsFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, timeUnitTense: Tense.Future, count: 10)], - [0, "DateHumanize_MultipleYearsFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, timeUnitTense: Tense.Future, count: 10)], - [0, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Millisecond, Tense.Past, count: 0)], - [1, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, Tense.Past, count: 0)], - [2, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, Tense.Past, count: 0)], - [3, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, Tense.Past, count: 0)], - [4, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, Tense.Past, count: 0)], - [5, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Week, Tense.Past, count: 0)], - [6, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, Tense.Past, count: 0)], - [7, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, Tense.Past, count: 0)], - new object[]{8, "DateHumanize_Now", ResourceKeys.DateHumanize.Now } - }; + public static IEnumerable DateHumanizeResourceKeys => + new[] { + [0, "DateHumanize_SingleSecondAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, Tense.Past)], + [0, "DateHumanize_SingleMinuteAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, Tense.Past)], + [0, "DateHumanize_SingleHourAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, Tense.Past)], + [0, "DateHumanize_SingleDayAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, Tense.Past)], + [0, "DateHumanize_SingleMonthAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, Tense.Past)], + [0, "DateHumanize_SingleYearAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, Tense.Past)], + [0, "DateHumanize_MultipleSecondsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, Tense.Past, count: 10)], + [0, "DateHumanize_MultipleMinutesAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, Tense.Past, count: 10)], + [0, "DateHumanize_MultipleHoursAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, Tense.Past, count: 10)], + [0, "DateHumanize_MultipleDaysAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, Tense.Past, count: 10)], + [0, "DateHumanize_MultipleMonthsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, Tense.Past, count: 10)], + [0, "DateHumanize_MultipleYearsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, Tense.Past, count: 10)], + [0, "DateHumanize_SingleSecondFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, timeUnitTense: Tense.Future, count: 1)], + [0, "DateHumanize_SingleMinuteFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, timeUnitTense: Tense.Future, count: 1)], + [0, "DateHumanize_SingleHourFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, timeUnitTense: Tense.Future, count: 1)], + [0, "DateHumanize_SingleDayFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, timeUnitTense: Tense.Future, count: 1)], + [0, "DateHumanize_SingleMonthFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, timeUnitTense: Tense.Future, count: 1)], + [0, "DateHumanize_SingleYearFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, timeUnitTense: Tense.Future, count: 1)], + [0, "DateHumanize_MultipleSecondsFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, timeUnitTense: Tense.Future, count: 10)], + [0, "DateHumanize_MultipleMinutesFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, timeUnitTense: Tense.Future, count: 10)], + [0, "DateHumanize_MultipleHoursFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, timeUnitTense: Tense.Future, count: 10)], + [0, "DateHumanize_MultipleDaysFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, timeUnitTense: Tense.Future, count: 10)], + [0, "DateHumanize_MultipleMonthsFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, timeUnitTense: Tense.Future, count: 10)], + [0, "DateHumanize_MultipleYearsFromNow", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, timeUnitTense: Tense.Future, count: 10)], + [0, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Millisecond, Tense.Past, count: 0)], + [1, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, Tense.Past, count: 0)], + [2, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, Tense.Past, count: 0)], + [3, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, Tense.Past, count: 0)], + [4, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, Tense.Past, count: 0)], + [5, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Week, Tense.Past, count: 0)], + [6, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, Tense.Past, count: 0)], + [7, "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, Tense.Past, count: 0)], + new object[]{8, "DateHumanize_Now", ResourceKeys.DateHumanize.Now } + }; - public static IEnumerable TimeSpanHumanizeResourceKeys => - new[] { - [0, "TimeSpanHumanize_SingleMillisecond", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond)], - [0, "TimeSpanHumanize_SingleSecond", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second)], - [0, "TimeSpanHumanize_SingleMinute", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute)], - [0, "TimeSpanHumanize_SingleHour", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour)], - [0, "TimeSpanHumanize_SingleDay", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day)], - [0, "TimeSpanHumanize_SingleWeek", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week)], - [0, "TimeSpanHumanize_SingleMonth", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month)], - [0, "TimeSpanHumanize_SingleYear", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year)], - [0, "TimeSpanHumanize_MultipleMilliseconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond, 10)], - [0, "TimeSpanHumanize_MultipleSeconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 10)], - [0, "TimeSpanHumanize_MultipleMinutes", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 10)], - [0, "TimeSpanHumanize_MultipleHours", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 10)], - [0, "TimeSpanHumanize_MultipleDays", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 10)], - [0, "TimeSpanHumanize_MultipleWeeks", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 10)], - [0, "TimeSpanHumanize_MultipleMonths", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month, 10)], - [0, "TimeSpanHumanize_MultipleYears", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year, 10)], - [0, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond, 0, true)], - [1, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 0, true)], - [2, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 0, true)], - [3, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 0, true)], - [4, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 0, true)], - [5, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 0, true)], - [6, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month, 0, true)], - [7, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year, 0, true)], - [1, "TimeSpanHumanize_MultipleMilliseconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond, 0)], - [2, "TimeSpanHumanize_MultipleSeconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 0)], - [3, "TimeSpanHumanize_MultipleMinutes", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 0)], - [4, "TimeSpanHumanize_MultipleHours", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 0)], - [5, "TimeSpanHumanize_MultipleDays", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 0)], - [6, "TimeSpanHumanize_MultipleWeeks", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 0)], - [7, "TimeSpanHumanize_MultipleMonths", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month, 0)], - new object[]{8, "TimeSpanHumanize_MultipleYears", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year, 0) } - }; - } -#pragma warning restore xUnit1026 // Theory methods should use all of their parameters + public static IEnumerable TimeSpanHumanizeResourceKeys => + new[] { + [0, "TimeSpanHumanize_SingleMillisecond", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond)], + [0, "TimeSpanHumanize_SingleSecond", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second)], + [0, "TimeSpanHumanize_SingleMinute", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute)], + [0, "TimeSpanHumanize_SingleHour", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour)], + [0, "TimeSpanHumanize_SingleDay", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day)], + [0, "TimeSpanHumanize_SingleWeek", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week)], + [0, "TimeSpanHumanize_SingleMonth", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month)], + [0, "TimeSpanHumanize_SingleYear", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year)], + [0, "TimeSpanHumanize_MultipleMilliseconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond, 10)], + [0, "TimeSpanHumanize_MultipleSeconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 10)], + [0, "TimeSpanHumanize_MultipleMinutes", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 10)], + [0, "TimeSpanHumanize_MultipleHours", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 10)], + [0, "TimeSpanHumanize_MultipleDays", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 10)], + [0, "TimeSpanHumanize_MultipleWeeks", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 10)], + [0, "TimeSpanHumanize_MultipleMonths", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month, 10)], + [0, "TimeSpanHumanize_MultipleYears", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year, 10)], + [0, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond, 0, true)], + [1, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 0, true)], + [2, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 0, true)], + [3, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 0, true)], + [4, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 0, true)], + [5, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 0, true)], + [6, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month, 0, true)], + [7, "TimeSpanHumanize_Zero", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year, 0, true)], + [1, "TimeSpanHumanize_MultipleMilliseconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Millisecond, 0)], + [2, "TimeSpanHumanize_MultipleSeconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 0)], + [3, "TimeSpanHumanize_MultipleMinutes", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 0)], + [4, "TimeSpanHumanize_MultipleHours", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 0)], + [5, "TimeSpanHumanize_MultipleDays", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 0)], + [6, "TimeSpanHumanize_MultipleWeeks", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 0)], + [7, "TimeSpanHumanize_MultipleMonths", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Month, 0)], + new object[]{8, "TimeSpanHumanize_MultipleYears", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Year, 0) } + }; } +#pragma warning restore xUnit1026 // Theory methods should use all of their parameters \ No newline at end of file diff --git a/src/Humanizer.Tests/RomanNumeralTests.cs b/src/Humanizer.Tests/RomanNumeralTests.cs index cb1b395fd..307f430fa 100644 --- a/src/Humanizer.Tests/RomanNumeralTests.cs +++ b/src/Humanizer.Tests/RomanNumeralTests.cs @@ -1,51 +1,50 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class RomanNumeralTests { - public class RomanNumeralTests - { - [Theory] - [InlineData(1, "I")] - [InlineData(2, "II")] - [InlineData(3, "III")] - [InlineData(4, "IV")] - [InlineData(5, "V")] - [InlineData(6, "VI")] - [InlineData(7, "VII")] - [InlineData(8, "VIII")] - [InlineData(9, "IX")] - [InlineData(10, "X")] - [InlineData(11, "XI")] - [InlineData(12, "XII")] - [InlineData(40, "XL")] - [InlineData(50, "L")] - [InlineData(90, "XC")] - [InlineData(100, "C")] - [InlineData(400, "CD")] - [InlineData(500, "D")] - [InlineData(3999, "MMMCMXCIX")] - public void ToRoman(int input, string expected) => - Assert.Equal(expected, input.ToRoman()); + [Theory] + [InlineData(1, "I")] + [InlineData(2, "II")] + [InlineData(3, "III")] + [InlineData(4, "IV")] + [InlineData(5, "V")] + [InlineData(6, "VI")] + [InlineData(7, "VII")] + [InlineData(8, "VIII")] + [InlineData(9, "IX")] + [InlineData(10, "X")] + [InlineData(11, "XI")] + [InlineData(12, "XII")] + [InlineData(40, "XL")] + [InlineData(50, "L")] + [InlineData(90, "XC")] + [InlineData(100, "C")] + [InlineData(400, "CD")] + [InlineData(500, "D")] + [InlineData(3999, "MMMCMXCIX")] + public void ToRoman(int input, string expected) => + Assert.Equal(expected, input.ToRoman()); - [Theory] - [InlineData(1, "I")] - [InlineData(2, "II")] - [InlineData(3, "III")] - [InlineData(4, "IV")] - [InlineData(5, "V")] - [InlineData(6, "VI")] - [InlineData(7, "VII")] - [InlineData(8, "VIII")] - [InlineData(9, "IX")] - [InlineData(10, "X")] - [InlineData(11, "XI")] - [InlineData(12, "XII")] - [InlineData(40, "XL")] - [InlineData(50, "L")] - [InlineData(90, "XC")] - [InlineData(100, "C")] - [InlineData(400, "CD")] - [InlineData(500, "D")] - [InlineData(3999, "MMMCMXCIX")] - public void FromRoman(int expected, string input) => - Assert.Equal(expected, input.FromRoman()); - } -} + [Theory] + [InlineData(1, "I")] + [InlineData(2, "II")] + [InlineData(3, "III")] + [InlineData(4, "IV")] + [InlineData(5, "V")] + [InlineData(6, "VI")] + [InlineData(7, "VII")] + [InlineData(8, "VIII")] + [InlineData(9, "IX")] + [InlineData(10, "X")] + [InlineData(11, "XI")] + [InlineData(12, "XII")] + [InlineData(40, "XL")] + [InlineData(50, "L")] + [InlineData(90, "XC")] + [InlineData(100, "C")] + [InlineData(400, "CD")] + [InlineData(500, "D")] + [InlineData(3999, "MMMCMXCIX")] + public void FromRoman(int expected, string input) => + Assert.Equal(expected, input.FromRoman()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/StringDehumanizeTests.cs b/src/Humanizer.Tests/StringDehumanizeTests.cs index 8ff8355aa..226a536b6 100644 --- a/src/Humanizer.Tests/StringDehumanizeTests.cs +++ b/src/Humanizer.Tests/StringDehumanizeTests.cs @@ -1,29 +1,28 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class StringDehumanizeTests { - public class StringDehumanizeTests - { - [Theory] - [InlineData("", "")] - [InlineData("Pascal case sentence is pascalized", "PascalCaseSentenceIsPascalized")] - [InlineData("Title Case Sentence Is Pascalized", "TitleCaseSentenceIsPascalized")] - [InlineData("Mixed case sentence Is Pascalized", "MixedCaseSentenceIsPascalized")] - [InlineData("lower case sentence is pascalized", "LowerCaseSentenceIsPascalized")] - [InlineData("A special character is removed?", "ASpecialCharacterIsRemoved")] - [InlineData("A special character is removed after a space ?", "ASpecialCharacterIsRemovedAfterASpace")] - [InlineData("Internal special characters ?)@ are removed", "InternalSpecialCharactersAreRemoved")] - [InlineData("AlreadyDehumanizedStringIsUntouched", "AlreadyDehumanizedStringIsUntouched")] - [InlineData("CanDehumanizeIntoAPascalCaseWord", "CanDehumanizeIntoAPascalCaseWord")] - [InlineData("CanDehumanizeIntoAPascalCaseWord AndAnother", "CanDehumanizeIntoAPascalCaseWordAndAnother")] - [InlineData("OneAndTwo", "OneAndTwo")] - [InlineData("OneOrTwo", "OneOrTwo")] - [InlineData("OneOfTwo", "OneOfTwo")] - [InlineData("OneButTwo", "OneButTwo")] - [InlineData("OneATwo", "OneATwo")] - [InlineData("OneAsTwo", "OneAsTwo")] - [InlineData("OneYetTwo", "OneYetTwo")] - [InlineData("OneNorTwo", "OneNorTwo")] - [InlineData("WordSoTwo", "WordSoTwo")] - public void CanDehumanizeIntoAPascalCaseWord(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Dehumanize()); - } -} + [Theory] + [InlineData("", "")] + [InlineData("Pascal case sentence is pascalized", "PascalCaseSentenceIsPascalized")] + [InlineData("Title Case Sentence Is Pascalized", "TitleCaseSentenceIsPascalized")] + [InlineData("Mixed case sentence Is Pascalized", "MixedCaseSentenceIsPascalized")] + [InlineData("lower case sentence is pascalized", "LowerCaseSentenceIsPascalized")] + [InlineData("A special character is removed?", "ASpecialCharacterIsRemoved")] + [InlineData("A special character is removed after a space ?", "ASpecialCharacterIsRemovedAfterASpace")] + [InlineData("Internal special characters ?)@ are removed", "InternalSpecialCharactersAreRemoved")] + [InlineData("AlreadyDehumanizedStringIsUntouched", "AlreadyDehumanizedStringIsUntouched")] + [InlineData("CanDehumanizeIntoAPascalCaseWord", "CanDehumanizeIntoAPascalCaseWord")] + [InlineData("CanDehumanizeIntoAPascalCaseWord AndAnother", "CanDehumanizeIntoAPascalCaseWordAndAnother")] + [InlineData("OneAndTwo", "OneAndTwo")] + [InlineData("OneOrTwo", "OneOrTwo")] + [InlineData("OneOfTwo", "OneOfTwo")] + [InlineData("OneButTwo", "OneButTwo")] + [InlineData("OneATwo", "OneATwo")] + [InlineData("OneAsTwo", "OneAsTwo")] + [InlineData("OneYetTwo", "OneYetTwo")] + [InlineData("OneNorTwo", "OneNorTwo")] + [InlineData("WordSoTwo", "WordSoTwo")] + public void CanDehumanizeIntoAPascalCaseWord(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Dehumanize()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/StringHumanizeTests.cs b/src/Humanizer.Tests/StringHumanizeTests.cs index a7f5fd2af..94dc2326e 100644 --- a/src/Humanizer.Tests/StringHumanizeTests.cs +++ b/src/Humanizer.Tests/StringHumanizeTests.cs @@ -1,93 +1,92 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class StringHumanizeTests { - public class StringHumanizeTests - { - [Theory] - [InlineData("PascalCaseInputStringIsTurnedIntoSentence", "Pascal case input string is turned into sentence")] - [InlineData("WhenIUseAnInputAHere", "When I use an input a here")] - [InlineData("10IsInTheBegining", "10 is in the begining")] - [InlineData("NumberIsFollowedByLowerCase5th", "Number is followed by lower case 5th")] - [InlineData("NumberIsAtTheEnd100", "Number is at the end 100")] - [InlineData("XIsFirstWordInTheSentence", "X is first word in the sentence")] - [InlineData("XIsFirstWordInTheSentence ThenThereIsASpace", "X is first word in the sentence then there is a space")] - [InlineData("ContainsSpecial?)@Characters", "Contains special characters")] - [InlineData("a", "A")] - [InlineData("A", "A")] - [InlineData("?)@", "")] - [InlineData("?", "")] - [InlineData("", "")] - [InlineData("JeNeParlePasFrançais", "Je ne parle pas français")] - public void CanHumanizeStringInPascalCase(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize()); + [Theory] + [InlineData("PascalCaseInputStringIsTurnedIntoSentence", "Pascal case input string is turned into sentence")] + [InlineData("WhenIUseAnInputAHere", "When I use an input a here")] + [InlineData("10IsInTheBegining", "10 is in the begining")] + [InlineData("NumberIsFollowedByLowerCase5th", "Number is followed by lower case 5th")] + [InlineData("NumberIsAtTheEnd100", "Number is at the end 100")] + [InlineData("XIsFirstWordInTheSentence", "X is first word in the sentence")] + [InlineData("XIsFirstWordInTheSentence ThenThereIsASpace", "X is first word in the sentence then there is a space")] + [InlineData("ContainsSpecial?)@Characters", "Contains special characters")] + [InlineData("a", "A")] + [InlineData("A", "A")] + [InlineData("?)@", "")] + [InlineData("?", "")] + [InlineData("", "")] + [InlineData("JeNeParlePasFrançais", "Je ne parle pas français")] + public void CanHumanizeStringInPascalCase(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize()); - [Theory, UseCulture("tr-TR")] - [InlineData("istanbul", "İstanbul")] - [InlineData("diyarbakır", "Diyarbakır")] - public void CanHumanizeStringInPascalCaseInTurkish(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize()); + [Theory, UseCulture("tr-TR")] + [InlineData("istanbul", "İstanbul")] + [InlineData("diyarbakır", "Diyarbakır")] + public void CanHumanizeStringInPascalCaseInTurkish(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize()); - [Theory, UseCulture("ar")] - [InlineData("جمهورية ألمانيا الاتحادية", "جمهورية ألمانيا الاتحادية")] - public void CanHumanizeOtherUnicodeLetter(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize()); + [Theory, UseCulture("ar")] + [InlineData("جمهورية ألمانيا الاتحادية", "جمهورية ألمانيا الاتحادية")] + public void CanHumanizeOtherUnicodeLetter(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize()); - [Theory] - [InlineData("Underscored_input_string_is_turned_into_sentence", "Underscored input string is turned into sentence")] - [InlineData("Underscored_input_String_is_turned_INTO_sentence", "Underscored input String is turned INTO sentence")] - [InlineData("TEST 1 - THIS IS A TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1 -THIS IS A TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1- THIS IS A TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1_ THIS IS A TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1 _THIS IS A TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1 _ THIS IS A TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1 - THIS_IS_A_TEST", "TEST 1 THIS IS A TEST")] - [InlineData("TEST 1 - THIS is A Test", "TEST 1 THIS is A test")] - public void CanHumanizeStringWithUnderscoresAndDashes(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize()); + [Theory] + [InlineData("Underscored_input_string_is_turned_into_sentence", "Underscored input string is turned into sentence")] + [InlineData("Underscored_input_String_is_turned_INTO_sentence", "Underscored input String is turned INTO sentence")] + [InlineData("TEST 1 - THIS IS A TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1 -THIS IS A TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1- THIS IS A TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1_ THIS IS A TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1 _THIS IS A TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1 _ THIS IS A TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1 - THIS_IS_A_TEST", "TEST 1 THIS IS A TEST")] + [InlineData("TEST 1 - THIS is A Test", "TEST 1 THIS is A test")] + public void CanHumanizeStringWithUnderscoresAndDashes(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize()); - [Theory] - [InlineData("HTML", "HTML")] - [InlineData("TheHTMLLanguage", "The HTML language")] - [InlineData("HTMLIsTheLanguage", "HTML is the language")] - [InlineData("TheLanguage IsHTML", "The language is HTML")] - [InlineData("TheLanguageIsHTML", "The language is HTML")] - [InlineData("HTML5", "HTML 5")] - [InlineData("1HTML", "1 HTML")] - public void CanHumanizeStringWithAcronyms(string input, string expectedValue) => - Assert.Equal(expectedValue, input.Humanize()); + [Theory] + [InlineData("HTML", "HTML")] + [InlineData("TheHTMLLanguage", "The HTML language")] + [InlineData("HTMLIsTheLanguage", "HTML is the language")] + [InlineData("TheLanguage IsHTML", "The language is HTML")] + [InlineData("TheLanguageIsHTML", "The language is HTML")] + [InlineData("HTML5", "HTML 5")] + [InlineData("1HTML", "1 HTML")] + public void CanHumanizeStringWithAcronyms(string input, string expectedValue) => + Assert.Equal(expectedValue, input.Humanize()); - [Theory] - [InlineData("CanReturnTitleCase", "Can Return Title Case")] - [InlineData("Can_return_title_Case", "Can Return Title Case")] - [InlineData("In titles use lower case for prepositions an article or conjunctions", "In Titles Use Lower Case for Prepositions an Article or Conjunctions")] - [InlineData("Title_humanization_Honors_ALLCAPS", "Title Humanization Honors ALLCAPS")] - [InlineData("MühldorferStraße23", "Mühldorfer Straße 23")] - [InlineData("mühldorfer_STRAẞE_23", "Mühldorfer STRAẞE 23")] - [InlineData("CAN RETURN TITLE CASE", "Can Return Title Case")] - public void CanHumanizeIntoTitleCase(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize(LetterCasing.Title)); + [Theory] + [InlineData("CanReturnTitleCase", "Can Return Title Case")] + [InlineData("Can_return_title_Case", "Can Return Title Case")] + [InlineData("In titles use lower case for prepositions an article or conjunctions", "In Titles Use Lower Case for Prepositions an Article or Conjunctions")] + [InlineData("Title_humanization_Honors_ALLCAPS", "Title Humanization Honors ALLCAPS")] + [InlineData("MühldorferStraße23", "Mühldorfer Straße 23")] + [InlineData("mühldorfer_STRAẞE_23", "Mühldorfer STRAẞE 23")] + [InlineData("CAN RETURN TITLE CASE", "Can Return Title Case")] + public void CanHumanizeIntoTitleCase(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize(LetterCasing.Title)); - [Theory] - [InlineData("CanReturnLowerCase", "can return lower case")] - [InlineData("LOWERCASE", "lowercase")] - [InlineData("STRAẞE", "straße")] - public void CanHumanizeIntoLowerCase(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize(LetterCasing.LowerCase)); + [Theory] + [InlineData("CanReturnLowerCase", "can return lower case")] + [InlineData("LOWERCASE", "lowercase")] + [InlineData("STRAẞE", "straße")] + public void CanHumanizeIntoLowerCase(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize(LetterCasing.LowerCase)); - [Theory] - [InlineData("CanReturnSentenceCase", "Can return sentence case")] - [InlineData("", "")] - [InlineData("égoïste", "Égoïste")] - [InlineData("Normal; Normal and PascalCase", "Normal; normal and pascal case")] - [InlineData("I,and No One else", "I, and no one else")] - public void CanHumanizeIntoSentenceCase(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize(LetterCasing.Sentence)); + [Theory] + [InlineData("CanReturnSentenceCase", "Can return sentence case")] + [InlineData("", "")] + [InlineData("égoïste", "Égoïste")] + [InlineData("Normal; Normal and PascalCase", "Normal; normal and pascal case")] + [InlineData("I,and No One else", "I, and no one else")] + public void CanHumanizeIntoSentenceCase(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize(LetterCasing.Sentence)); - [Theory] - [InlineData("CanHumanizeIntoUpperCase", "CAN HUMANIZE INTO UPPER CASE")] - [InlineData("Can_Humanize_into_Upper_case", "CAN HUMANIZE INTO UPPER CASE")] - [InlineData("coûts_privés", "COÛTS PRIVÉS")] - public void CanHumanizeIntoUpperCase(string input, string expectedResult) => - Assert.Equal(expectedResult, input.Humanize(LetterCasing.AllCaps)); - } -} + [Theory] + [InlineData("CanHumanizeIntoUpperCase", "CAN HUMANIZE INTO UPPER CASE")] + [InlineData("Can_Humanize_into_Upper_case", "CAN HUMANIZE INTO UPPER CASE")] + [InlineData("coûts_privés", "COÛTS PRIVÉS")] + public void CanHumanizeIntoUpperCase(string input, string expectedResult) => + Assert.Equal(expectedResult, input.Humanize(LetterCasing.AllCaps)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/TimeSpanHumanizeTests.cs index 37bdfd443..bbc9ec15c 100644 --- a/src/Humanizer.Tests/TimeSpanHumanizeTests.cs +++ b/src/Humanizer.Tests/TimeSpanHumanizeTests.cs @@ -1,462 +1,461 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class TimeSpanHumanizeTests { - [UseCulture("en-US")] - public class TimeSpanHumanizeTests + [Fact] + public void AllTimeSpansMustBeUniqueForASequenceOfDays() { - [Fact] - public void AllTimeSpansMustBeUniqueForASequenceOfDays() - { - var culture = new CultureInfo("en-US"); - var qry = from i in Enumerable.Range(0, 100000) - let ts = TimeSpan.FromDays(i) - let text = ts.Humanize(precision: 3, culture: culture, maxUnit: TimeUnit.Year) - select text; - var grouping = from t in qry - group t by t into g - select new { g.Key, Count = g.Count() }; - var allUnique = grouping.All(g => g.Count == 1); - Assert.True(allUnique); - } + var culture = new CultureInfo("en-US"); + var qry = from i in Enumerable.Range(0, 100000) + let ts = TimeSpan.FromDays(i) + let text = ts.Humanize(precision: 3, culture: culture, maxUnit: TimeUnit.Year) + select text; + var grouping = from t in qry + group t by t into g + select new { g.Key, Count = g.Count() }; + var allUnique = grouping.All(g => g.Count == 1); + Assert.True(allUnique); + } - [Theory] - [InlineData(365, "11 months, 30 days")] - [InlineData(365 + 1, "1 year")] - [InlineData(365 + 365, "1 year, 11 months, 29 days")] - [InlineData(365 + 365 + 1, "2 years")] - [InlineData(365 + 365 + 365, "2 years, 11 months, 29 days")] - [InlineData(365 + 365 + 365 + 1, "3 years")] - [InlineData(365 + 365 + 365 + 365, "3 years, 11 months, 29 days")] - [InlineData(365 + 365 + 365 + 365 + 1, "4 years")] - [InlineData(365 + 365 + 365 + 365 + 366, "4 years, 11 months, 30 days")] - [InlineData(365 + 365 + 365 + 365 + 366 + 1, "5 years")] - public void Years(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(365, "11 months, 30 days")] + [InlineData(365 + 1, "1 year")] + [InlineData(365 + 365, "1 year, 11 months, 29 days")] + [InlineData(365 + 365 + 1, "2 years")] + [InlineData(365 + 365 + 365, "2 years, 11 months, 29 days")] + [InlineData(365 + 365 + 365 + 1, "3 years")] + [InlineData(365 + 365 + 365 + 365, "3 years, 11 months, 29 days")] + [InlineData(365 + 365 + 365 + 365 + 1, "4 years")] + [InlineData(365 + 365 + 365 + 365 + 366, "4 years, 11 months, 30 days")] + [InlineData(365 + 365 + 365 + 365 + 366 + 1, "5 years")] + public void Years(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(30, "4 weeks, 2 days")] - [InlineData(30 + 1, "1 month")] - [InlineData(30 + 30, "1 month, 29 days")] - [InlineData(30 + 30 + 1, "2 months")] - [InlineData(30 + 30 + 31, "2 months, 30 days")] - [InlineData(30 + 30 + 31 + 1, "3 months")] - [InlineData(30 + 30 + 31 + 30, "3 months, 29 days")] - [InlineData(30 + 30 + 31 + 30 + 1, "4 months")] - [InlineData(30 + 30 + 31 + 30 + 31, "4 months, 30 days")] - [InlineData(30 + 30 + 31 + 30 + 31 + 1, "5 months")] - [InlineData(365, "11 months, 30 days")] - [InlineData(366, "1 year")] - public void Months(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(30, "4 weeks, 2 days")] + [InlineData(30 + 1, "1 month")] + [InlineData(30 + 30, "1 month, 29 days")] + [InlineData(30 + 30 + 1, "2 months")] + [InlineData(30 + 30 + 31, "2 months, 30 days")] + [InlineData(30 + 30 + 31 + 1, "3 months")] + [InlineData(30 + 30 + 31 + 30, "3 months, 29 days")] + [InlineData(30 + 30 + 31 + 30 + 1, "4 months")] + [InlineData(30 + 30 + 31 + 30 + 31, "4 months, 30 days")] + [InlineData(30 + 30 + 31 + 30 + 31 + 1, "5 months")] + [InlineData(365, "11 months, 30 days")] + [InlineData(366, "1 year")] + public void Months(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(precision: 7, maxUnit: TimeUnit.Year); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(14, "2 weeks")] - [InlineData(7, "1 week")] - [InlineData(-14, "2 weeks")] - [InlineData(-7, "1 week")] - [InlineData(730, "104 weeks")] - public void Weeks(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(14, "2 weeks")] + [InlineData(7, "1 week")] + [InlineData(-14, "2 weeks")] + [InlineData(-7, "1 week")] + [InlineData(730, "104 weeks")] + public void Weeks(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(6, "6 days")] - [InlineData(2, "2 days")] - [InlineData(1, "1 day")] - [InlineData(-6, "6 days")] - [InlineData(-2, "2 days")] - [InlineData(-1, "1 day")] - public void Days(int days, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(6, "6 days")] + [InlineData(2, "2 days")] + [InlineData(1, "1 day")] + [InlineData(-6, "6 days")] + [InlineData(-2, "2 days")] + [InlineData(-1, "1 day")] + public void Days(int days, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 hours")] - [InlineData(1, "1 hour")] - [InlineData(-2, "2 hours")] - [InlineData(-1, "1 hour")] - public void Hours(int hours, string expected) - { - var actual = TimeSpan.FromHours(hours).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 hours")] + [InlineData(1, "1 hour")] + [InlineData(-2, "2 hours")] + [InlineData(-1, "1 hour")] + public void Hours(int hours, string expected) + { + var actual = TimeSpan.FromHours(hours).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2, "2 minutes")] - [InlineData(1, "1 minute")] - [InlineData(-2, "2 minutes")] - [InlineData(-1, "1 minute")] - public void Minutes(int minutes, string expected) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2, "2 minutes")] + [InlineData(1, "1 minute")] + [InlineData(-2, "2 minutes")] + [InlineData(-1, "1 minute")] + public void Minutes(int minutes, string expected) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(135, "2 minutes")] - [InlineData(60, "1 minute")] - [InlineData(2, "2 seconds")] - [InlineData(1, "1 second")] - [InlineData(-135, "2 minutes")] - [InlineData(-60, "1 minute")] - [InlineData(-2, "2 seconds")] - [InlineData(-1, "1 second")] - public void Seconds(int seconds, string expected) - { - var actual = TimeSpan.FromSeconds(seconds).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(135, "2 minutes")] + [InlineData(60, "1 minute")] + [InlineData(2, "2 seconds")] + [InlineData(1, "1 second")] + [InlineData(-135, "2 minutes")] + [InlineData(-60, "1 minute")] + [InlineData(-2, "2 seconds")] + [InlineData(-1, "1 second")] + public void Seconds(int seconds, string expected) + { + var actual = TimeSpan.FromSeconds(seconds).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(2500, "2 seconds")] - [InlineData(1400, "1 second")] - [InlineData(2, "2 milliseconds")] - [InlineData(1, "1 millisecond")] - [InlineData(-2500, "2 seconds")] - [InlineData(-1400, "1 second")] - [InlineData(-2, "2 milliseconds")] - [InlineData(-1, "1 millisecond")] - public void Milliseconds(int ms, string expected) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(2500, "2 seconds")] + [InlineData(1400, "1 second")] + [InlineData(2, "2 milliseconds")] + [InlineData(1, "1 millisecond")] + [InlineData(-2500, "2 seconds")] + [InlineData(-1400, "1 second")] + [InlineData(-2, "2 milliseconds")] + [InlineData(-1, "1 millisecond")] + public void Milliseconds(int ms, string expected) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(4, false, "4 days old")] - [InlineData(23, false, "3 weeks old")] - [InlineData(64, false, "2 months old")] - [InlineData(367, true, "one year old")] - [InlineData(750, true, "two years old")] - public void Age(int days, bool toWords, string expected) - { - var actual = TimeSpan.FromDays(days).ToAge(toWords: toWords); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(4, false, "4 days old")] + [InlineData(23, false, "3 weeks old")] + [InlineData(64, false, "2 months old")] + [InlineData(367, true, "one year old")] + [InlineData(750, true, "two years old")] + public void Age(int days, bool toWords, string expected) + { + var actual = TimeSpan.FromDays(days).ToAge(toWords: toWords); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData((long)366 * 24 * 60 * 60 * 1000, "12 months", TimeUnit.Month)] - [InlineData((long)6 * 7 * 24 * 60 * 60 * 1000, "6 weeks", TimeUnit.Week)] - [InlineData(7 * 24 * 60 * 60 * 1000, "7 days", TimeUnit.Day)] - [InlineData(24 * 60 * 60 * 1000, "24 hours", TimeUnit.Hour)] - [InlineData(60 * 60 * 1000, "60 minutes", TimeUnit.Minute)] - [InlineData(60 * 1000, "60 seconds", TimeUnit.Second)] - [InlineData(1000, "1000 milliseconds", TimeUnit.Millisecond)] - public void TimeSpanWithMaxTimeUnit(long ms, string expected, TimeUnit maxUnit) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(maxUnit: maxUnit); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData((long)366 * 24 * 60 * 60 * 1000, "12 months", TimeUnit.Month)] + [InlineData((long)6 * 7 * 24 * 60 * 60 * 1000, "6 weeks", TimeUnit.Week)] + [InlineData(7 * 24 * 60 * 60 * 1000, "7 days", TimeUnit.Day)] + [InlineData(24 * 60 * 60 * 1000, "24 hours", TimeUnit.Hour)] + [InlineData(60 * 60 * 1000, "60 minutes", TimeUnit.Minute)] + [InlineData(60 * 1000, "60 seconds", TimeUnit.Second)] + [InlineData(1000, "1000 milliseconds", TimeUnit.Millisecond)] + public void TimeSpanWithMaxTimeUnit(long ms, string expected, TimeUnit maxUnit) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(maxUnit: maxUnit); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(10, "10 milliseconds", TimeUnit.Millisecond)] - [InlineData(10, "no time", TimeUnit.Second, true)] - [InlineData(10, "no time", TimeUnit.Minute, true)] - [InlineData(10, "no time", TimeUnit.Hour, true)] - [InlineData(10, "no time", TimeUnit.Day, true)] - [InlineData(10, "no time", TimeUnit.Week, true)] - [InlineData(10, "0 seconds", TimeUnit.Second)] - [InlineData(10, "0 minutes", TimeUnit.Minute)] - [InlineData(10, "0 hours", TimeUnit.Hour)] - [InlineData(10, "0 days", TimeUnit.Day)] - [InlineData(10, "0 weeks", TimeUnit.Week)] - [InlineData(2500, "2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(2500, "2 seconds", TimeUnit.Second)] - [InlineData(2500, "no time", TimeUnit.Minute, true)] - [InlineData(2500, "no time", TimeUnit.Hour, true)] - [InlineData(2500, "no time", TimeUnit.Day, true)] - [InlineData(2500, "no time", TimeUnit.Week, true)] - [InlineData(2500, "0 minutes", TimeUnit.Minute)] - [InlineData(2500, "0 hours", TimeUnit.Hour)] - [InlineData(2500, "0 days", TimeUnit.Day)] - [InlineData(2500, "0 weeks", TimeUnit.Week)] - [InlineData(122500, "2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(122500, "2 minutes, 2 seconds", TimeUnit.Second)] - [InlineData(122500, "2 minutes", TimeUnit.Minute)] - [InlineData(122500, "no time", TimeUnit.Hour, true)] - [InlineData(122500, "no time", TimeUnit.Day, true)] - [InlineData(122500, "no time", TimeUnit.Week, true)] - [InlineData(122500, "0 hours", TimeUnit.Hour)] - [InlineData(122500, "0 days", TimeUnit.Day)] - [InlineData(122500, "0 weeks", TimeUnit.Week)] - [InlineData(3722500, "1 hour, 2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(3722500, "1 hour, 2 minutes, 2 seconds", TimeUnit.Second)] - [InlineData(3722500, "1 hour, 2 minutes", TimeUnit.Minute)] - [InlineData(3722500, "1 hour", TimeUnit.Hour)] - [InlineData(3722500, "no time", TimeUnit.Day, true)] - [InlineData(3722500, "no time", TimeUnit.Week, true)] - [InlineData(3722500, "0 days", TimeUnit.Day)] - [InlineData(3722500, "0 weeks", TimeUnit.Week)] - [InlineData(90122500, "1 day, 1 hour, 2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(90122500, "1 day, 1 hour, 2 minutes, 2 seconds", TimeUnit.Second)] - [InlineData(90122500, "1 day, 1 hour, 2 minutes", TimeUnit.Minute)] - [InlineData(90122500, "1 day, 1 hour", TimeUnit.Hour)] - [InlineData(90122500, "1 day", TimeUnit.Day)] - [InlineData(90122500, "no time", TimeUnit.Week, true)] - [InlineData(90122500, "0 weeks", TimeUnit.Week)] - [InlineData(694922500, "1 week, 1 day, 1 hour, 2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(694922500, "1 week, 1 day, 1 hour, 2 minutes, 2 seconds", TimeUnit.Second)] - [InlineData(694922500, "1 week, 1 day, 1 hour, 2 minutes", TimeUnit.Minute)] - [InlineData(694922500, "1 week, 1 day, 1 hour", TimeUnit.Hour)] - [InlineData(694922500, "1 week, 1 day", TimeUnit.Day)] - [InlineData(694922500, "1 week", TimeUnit.Week)] - [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute, 2 seconds", TimeUnit.Second)] - [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute", TimeUnit.Minute)] - [InlineData(2768462500, "1 month, 1 day, 1 hour", TimeUnit.Hour)] - [InlineData(2768462500, "1 month, 1 day", TimeUnit.Day)] - [InlineData(2768462500, "1 month", TimeUnit.Week)] - [InlineData(2768462500, "1 month", TimeUnit.Month)] - [InlineData(2768462500, "no time", TimeUnit.Year, true)] - [InlineData(2768462500, "0 years", TimeUnit.Year)] - [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] - [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds", TimeUnit.Second)] - [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute", TimeUnit.Minute)] - [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour", TimeUnit.Hour)] - [InlineData(34390862500, "1 year, 1 month, 2 days", TimeUnit.Day)] - [InlineData(34390862500, "1 year, 1 month", TimeUnit.Week)] - [InlineData(34390862500, "1 year, 1 month", TimeUnit.Month)] - [InlineData(34390862500, "1 year", TimeUnit.Year)] - public void TimeSpanWithMinTimeUnit(long ms, string expected, TimeUnit minUnit, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(minUnit: minUnit, precision: 7, maxUnit: TimeUnit.Year, toWords: toWords); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(10, "10 milliseconds", TimeUnit.Millisecond)] + [InlineData(10, "no time", TimeUnit.Second, true)] + [InlineData(10, "no time", TimeUnit.Minute, true)] + [InlineData(10, "no time", TimeUnit.Hour, true)] + [InlineData(10, "no time", TimeUnit.Day, true)] + [InlineData(10, "no time", TimeUnit.Week, true)] + [InlineData(10, "0 seconds", TimeUnit.Second)] + [InlineData(10, "0 minutes", TimeUnit.Minute)] + [InlineData(10, "0 hours", TimeUnit.Hour)] + [InlineData(10, "0 days", TimeUnit.Day)] + [InlineData(10, "0 weeks", TimeUnit.Week)] + [InlineData(2500, "2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(2500, "2 seconds", TimeUnit.Second)] + [InlineData(2500, "no time", TimeUnit.Minute, true)] + [InlineData(2500, "no time", TimeUnit.Hour, true)] + [InlineData(2500, "no time", TimeUnit.Day, true)] + [InlineData(2500, "no time", TimeUnit.Week, true)] + [InlineData(2500, "0 minutes", TimeUnit.Minute)] + [InlineData(2500, "0 hours", TimeUnit.Hour)] + [InlineData(2500, "0 days", TimeUnit.Day)] + [InlineData(2500, "0 weeks", TimeUnit.Week)] + [InlineData(122500, "2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(122500, "2 minutes, 2 seconds", TimeUnit.Second)] + [InlineData(122500, "2 minutes", TimeUnit.Minute)] + [InlineData(122500, "no time", TimeUnit.Hour, true)] + [InlineData(122500, "no time", TimeUnit.Day, true)] + [InlineData(122500, "no time", TimeUnit.Week, true)] + [InlineData(122500, "0 hours", TimeUnit.Hour)] + [InlineData(122500, "0 days", TimeUnit.Day)] + [InlineData(122500, "0 weeks", TimeUnit.Week)] + [InlineData(3722500, "1 hour, 2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(3722500, "1 hour, 2 minutes, 2 seconds", TimeUnit.Second)] + [InlineData(3722500, "1 hour, 2 minutes", TimeUnit.Minute)] + [InlineData(3722500, "1 hour", TimeUnit.Hour)] + [InlineData(3722500, "no time", TimeUnit.Day, true)] + [InlineData(3722500, "no time", TimeUnit.Week, true)] + [InlineData(3722500, "0 days", TimeUnit.Day)] + [InlineData(3722500, "0 weeks", TimeUnit.Week)] + [InlineData(90122500, "1 day, 1 hour, 2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(90122500, "1 day, 1 hour, 2 minutes, 2 seconds", TimeUnit.Second)] + [InlineData(90122500, "1 day, 1 hour, 2 minutes", TimeUnit.Minute)] + [InlineData(90122500, "1 day, 1 hour", TimeUnit.Hour)] + [InlineData(90122500, "1 day", TimeUnit.Day)] + [InlineData(90122500, "no time", TimeUnit.Week, true)] + [InlineData(90122500, "0 weeks", TimeUnit.Week)] + [InlineData(694922500, "1 week, 1 day, 1 hour, 2 minutes, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(694922500, "1 week, 1 day, 1 hour, 2 minutes, 2 seconds", TimeUnit.Second)] + [InlineData(694922500, "1 week, 1 day, 1 hour, 2 minutes", TimeUnit.Minute)] + [InlineData(694922500, "1 week, 1 day, 1 hour", TimeUnit.Hour)] + [InlineData(694922500, "1 week, 1 day", TimeUnit.Day)] + [InlineData(694922500, "1 week", TimeUnit.Week)] + [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute, 2 seconds", TimeUnit.Second)] + [InlineData(2768462500, "1 month, 1 day, 1 hour, 1 minute", TimeUnit.Minute)] + [InlineData(2768462500, "1 month, 1 day, 1 hour", TimeUnit.Hour)] + [InlineData(2768462500, "1 month, 1 day", TimeUnit.Day)] + [InlineData(2768462500, "1 month", TimeUnit.Week)] + [InlineData(2768462500, "1 month", TimeUnit.Month)] + [InlineData(2768462500, "no time", TimeUnit.Year, true)] + [InlineData(2768462500, "0 years", TimeUnit.Year)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds, 500 milliseconds", TimeUnit.Millisecond)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds", TimeUnit.Second)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour, 1 minute", TimeUnit.Minute)] + [InlineData(34390862500, "1 year, 1 month, 2 days, 1 hour", TimeUnit.Hour)] + [InlineData(34390862500, "1 year, 1 month, 2 days", TimeUnit.Day)] + [InlineData(34390862500, "1 year, 1 month", TimeUnit.Week)] + [InlineData(34390862500, "1 year, 1 month", TimeUnit.Month)] + [InlineData(34390862500, "1 year", TimeUnit.Year)] + public void TimeSpanWithMinTimeUnit(long ms, string expected, TimeUnit minUnit, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(minUnit: minUnit, precision: 7, maxUnit: TimeUnit.Year, toWords: toWords); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(0, 3, "no time", true)] - [InlineData(0, 2, "no time", true)] - [InlineData(0, 3, "0 milliseconds")] - [InlineData(0, 2, "0 milliseconds")] - [InlineData(10, 2, "10 milliseconds")] - [InlineData(1400, 2, "1 second, 400 milliseconds")] - [InlineData(2500, 2, "2 seconds, 500 milliseconds")] - [InlineData(120000, 2, "2 minutes")] - [InlineData(62000, 2, "1 minute, 2 seconds")] - [InlineData(62020, 2, "1 minute, 2 seconds")] - [InlineData(62020, 3, "1 minute, 2 seconds, 20 milliseconds")] - [InlineData(3600020, 4, "1 hour, 20 milliseconds")] - [InlineData(3600020, 3, "1 hour, 20 milliseconds")] - [InlineData(3600020, 2, "1 hour, 20 milliseconds")] - [InlineData(3600020, 1, "1 hour")] - [InlineData(3603001, 2, "1 hour, 3 seconds")] - [InlineData(3603001, 3, "1 hour, 3 seconds, 1 millisecond")] - [InlineData(86400000, 3, "1 day")] - [InlineData(86400000, 2, "1 day")] - [InlineData(86400000, 1, "1 day")] - [InlineData(86401000, 1, "1 day")] - [InlineData(86401000, 2, "1 day, 1 second")] - [InlineData(86401200, 2, "1 day, 1 second")] - [InlineData(86401200, 3, "1 day, 1 second, 200 milliseconds")] - [InlineData(1296000000, 1, "2 weeks")] - [InlineData(1296000000, 2, "2 weeks, 1 day")] - [InlineData(1299600000, 2, "2 weeks, 1 day")] - [InlineData(1299600000, 3, "2 weeks, 1 day, 1 hour")] - [InlineData(1299630020, 3, "2 weeks, 1 day, 1 hour")] - [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour, 30 seconds")] - [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds, 20 milliseconds")] - [InlineData(2768462500, 6, "1 month, 1 day, 1 hour, 1 minute, 2 seconds, 500 milliseconds")] - [InlineData(2768462500, 5, "1 month, 1 day, 1 hour, 1 minute, 2 seconds")] - [InlineData(2768462500, 4, "1 month, 1 day, 1 hour, 1 minute")] - [InlineData(2768462500, 3, "1 month, 1 day, 1 hour")] - [InlineData(2768462500, 2, "1 month, 1 day")] - [InlineData(2768462500, 1, "1 month")] - [InlineData(34390862500, 7, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds, 500 milliseconds")] - [InlineData(34390862500, 6, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds")] - [InlineData(34390862500, 5, "1 year, 1 month, 2 days, 1 hour, 1 minute")] - [InlineData(34390862500, 4, "1 year, 1 month, 2 days, 1 hour")] - [InlineData(34390862500, 3, "1 year, 1 month, 2 days")] - [InlineData(34390862500, 2, "1 year, 1 month")] - [InlineData(34390862500, 1, "1 year")] - public void TimeSpanWithPrecision(long milliseconds, int precision, string expected, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, maxUnit: TimeUnit.Year, toWords: toWords); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(0, 3, "no time", true)] + [InlineData(0, 2, "no time", true)] + [InlineData(0, 3, "0 milliseconds")] + [InlineData(0, 2, "0 milliseconds")] + [InlineData(10, 2, "10 milliseconds")] + [InlineData(1400, 2, "1 second, 400 milliseconds")] + [InlineData(2500, 2, "2 seconds, 500 milliseconds")] + [InlineData(120000, 2, "2 minutes")] + [InlineData(62000, 2, "1 minute, 2 seconds")] + [InlineData(62020, 2, "1 minute, 2 seconds")] + [InlineData(62020, 3, "1 minute, 2 seconds, 20 milliseconds")] + [InlineData(3600020, 4, "1 hour, 20 milliseconds")] + [InlineData(3600020, 3, "1 hour, 20 milliseconds")] + [InlineData(3600020, 2, "1 hour, 20 milliseconds")] + [InlineData(3600020, 1, "1 hour")] + [InlineData(3603001, 2, "1 hour, 3 seconds")] + [InlineData(3603001, 3, "1 hour, 3 seconds, 1 millisecond")] + [InlineData(86400000, 3, "1 day")] + [InlineData(86400000, 2, "1 day")] + [InlineData(86400000, 1, "1 day")] + [InlineData(86401000, 1, "1 day")] + [InlineData(86401000, 2, "1 day, 1 second")] + [InlineData(86401200, 2, "1 day, 1 second")] + [InlineData(86401200, 3, "1 day, 1 second, 200 milliseconds")] + [InlineData(1296000000, 1, "2 weeks")] + [InlineData(1296000000, 2, "2 weeks, 1 day")] + [InlineData(1299600000, 2, "2 weeks, 1 day")] + [InlineData(1299600000, 3, "2 weeks, 1 day, 1 hour")] + [InlineData(1299630020, 3, "2 weeks, 1 day, 1 hour")] + [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour, 30 seconds")] + [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds, 20 milliseconds")] + [InlineData(2768462500, 6, "1 month, 1 day, 1 hour, 1 minute, 2 seconds, 500 milliseconds")] + [InlineData(2768462500, 5, "1 month, 1 day, 1 hour, 1 minute, 2 seconds")] + [InlineData(2768462500, 4, "1 month, 1 day, 1 hour, 1 minute")] + [InlineData(2768462500, 3, "1 month, 1 day, 1 hour")] + [InlineData(2768462500, 2, "1 month, 1 day")] + [InlineData(2768462500, 1, "1 month")] + [InlineData(34390862500, 7, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds, 500 milliseconds")] + [InlineData(34390862500, 6, "1 year, 1 month, 2 days, 1 hour, 1 minute, 2 seconds")] + [InlineData(34390862500, 5, "1 year, 1 month, 2 days, 1 hour, 1 minute")] + [InlineData(34390862500, 4, "1 year, 1 month, 2 days, 1 hour")] + [InlineData(34390862500, 3, "1 year, 1 month, 2 days")] + [InlineData(34390862500, 2, "1 year, 1 month")] + [InlineData(34390862500, 1, "1 year")] + public void TimeSpanWithPrecision(long milliseconds, int precision, string expected, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, maxUnit: TimeUnit.Year, toWords: toWords); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(3 * 7 + 4, 2, "3 weeks, 4 days")] - [InlineData(6 * 7 + 3, 2, "6 weeks, 3 days")] - [InlineData(72 * 7 + 6, 2, "72 weeks, 6 days")] - public void DaysWithPrecision(int days, int precision, string expected) - { - var actual = TimeSpan.FromDays(days).Humanize(precision: precision); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(3 * 7 + 4, 2, "3 weeks, 4 days")] + [InlineData(6 * 7 + 3, 2, "6 weeks, 3 days")] + [InlineData(72 * 7 + 6, 2, "72 weeks, 6 days")] + public void DaysWithPrecision(int days, int precision, string expected) + { + var actual = TimeSpan.FromDays(days).Humanize(precision: precision); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(50)] - [InlineData(52)] - public void TimeSpanWithMinAndMaxUnits_DoesNotReportExcessiveTime(int minutes) - { - var actual = TimeSpan.FromMinutes(minutes).Humanize(2, null, TimeUnit.Hour, TimeUnit.Minute); - var expected = TimeSpan.FromMinutes(minutes).Humanize(2); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(50)] + [InlineData(52)] + public void TimeSpanWithMinAndMaxUnits_DoesNotReportExcessiveTime(int minutes) + { + var actual = TimeSpan.FromMinutes(minutes).Humanize(2, null, TimeUnit.Hour, TimeUnit.Minute); + var expected = TimeSpan.FromMinutes(minutes).Humanize(2); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(0, 3, "no time", true)] - [InlineData(0, 2, "no time", true)] - [InlineData(0, 3, "0 milliseconds")] - [InlineData(0, 2, "0 milliseconds")] - [InlineData(10, 2, "10 milliseconds")] - [InlineData(1400, 2, "1 second, 400 milliseconds")] - [InlineData(2500, 2, "2 seconds, 500 milliseconds")] - [InlineData(60001, 1, "1 minute")] - [InlineData(60001, 2, "1 minute")] - [InlineData(60001, 3, "1 minute, 1 millisecond")] - [InlineData(120000, 2, "2 minutes")] - [InlineData(62000, 2, "1 minute, 2 seconds")] - [InlineData(62020, 2, "1 minute, 2 seconds")] - [InlineData(62020, 3, "1 minute, 2 seconds, 20 milliseconds")] - [InlineData(3600020, 4, "1 hour, 20 milliseconds")] - [InlineData(3600020, 3, "1 hour")] - [InlineData(3600020, 2, "1 hour")] - [InlineData(3600020, 1, "1 hour")] - [InlineData(3603001, 2, "1 hour")] - [InlineData(3603001, 3, "1 hour, 3 seconds")] - [InlineData(86400000, 3, "1 day")] - [InlineData(86400000, 2, "1 day")] - [InlineData(86400000, 1, "1 day")] - [InlineData(86401000, 1, "1 day")] - [InlineData(86401000, 2, "1 day")] - [InlineData(86401000, 3, "1 day")] - [InlineData(86401000, 4, "1 day, 1 second")] - [InlineData(86401200, 4, "1 day, 1 second")] - [InlineData(86401200, 5, "1 day, 1 second, 200 milliseconds")] - [InlineData(1296000000, 1, "2 weeks")] - [InlineData(1296000000, 2, "2 weeks, 1 day")] - [InlineData(1299600000, 2, "2 weeks, 1 day")] - [InlineData(1299600000, 3, "2 weeks, 1 day, 1 hour")] - [InlineData(1299630020, 3, "2 weeks, 1 day, 1 hour")] - [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour")] - [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds")] - [InlineData(1299630020, 6, "2 weeks, 1 day, 1 hour, 30 seconds, 20 milliseconds")] - public void TimeSpanWithPrecisionAndCountingEmptyUnits(int milliseconds, int precision, string expected, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision: precision, countEmptyUnits: true, toWords: toWords); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(0, 3, "no time", true)] + [InlineData(0, 2, "no time", true)] + [InlineData(0, 3, "0 milliseconds")] + [InlineData(0, 2, "0 milliseconds")] + [InlineData(10, 2, "10 milliseconds")] + [InlineData(1400, 2, "1 second, 400 milliseconds")] + [InlineData(2500, 2, "2 seconds, 500 milliseconds")] + [InlineData(60001, 1, "1 minute")] + [InlineData(60001, 2, "1 minute")] + [InlineData(60001, 3, "1 minute, 1 millisecond")] + [InlineData(120000, 2, "2 minutes")] + [InlineData(62000, 2, "1 minute, 2 seconds")] + [InlineData(62020, 2, "1 minute, 2 seconds")] + [InlineData(62020, 3, "1 minute, 2 seconds, 20 milliseconds")] + [InlineData(3600020, 4, "1 hour, 20 milliseconds")] + [InlineData(3600020, 3, "1 hour")] + [InlineData(3600020, 2, "1 hour")] + [InlineData(3600020, 1, "1 hour")] + [InlineData(3603001, 2, "1 hour")] + [InlineData(3603001, 3, "1 hour, 3 seconds")] + [InlineData(86400000, 3, "1 day")] + [InlineData(86400000, 2, "1 day")] + [InlineData(86400000, 1, "1 day")] + [InlineData(86401000, 1, "1 day")] + [InlineData(86401000, 2, "1 day")] + [InlineData(86401000, 3, "1 day")] + [InlineData(86401000, 4, "1 day, 1 second")] + [InlineData(86401200, 4, "1 day, 1 second")] + [InlineData(86401200, 5, "1 day, 1 second, 200 milliseconds")] + [InlineData(1296000000, 1, "2 weeks")] + [InlineData(1296000000, 2, "2 weeks, 1 day")] + [InlineData(1299600000, 2, "2 weeks, 1 day")] + [InlineData(1299600000, 3, "2 weeks, 1 day, 1 hour")] + [InlineData(1299630020, 3, "2 weeks, 1 day, 1 hour")] + [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour")] + [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds")] + [InlineData(1299630020, 6, "2 weeks, 1 day, 1 hour, 30 seconds, 20 milliseconds")] + public void TimeSpanWithPrecisionAndCountingEmptyUnits(int milliseconds, int precision, string expected, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision: precision, countEmptyUnits: true, toWords: toWords); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(0, 3, "no time", true)] - [InlineData(0, 2, "no time", true)] - [InlineData(0, 3, "0 milliseconds")] - [InlineData(0, 2, "0 milliseconds")] - [InlineData(10, 2, "10 milliseconds")] - [InlineData(1400, 2, "1 second and 400 milliseconds")] - [InlineData(2500, 2, "2 seconds and 500 milliseconds")] - [InlineData(120000, 2, "2 minutes")] - [InlineData(62000, 2, "1 minute and 2 seconds")] - [InlineData(62020, 2, "1 minute and 2 seconds")] - [InlineData(62020, 3, "1 minute, 2 seconds, and 20 milliseconds")] - [InlineData(3600020, 4, "1 hour and 20 milliseconds")] - [InlineData(3600020, 3, "1 hour and 20 milliseconds")] - [InlineData(3600020, 2, "1 hour and 20 milliseconds")] - [InlineData(3600020, 1, "1 hour")] - [InlineData(3603001, 2, "1 hour and 3 seconds")] - [InlineData(3603001, 3, "1 hour, 3 seconds, and 1 millisecond")] - [InlineData(86400000, 3, "1 day")] - [InlineData(86400000, 2, "1 day")] - [InlineData(86400000, 1, "1 day")] - [InlineData(86401000, 1, "1 day")] - [InlineData(86401000, 2, "1 day and 1 second")] - [InlineData(86401200, 2, "1 day and 1 second")] - [InlineData(86401200, 3, "1 day, 1 second, and 200 milliseconds")] - [InlineData(1296000000, 1, "2 weeks")] - [InlineData(1296000000, 2, "2 weeks and 1 day")] - [InlineData(1299600000, 2, "2 weeks and 1 day")] - [InlineData(1299600000, 3, "2 weeks, 1 day, and 1 hour")] - [InlineData(1299630020, 3, "2 weeks, 1 day, and 1 hour")] - [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour, and 30 seconds")] - [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds, and 20 milliseconds")] - public void TimeSpanWithPrecisionAndAlternativeCollectionFormatter(int milliseconds, int precision, - string expected, bool toWords = false) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, collectionSeparator: null, toWords: toWords); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(0, 3, "no time", true)] + [InlineData(0, 2, "no time", true)] + [InlineData(0, 3, "0 milliseconds")] + [InlineData(0, 2, "0 milliseconds")] + [InlineData(10, 2, "10 milliseconds")] + [InlineData(1400, 2, "1 second and 400 milliseconds")] + [InlineData(2500, 2, "2 seconds and 500 milliseconds")] + [InlineData(120000, 2, "2 minutes")] + [InlineData(62000, 2, "1 minute and 2 seconds")] + [InlineData(62020, 2, "1 minute and 2 seconds")] + [InlineData(62020, 3, "1 minute, 2 seconds, and 20 milliseconds")] + [InlineData(3600020, 4, "1 hour and 20 milliseconds")] + [InlineData(3600020, 3, "1 hour and 20 milliseconds")] + [InlineData(3600020, 2, "1 hour and 20 milliseconds")] + [InlineData(3600020, 1, "1 hour")] + [InlineData(3603001, 2, "1 hour and 3 seconds")] + [InlineData(3603001, 3, "1 hour, 3 seconds, and 1 millisecond")] + [InlineData(86400000, 3, "1 day")] + [InlineData(86400000, 2, "1 day")] + [InlineData(86400000, 1, "1 day")] + [InlineData(86401000, 1, "1 day")] + [InlineData(86401000, 2, "1 day and 1 second")] + [InlineData(86401200, 2, "1 day and 1 second")] + [InlineData(86401200, 3, "1 day, 1 second, and 200 milliseconds")] + [InlineData(1296000000, 1, "2 weeks")] + [InlineData(1296000000, 2, "2 weeks and 1 day")] + [InlineData(1299600000, 2, "2 weeks and 1 day")] + [InlineData(1299600000, 3, "2 weeks, 1 day, and 1 hour")] + [InlineData(1299630020, 3, "2 weeks, 1 day, and 1 hour")] + [InlineData(1299630020, 4, "2 weeks, 1 day, 1 hour, and 30 seconds")] + [InlineData(1299630020, 5, "2 weeks, 1 day, 1 hour, 30 seconds, and 20 milliseconds")] + public void TimeSpanWithPrecisionAndAlternativeCollectionFormatter(int milliseconds, int precision, + string expected, bool toWords = false) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, collectionSeparator: null, toWords: toWords); + Assert.Equal(expected, actual); + } - [Theory] - [InlineData(0, 3, "no time")] - [InlineData(0, 2, "no time")] - [InlineData(10, 2, "ten milliseconds")] - [InlineData(1400, 2, "one second, four hundred milliseconds")] - [InlineData(2500, 2, "two seconds, five hundred milliseconds")] - [InlineData(120000, 2, "two minutes")] - [InlineData(62000, 2, "one minute, two seconds")] - [InlineData(62020, 2, "one minute, two seconds")] - [InlineData(62020, 3, "one minute, two seconds, twenty milliseconds")] - [InlineData(3600020, 4, "one hour, twenty milliseconds")] - [InlineData(3600020, 3, "one hour, twenty milliseconds")] - [InlineData(3600020, 2, "one hour, twenty milliseconds")] - [InlineData(3600020, 1, "one hour")] - [InlineData(3603001, 2, "one hour, three seconds")] - [InlineData(3603001, 3, "one hour, three seconds, one millisecond")] - [InlineData(86400000, 3, "one day")] - [InlineData(86400000, 2, "one day")] - [InlineData(86400000, 1, "one day")] - [InlineData(86401000, 1, "one day")] - [InlineData(86401000, 2, "one day, one second")] - [InlineData(86401200, 2, "one day, one second")] - [InlineData(86401200, 3, "one day, one second, two hundred milliseconds")] - [InlineData(1296000000, 1, "two weeks")] - [InlineData(1296000000, 2, "two weeks, one day")] - [InlineData(1299600000, 2, "two weeks, one day")] - [InlineData(1299600000, 3, "two weeks, one day, one hour")] - [InlineData(1299630020, 3, "two weeks, one day, one hour")] - [InlineData(1299630020, 4, "two weeks, one day, one hour, thirty seconds")] - [InlineData(1299630020, 5, "two weeks, one day, one hour, thirty seconds, twenty milliseconds")] - public void TimeSpanWithNumbersConvertedToWords(int milliseconds, int precision, string expected) - { - var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, toWords: true); - Assert.Equal(expected, actual); - } + [Theory] + [InlineData(0, 3, "no time")] + [InlineData(0, 2, "no time")] + [InlineData(10, 2, "ten milliseconds")] + [InlineData(1400, 2, "one second, four hundred milliseconds")] + [InlineData(2500, 2, "two seconds, five hundred milliseconds")] + [InlineData(120000, 2, "two minutes")] + [InlineData(62000, 2, "one minute, two seconds")] + [InlineData(62020, 2, "one minute, two seconds")] + [InlineData(62020, 3, "one minute, two seconds, twenty milliseconds")] + [InlineData(3600020, 4, "one hour, twenty milliseconds")] + [InlineData(3600020, 3, "one hour, twenty milliseconds")] + [InlineData(3600020, 2, "one hour, twenty milliseconds")] + [InlineData(3600020, 1, "one hour")] + [InlineData(3603001, 2, "one hour, three seconds")] + [InlineData(3603001, 3, "one hour, three seconds, one millisecond")] + [InlineData(86400000, 3, "one day")] + [InlineData(86400000, 2, "one day")] + [InlineData(86400000, 1, "one day")] + [InlineData(86401000, 1, "one day")] + [InlineData(86401000, 2, "one day, one second")] + [InlineData(86401200, 2, "one day, one second")] + [InlineData(86401200, 3, "one day, one second, two hundred milliseconds")] + [InlineData(1296000000, 1, "two weeks")] + [InlineData(1296000000, 2, "two weeks, one day")] + [InlineData(1299600000, 2, "two weeks, one day")] + [InlineData(1299600000, 3, "two weeks, one day, one hour")] + [InlineData(1299630020, 3, "two weeks, one day, one hour")] + [InlineData(1299630020, 4, "two weeks, one day, one hour, thirty seconds")] + [InlineData(1299630020, 5, "two weeks, one day, one hour, thirty seconds, twenty milliseconds")] + public void TimeSpanWithNumbersConvertedToWords(int milliseconds, int precision, string expected) + { + var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precision, toWords: true); + Assert.Equal(expected, actual); + } - [Fact] - public void NoTime() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(); - Assert.Equal("0 milliseconds", actual); - } + [Fact] + public void NoTime() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(); + Assert.Equal("0 milliseconds", actual); + } - [Fact] - public void NoTimeToWords() - { - var noTime = TimeSpan.Zero; - var actual = noTime.Humanize(toWords: true); - Assert.Equal("no time", actual); - } + [Fact] + public void NoTimeToWords() + { + var noTime = TimeSpan.Zero; + var actual = noTime.Humanize(toWords: true); + Assert.Equal("no time", actual); + } - [Theory] - [InlineData(1, 1, "en-US", "1 millisecond", ", ")] - [InlineData(6 * 24 * 60 * 60 * 1000, 1, "ru-RU", "6 дней", ", ")] - [InlineData(11 * 60 * 60 * 1000, 1, "ar", "11 ساعة", ", ")] - [InlineData(3603001, 2, "it-IT", "1 ora e 3 secondi", null)] - public void CanSpecifyCultureExplicitly(int ms, int precision, string culture, string expected, string? collectionSeparator) - { - var actual = TimeSpan.FromMilliseconds(ms).Humanize(precision: precision, culture: new(culture), collectionSeparator: collectionSeparator); - Assert.Equal(expected, actual); - } - [Theory] - [InlineData(31 * 4, 1, "en-US", "four months")] - [InlineData(236, 2, "ar", "سبعة أشهر, اثنان و عشرون يوم")] - [InlineData(321, 2, "es", "diez meses, dieciséis días")] - public void CanSpecifyCultureExplicitlyToWords(int days, int precision, string culture, string expected) - { - var timeSpan = new TimeSpan(days, 0, 0, 0); - var actual = timeSpan.Humanize(precision: precision, culture: new(culture), maxUnit: TimeUnit.Year, toWords: true); - Assert.Equal(expected: expected, actual); - } + [Theory] + [InlineData(1, 1, "en-US", "1 millisecond", ", ")] + [InlineData(6 * 24 * 60 * 60 * 1000, 1, "ru-RU", "6 дней", ", ")] + [InlineData(11 * 60 * 60 * 1000, 1, "ar", "11 ساعة", ", ")] + [InlineData(3603001, 2, "it-IT", "1 ora e 3 secondi", null)] + public void CanSpecifyCultureExplicitly(int ms, int precision, string culture, string expected, string? collectionSeparator) + { + var actual = TimeSpan.FromMilliseconds(ms).Humanize(precision: precision, culture: new(culture), collectionSeparator: collectionSeparator); + Assert.Equal(expected, actual); + } + [Theory] + [InlineData(31 * 4, 1, "en-US", "four months")] + [InlineData(236, 2, "ar", "سبعة أشهر, اثنان و عشرون يوم")] + [InlineData(321, 2, "es", "diez meses, dieciséis días")] + public void CanSpecifyCultureExplicitlyToWords(int days, int precision, string culture, string expected) + { + var timeSpan = new TimeSpan(days, 0, 0, 0); + var actual = timeSpan.Humanize(precision: precision, culture: new(culture), maxUnit: TimeUnit.Year, toWords: true); + Assert.Equal(expected: expected, actual); } -} +} \ No newline at end of file diff --git a/src/Humanizer.Tests/TimeUnitToSymbolTests.cs b/src/Humanizer.Tests/TimeUnitToSymbolTests.cs index 56aa2082f..b1f3ff2ed 100644 --- a/src/Humanizer.Tests/TimeUnitToSymbolTests.cs +++ b/src/Humanizer.Tests/TimeUnitToSymbolTests.cs @@ -1,18 +1,17 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +[UseCulture("en-US")] +public class TimeUnitToSymbolTests { - [UseCulture("en-US")] - public class TimeUnitToSymbolTests - { - [Theory] - [InlineData(TimeUnit.Millisecond, "ms")] - [InlineData(TimeUnit.Second, "s")] - [InlineData(TimeUnit.Minute, "min")] - [InlineData(TimeUnit.Hour, "h")] - [InlineData(TimeUnit.Day, "d")] - [InlineData(TimeUnit.Week, "week")] - [InlineData(TimeUnit.Month, "mo")] - [InlineData(TimeUnit.Year, "y")] - public void ToSymbol(TimeUnit unit, string expected) => - Assert.Equal(expected, unit.ToSymbol()); - } -} + [Theory] + [InlineData(TimeUnit.Millisecond, "ms")] + [InlineData(TimeUnit.Second, "s")] + [InlineData(TimeUnit.Minute, "min")] + [InlineData(TimeUnit.Hour, "h")] + [InlineData(TimeUnit.Day, "d")] + [InlineData(TimeUnit.Week, "week")] + [InlineData(TimeUnit.Month, "mo")] + [InlineData(TimeUnit.Year, "y")] + public void ToSymbol(TimeUnit unit, string expected) => + Assert.Equal(expected, unit.ToSymbol()); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/ToQuantityTests.cs b/src/Humanizer.Tests/ToQuantityTests.cs index b0e3ba217..22d1aff17 100644 --- a/src/Humanizer.Tests/ToQuantityTests.cs +++ b/src/Humanizer.Tests/ToQuantityTests.cs @@ -1,114 +1,113 @@ -namespace Humanizer.Tests -{ - [UseCulture("en-US")] - public class ToQuantityTests - { - [Theory] - [InlineData("case", 0, "0 cases")] - [InlineData("case", 1, "1 case")] - [InlineData("case", 5, "5 cases")] - [InlineData("man", 0, "0 men")] - [InlineData("man", 1, "1 man")] - [InlineData("man", 2, "2 men")] - [InlineData("men", 2, "2 men")] - [InlineData("process", 2, "2 processes")] - [InlineData("process", 1, "1 process")] - [InlineData("processes", 2, "2 processes")] - [InlineData("processes", 1, "1 process")] - [InlineData("slice", 1, "1 slice")] - [InlineData("slice", 2, "2 slices")] - [InlineData("slices", 1, "1 slice")] - [InlineData("slices", 2, "2 slices")] - public void ToQuantity(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity)); +namespace Humanizer.Tests; - [Theory] - [InlineData("case", 0, "cases")] - [InlineData("case", 1, "case")] - [InlineData("case", 5, "cases")] - [InlineData("man", 0, "men")] - [InlineData("man", 1, "man")] - [InlineData("man", 2, "men")] - [InlineData("men", 2, "men")] - [InlineData("process", 2, "processes")] - [InlineData("process", 1, "process")] - [InlineData("processes", 2, "processes")] - [InlineData("processes", 1, "process")] - public void ToQuantityWithNoQuantity(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.None)); +[UseCulture("en-US")] +public class ToQuantityTests +{ + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1, "1 process")] + [InlineData("slice", 1, "1 slice")] + [InlineData("slice", 2, "2 slices")] + [InlineData("slices", 1, "1 slice")] + [InlineData("slices", 2, "2 slices")] + public void ToQuantity(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity)); - [Theory] - [InlineData("case", 0, "0 cases")] - [InlineData("case", 1, "1 case")] - [InlineData("case", 5, "5 cases")] - [InlineData("man", 0, "0 men")] - [InlineData("man", 1, "1 man")] - [InlineData("man", 2, "2 men")] - [InlineData("men", 2, "2 men")] - [InlineData("process", 2, "2 processes")] - [InlineData("process", 1, "1 process")] - [InlineData("processes", 2, "2 processes")] - [InlineData("processes", 1, "1 process")] - public void ToQuantityNumeric(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity)); + [Theory] + [InlineData("case", 0, "cases")] + [InlineData("case", 1, "case")] + [InlineData("case", 5, "cases")] + [InlineData("man", 0, "men")] + [InlineData("man", 1, "man")] + [InlineData("man", 2, "men")] + [InlineData("men", 2, "men")] + [InlineData("process", 2, "processes")] + [InlineData("process", 1, "process")] + [InlineData("processes", 2, "processes")] + [InlineData("processes", 1, "process")] + public void ToQuantityWithNoQuantity(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.None)); - [Theory] - [InlineData("hour", 1, "1 hour")] - [InlineData("hour", 0.5, "0.5 hours")] - [InlineData("hour", 22.4, "22.4 hours")] - public void ToDoubleQuantityNumeric(string word, double quantity, string expected) => - // ReSharper disable once RedundantArgumentDefaultValue - Assert.Equal(expected, word.ToQuantity(quantity)); + [Theory] + [InlineData("case", 0, "0 cases")] + [InlineData("case", 1, "1 case")] + [InlineData("case", 5, "5 cases")] + [InlineData("man", 0, "0 men")] + [InlineData("man", 1, "1 man")] + [InlineData("man", 2, "2 men")] + [InlineData("men", 2, "2 men")] + [InlineData("process", 2, "2 processes")] + [InlineData("process", 1, "1 process")] + [InlineData("processes", 2, "2 processes")] + [InlineData("processes", 1, "1 process")] + public void ToQuantityNumeric(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity)); - [Theory] - [InlineData("case", 0, "zero cases")] - [InlineData("case", 1, "one case")] - [InlineData("case", 5, "five cases")] - [InlineData("man", 0, "zero men")] - [InlineData("man", 1, "one man")] - [InlineData("man", 2, "two men")] - [InlineData("men", 2, "two men")] - [InlineData("process", 2, "two processes")] - [InlineData("process", 1, "one process")] - [InlineData("processes", 2, "two processes")] - [InlineData("processes", 1200, "one thousand two hundred processes")] - [InlineData("processes", 1, "one process")] - public void ToQuantityWords(string word, int quantity, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Words)); + [Theory] + [InlineData("hour", 1, "1 hour")] + [InlineData("hour", 0.5, "0.5 hours")] + [InlineData("hour", 22.4, "22.4 hours")] + public void ToDoubleQuantityNumeric(string word, double quantity, string expected) => + // ReSharper disable once RedundantArgumentDefaultValue + Assert.Equal(expected, word.ToQuantity(quantity)); - [Theory] - [InlineData("case", 0, null, "0 cases")] - [InlineData("case", 1, null, "1 case")] - [InlineData("case", 2, null, "2 cases")] - [InlineData("case", 1, "N0", "1 case")] - [InlineData("case", 2, "N0", "2 cases")] - [InlineData("case", 123456, "N0", "123,456 cases")] - [InlineData("case", 123456, "N2", "123,456.00 cases")] - [InlineData("dollar", 0, "C0", "$0 dollars")] - [InlineData("dollar", 1, "C0", "$1 dollar")] - [InlineData("dollar", 2, "C0", "$2 dollars")] - [InlineData("dollar", 2, "C2", "$2.00 dollars")] - public void ToQuantityWordsWithCurrentCultureFormatting(string word, int quantity, string? format, string expected) => - Assert.Equal(expected, word.ToQuantity(quantity, format)); + [Theory] + [InlineData("case", 0, "zero cases")] + [InlineData("case", 1, "one case")] + [InlineData("case", 5, "five cases")] + [InlineData("man", 0, "zero men")] + [InlineData("man", 1, "one man")] + [InlineData("man", 2, "two men")] + [InlineData("men", 2, "two men")] + [InlineData("process", 2, "two processes")] + [InlineData("process", 1, "one process")] + [InlineData("processes", 2, "two processes")] + [InlineData("processes", 1200, "one thousand two hundred processes")] + [InlineData("processes", 1, "one process")] + public void ToQuantityWords(string word, int quantity, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity, ShowQuantityAs.Words)); - [Theory] - [InlineData("case", 0, "N0", "it-IT", "0 cases")] - [InlineData("case", 1, "N0", "it-IT", "1 case")] - [InlineData("case", 2, "N0", "it-IT", "2 cases")] - [InlineData("case", 1234567, "N0", "it-IT", "1.234.567 cases")] - [InlineData("case", 1234567, "N2", "it-IT", "1.234.567,00 cases")] - [InlineData("euro", 0, "C0", "es-ES", "0 € euros")] - [InlineData("euro", 1, "C0", "es-ES", "1 € euro")] - [InlineData("euro", 2, "C0", "es-ES", "2 € euros")] - [InlineData("euro", 2, "C2", "es-ES", "2,00 € euros")] - public void ToQuantityWordsWithCustomCultureFormatting(string word, int quantity, string format, string cultureCode, string expected) - { - var culture = new CultureInfo(cultureCode); + [Theory] + [InlineData("case", 0, null, "0 cases")] + [InlineData("case", 1, null, "1 case")] + [InlineData("case", 2, null, "2 cases")] + [InlineData("case", 1, "N0", "1 case")] + [InlineData("case", 2, "N0", "2 cases")] + [InlineData("case", 123456, "N0", "123,456 cases")] + [InlineData("case", 123456, "N2", "123,456.00 cases")] + [InlineData("dollar", 0, "C0", "$0 dollars")] + [InlineData("dollar", 1, "C0", "$1 dollar")] + [InlineData("dollar", 2, "C0", "$2 dollars")] + [InlineData("dollar", 2, "C2", "$2.00 dollars")] + public void ToQuantityWordsWithCurrentCultureFormatting(string word, int quantity, string? format, string expected) => + Assert.Equal(expected, word.ToQuantity(quantity, format)); - Assert.Equal(expected, word.ToQuantity(quantity, format, culture), GetStringComparer(culture)); - } + [Theory] + [InlineData("case", 0, "N0", "it-IT", "0 cases")] + [InlineData("case", 1, "N0", "it-IT", "1 case")] + [InlineData("case", 2, "N0", "it-IT", "2 cases")] + [InlineData("case", 1234567, "N0", "it-IT", "1.234.567 cases")] + [InlineData("case", 1234567, "N2", "it-IT", "1.234.567,00 cases")] + [InlineData("euro", 0, "C0", "es-ES", "0 € euros")] + [InlineData("euro", 1, "C0", "es-ES", "1 € euro")] + [InlineData("euro", 2, "C0", "es-ES", "2 € euros")] + [InlineData("euro", 2, "C2", "es-ES", "2,00 € euros")] + public void ToQuantityWordsWithCustomCultureFormatting(string word, int quantity, string format, string cultureCode, string expected) + { + var culture = new CultureInfo(cultureCode); - internal static StringComparer GetStringComparer(CultureInfo culture) => - StringComparer.Create(culture, false); + Assert.Equal(expected, word.ToQuantity(quantity, format, culture), GetStringComparer(culture)); } -} + + internal static StringComparer GetStringComparer(CultureInfo culture) => + StringComparer.Create(culture, false); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/TransformersTests.cs b/src/Humanizer.Tests/TransformersTests.cs index 152332543..21e965115 100644 --- a/src/Humanizer.Tests/TransformersTests.cs +++ b/src/Humanizer.Tests/TransformersTests.cs @@ -1,40 +1,39 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class TransformersTests { - public class TransformersTests - { - [Theory] - [InlineData("lower case statement", "Lower Case Statement")] - [InlineData("Sentence casing", "Sentence Casing")] - [InlineData("honors UPPER case", "Honors UPPER Case")] - [InlineData("INvalid caSEs arE corrected", "Invalid Cases Are Corrected")] - [InlineData("Can deal w 1 letter words as i do", "Can Deal W 1 Letter Words as I Do")] - [InlineData(" random spaces are HONORED too ", " Random Spaces Are HONORED Too ")] - [InlineData("Title Case", "Title Case")] - [InlineData("apostrophe's aren't capitalized", "Apostrophe's Aren't Capitalized")] - [InlineData("titles with, commas work too", "Titles With, Commas Work Too")] - public void TransformToTitleCase(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Transform(To.TitleCase)); + [Theory] + [InlineData("lower case statement", "Lower Case Statement")] + [InlineData("Sentence casing", "Sentence Casing")] + [InlineData("honors UPPER case", "Honors UPPER Case")] + [InlineData("INvalid caSEs arE corrected", "Invalid Cases Are Corrected")] + [InlineData("Can deal w 1 letter words as i do", "Can Deal W 1 Letter Words as I Do")] + [InlineData(" random spaces are HONORED too ", " Random Spaces Are HONORED Too ")] + [InlineData("Title Case", "Title Case")] + [InlineData("apostrophe's aren't capitalized", "Apostrophe's Aren't Capitalized")] + [InlineData("titles with, commas work too", "Titles With, Commas Work Too")] + public void TransformToTitleCase(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Transform(To.TitleCase)); - [Theory] - [InlineData("lower case statement", "lower case statement")] - [InlineData("Sentence casing", "sentence casing")] - [InlineData("No honor for UPPER case", "no honor for upper case")] - [InlineData("Title Case", "title case")] - public void TransformToLowerCase(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Transform(To.LowerCase)); + [Theory] + [InlineData("lower case statement", "lower case statement")] + [InlineData("Sentence casing", "sentence casing")] + [InlineData("No honor for UPPER case", "no honor for upper case")] + [InlineData("Title Case", "title case")] + public void TransformToLowerCase(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Transform(To.LowerCase)); - [Theory] - [InlineData("lower case statement", "Lower case statement")] - [InlineData("Sentence casing", "Sentence casing")] - [InlineData("honors UPPER case", "Honors UPPER case")] - public void TransformToSentenceCase(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Transform(To.SentenceCase)); + [Theory] + [InlineData("lower case statement", "Lower case statement")] + [InlineData("Sentence casing", "Sentence casing")] + [InlineData("honors UPPER case", "Honors UPPER case")] + public void TransformToSentenceCase(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Transform(To.SentenceCase)); - [Theory] - [InlineData("lower case statement", "LOWER CASE STATEMENT")] - [InlineData("Sentence casing", "SENTENCE CASING")] - [InlineData("Title Case", "TITLE CASE")] - public void TransformToUpperCase(string input, string expectedOutput) => - Assert.Equal(expectedOutput, input.Transform(To.UpperCase)); - } -} + [Theory] + [InlineData("lower case statement", "LOWER CASE STATEMENT")] + [InlineData("Sentence casing", "SENTENCE CASING")] + [InlineData("Title Case", "TITLE CASE")] + public void TransformToUpperCase(string input, string expectedOutput) => + Assert.Equal(expectedOutput, input.Transform(To.UpperCase)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/TruncatorTests.cs b/src/Humanizer.Tests/TruncatorTests.cs index 8d65af2ed..c4d33f575 100644 --- a/src/Humanizer.Tests/TruncatorTests.cs +++ b/src/Humanizer.Tests/TruncatorTests.cs @@ -1,171 +1,170 @@ -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class TruncatorTests { - public class TruncatorTests - { - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text longer than truncate length", 10, "Text long…")] - [InlineData("Text with length equal to truncate length", 41, "Text with length equal to truncate length")] - [InlineData("Text smaller than truncate length", 34, "Text smaller than truncate length")] - public void Truncate(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text longer than truncate length", 10, "Text long…")] + [InlineData("Text with length equal to truncate length", 41, "Text with length equal to truncate length")] + [InlineData("Text smaller than truncate length", 34, "Text smaller than truncate length")] + public void Truncate(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length)); - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text longer than truncate length", 10, "Text long…")] - [InlineData("Text with length equal to truncate length", 41, "Text with length equal to truncate length")] - [InlineData("Text smaller than truncate length", 34, "Text smaller than truncate length")] - public void TruncateWithFixedLengthTruncator(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedLength)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text longer than truncate length", 10, "Text long…")] + [InlineData("Text with length equal to truncate length", 41, "Text with length equal to truncate length")] + [InlineData("Text smaller than truncate length", 34, "Text smaller than truncate length")] + public void TruncateWithFixedLengthTruncator(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedLength)); - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text with more characters than truncate length", 10, "Text with m…")] - [InlineData("Text with number of characters equal to truncate length", 47, "Text with number of characters equal to truncate length")] - [InlineData("Text with less characters than truncate length", 41, "Text with less characters than truncate length")] - public void TruncateWithFixedNumberOfCharactersTruncator(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfCharacters)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text with more characters than truncate length", 10, "Text with m…")] + [InlineData("Text with number of characters equal to truncate length", 47, "Text with number of characters equal to truncate length")] + [InlineData("Text with less characters than truncate length", 41, "Text with less characters than truncate length")] + public void TruncateWithFixedNumberOfCharactersTruncator(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfCharacters)); - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text with more words than truncate length", 4, "Text with more words…")] - [InlineData("Text with number of words equal to truncate length", 9, "Text with number of words equal to truncate length")] - [InlineData("Text with less words than truncate length", 8, "Text with less words than truncate length")] - [InlineData("Words are\nsplit\rby\twhitespace", 4, "Words are\nsplit\rby…")] - public void TruncateWithFixedNumberOfWordsTruncator(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfWords)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text with more words than truncate length", 4, "Text with more words…")] + [InlineData("Text with number of words equal to truncate length", 9, "Text with number of words equal to truncate length")] + [InlineData("Text with less words than truncate length", 8, "Text with less words than truncate length")] + [InlineData("Words are\nsplit\rby\twhitespace", 4, "Words are\nsplit\rby…")] + public void TruncateWithFixedNumberOfWordsTruncator(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfWords)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text longer than truncate length", 10, "...", "Text lo...")] - [InlineData("Text with length equal to truncate length", 41, "...", "Text with length equal to truncate length")] - [InlineData("Text smaller than truncate length", 34, "...", "Text smaller than truncate length")] - [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "Te")] - [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "Null")] - public void TruncateWithTruncationString(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString)); + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text longer than truncate length", 10, "...", "Text lo...")] + [InlineData("Text with length equal to truncate length", 41, "...", "Text with length equal to truncate length")] + [InlineData("Text smaller than truncate length", 34, "...", "Text smaller than truncate length")] + [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "Te")] + [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "Null")] + public void TruncateWithTruncationString(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text longer than truncate length", 10, "...", "Text lo...")] - [InlineData("Text with different truncation string", 10, "---", "Text wi---")] - [InlineData("Text with length equal to truncate length", 41, "...", "Text with length equal to truncate length")] - [InlineData("Text smaller than truncate length", 34, "...", "Text smaller than truncate length")] - [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "Te")] - [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "Null")] - public void TruncateWithTruncationStringAndFixedLengthTruncator(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedLength)); + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text longer than truncate length", 10, "...", "Text lo...")] + [InlineData("Text with different truncation string", 10, "---", "Text wi---")] + [InlineData("Text with length equal to truncate length", 41, "...", "Text with length equal to truncate length")] + [InlineData("Text smaller than truncate length", 34, "...", "Text smaller than truncate length")] + [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "Te")] + [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "Null")] + public void TruncateWithTruncationStringAndFixedLengthTruncator(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedLength)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text with more characters than truncate length", 10, "...", "Text wit...")] - [InlineData("Text with different truncation string", 10, "---", "Text wit---")] - [InlineData("Text with number of characters equal to truncate length", 47, "...", "Text with number of characters equal to truncate length")] - [InlineData("Text with less characters than truncate length", 41, "...", "Text with less characters than truncate length")] - [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "Te")] - [InlineData("Text with additional spaces and null truncate string", 10, null, "Text with ad")] - [InlineData("Text with additional spaces and empty string as truncate string", 10, "", "Text with ad")] - public void TruncateWithTruncationStringAndFixedNumberOfCharactersTruncator(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfCharacters)); + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text with more characters than truncate length", 10, "...", "Text wit...")] + [InlineData("Text with different truncation string", 10, "---", "Text wit---")] + [InlineData("Text with number of characters equal to truncate length", 47, "...", "Text with number of characters equal to truncate length")] + [InlineData("Text with less characters than truncate length", 41, "...", "Text with less characters than truncate length")] + [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "Te")] + [InlineData("Text with additional spaces and null truncate string", 10, null, "Text with ad")] + [InlineData("Text with additional spaces and empty string as truncate string", 10, "", "Text with ad")] + public void TruncateWithTruncationStringAndFixedNumberOfCharactersTruncator(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfCharacters)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text with more words than truncate length", 4, "...", "Text with more words...")] - [InlineData("Text with different truncation string", 4, "---", "Text with different truncation---")] - [InlineData("Text with number of words equal to truncate length", 9, "...", "Text with number of words equal to truncate length")] - [InlineData("Text with less words than truncate length", 8, "...", "Text with less words than truncate length")] - [InlineData("Words are\nsplit\rby\twhitespace", 4, "...", "Words are\nsplit\rby...")] - [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "Null truncation string truncates")] - public void TruncateWithTruncationStringAndFixedNumberOfWordsTruncator(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfWords)); + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text with more words than truncate length", 4, "...", "Text with more words...")] + [InlineData("Text with different truncation string", 4, "---", "Text with different truncation---")] + [InlineData("Text with number of words equal to truncate length", 9, "...", "Text with number of words equal to truncate length")] + [InlineData("Text with less words than truncate length", 8, "...", "Text with less words than truncate length")] + [InlineData("Words are\nsplit\rby\twhitespace", 4, "...", "Words are\nsplit\rby...")] + [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "Null truncation string truncates")] + public void TruncateWithTruncationStringAndFixedNumberOfWordsTruncator(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfWords)); - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text longer than truncate length", 10, "…te length")] - [InlineData("Text with length equal to truncate length", 41, "Text with length equal to truncate length")] - [InlineData("Text smaller than truncate length", 34, "Text smaller than truncate length")] - public void TruncateWithFixedLengthTruncatorTruncateFromLeft(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedLength, TruncateFrom.Left)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text longer than truncate length", 10, "…te length")] + [InlineData("Text with length equal to truncate length", 41, "Text with length equal to truncate length")] + [InlineData("Text smaller than truncate length", 34, "Text smaller than truncate length")] + public void TruncateWithFixedLengthTruncatorTruncateFromLeft(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedLength, TruncateFrom.Left)); - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text with more characters than truncate length", 10, "…ate length")] - [InlineData("Text with number of characters equal to truncate length", 47, "Text with number of characters equal to truncate length")] - [InlineData("Text with less characters than truncate length", 41, "Text with less characters than truncate length")] - [InlineData("Text with strange characters ^$(*^ and more ^$**)% ", 10, "…rs ^$(*^ and more ^$**)% ")] - public void TruncateWithFixedNumberOfCharactersTruncatorTruncateFromLeft(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfCharacters, TruncateFrom.Left)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text with more characters than truncate length", 10, "…ate length")] + [InlineData("Text with number of characters equal to truncate length", 47, "Text with number of characters equal to truncate length")] + [InlineData("Text with less characters than truncate length", 41, "Text with less characters than truncate length")] + [InlineData("Text with strange characters ^$(*^ and more ^$**)% ", 10, "…rs ^$(*^ and more ^$**)% ")] + public void TruncateWithFixedNumberOfCharactersTruncatorTruncateFromLeft(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfCharacters, TruncateFrom.Left)); - [Theory] - [InlineData(null, 10, null)] - [InlineData("", 10, "")] - [InlineData("a", 1, "a")] - [InlineData("Text with more words than truncate length", 4, "…words than truncate length")] - [InlineData("Text with number of words equal to truncate length", 9, "Text with number of words equal to truncate length")] - [InlineData("Text with less words than truncate length", 8, "Text with less words than truncate length")] - [InlineData("Words are\nsplit\rby\twhitespace", 4, "…are\nsplit\rby\twhitespace")] - [InlineData("Text with whitespace at the end ", 4, "…whitespace at the end")] - public void TruncateWithFixedNumberOfWordsTruncatorTruncateFromLeft(string? input, int length, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfWords, TruncateFrom.Left)); + [Theory] + [InlineData(null, 10, null)] + [InlineData("", 10, "")] + [InlineData("a", 1, "a")] + [InlineData("Text with more words than truncate length", 4, "…words than truncate length")] + [InlineData("Text with number of words equal to truncate length", 9, "Text with number of words equal to truncate length")] + [InlineData("Text with less words than truncate length", 8, "Text with less words than truncate length")] + [InlineData("Words are\nsplit\rby\twhitespace", 4, "…are\nsplit\rby\twhitespace")] + [InlineData("Text with whitespace at the end ", 4, "…whitespace at the end")] + public void TruncateWithFixedNumberOfWordsTruncatorTruncateFromLeft(string? input, int length, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, Truncator.FixedNumberOfWords, TruncateFrom.Left)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text longer than truncate length", 10, "...", "... length")] - [InlineData("Text with different truncation string", 10, "---", "--- string")] - [InlineData("Text with length equal to truncate length", 41, "...", "Text with length equal to truncate length")] - [InlineData("Text smaller than truncate length", 34, "...", "Text smaller than truncate length")] - [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "ng")] - [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "ring")] - public void TruncateWithTruncationStringAndFixedLengthTruncatorTruncateFromLeft(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedLength, TruncateFrom.Left)); + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text longer than truncate length", 10, "...", "... length")] + [InlineData("Text with different truncation string", 10, "---", "--- string")] + [InlineData("Text with length equal to truncate length", 41, "...", "Text with length equal to truncate length")] + [InlineData("Text smaller than truncate length", 34, "...", "Text smaller than truncate length")] + [InlineData("Text with delimiter length greater than truncate length truncates to fixed length without truncation string", 2, "...", "ng")] + [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "ring")] + public void TruncateWithTruncationStringAndFixedLengthTruncatorTruncateFromLeft(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedLength, TruncateFrom.Left)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text with more characters than truncate length", 10, "...", "...e length")] - [InlineData("Text with different truncation string", 10, "---", "---n string")] - [InlineData("Text with number of characters equal to truncate length", 47, "...", "Text with number of characters equal to truncate length")] - [InlineData("Text with less characters than truncate length", 41, "...", "Text with less characters than truncate length")] - [InlineData("Text with delimiter length greater than truncate length truncates to fixed number of characters without truncation string", 2, "...", "ng")] - [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "ring")] - public void TruncateWithTruncationStringAndFixedNumberOfCharactersTruncatorTruncateFromLeft(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfCharacters, TruncateFrom.Left)); + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text with more characters than truncate length", 10, "...", "...e length")] + [InlineData("Text with different truncation string", 10, "---", "---n string")] + [InlineData("Text with number of characters equal to truncate length", 47, "...", "Text with number of characters equal to truncate length")] + [InlineData("Text with less characters than truncate length", 41, "...", "Text with less characters than truncate length")] + [InlineData("Text with delimiter length greater than truncate length truncates to fixed number of characters without truncation string", 2, "...", "ng")] + [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "ring")] + public void TruncateWithTruncationStringAndFixedNumberOfCharactersTruncatorTruncateFromLeft(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfCharacters, TruncateFrom.Left)); - [Theory] - [InlineData(null, 10, "...", null)] - [InlineData("", 10, "...", "")] - [InlineData("a", 1, "...", "a")] - [InlineData("Text with more words than truncate length", 4, "...", "...words than truncate length")] - [InlineData("Text with different truncation string", 4, "---", "---with different truncation string")] - [InlineData("Text with number of words equal to truncate length", 9, "...", "Text with number of words equal to truncate length")] - [InlineData("Text with less words than truncate length", 8, "...", "Text with less words than truncate length")] - [InlineData("Words are\nsplit\rby\twhitespace", 4, "...", "...are\nsplit\rby\twhitespace")] - [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "length without truncation string")] - [InlineData("Text with whitespace at the end ", 4, "...", "...whitespace at the end")] - public void TruncateWithTruncationStringAndFixedNumberOfWordsTruncatorTruncateFromLeft(string? input, int length, string? truncationString, string? expectedOutput) => - Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfWords, TruncateFrom.Left)); - } -} + [Theory] + [InlineData(null, 10, "...", null)] + [InlineData("", 10, "...", "")] + [InlineData("a", 1, "...", "a")] + [InlineData("Text with more words than truncate length", 4, "...", "...words than truncate length")] + [InlineData("Text with different truncation string", 4, "---", "---with different truncation string")] + [InlineData("Text with number of words equal to truncate length", 9, "...", "Text with number of words equal to truncate length")] + [InlineData("Text with less words than truncate length", 8, "...", "Text with less words than truncate length")] + [InlineData("Words are\nsplit\rby\twhitespace", 4, "...", "...are\nsplit\rby\twhitespace")] + [InlineData("Null truncation string truncates to truncate length without truncation string", 4, null, "length without truncation string")] + [InlineData("Text with whitespace at the end ", 4, "...", "...whitespace at the end")] + public void TruncateWithTruncationStringAndFixedNumberOfWordsTruncatorTruncateFromLeft(string? input, int length, string? truncationString, string? expectedOutput) => + Assert.Equal(expectedOutput, input.Truncate(length, truncationString, Truncator.FixedNumberOfWords, TruncateFrom.Left)); +} \ No newline at end of file diff --git a/src/Humanizer.Tests/TupleizeTests.cs b/src/Humanizer.Tests/TupleizeTests.cs index e07bbb7de..c7ad97254 100644 --- a/src/Humanizer.Tests/TupleizeTests.cs +++ b/src/Humanizer.Tests/TupleizeTests.cs @@ -1,32 +1,31 @@ // ReSharper disable IdentifierTypo // ReSharper disable StringLiteralTypo -namespace Humanizer.Tests +namespace Humanizer.Tests; + +public class TupleizeTests { - public class TupleizeTests - { - [Theory] - [InlineData(1, "single")] - [InlineData(2, "double")] - [InlineData(3, "triple")] - [InlineData(4, "quadruple")] - [InlineData(5, "quintuple")] - [InlineData(6, "sextuple")] - [InlineData(7, "septuple")] - [InlineData(8, "octuple")] - [InlineData(9, "nonuple")] - [InlineData(10, "decuple")] - [InlineData(100, "centuple")] - [InlineData(1000, "milluple")] - public void Given_int_with_named_tuple_gives_correct_result(int n, string expected) => - Assert.Equal(expected, n.Tupleize()); + [Theory] + [InlineData(1, "single")] + [InlineData(2, "double")] + [InlineData(3, "triple")] + [InlineData(4, "quadruple")] + [InlineData(5, "quintuple")] + [InlineData(6, "sextuple")] + [InlineData(7, "septuple")] + [InlineData(8, "octuple")] + [InlineData(9, "nonuple")] + [InlineData(10, "decuple")] + [InlineData(100, "centuple")] + [InlineData(1000, "milluple")] + public void Given_int_with_named_tuple_gives_correct_result(int n, string expected) => + Assert.Equal(expected, n.Tupleize()); - [Theory] - [InlineData(0)] - [InlineData(-1)] - [InlineData(int.MinValue)] - [InlineData(int.MaxValue)] - public void Given_other_number_returns_n_tuple(int n) => - Assert.Equal($"{n}-tuple", n.Tupleize()); - } -} + [Theory] + [InlineData(0)] + [InlineData(-1)] + [InlineData(int.MinValue)] + [InlineData(int.MaxValue)] + public void Given_other_number_returns_n_tuple(int n) => + Assert.Equal($"{n}-tuple", n.Tupleize()); +} \ No newline at end of file diff --git a/src/Humanizer/ArticlePrefixSort.cs b/src/Humanizer/ArticlePrefixSort.cs index 3930ddc48..03ef2e0a2 100644 --- a/src/Humanizer/ArticlePrefixSort.cs +++ b/src/Humanizer/ArticlePrefixSort.cs @@ -1,19 +1,19 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Contains methods for removing, appending and prepending article prefixes for sorting strings ignoring the article. +/// +public static class EnglishArticle { + static Regex _regex = new("^((The)|(the)|(a)|(A)|(An)|(an))\\s\\w+", RegexOptions.Compiled); + /// - /// Contains methods for removing, appending and prepending article prefixes for sorting strings ignoring the article. + /// Removes the prefixed article and appends it to the same string. /// - public static class EnglishArticle + /// The input array of strings + /// Sorted string array + public static string[] AppendArticlePrefix(string[] items) { - static Regex _regex = new("^((The)|(the)|(a)|(A)|(An)|(an))\\s\\w+", RegexOptions.Compiled); - - /// - /// Removes the prefixed article and appends it to the same string. - /// - /// The input array of strings - /// Sorted string array - public static string[] AppendArticlePrefix(string[] items) - { if (items.Length == 0) { throw new ArgumentOutOfRangeException(nameof(items)); @@ -39,13 +39,13 @@ public static string[] AppendArticlePrefix(string[] items) return transformed; } - /// - /// Removes the previously appended article and prepends it to the same string. - /// - /// Sorted string array - /// String array - public static string[] PrependArticleSuffix(string[] appended) - { + /// + /// Removes the previously appended article and prepends it to the same string. + /// + /// Sorted string array + /// String array + public static string[] PrependArticleSuffix(string[] appended) + { var inserted = new string[appended.Length]; var the = " the".AsSpan(); var an = " an".AsSpan(); @@ -74,7 +74,6 @@ public static string[] PrependArticleSuffix(string[] appended) return inserted; } - static string ToOriginalFormat(CharSpan value, int suffixLength) => - $"{value[^suffixLength..]} {value[..^(suffixLength + 1)]}"; - } -} + static string ToOriginalFormat(CharSpan value, int suffixLength) => + $"{value[^suffixLength..]} {value[..^(suffixLength + 1)]}"; +} \ No newline at end of file diff --git a/src/Humanizer/Bytes/ByteRate.cs b/src/Humanizer/Bytes/ByteRate.cs index 62035ec00..640e85e18 100644 --- a/src/Humanizer/Bytes/ByteRate.cs +++ b/src/Humanizer/Bytes/ByteRate.cs @@ -1,44 +1,44 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Class to hold a ByteSize and a measurement interval, for the purpose of calculating the rate of transfer +/// +public class ByteRate { /// - /// Class to hold a ByteSize and a measurement interval, for the purpose of calculating the rate of transfer + /// Quantity of bytes /// - public class ByteRate - { - /// - /// Quantity of bytes - /// - public ByteSize Size { get; } + public ByteSize Size { get; } - /// - /// Interval that bytes were transferred in - /// - public TimeSpan Interval { get; } + /// + /// Interval that bytes were transferred in + /// + public TimeSpan Interval { get; } - /// - /// Create a ByteRate with given quantity of bytes across an interval - /// - public ByteRate(ByteSize size, TimeSpan interval) - { + /// + /// Create a ByteRate with given quantity of bytes across an interval + /// + public ByteRate(ByteSize size, TimeSpan interval) + { this.Size = size; this.Interval = interval; } - /// - /// Calculate rate for the quantity of bytes and interval defined by this instance - /// - /// Unit of time to calculate rate for (defaults is per second) - public string Humanize(TimeUnit timeUnit = TimeUnit.Second) => - Humanize(null, timeUnit); + /// + /// Calculate rate for the quantity of bytes and interval defined by this instance + /// + /// Unit of time to calculate rate for (defaults is per second) + public string Humanize(TimeUnit timeUnit = TimeUnit.Second) => + Humanize(null, timeUnit); - /// - /// Calculate rate for the quantity of bytes and interval defined by this instance - /// - /// Unit of time to calculate rate for (defaults is per second) - /// The string format to use for the number of bytes - /// Culture to use. If null, current thread's UI culture is used. - public string Humanize(string? format, TimeUnit timeUnit = TimeUnit.Second, CultureInfo? culture = null) - { + /// + /// Calculate rate for the quantity of bytes and interval defined by this instance + /// + /// Unit of time to calculate rate for (defaults is per second) + /// The string format to use for the number of bytes + /// Culture to use. If null, current thread's UI culture is used. + public string Humanize(string? format, TimeUnit timeUnit = TimeUnit.Second, CultureInfo? culture = null) + { var displayInterval = timeUnit switch { TimeUnit.Second => TimeSpan.FromSeconds(1), @@ -49,5 +49,4 @@ public string Humanize(string? format, TimeUnit timeUnit = TimeUnit.Second, Cult return new ByteSize(Size.Bytes / Interval.TotalSeconds * displayInterval.TotalSeconds) .Humanize(format, culture) + '/' + timeUnit.ToSymbol(culture); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Bytes/ByteSize.cs b/src/Humanizer/Bytes/ByteSize.cs index 9cb75024e..86b18e964 100644 --- a/src/Humanizer/Bytes/ByteSize.cs +++ b/src/Humanizer/Bytes/ByteSize.cs @@ -22,48 +22,47 @@ using static System.Globalization.NumberStyles; -namespace Humanizer -{ +namespace Humanizer; #pragma warning disable 1591 - public struct ByteSize(double byteSize) : - IComparable, - IEquatable, - IComparable, - IFormattable +public struct ByteSize(double byteSize) : + IComparable, + IEquatable, + IComparable, + IFormattable +{ + public static readonly ByteSize MinValue = FromBits(long.MinValue); + public static readonly ByteSize MaxValue = FromBits(long.MaxValue); + + public const long BitsInByte = 8; + public const long BytesInKilobyte = 1024; + public const long BytesInMegabyte = 1048576; + public const long BytesInGigabyte = 1073741824; + public const long BytesInTerabyte = 1099511627776; + + public const string BitSymbol = "b"; + public const string Bit = "bit"; + public const string ByteSymbol = "B"; + public const string Byte = "byte"; + public const string KilobyteSymbol = "KB"; + public const string Kilobyte = "kilobyte"; + public const string MegabyteSymbol = "MB"; + public const string Megabyte = "megabyte"; + public const string GigabyteSymbol = "GB"; + public const string Gigabyte = "gigabyte"; + public const string TerabyteSymbol = "TB"; + public const string Terabyte = "terabyte"; + + public long Bits { get; } = (long)Math.Ceiling(byteSize * BitsInByte); + public double Bytes { get; } = byteSize; + public double Kilobytes { get; } = byteSize / BytesInKilobyte; + public double Megabytes { get; } = byteSize / BytesInMegabyte; + public double Gigabytes { get; } = byteSize / BytesInGigabyte; + public double Terabytes { get; } = byteSize / BytesInTerabyte; + + public string LargestWholeNumberSymbol => GetLargestWholeNumberSymbol(); + + public string GetLargestWholeNumberSymbol(IFormatProvider? provider = null) { - public static readonly ByteSize MinValue = FromBits(long.MinValue); - public static readonly ByteSize MaxValue = FromBits(long.MaxValue); - - public const long BitsInByte = 8; - public const long BytesInKilobyte = 1024; - public const long BytesInMegabyte = 1048576; - public const long BytesInGigabyte = 1073741824; - public const long BytesInTerabyte = 1099511627776; - - public const string BitSymbol = "b"; - public const string Bit = "bit"; - public const string ByteSymbol = "B"; - public const string Byte = "byte"; - public const string KilobyteSymbol = "KB"; - public const string Kilobyte = "kilobyte"; - public const string MegabyteSymbol = "MB"; - public const string Megabyte = "megabyte"; - public const string GigabyteSymbol = "GB"; - public const string Gigabyte = "gigabyte"; - public const string TerabyteSymbol = "TB"; - public const string Terabyte = "terabyte"; - - public long Bits { get; } = (long)Math.Ceiling(byteSize * BitsInByte); - public double Bytes { get; } = byteSize; - public double Kilobytes { get; } = byteSize / BytesInKilobyte; - public double Megabytes { get; } = byteSize / BytesInMegabyte; - public double Gigabytes { get; } = byteSize / BytesInGigabyte; - public double Terabytes { get; } = byteSize / BytesInTerabyte; - - public string LargestWholeNumberSymbol => GetLargestWholeNumberSymbol(); - - public string GetLargestWholeNumberSymbol(IFormatProvider? provider = null) - { var cultureFormatter = Configurator.GetFormatter(provider as CultureInfo); // Absolute value is used to deal with negative values @@ -95,10 +94,10 @@ public string GetLargestWholeNumberSymbol(IFormatProvider? provider = null) return cultureFormatter.DataUnitHumanize(DataUnit.Bit, Bits, toSymbol: true); } - public string LargestWholeNumberFullWord => GetLargestWholeNumberFullWord(); + public string LargestWholeNumberFullWord => GetLargestWholeNumberFullWord(); - public string GetLargestWholeNumberFullWord(IFormatProvider? provider = null) - { + public string GetLargestWholeNumberFullWord(IFormatProvider? provider = null) + { var cultureFormatter = Configurator.GetFormatter(provider as CultureInfo); // Absolute value is used to deal with negative values @@ -130,10 +129,10 @@ public string GetLargestWholeNumberFullWord(IFormatProvider? provider = null) return cultureFormatter.DataUnitHumanize(DataUnit.Bit, Bits, toSymbol: false); } - public double LargestWholeNumberValue + public double LargestWholeNumberValue + { + get { - get - { // Absolute value is used to deal with negative values if (Math.Abs(Terabytes) >= 1) { @@ -162,52 +161,52 @@ public double LargestWholeNumberValue return Bits; } - } + } - // Get ceiling because bis are whole units + // Get ceiling because bis are whole units - public static ByteSize FromBits(long value) => - new(value / (double) BitsInByte); + public static ByteSize FromBits(long value) => + new(value / (double) BitsInByte); - public static ByteSize FromBytes(double value) => - new(value); + public static ByteSize FromBytes(double value) => + new(value); - public static ByteSize FromKilobytes(double value) => - new(value * BytesInKilobyte); + public static ByteSize FromKilobytes(double value) => + new(value * BytesInKilobyte); - public static ByteSize FromMegabytes(double value) => - new(value * BytesInMegabyte); + public static ByteSize FromMegabytes(double value) => + new(value * BytesInMegabyte); - public static ByteSize FromGigabytes(double value) => - new(value * BytesInGigabyte); + public static ByteSize FromGigabytes(double value) => + new(value * BytesInGigabyte); - public static ByteSize FromTerabytes(double value) => - new(value * BytesInTerabyte); + public static ByteSize FromTerabytes(double value) => + new(value * BytesInTerabyte); - /// - /// Converts the value of the current ByteSize object to a string. - /// The metric prefix symbol (bit, byte, kilo, mega, giga, tera) used is - /// the largest metric prefix such that the corresponding value is greater - /// than or equal to one. - /// - public override string ToString() => - ToString(NumberFormatInfo.CurrentInfo); + /// + /// Converts the value of the current ByteSize object to a string. + /// The metric prefix symbol (bit, byte, kilo, mega, giga, tera) used is + /// the largest metric prefix such that the corresponding value is greater + /// than or equal to one. + /// + public override string ToString() => + ToString(NumberFormatInfo.CurrentInfo); - public string ToString(IFormatProvider? provider) - { + public string ToString(IFormatProvider? provider) + { provider ??= CultureInfo.CurrentCulture; return string.Format(provider, "{0:0.##} {1}", LargestWholeNumberValue, GetLargestWholeNumberSymbol(provider)); } - public string ToString(string? format) => - ToString(format, NumberFormatInfo.CurrentInfo); + public string ToString(string? format) => + ToString(format, NumberFormatInfo.CurrentInfo); - public string ToString(string? format, IFormatProvider? provider) => - ToString(format, provider, toSymbol: true); + public string ToString(string? format, IFormatProvider? provider) => + ToString(format, provider, toSymbol: true); - string ToString(string? format, IFormatProvider? provider, bool toSymbol) - { + string ToString(string? format, IFormatProvider? provider, bool toSymbol) + { format ??= "G"; provider ??= CultureInfo.CurrentCulture; @@ -274,17 +273,17 @@ string ToString(string? format, IFormatProvider? provider, bool toSymbol) return $"{formattedLargeWholeNumberValue} {(toSymbol ? GetLargestWholeNumberSymbol(provider) : GetLargestWholeNumberFullWord(provider))}"; } - /// - /// Converts the value of the current ByteSize object to a string with - /// full words. The metric prefix symbol (bit, byte, kilo, mega, giga, - /// tera) used is the largest metric prefix such that the corresponding - /// value is greater than or equal to one. - /// - public string ToFullWords(string? format = null, IFormatProvider? provider = null) => - ToString(format, provider, toSymbol: false); + /// + /// Converts the value of the current ByteSize object to a string with + /// full words. The metric prefix symbol (bit, byte, kilo, mega, giga, + /// tera) used is the largest metric prefix such that the corresponding + /// value is greater than or equal to one. + /// + public string ToFullWords(string? format = null, IFormatProvider? provider = null) => + ToString(format, provider, toSymbol: false); - public override bool Equals(object? value) - { + public override bool Equals(object? value) + { if (value == null) { return false; @@ -303,14 +302,14 @@ public override bool Equals(object? value) return Equals(other); } - public bool Equals(ByteSize value) => - Bits == value.Bits; + public bool Equals(ByteSize value) => + Bits == value.Bits; - public override int GetHashCode() => - Bits.GetHashCode(); + public override int GetHashCode() => + Bits.GetHashCode(); - public int CompareTo(object? obj) - { + public int CompareTo(object? obj) + { if (obj == null) { return 1; @@ -324,71 +323,71 @@ public int CompareTo(object? obj) throw new ArgumentException("Object is not a ByteSize"); } - public int CompareTo(ByteSize other) => - Bits.CompareTo(other.Bits); + public int CompareTo(ByteSize other) => + Bits.CompareTo(other.Bits); - public ByteSize Add(ByteSize bs) => - new(Bytes + bs.Bytes); + public ByteSize Add(ByteSize bs) => + new(Bytes + bs.Bytes); - public ByteSize AddBits(long value) => - this + FromBits(value); + public ByteSize AddBits(long value) => + this + FromBits(value); - public ByteSize AddBytes(double value) => - this + FromBytes(value); + public ByteSize AddBytes(double value) => + this + FromBytes(value); - public ByteSize AddKilobytes(double value) => - this + FromKilobytes(value); + public ByteSize AddKilobytes(double value) => + this + FromKilobytes(value); - public ByteSize AddMegabytes(double value) => - this + FromMegabytes(value); + public ByteSize AddMegabytes(double value) => + this + FromMegabytes(value); - public ByteSize AddGigabytes(double value) => - this + FromGigabytes(value); + public ByteSize AddGigabytes(double value) => + this + FromGigabytes(value); - public ByteSize AddTerabytes(double value) => - this + FromTerabytes(value); + public ByteSize AddTerabytes(double value) => + this + FromTerabytes(value); - public ByteSize Subtract(ByteSize bs) => - new(Bytes - bs.Bytes); + public ByteSize Subtract(ByteSize bs) => + new(Bytes - bs.Bytes); - public static ByteSize operator +(ByteSize b1, ByteSize b2) => - new(b1.Bytes + b2.Bytes); + public static ByteSize operator +(ByteSize b1, ByteSize b2) => + new(b1.Bytes + b2.Bytes); - public static ByteSize operator -(ByteSize b1, ByteSize b2) => - new(b1.Bytes - b2.Bytes); + public static ByteSize operator -(ByteSize b1, ByteSize b2) => + new(b1.Bytes - b2.Bytes); - public static ByteSize operator ++(ByteSize b) => - new(b.Bytes + 1); + public static ByteSize operator ++(ByteSize b) => + new(b.Bytes + 1); - public static ByteSize operator -(ByteSize b) => - new(-b.Bytes); + public static ByteSize operator -(ByteSize b) => + new(-b.Bytes); - public static ByteSize operator --(ByteSize b) => - new(b.Bytes - 1); + public static ByteSize operator --(ByteSize b) => + new(b.Bytes - 1); - public static bool operator ==(ByteSize b1, ByteSize b2) => - b1.Bits == b2.Bits; + public static bool operator ==(ByteSize b1, ByteSize b2) => + b1.Bits == b2.Bits; - public static bool operator !=(ByteSize b1, ByteSize b2) => - b1.Bits != b2.Bits; + public static bool operator !=(ByteSize b1, ByteSize b2) => + b1.Bits != b2.Bits; - public static bool operator <(ByteSize b1, ByteSize b2) => - b1.Bits < b2.Bits; + public static bool operator <(ByteSize b1, ByteSize b2) => + b1.Bits < b2.Bits; - public static bool operator <=(ByteSize b1, ByteSize b2) => - b1.Bits <= b2.Bits; + public static bool operator <=(ByteSize b1, ByteSize b2) => + b1.Bits <= b2.Bits; - public static bool operator >(ByteSize b1, ByteSize b2) => - b1.Bits > b2.Bits; + public static bool operator >(ByteSize b1, ByteSize b2) => + b1.Bits > b2.Bits; - public static bool operator >=(ByteSize b1, ByteSize b2) => - b1.Bits >= b2.Bits; + public static bool operator >=(ByteSize b1, ByteSize b2) => + b1.Bits >= b2.Bits; - public static bool TryParse(string? s, out ByteSize result) => - TryParse(s, null, out result); + public static bool TryParse(string? s, out ByteSize result) => + TryParse(s, null, out result); - public static bool TryParse(string? s, IFormatProvider? formatProvider, out ByteSize result) - { + public static bool TryParse(string? s, IFormatProvider? formatProvider, out ByteSize result) + { // Arg checking if (string.IsNullOrWhiteSpace(s)) { @@ -486,8 +485,8 @@ public static bool TryParse(string? s, IFormatProvider? formatProvider, out Byte return true; } - static NumberFormatInfo GetNumberFormatInfo(IFormatProvider? formatProvider) - { + static NumberFormatInfo GetNumberFormatInfo(IFormatProvider? formatProvider) + { if (formatProvider is NumberFormatInfo numberFormat) return numberFormat; @@ -496,11 +495,11 @@ static NumberFormatInfo GetNumberFormatInfo(IFormatProvider? formatProvider) return culture.NumberFormat; } - public static ByteSize Parse(string s) => - Parse(s, null); + public static ByteSize Parse(string s) => + Parse(s, null); - public static ByteSize Parse(string s, IFormatProvider? formatProvider) - { + public static ByteSize Parse(string s, IFormatProvider? formatProvider) + { if (s == null) { throw new ArgumentNullException(nameof(s)); @@ -513,6 +512,5 @@ public static ByteSize Parse(string s, IFormatProvider? formatProvider) throw new FormatException("Value is not in the correct format"); } - } } #pragma warning restore 1591 diff --git a/src/Humanizer/Bytes/ByteSizeExtensions.cs b/src/Humanizer/Bytes/ByteSizeExtensions.cs index 8db587650..d9494604a 100644 --- a/src/Humanizer/Bytes/ByteSizeExtensions.cs +++ b/src/Humanizer/Bytes/ByteSizeExtensions.cs @@ -1,321 +1,320 @@ // ReSharper disable once CheckNamespace -namespace Humanizer +namespace Humanizer; + +/// +/// Provides extension methods for ByteSize +/// +public static class ByteSizeExtensions { /// - /// Provides extension methods for ByteSize - /// - public static class ByteSizeExtensions - { - /// - /// Considers input as bits - /// - public static ByteSize Bits(this byte input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bits - /// - public static ByteSize Bits(this sbyte input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bits - /// - public static ByteSize Bits(this short input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bits - /// - public static ByteSize Bits(this ushort input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bits - /// - public static ByteSize Bits(this int input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bits - /// - public static ByteSize Bits(this uint input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bits - /// - public static ByteSize Bits(this long input) => - ByteSize.FromBits(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this byte input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this sbyte input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this short input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this ushort input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this int input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this uint input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this double input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as bytes - /// - public static ByteSize Bytes(this long input) => - ByteSize.FromBytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this byte input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this sbyte input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this short input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this ushort input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this int input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this uint input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this double input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as kilobytes - /// - public static ByteSize Kilobytes(this long input) => - ByteSize.FromKilobytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this byte input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this sbyte input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this short input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this ushort input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this int input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this uint input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this double input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as megabytes - /// - public static ByteSize Megabytes(this long input) => - ByteSize.FromMegabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this byte input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this sbyte input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this short input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this ushort input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this int input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this uint input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this double input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as gigabytes - /// - public static ByteSize Gigabytes(this long input) => - ByteSize.FromGigabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this byte input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this sbyte input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this short input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this ushort input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this int input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this uint input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this double input) => - ByteSize.FromTerabytes(input); - - /// - /// Considers input as terabytes - /// - public static ByteSize Terabytes(this long input) => - ByteSize.FromTerabytes(input); - - /// - /// Turns a byte quantity into human readable form, eg 2 GB - /// - /// The string format to use - public static string Humanize(this ByteSize input, string? format = null) => - string.IsNullOrWhiteSpace(format) ? input.ToString() : input.ToString(format); - - /// - /// Turns a byte quantity into human readable form, eg 2 GB - /// - /// The format provider to use - public static string Humanize(this ByteSize input, IFormatProvider formatProvider) => - input.ToString(formatProvider); - - /// - /// Turns a byte quantity into human readable form, eg 2 GB - /// - /// The string format to use - /// The format provider to use - public static string Humanize(this ByteSize input, string? format, IFormatProvider? formatProvider) => - string.IsNullOrWhiteSpace(format) ? input.ToString(formatProvider) : input.ToString(format, formatProvider); - - /// - /// Turns a quantity of bytes in a given interval into a rate that can be manipulated - /// - /// Quantity of bytes - /// Interval to create rate for - public static ByteRate Per(this ByteSize size, TimeSpan interval) => - new(size, interval); - } -} + /// Considers input as bits + /// + public static ByteSize Bits(this byte input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bits + /// + public static ByteSize Bits(this sbyte input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bits + /// + public static ByteSize Bits(this short input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bits + /// + public static ByteSize Bits(this ushort input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bits + /// + public static ByteSize Bits(this int input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bits + /// + public static ByteSize Bits(this uint input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bits + /// + public static ByteSize Bits(this long input) => + ByteSize.FromBits(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this byte input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this sbyte input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this short input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this ushort input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this int input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this uint input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this double input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as bytes + /// + public static ByteSize Bytes(this long input) => + ByteSize.FromBytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this byte input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this sbyte input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this short input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this ushort input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this int input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this uint input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this double input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as kilobytes + /// + public static ByteSize Kilobytes(this long input) => + ByteSize.FromKilobytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this byte input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this sbyte input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this short input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this ushort input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this int input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this uint input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this double input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as megabytes + /// + public static ByteSize Megabytes(this long input) => + ByteSize.FromMegabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this byte input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this sbyte input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this short input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this ushort input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this int input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this uint input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this double input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as gigabytes + /// + public static ByteSize Gigabytes(this long input) => + ByteSize.FromGigabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this byte input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this sbyte input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this short input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this ushort input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this int input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this uint input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this double input) => + ByteSize.FromTerabytes(input); + + /// + /// Considers input as terabytes + /// + public static ByteSize Terabytes(this long input) => + ByteSize.FromTerabytes(input); + + /// + /// Turns a byte quantity into human readable form, eg 2 GB + /// + /// The string format to use + public static string Humanize(this ByteSize input, string? format = null) => + string.IsNullOrWhiteSpace(format) ? input.ToString() : input.ToString(format); + + /// + /// Turns a byte quantity into human readable form, eg 2 GB + /// + /// The format provider to use + public static string Humanize(this ByteSize input, IFormatProvider formatProvider) => + input.ToString(formatProvider); + + /// + /// Turns a byte quantity into human readable form, eg 2 GB + /// + /// The string format to use + /// The format provider to use + public static string Humanize(this ByteSize input, string? format, IFormatProvider? formatProvider) => + string.IsNullOrWhiteSpace(format) ? input.ToString(formatProvider) : input.ToString(format, formatProvider); + + /// + /// Turns a quantity of bytes in a given interval into a rate that can be manipulated + /// + /// Quantity of bytes + /// Interval to create rate for + public static ByteRate Per(this ByteSize size, TimeSpan interval) => + new(size, interval); +} \ No newline at end of file diff --git a/src/Humanizer/CasingExtensions.cs b/src/Humanizer/CasingExtensions.cs index 2cb3d220f..b875749fe 100644 --- a/src/Humanizer/CasingExtensions.cs +++ b/src/Humanizer/CasingExtensions.cs @@ -1,15 +1,15 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// ApplyCase method to allow changing the case of a sentence easily +/// +public static class CasingExtensions { /// - /// ApplyCase method to allow changing the case of a sentence easily + /// Changes the casing of the provided input /// - public static class CasingExtensions + public static string ApplyCase(this string input, LetterCasing casing) { - /// - /// Changes the casing of the provided input - /// - public static string ApplyCase(this string input, LetterCasing casing) - { switch (casing) { case LetterCasing.Title: @@ -28,5 +28,4 @@ public static string ApplyCase(this string input, LetterCasing casing) throw new ArgumentOutOfRangeException(nameof(casing)); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/ClockNotationRounding.cs b/src/Humanizer/ClockNotationRounding.cs index 9f7732a3d..83cc94a94 100644 --- a/src/Humanizer/ClockNotationRounding.cs +++ b/src/Humanizer/ClockNotationRounding.cs @@ -1,18 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Options for specifying readable clock notation +/// +public enum ClockNotationRounding { /// - /// Options for specifying readable clock notation + /// Do not round minutes /// - public enum ClockNotationRounding - { - /// - /// Do not round minutes - /// - None, + None, - /// - /// Round time to nearest five minutes - /// - NearestFiveMinutes - } -} + /// + /// Round time to nearest five minutes + /// + NearestFiveMinutes +} \ No newline at end of file diff --git a/src/Humanizer/CollectionHumanizeExtensions.cs b/src/Humanizer/CollectionHumanizeExtensions.cs index e335e7fa7..7d7c57bf9 100644 --- a/src/Humanizer/CollectionHumanizeExtensions.cs +++ b/src/Humanizer/CollectionHumanizeExtensions.cs @@ -1,23 +1,23 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Humanizes an IEnumerable into a human readable list +/// +public static class CollectionHumanizeExtensions { /// - /// Humanizes an IEnumerable into a human readable list + /// Formats the collection for display, calling ToString() on each object and + /// using the default separator for the current culture. /// - public static class CollectionHumanizeExtensions - { - /// - /// Formats the collection for display, calling ToString() on each object and - /// using the default separator for the current culture. - /// - public static string Humanize(this IEnumerable collection) => - Configurator.CollectionFormatter.Humanize(collection); + public static string Humanize(this IEnumerable collection) => + Configurator.CollectionFormatter.Humanize(collection); - /// - /// Formats the collection for display, calling on each element - /// and using the default separator for the current culture. - /// - public static string Humanize(this IEnumerable collection, Func displayFormatter) - { + /// + /// Formats the collection for display, calling on each element + /// and using the default separator for the current culture. + /// + public static string Humanize(this IEnumerable collection, Func displayFormatter) + { if (displayFormatter == null) { throw new ArgumentNullException(nameof(displayFormatter)); @@ -26,12 +26,12 @@ public static string Humanize(this IEnumerable collection, Func return Configurator.CollectionFormatter.Humanize(collection, displayFormatter); } - /// - /// Formats the collection for display, calling on each element - /// and using the default separator for the current culture. - /// - public static string Humanize(this IEnumerable collection, Func displayFormatter) - { + /// + /// Formats the collection for display, calling on each element + /// and using the default separator for the current culture. + /// + public static string Humanize(this IEnumerable collection, Func displayFormatter) + { if (displayFormatter == null) { throw new ArgumentNullException(nameof(displayFormatter)); @@ -40,19 +40,19 @@ public static string Humanize(this IEnumerable collection, Func return Configurator.CollectionFormatter.Humanize(collection, displayFormatter); } - /// - /// Formats the collection for display, calling ToString() on each object - /// and using the provided separator. - /// - public static string Humanize(this IEnumerable collection, string separator) => - Configurator.CollectionFormatter.Humanize(collection, separator); + /// + /// Formats the collection for display, calling ToString() on each object + /// and using the provided separator. + /// + public static string Humanize(this IEnumerable collection, string separator) => + Configurator.CollectionFormatter.Humanize(collection, separator); - /// - /// Formats the collection for display, calling on each element - /// and using the provided separator. - /// - public static string Humanize(this IEnumerable collection, Func displayFormatter, string separator) - { + /// + /// Formats the collection for display, calling on each element + /// and using the provided separator. + /// + public static string Humanize(this IEnumerable collection, Func displayFormatter, string separator) + { if (displayFormatter == null) { throw new ArgumentNullException(nameof(displayFormatter)); @@ -61,12 +61,12 @@ public static string Humanize(this IEnumerable collection, Func return Configurator.CollectionFormatter.Humanize(collection, displayFormatter, separator); } - /// - /// Formats the collection for display, calling on each element - /// and using the provided separator. - /// - public static string Humanize(this IEnumerable collection, Func displayFormatter, string separator) - { + /// + /// Formats the collection for display, calling on each element + /// and using the provided separator. + /// + public static string Humanize(this IEnumerable collection, Func displayFormatter, string separator) + { if (displayFormatter == null) { throw new ArgumentNullException(nameof(displayFormatter)); @@ -74,5 +74,4 @@ public static string Humanize(this IEnumerable collection, Func return Configurator.CollectionFormatter.Humanize(collection, displayFormatter, separator); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/CollectionFormatterRegistry.cs b/src/Humanizer/Configuration/CollectionFormatterRegistry.cs index 122d89abe..46af9ce46 100644 --- a/src/Humanizer/Configuration/CollectionFormatterRegistry.cs +++ b/src/Humanizer/Configuration/CollectionFormatterRegistry.cs @@ -1,10 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +class CollectionFormatterRegistry : LocaliserRegistry { - class CollectionFormatterRegistry : LocaliserRegistry + public CollectionFormatterRegistry() + : base(new DefaultCollectionFormatter("&")) { - public CollectionFormatterRegistry() - : base(new DefaultCollectionFormatter("&")) - { Register("en", new OxfordStyleCollectionFormatter()); Register("it", new DefaultCollectionFormatter("e")); Register("de", new DefaultCollectionFormatter("und")); @@ -19,5 +19,4 @@ public CollectionFormatterRegistry() Register("es", new DefaultCollectionFormatter("y")); Register("lb", new DefaultCollectionFormatter("an")); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/Configurator.cs b/src/Humanizer/Configuration/Configurator.cs index db8ef4571..2bffe6705 100644 --- a/src/Humanizer/Configuration/Configurator.cs +++ b/src/Humanizer/Configuration/Configurator.cs @@ -1,123 +1,123 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Provides a configuration point for Humanizer +/// +public static class Configurator { /// - /// Provides a configuration point for Humanizer + /// A registry of formatters used to format collections based on the current locale /// - public static class Configurator - { - /// - /// A registry of formatters used to format collections based on the current locale - /// - public static LocaliserRegistry CollectionFormatters { get; } = new CollectionFormatterRegistry(); - - /// - /// A registry of formatters used to format strings based on the current locale - /// - public static LocaliserRegistry Formatters { get; } = new FormatterRegistry(); - - /// - /// A registry of number to words converters used to localise ToWords and ToOrdinalWords methods - /// - public static LocaliserRegistry NumberToWordsConverters { get; } = new NumberToWordsConverterRegistry(); - - /// - /// A registry of ordinalizers used to localise Ordinalize method - /// - public static LocaliserRegistry Ordinalizers { get; } = new OrdinalizerRegistry(); - - /// - /// A registry of ordinalizers used to localise Ordinalize method - /// - public static LocaliserRegistry DateToOrdinalWordsConverters { get; } = new DateToOrdinalWordsConverterRegistry(); + public static LocaliserRegistry CollectionFormatters { get; } = new CollectionFormatterRegistry(); + + /// + /// A registry of formatters used to format strings based on the current locale + /// + public static LocaliserRegistry Formatters { get; } = new FormatterRegistry(); + + /// + /// A registry of number to words converters used to localise ToWords and ToOrdinalWords methods + /// + public static LocaliserRegistry NumberToWordsConverters { get; } = new NumberToWordsConverterRegistry(); + + /// + /// A registry of ordinalizers used to localise Ordinalize method + /// + public static LocaliserRegistry Ordinalizers { get; } = new OrdinalizerRegistry(); + + /// + /// A registry of ordinalizers used to localise Ordinalize method + /// + public static LocaliserRegistry DateToOrdinalWordsConverters { get; } = new DateToOrdinalWordsConverterRegistry(); #if NET6_0_OR_GREATER - /// - /// A registry of ordinalizers used to localise Ordinalize method - /// - public static LocaliserRegistry DateOnlyToOrdinalWordsConverters { get; } = new DateOnlyToOrdinalWordsConverterRegistry(); - - /// - /// A registry of time to clock notation converters used to localise ToClockNotation methods - /// - public static LocaliserRegistry TimeOnlyToClockNotationConverters { get; } = new TimeOnlyToClockNotationConvertersRegistry(); + /// + /// A registry of ordinalizers used to localise Ordinalize method + /// + public static LocaliserRegistry DateOnlyToOrdinalWordsConverters { get; } = new DateOnlyToOrdinalWordsConverterRegistry(); + + /// + /// A registry of time to clock notation converters used to localise ToClockNotation methods + /// + public static LocaliserRegistry TimeOnlyToClockNotationConverters { get; } = new TimeOnlyToClockNotationConvertersRegistry(); #endif - internal static ICollectionFormatter CollectionFormatter => CollectionFormatters.ResolveForUiCulture(); + internal static ICollectionFormatter CollectionFormatter => CollectionFormatters.ResolveForUiCulture(); - /// - /// The formatter to be used - /// - /// The culture to retrieve formatter for. Null means that current thread's UI culture should be used. - internal static IFormatter GetFormatter(CultureInfo? culture) => - Formatters.ResolveForCulture(culture); + /// + /// The formatter to be used + /// + /// The culture to retrieve formatter for. Null means that current thread's UI culture should be used. + internal static IFormatter GetFormatter(CultureInfo? culture) => + Formatters.ResolveForCulture(culture); - /// - /// The converter to be used - /// - /// The culture to retrieve number to words converter for. Null means that current thread's UI culture should be used. - internal static INumberToWordsConverter GetNumberToWordsConverter(CultureInfo? culture) => - NumberToWordsConverters.ResolveForCulture(culture); + /// + /// The converter to be used + /// + /// The culture to retrieve number to words converter for. Null means that current thread's UI culture should be used. + internal static INumberToWordsConverter GetNumberToWordsConverter(CultureInfo? culture) => + NumberToWordsConverters.ResolveForCulture(culture); - /// - /// The ordinalizer to be used - /// - internal static IOrdinalizer Ordinalizer => Ordinalizers.ResolveForUiCulture(); + /// + /// The ordinalizer to be used + /// + internal static IOrdinalizer Ordinalizer => Ordinalizers.ResolveForUiCulture(); - /// - /// The ordinalizer to be used - /// - internal static IDateToOrdinalWordConverter DateToOrdinalWordsConverter => DateToOrdinalWordsConverters.ResolveForUiCulture(); + /// + /// The ordinalizer to be used + /// + internal static IDateToOrdinalWordConverter DateToOrdinalWordsConverter => DateToOrdinalWordsConverters.ResolveForUiCulture(); #if NET6_0_OR_GREATER - /// - /// The ordinalizer to be used - /// - internal static IDateOnlyToOrdinalWordConverter DateOnlyToOrdinalWordsConverter => DateOnlyToOrdinalWordsConverters.ResolveForUiCulture(); + /// + /// The ordinalizer to be used + /// + internal static IDateOnlyToOrdinalWordConverter DateOnlyToOrdinalWordsConverter => DateOnlyToOrdinalWordsConverters.ResolveForUiCulture(); - internal static ITimeOnlyToClockNotationConverter TimeOnlyToClockNotationConverter => TimeOnlyToClockNotationConverters.ResolveForUiCulture(); + internal static ITimeOnlyToClockNotationConverter TimeOnlyToClockNotationConverter => TimeOnlyToClockNotationConverters.ResolveForUiCulture(); #endif - /// - /// The strategy to be used for DateTime.Humanize - /// - public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } = new DefaultDateTimeHumanizeStrategy(); + /// + /// The strategy to be used for DateTime.Humanize + /// + public static IDateTimeHumanizeStrategy DateTimeHumanizeStrategy { get; set; } = new DefaultDateTimeHumanizeStrategy(); - /// - /// The strategy to be used for DateTimeOffset.Humanize - /// - public static IDateTimeOffsetHumanizeStrategy DateTimeOffsetHumanizeStrategy { get; set; } = new DefaultDateTimeOffsetHumanizeStrategy(); + /// + /// The strategy to be used for DateTimeOffset.Humanize + /// + public static IDateTimeOffsetHumanizeStrategy DateTimeOffsetHumanizeStrategy { get; set; } = new DefaultDateTimeOffsetHumanizeStrategy(); #if NET6_0_OR_GREATER - /// - /// The strategy to be used for DateOnly.Humanize - /// - public static IDateOnlyHumanizeStrategy DateOnlyHumanizeStrategy { get; set; } = new DefaultDateOnlyHumanizeStrategy(); - - /// - /// The strategy to be used for TimeOnly.Humanize - /// - public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy { get; set; } = new DefaultTimeOnlyHumanizeStrategy(); + /// + /// The strategy to be used for DateOnly.Humanize + /// + public static IDateOnlyHumanizeStrategy DateOnlyHumanizeStrategy { get; set; } = new DefaultDateOnlyHumanizeStrategy(); + + /// + /// The strategy to be used for TimeOnly.Humanize + /// + public static ITimeOnlyHumanizeStrategy TimeOnlyHumanizeStrategy { get; set; } = new DefaultTimeOnlyHumanizeStrategy(); #endif - static readonly Func DefaultEnumDescriptionPropertyLocator = p => p.Name == "Description"; - static Func enumDescriptionPropertyLocator = DefaultEnumDescriptionPropertyLocator; - static bool enumDescriptionPropertyLocatorHasBeenUsed; + static readonly Func DefaultEnumDescriptionPropertyLocator = p => p.Name == "Description"; + static Func enumDescriptionPropertyLocator = DefaultEnumDescriptionPropertyLocator; + static bool enumDescriptionPropertyLocatorHasBeenUsed; - internal static Func EnumDescriptionPropertyLocator + internal static Func EnumDescriptionPropertyLocator + { + get { - get - { enumDescriptionPropertyLocatorHasBeenUsed = true; return enumDescriptionPropertyLocator; } - private set => enumDescriptionPropertyLocator = value; - } + private set => enumDescriptionPropertyLocator = value; + } - /// - /// Use a predicate function for description property of attribute to use for Enum.Humanize - /// - public static void UseEnumDescriptionPropertyLocator(Func func) - { + /// + /// Use a predicate function for description property of attribute to use for Enum.Humanize + /// + public static void UseEnumDescriptionPropertyLocator(Func func) + { if (enumDescriptionPropertyLocatorHasBeenUsed) { throw new("UseEnumDescriptionPropertyLocator must be called before any Enum.Humanize has already been. Move the call to UseEnumDescriptionPropertyLocator to the app startup or a ModuleInitializer."); @@ -126,10 +126,9 @@ public static void UseEnumDescriptionPropertyLocator(Func fu EnumDescriptionPropertyLocator = func; } - internal static void ResetUseEnumDescriptionPropertyLocator() - { + internal static void ResetUseEnumDescriptionPropertyLocator() + { enumDescriptionPropertyLocatorHasBeenUsed = false; EnumDescriptionPropertyLocator = DefaultEnumDescriptionPropertyLocator; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs b/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs index 6d21dfd29..6d03ce4f0 100644 --- a/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs +++ b/src/Humanizer/Configuration/DateToOrdinalWordsConverterRegistry.cs @@ -1,13 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class DateToOrdinalWordsConverterRegistry : LocaliserRegistry { - class DateToOrdinalWordsConverterRegistry : LocaliserRegistry + public DateToOrdinalWordsConverterRegistry() : base(new DefaultDateToOrdinalWordConverter()) { - public DateToOrdinalWordsConverterRegistry() : base(new DefaultDateToOrdinalWordConverter()) - { Register("en-US", new UsDateToOrdinalWordsConverter()); Register("fr", new FrDateToOrdinalWordsConverter()); Register("es", new EsDateToOrdinalWordsConverter()); Register("lt", new LtDateToOrdinalWordsConverter()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/FormatterRegistry.cs b/src/Humanizer/Configuration/FormatterRegistry.cs index b7c1e66ca..ecf503094 100644 --- a/src/Humanizer/Configuration/FormatterRegistry.cs +++ b/src/Humanizer/Configuration/FormatterRegistry.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class FormatterRegistry : LocaliserRegistry { - class FormatterRegistry : LocaliserRegistry + public FormatterRegistry() : base(new DefaultFormatter("en-US")) { - public FormatterRegistry() : base(new DefaultFormatter("en-US")) - { Register("ar", new ArabicFormatter()); Register("de", new GermanFormatter()); Register("he", new HebrewFormatter()); @@ -60,8 +60,8 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US")) Register("lb", new LuxembourgishFormatter()); } - void RegisterDefaultFormatter(string localeCode) - { + void RegisterDefaultFormatter(string localeCode) + { try { Register(localeCode, new DefaultFormatter(localeCode)); @@ -72,7 +72,6 @@ void RegisterDefaultFormatter(string localeCode) } } - void RegisterCzechSlovakPolishFormatter(string localeCode) => - Register(localeCode, new CzechSlovakPolishFormatter(localeCode)); - } -} + void RegisterCzechSlovakPolishFormatter(string localeCode) => + Register(localeCode, new CzechSlovakPolishFormatter(localeCode)); +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/LocaliserRegistry.cs b/src/Humanizer/Configuration/LocaliserRegistry.cs index 6efc8141d..f6e098456 100644 --- a/src/Humanizer/Configuration/LocaliserRegistry.cs +++ b/src/Humanizer/Configuration/LocaliserRegistry.cs @@ -1,53 +1,53 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// A registry of localised system components with their associated locales +/// +public class LocaliserRegistry + where TLocaliser : class { + readonly Dictionary> _localisers = new(); + readonly Func _defaultLocaliser; + + /// + /// Creates a localiser registry with the default localiser set to the provided value + /// + public LocaliserRegistry(TLocaliser defaultLocaliser) => + _defaultLocaliser = _ => defaultLocaliser; + + /// + /// Creates a localiser registry with the default localiser factory set to the provided value + /// + public LocaliserRegistry(Func defaultLocaliser) => + _defaultLocaliser = defaultLocaliser; + + /// + /// Gets the localiser for the current thread's UI culture + /// + public TLocaliser ResolveForUiCulture() => + ResolveForCulture(null); + + /// + /// Gets the localiser for the specified culture + /// + /// The culture to retrieve localiser for. If not specified, current thread's UI culture is used. + public TLocaliser ResolveForCulture(CultureInfo? culture) => + FindLocaliser(culture ?? CultureInfo.CurrentUICulture)(culture); + /// - /// A registry of localised system components with their associated locales + /// Registers the localiser for the culture provided /// - public class LocaliserRegistry - where TLocaliser : class + public void Register(string localeCode, TLocaliser localiser) => + _localisers[localeCode] = _ => localiser; + + /// + /// Registers the localiser factory for the culture provided + /// + public void Register(string localeCode, Func localiser) => + _localisers[localeCode] = localiser; + + Func FindLocaliser(CultureInfo culture) { - readonly Dictionary> _localisers = new(); - readonly Func _defaultLocaliser; - - /// - /// Creates a localiser registry with the default localiser set to the provided value - /// - public LocaliserRegistry(TLocaliser defaultLocaliser) => - _defaultLocaliser = _ => defaultLocaliser; - - /// - /// Creates a localiser registry with the default localiser factory set to the provided value - /// - public LocaliserRegistry(Func defaultLocaliser) => - _defaultLocaliser = defaultLocaliser; - - /// - /// Gets the localiser for the current thread's UI culture - /// - public TLocaliser ResolveForUiCulture() => - ResolveForCulture(null); - - /// - /// Gets the localiser for the specified culture - /// - /// The culture to retrieve localiser for. If not specified, current thread's UI culture is used. - public TLocaliser ResolveForCulture(CultureInfo? culture) => - FindLocaliser(culture ?? CultureInfo.CurrentUICulture)(culture); - - /// - /// Registers the localiser for the culture provided - /// - public void Register(string localeCode, TLocaliser localiser) => - _localisers[localeCode] = _ => localiser; - - /// - /// Registers the localiser factory for the culture provided - /// - public void Register(string localeCode, Func localiser) => - _localisers[localeCode] = localiser; - - Func FindLocaliser(CultureInfo culture) - { for (var c = culture; !string.IsNullOrEmpty(c?.Name); c = c.Parent) { if (_localisers.TryGetValue(c!.Name, out var localiser)) @@ -58,5 +58,4 @@ public void Register(string localeCode, Func localiser return _defaultLocaliser; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs b/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs index aaff72647..e24954d00 100644 --- a/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs +++ b/src/Humanizer/Configuration/NumberToWordsConverterRegistry.cs @@ -1,10 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +class NumberToWordsConverterRegistry : LocaliserRegistry { - class NumberToWordsConverterRegistry : LocaliserRegistry + public NumberToWordsConverterRegistry() + : base(_ => new EnglishNumberToWordsConverter()) { - public NumberToWordsConverterRegistry() - : base(_ => new EnglishNumberToWordsConverter()) - { Register("af", new AfrikaansNumberToWordsConverter()); Register("en", new EnglishNumberToWordsConverter()); Register("ar", new ArabicNumberToWordsConverter()); @@ -55,5 +55,4 @@ public NumberToWordsConverterRegistry() Register("lt", new LithuanianNumberToWordsConverter()); Register("lb", new LuxembourgishNumberToWordsConverter()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Configuration/OrdinalizerRegistry.cs b/src/Humanizer/Configuration/OrdinalizerRegistry.cs index 7cc8a6084..0c21c6eb6 100644 --- a/src/Humanizer/Configuration/OrdinalizerRegistry.cs +++ b/src/Humanizer/Configuration/OrdinalizerRegistry.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class OrdinalizerRegistry : LocaliserRegistry { - class OrdinalizerRegistry : LocaliserRegistry + public OrdinalizerRegistry() : base(new DefaultOrdinalizer()) { - public OrdinalizerRegistry() : base(new DefaultOrdinalizer()) - { Register("de", new GermanOrdinalizer()); Register("en", new EnglishOrdinalizer()); Register("es", new SpanishOrdinalizer()); @@ -20,5 +20,4 @@ public OrdinalizerRegistry() : base(new DefaultOrdinalizer()) Register("az", new AzerbaijaniOrdinalizer()); Register("lb", new LuxembourgishOrdinalizer()); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/DateHumanizeExtensions.cs b/src/Humanizer/DateHumanizeExtensions.cs index 89708f195..a8d640dbe 100644 --- a/src/Humanizer/DateHumanizeExtensions.cs +++ b/src/Humanizer/DateHumanizeExtensions.cs @@ -1,20 +1,20 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Humanizes DateTime into human readable sentence +/// +public static class DateHumanizeExtensions { /// - /// Humanizes DateTime into human readable sentence + /// Turns the current or provided date into a human readable sentence /// - public static class DateHumanizeExtensions + /// The date to be humanized + /// Nullable boolean value indicating whether the date is in UTC or local. If null, current date is used with the same DateTimeKind of input + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this DateTime input, bool? utcDate = null, DateTime? dateToCompareAgainst = null, CultureInfo? culture = null) { - /// - /// Turns the current or provided date into a human readable sentence - /// - /// The date to be humanized - /// Nullable boolean value indicating whether the date is in UTC or local. If null, current date is used with the same DateTimeKind of input - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this DateTime input, bool? utcDate = null, DateTime? dateToCompareAgainst = null, CultureInfo? culture = null) - { var comparisonBase = dateToCompareAgainst ?? DateTime.UtcNow; utcDate ??= input.Kind != DateTimeKind.Local; comparisonBase = utcDate.Value ? comparisonBase.ToUniversalTime() : comparisonBase.ToLocalTime(); @@ -22,16 +22,16 @@ public static string Humanize(this DateTime input, bool? utcDate = null, DateTim return Configurator.DateTimeHumanizeStrategy.Humanize(input, comparisonBase, culture); } - /// - /// Turns the current or provided date into a human readable sentence, overload for the nullable DateTime, returning 'never' in case null - /// - /// The date to be humanized - /// Nullable boolean value indicating whether the date is in UTC or local. If null, current date is used with the same DateTimeKind of input - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this DateTime? input, bool? utcDate = null, DateTime? dateToCompareAgainst = null, CultureInfo? culture = null) - { + /// + /// Turns the current or provided date into a human readable sentence, overload for the nullable DateTime, returning 'never' in case null + /// + /// The date to be humanized + /// Nullable boolean value indicating whether the date is in UTC or local. If null, current date is used with the same DateTimeKind of input + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this DateTime? input, bool? utcDate = null, DateTime? dateToCompareAgainst = null, CultureInfo? culture = null) + { if (input.HasValue) { return Humanize(input.Value, utcDate, dateToCompareAgainst, culture); @@ -40,29 +40,29 @@ public static string Humanize(this DateTime? input, bool? utcDate = null, DateTi return Configurator.GetFormatter(culture).DateHumanize_Never(); } - /// - /// Turns the current or provided date into a human readable sentence - /// - /// The date to be humanized - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this DateTimeOffset input, DateTimeOffset? dateToCompareAgainst = null, CultureInfo? culture = null) - { + /// + /// Turns the current or provided date into a human readable sentence + /// + /// The date to be humanized + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this DateTimeOffset input, DateTimeOffset? dateToCompareAgainst = null, CultureInfo? culture = null) + { var comparisonBase = dateToCompareAgainst ?? DateTimeOffset.UtcNow; return Configurator.DateTimeOffsetHumanizeStrategy.Humanize(input, comparisonBase, culture); } - /// - /// Turns the current or provided date into a human readable sentence, overload for the nullable DateTimeOffset, returning 'never' in case null - /// - /// The date to be humanized - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this DateTimeOffset? input, DateTimeOffset? dateToCompareAgainst = null, CultureInfo? culture = null) - { + /// + /// Turns the current or provided date into a human readable sentence, overload for the nullable DateTimeOffset, returning 'never' in case null + /// + /// The date to be humanized + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this DateTimeOffset? input, DateTimeOffset? dateToCompareAgainst = null, CultureInfo? culture = null) + { if (input.HasValue) { return Humanize(input.Value, dateToCompareAgainst, culture); @@ -72,28 +72,28 @@ public static string Humanize(this DateTimeOffset? input, DateTimeOffset? dateTo } #if NET6_0_OR_GREATER - /// - /// Turns the current or provided date into a human readable sentence - /// - /// The date to be humanized - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this DateOnly input, DateOnly? dateToCompareAgainst = null, CultureInfo? culture = null) - { + /// + /// Turns the current or provided date into a human readable sentence + /// + /// The date to be humanized + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this DateOnly input, DateOnly? dateToCompareAgainst = null, CultureInfo? culture = null) + { var comparisonBase = dateToCompareAgainst ?? DateOnly.FromDateTime(DateTime.UtcNow); return Configurator.DateOnlyHumanizeStrategy.Humanize(input, comparisonBase, culture); } - /// - /// Turns the current or provided date into a human readable sentence, overload for the nullable DateTime, returning 'never' in case null - /// - /// The date to be humanized - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this DateOnly? input, DateOnly? dateToCompareAgainst = null, CultureInfo? culture = null) - { + /// + /// Turns the current or provided date into a human readable sentence, overload for the nullable DateTime, returning 'never' in case null + /// + /// The date to be humanized + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this DateOnly? input, DateOnly? dateToCompareAgainst = null, CultureInfo? culture = null) + { if (input.HasValue) { return Humanize(input.Value, dateToCompareAgainst, culture); @@ -102,31 +102,31 @@ public static string Humanize(this DateOnly? input, DateOnly? dateToCompareAgain return Configurator.GetFormatter(culture).DateHumanize_Never(); } - /// - /// Turns the current or provided time into a human readable sentence - /// - /// The date to be humanized - /// If is null, used to determine if the current time is UTC or local. Defaults to UTC. - /// Date to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this TimeOnly input, TimeOnly? timeToCompareAgainst = null, bool useUtc = true, CultureInfo? culture = null) - { + /// + /// Turns the current or provided time into a human readable sentence + /// + /// The date to be humanized + /// If is null, used to determine if the current time is UTC or local. Defaults to UTC. + /// Date to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this TimeOnly input, TimeOnly? timeToCompareAgainst = null, bool useUtc = true, CultureInfo? culture = null) + { var comparisonBase = timeToCompareAgainst ?? TimeOnly.FromDateTime(useUtc ? DateTime.UtcNow : DateTime.Now); return Configurator.TimeOnlyHumanizeStrategy.Humanize(input, comparisonBase, culture); } - /// - /// Turns the current or provided time into a human readable sentence, overload for the nullable TimeOnly, returning 'never' in case null - /// - /// The date to be humanized - /// If is null, used to determine if the current time is UTC or local. Defaults to UTC. - /// Time to compare the input against. If null, current date is used as base - /// Culture to use. If null, current thread's UI culture is used. - /// distance of time in words - public static string Humanize(this TimeOnly? input, TimeOnly? timeToCompareAgainst = null, bool useUtc = true, CultureInfo? culture = null) - { + /// + /// Turns the current or provided time into a human readable sentence, overload for the nullable TimeOnly, returning 'never' in case null + /// + /// The date to be humanized + /// If is null, used to determine if the current time is UTC or local. Defaults to UTC. + /// Time to compare the input against. If null, current date is used as base + /// Culture to use. If null, current thread's UI culture is used. + /// distance of time in words + public static string Humanize(this TimeOnly? input, TimeOnly? timeToCompareAgainst = null, bool useUtc = true, CultureInfo? culture = null) + { if (input.HasValue) { return Humanize(input.Value, timeToCompareAgainst, useUtc, culture); @@ -136,5 +136,4 @@ public static string Humanize(this TimeOnly? input, TimeOnly? timeToCompareAgain } #endif - } -} +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs b/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs index b61eedf33..63d16cec6 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs @@ -1,244 +1,243 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Algorithms used to convert distance between two dates into words. +/// +static class DateTimeHumanizeAlgorithms { /// - /// Algorithms used to convert distance between two dates into words. + /// Returns localized & humanized distance of time between two dates; given a specific precision. /// - static class DateTimeHumanizeAlgorithms + public static string PrecisionHumanize(DateTime input, DateTime comparisonBase, double precision, CultureInfo? culture) { - /// - /// Returns localized & humanized distance of time between two dates; given a specific precision. - /// - public static string PrecisionHumanize(DateTime input, DateTime comparisonBase, double precision, CultureInfo? culture) - { - var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); - var tense = input > comparisonBase ? Tense.Future : Tense.Past; + var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); + var tense = input > comparisonBase ? Tense.Future : Tense.Past; - return PrecisionHumanize(ts, tense, precision, culture); - } + return PrecisionHumanize(ts, tense, precision, culture); + } #if NET6_0_OR_GREATER - /// - /// Returns localized & humanized distance of time between two dates; given a specific precision. - /// - public static string PrecisionHumanize(DateOnly input, DateOnly comparisonBase, double precision, CultureInfo? culture) - { - var diffDays = Math.Abs(comparisonBase.DayOfYear - input.DayOfYear); - var ts = new TimeSpan(diffDays, 0, 0, 0); - var tense = input > comparisonBase ? Tense.Future : Tense.Past; + /// + /// Returns localized & humanized distance of time between two dates; given a specific precision. + /// + public static string PrecisionHumanize(DateOnly input, DateOnly comparisonBase, double precision, CultureInfo? culture) + { + var diffDays = Math.Abs(comparisonBase.DayOfYear - input.DayOfYear); + var ts = new TimeSpan(diffDays, 0, 0, 0); + var tense = input > comparisonBase ? Tense.Future : Tense.Past; + + return PrecisionHumanize(ts, tense, precision, culture); + } + + /// + /// Returns localized & humanized distance of time between two times; given a specific precision. + /// + public static string PrecisionHumanize(TimeOnly input, TimeOnly comparisonBase, double precision, CultureInfo? culture) + { + var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); + var tense = input > comparisonBase ? Tense.Future : Tense.Past; + + return PrecisionHumanize(ts, tense, precision, culture); + } +#endif + static string PrecisionHumanize(TimeSpan ts, Tense tense, double precision, CultureInfo? culture) + { + int seconds = ts.Seconds, minutes = ts.Minutes, hours = ts.Hours, days = ts.Days; + int years = 0, months = 0; - return PrecisionHumanize(ts, tense, precision, culture); + // start approximate from smaller units towards bigger ones + if (ts.Milliseconds >= 999 * precision) + { + seconds += 1; } - /// - /// Returns localized & humanized distance of time between two times; given a specific precision. - /// - public static string PrecisionHumanize(TimeOnly input, TimeOnly comparisonBase, double precision, CultureInfo? culture) + if (seconds >= 59 * precision) { - var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); - var tense = input > comparisonBase ? Tense.Future : Tense.Past; + minutes += 1; + } - return PrecisionHumanize(ts, tense, precision, culture); + if (minutes >= 59 * precision) + { + hours += 1; } -#endif - static string PrecisionHumanize(TimeSpan ts, Tense tense, double precision, CultureInfo? culture) + + if (hours >= 23 * precision) { - int seconds = ts.Seconds, minutes = ts.Minutes, hours = ts.Hours, days = ts.Days; - int years = 0, months = 0; + days += 1; + } - // start approximate from smaller units towards bigger ones - if (ts.Milliseconds >= 999 * precision) - { - seconds += 1; - } + // month calculation + if (days >= 30 * precision & days <= 31) + { + months = 1; + } - if (seconds >= 59 * precision) - { - minutes += 1; - } + if (days > 31 && days < 365 * precision) + { + var factor = Convert.ToInt32(Math.Floor((double)days / 30)); + var maxMonths = Convert.ToInt32(Math.Ceiling((double)days / 30)); + months = days >= 30 * (factor + precision) ? maxMonths : maxMonths - 1; + } - if (minutes >= 59 * precision) - { - hours += 1; - } + // year calculation + if (days >= 365 * precision && days <= 366) + { + years = 1; + } - if (hours >= 23 * precision) - { - days += 1; - } + if (days > 365) + { + var factor = Convert.ToInt32(Math.Floor((double)days / 365)); + var maxMonths = Convert.ToInt32(Math.Ceiling((double)days / 365)); + years = days >= 365 * (factor + precision) ? maxMonths : maxMonths - 1; + } - // month calculation - if (days >= 30 * precision & days <= 31) - { - months = 1; - } + // start computing result from larger units to smaller ones + var formatter = Configurator.GetFormatter(culture); + if (years > 0) + { + return formatter.DateHumanize(TimeUnit.Year, tense, years); + } - if (days > 31 && days < 365 * precision) - { - var factor = Convert.ToInt32(Math.Floor((double)days / 30)); - var maxMonths = Convert.ToInt32(Math.Ceiling((double)days / 30)); - months = days >= 30 * (factor + precision) ? maxMonths : maxMonths - 1; - } + if (months > 0) + { + return formatter.DateHumanize(TimeUnit.Month, tense, months); + } - // year calculation - if (days >= 365 * precision && days <= 366) - { - years = 1; - } + if (days > 0) + { + return formatter.DateHumanize(TimeUnit.Day, tense, days); + } - if (days > 365) - { - var factor = Convert.ToInt32(Math.Floor((double)days / 365)); - var maxMonths = Convert.ToInt32(Math.Ceiling((double)days / 365)); - years = days >= 365 * (factor + precision) ? maxMonths : maxMonths - 1; - } + if (hours > 0) + { + return formatter.DateHumanize(TimeUnit.Hour, tense, hours); + } - // start computing result from larger units to smaller ones - var formatter = Configurator.GetFormatter(culture); - if (years > 0) - { - return formatter.DateHumanize(TimeUnit.Year, tense, years); - } + if (minutes > 0) + { + return formatter.DateHumanize(TimeUnit.Minute, tense, minutes); + } - if (months > 0) - { - return formatter.DateHumanize(TimeUnit.Month, tense, months); - } + if (seconds > 0) + { + return formatter.DateHumanize(TimeUnit.Second, tense, seconds); + } - if (days > 0) - { - return formatter.DateHumanize(TimeUnit.Day, tense, days); - } + return formatter.DateHumanize(TimeUnit.Millisecond, tense, 0); + } - if (hours > 0) - { - return formatter.DateHumanize(TimeUnit.Hour, tense, hours); - } + // http://stackoverflow.com/questions/11/how-do-i-calculate-relative-time + /// + /// Calculates the distance of time in words between two provided dates + /// + public static string DefaultHumanize(DateTime input, DateTime comparisonBase, CultureInfo? culture) + { + var tense = input > comparisonBase ? Tense.Future : Tense.Past; + var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); - if (minutes > 0) - { - return formatter.DateHumanize(TimeUnit.Minute, tense, minutes); - } + var sameMonth = comparisonBase.Date.AddMonths(tense == Tense.Future ? 1 : -1) == input.Date; - if (seconds > 0) - { - return formatter.DateHumanize(TimeUnit.Second, tense, seconds); - } + var days = Math.Abs((input.Date - comparisonBase.Date).Days); - return formatter.DateHumanize(TimeUnit.Millisecond, tense, 0); - } + return DefaultHumanize(ts, sameMonth, days, tense, culture); + } - // http://stackoverflow.com/questions/11/how-do-i-calculate-relative-time - /// - /// Calculates the distance of time in words between two provided dates - /// - public static string DefaultHumanize(DateTime input, DateTime comparisonBase, CultureInfo? culture) - { - var tense = input > comparisonBase ? Tense.Future : Tense.Past; - var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); +#if NET6_0_OR_GREATER + /// + /// Calculates the distance of time in words between two provided dates + /// + public static string DefaultHumanize(DateOnly input, DateOnly comparisonBase, CultureInfo? culture) + { + var tense = input > comparisonBase ? Tense.Future : Tense.Past; + var diffDays = Math.Abs(comparisonBase.DayNumber - input.DayNumber); + var ts = new TimeSpan(diffDays, 0, 0, 0); - var sameMonth = comparisonBase.Date.AddMonths(tense == Tense.Future ? 1 : -1) == input.Date; + var sameMonth = comparisonBase.AddMonths(tense == Tense.Future ? 1 : -1) == input; - var days = Math.Abs((input.Date - comparisonBase.Date).Days); + var days = Math.Abs(input.DayNumber - comparisonBase.DayNumber); - return DefaultHumanize(ts, sameMonth, days, tense, culture); - } + return DefaultHumanize(ts, sameMonth, days, tense, culture); + } -#if NET6_0_OR_GREATER - /// - /// Calculates the distance of time in words between two provided dates - /// - public static string DefaultHumanize(DateOnly input, DateOnly comparisonBase, CultureInfo? culture) - { - var tense = input > comparisonBase ? Tense.Future : Tense.Past; - var diffDays = Math.Abs(comparisonBase.DayNumber - input.DayNumber); - var ts = new TimeSpan(diffDays, 0, 0, 0); + /// + /// Calculates the distance of time in words between two provided times + /// + public static string DefaultHumanize(TimeOnly input, TimeOnly comparisonBase, CultureInfo? culture) + { + var tense = input > comparisonBase ? Tense.Future : Tense.Past; + var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); - var sameMonth = comparisonBase.AddMonths(tense == Tense.Future ? 1 : -1) == input; + return DefaultHumanize(ts, true, 0, tense, culture); + } +#endif - var days = Math.Abs(input.DayNumber - comparisonBase.DayNumber); + static string DefaultHumanize(TimeSpan ts, bool sameMonth, int days, Tense tense, CultureInfo? culture) + { + var formatter = Configurator.GetFormatter(culture); - return DefaultHumanize(ts, sameMonth, days, tense, culture); + if (ts.TotalMilliseconds < 500) + { + return formatter.DateHumanize(TimeUnit.Millisecond, tense, 0); } - /// - /// Calculates the distance of time in words between two provided times - /// - public static string DefaultHumanize(TimeOnly input, TimeOnly comparisonBase, CultureInfo? culture) + if (ts.TotalSeconds < 60) { - var tense = input > comparisonBase ? Tense.Future : Tense.Past; - var ts = new TimeSpan(Math.Abs(comparisonBase.Ticks - input.Ticks)); - - return DefaultHumanize(ts, true, 0, tense, culture); + return formatter.DateHumanize(TimeUnit.Second, tense, ts.Seconds); } -#endif - static string DefaultHumanize(TimeSpan ts, bool sameMonth, int days, Tense tense, CultureInfo? culture) + if (ts.TotalSeconds < 120) { - var formatter = Configurator.GetFormatter(culture); - - if (ts.TotalMilliseconds < 500) - { - return formatter.DateHumanize(TimeUnit.Millisecond, tense, 0); - } - - if (ts.TotalSeconds < 60) - { - return formatter.DateHumanize(TimeUnit.Second, tense, ts.Seconds); - } - - if (ts.TotalSeconds < 120) - { - return formatter.DateHumanize(TimeUnit.Minute, tense, 1); - } + return formatter.DateHumanize(TimeUnit.Minute, tense, 1); + } - if (ts.TotalMinutes < 60) - { - return formatter.DateHumanize(TimeUnit.Minute, tense, ts.Minutes); - } + if (ts.TotalMinutes < 60) + { + return formatter.DateHumanize(TimeUnit.Minute, tense, ts.Minutes); + } - if (ts.TotalMinutes < 90) - { - return formatter.DateHumanize(TimeUnit.Hour, tense, 1); - } + if (ts.TotalMinutes < 90) + { + return formatter.DateHumanize(TimeUnit.Hour, tense, 1); + } - if (ts.TotalHours < 24) - { - return formatter.DateHumanize(TimeUnit.Hour, tense, ts.Hours); - } + if (ts.TotalHours < 24) + { + return formatter.DateHumanize(TimeUnit.Hour, tense, ts.Hours); + } - if (ts.TotalHours < 48) - { - return formatter.DateHumanize(TimeUnit.Day, tense, days); - } + if (ts.TotalHours < 48) + { + return formatter.DateHumanize(TimeUnit.Day, tense, days); + } - if (ts.TotalDays < 28) - { - return formatter.DateHumanize(TimeUnit.Day, tense, ts.Days); - } + if (ts.TotalDays < 28) + { + return formatter.DateHumanize(TimeUnit.Day, tense, ts.Days); + } - if (ts.TotalDays is >= 28 and < 30) + if (ts.TotalDays is >= 28 and < 30) + { + if (sameMonth) { - if (sameMonth) - { - return formatter.DateHumanize(TimeUnit.Month, tense, 1); - } - - return formatter.DateHumanize(TimeUnit.Day, tense, ts.Days); + return formatter.DateHumanize(TimeUnit.Month, tense, 1); } - if (ts.TotalDays < 345) - { - var months = Convert.ToInt32(Math.Floor(ts.TotalDays / 29.5)); - return formatter.DateHumanize(TimeUnit.Month, tense, months); - } + return formatter.DateHumanize(TimeUnit.Day, tense, ts.Days); + } - var years = Convert.ToInt32(Math.Floor(ts.TotalDays / 365)); - if (years == 0) - { - years = 1; - } + if (ts.TotalDays < 345) + { + var months = Convert.ToInt32(Math.Floor(ts.TotalDays / 29.5)); + return formatter.DateHumanize(TimeUnit.Month, tense, months); + } - return formatter.DateHumanize(TimeUnit.Year, tense, years); + var years = Convert.ToInt32(Math.Floor(ts.TotalDays / 365)); + if (years == 0) + { + years = 1; } + + return formatter.DateHumanize(TimeUnit.Year, tense, years); } -} +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeHumanizeStrategy.cs b/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeHumanizeStrategy.cs index dc96c1ed6..8bad43ba4 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeHumanizeStrategy.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeHumanizeStrategy.cs @@ -1,14 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// The default 'distance of time' -> words calculator. +/// +public class DefaultDateTimeHumanizeStrategy : IDateTimeHumanizeStrategy { /// - /// The default 'distance of time' -> words calculator. + /// Calculates the distance of time in words between two provided dates /// - public class DefaultDateTimeHumanizeStrategy : IDateTimeHumanizeStrategy - { - /// - /// Calculates the distance of time in words between two provided dates - /// - public string Humanize(DateTime input, DateTime comparisonBase, CultureInfo? culture) => - DateTimeHumanizeAlgorithms.DefaultHumanize(input, comparisonBase, culture); - } -} + public string Humanize(DateTime input, DateTime comparisonBase, CultureInfo? culture) => + DateTimeHumanizeAlgorithms.DefaultHumanize(input, comparisonBase, culture); +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeOffsetHumanizeStrategy.cs b/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeOffsetHumanizeStrategy.cs index 96f178b9d..2f67400c5 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeOffsetHumanizeStrategy.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/DefaultDateTimeOffsetHumanizeStrategy.cs @@ -1,14 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// The default 'distance of time' -> words calculator. +/// +public class DefaultDateTimeOffsetHumanizeStrategy : IDateTimeOffsetHumanizeStrategy { /// - /// The default 'distance of time' -> words calculator. + /// Calculates the distance of time in words between two provided dates /// - public class DefaultDateTimeOffsetHumanizeStrategy : IDateTimeOffsetHumanizeStrategy - { - /// - /// Calculates the distance of time in words between two provided dates - /// - public string Humanize(DateTimeOffset input, DateTimeOffset comparisonBase, CultureInfo? culture) => - DateTimeHumanizeAlgorithms.DefaultHumanize(input.UtcDateTime, comparisonBase.UtcDateTime, culture); - } -} + public string Humanize(DateTimeOffset input, DateTimeOffset comparisonBase, CultureInfo? culture) => + DateTimeHumanizeAlgorithms.DefaultHumanize(input.UtcDateTime, comparisonBase.UtcDateTime, culture); +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeHumanizeStrategy.cs b/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeHumanizeStrategy.cs index f5bd2a933..4bb5ab71e 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeHumanizeStrategy.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeHumanizeStrategy.cs @@ -1,13 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Implement this interface to create a new strategy for DateTime.Humanize and hook it in the Configurator.DateTimeHumanizeStrategy +/// +public interface IDateTimeHumanizeStrategy { /// - /// Implement this interface to create a new strategy for DateTime.Humanize and hook it in the Configurator.DateTimeHumanizeStrategy + /// Calculates the distance of time in words between two provided dates used for DateTime.Humanize /// - public interface IDateTimeHumanizeStrategy - { - /// - /// Calculates the distance of time in words between two provided dates used for DateTime.Humanize - /// - string Humanize(DateTime input, DateTime comparisonBase, CultureInfo? culture); - } -} + string Humanize(DateTime input, DateTime comparisonBase, CultureInfo? culture); +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeOffsetHumanizeStrategy.cs b/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeOffsetHumanizeStrategy.cs index 5c13a28b4..4cacb96f3 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeOffsetHumanizeStrategy.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/IDateTimeOffsetHumanizeStrategy.cs @@ -1,13 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Implement this interface to create a new strategy for DateTime.Humanize and hook it in the Configurator.DateTimeOffsetHumanizeStrategy +/// +public interface IDateTimeOffsetHumanizeStrategy { /// - /// Implement this interface to create a new strategy for DateTime.Humanize and hook it in the Configurator.DateTimeOffsetHumanizeStrategy + /// Calculates the distance of time in words between two provided dates used for DateTimeOffset.Humanize /// - public interface IDateTimeOffsetHumanizeStrategy - { - /// - /// Calculates the distance of time in words between two provided dates used for DateTimeOffset.Humanize - /// - string Humanize(DateTimeOffset input, DateTimeOffset comparisonBase, CultureInfo? culture); - } -} + string Humanize(DateTimeOffset input, DateTimeOffset comparisonBase, CultureInfo? culture); +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeHumanizeStrategy.cs b/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeHumanizeStrategy.cs index 653a06d62..e4d8efd06 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeHumanizeStrategy.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeHumanizeStrategy.cs @@ -1,23 +1,22 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Precision-based calculator for distance between two times +/// +public class PrecisionDateTimeHumanizeStrategy : IDateTimeHumanizeStrategy { + readonly double _precision; + /// - /// Precision-based calculator for distance between two times + /// Constructs a precision-based calculator for distance of time with default precision 0.75. /// - public class PrecisionDateTimeHumanizeStrategy : IDateTimeHumanizeStrategy - { - readonly double _precision; - - /// - /// Constructs a precision-based calculator for distance of time with default precision 0.75. - /// - /// precision of approximation, if not provided 0.75 will be used as a default precision. - public PrecisionDateTimeHumanizeStrategy(double precision = .75) => - _precision = precision; + /// precision of approximation, if not provided 0.75 will be used as a default precision. + public PrecisionDateTimeHumanizeStrategy(double precision = .75) => + _precision = precision; - /// - /// Returns localized & humanized distance of time between two dates; given a specific precision. - /// - public string Humanize(DateTime input, DateTime comparisonBase, CultureInfo? culture) => - DateTimeHumanizeAlgorithms.PrecisionHumanize(input, comparisonBase, _precision, culture); - } -} + /// + /// Returns localized & humanized distance of time between two dates; given a specific precision. + /// + public string Humanize(DateTime input, DateTime comparisonBase, CultureInfo? culture) => + DateTimeHumanizeAlgorithms.PrecisionHumanize(input, comparisonBase, _precision, culture); +} \ No newline at end of file diff --git a/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeOffsetHumanizeStrategy.cs b/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeOffsetHumanizeStrategy.cs index 220ee6857..957d5b2c4 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeOffsetHumanizeStrategy.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/PrecisionDateTimeOffsetHumanizeStrategy.cs @@ -1,23 +1,22 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Precision-based calculator for distance between two times +/// +public class PrecisionDateTimeOffsetHumanizeStrategy : IDateTimeOffsetHumanizeStrategy { + readonly double _precision; + /// - /// Precision-based calculator for distance between two times + /// Constructs a precision-based calculator for distance of time with default precision 0.75. /// - public class PrecisionDateTimeOffsetHumanizeStrategy : IDateTimeOffsetHumanizeStrategy - { - readonly double _precision; - - /// - /// Constructs a precision-based calculator for distance of time with default precision 0.75. - /// - /// precision of approximation, if not provided 0.75 will be used as a default precision. - public PrecisionDateTimeOffsetHumanizeStrategy(double precision = .75) => - _precision = precision; + /// precision of approximation, if not provided 0.75 will be used as a default precision. + public PrecisionDateTimeOffsetHumanizeStrategy(double precision = .75) => + _precision = precision; - /// - /// Returns localized & humanized distance of time between two dates; given a specific precision. - /// - public string Humanize(DateTimeOffset input, DateTimeOffset comparisonBase, CultureInfo? culture) => - DateTimeHumanizeAlgorithms.PrecisionHumanize(input.UtcDateTime, comparisonBase.UtcDateTime, _precision, culture); - } -} + /// + /// Returns localized & humanized distance of time between two dates; given a specific precision. + /// + public string Humanize(DateTimeOffset input, DateTimeOffset comparisonBase, CultureInfo? culture) => + DateTimeHumanizeAlgorithms.PrecisionHumanize(input.UtcDateTime, comparisonBase.UtcDateTime, _precision, culture); +} \ No newline at end of file diff --git a/src/Humanizer/DateToOrdinalWordsExtensions.cs b/src/Humanizer/DateToOrdinalWordsExtensions.cs index 28bc838e3..3600248e0 100644 --- a/src/Humanizer/DateToOrdinalWordsExtensions.cs +++ b/src/Humanizer/DateToOrdinalWordsExtensions.cs @@ -1,44 +1,43 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Humanizes DateTime into human readable sentence +/// +public static class DateToOrdinalWordsExtensions { /// - /// Humanizes DateTime into human readable sentence + /// Turns the provided date into ordinal words /// - public static class DateToOrdinalWordsExtensions - { - /// - /// Turns the provided date into ordinal words - /// - /// The date to be made into ordinal words - /// The date in ordinal words - public static string ToOrdinalWords(this DateTime input) => - Configurator.DateToOrdinalWordsConverter.Convert(input); + /// The date to be made into ordinal words + /// The date in ordinal words + public static string ToOrdinalWords(this DateTime input) => + Configurator.DateToOrdinalWordsConverter.Convert(input); - /// - /// Turns the provided date into ordinal words - /// - /// The date to be made into ordinal words - /// The grammatical case to use for output words - /// The date in ordinal words - public static string ToOrdinalWords(this DateTime input, GrammaticalCase grammaticalCase) => - Configurator.DateToOrdinalWordsConverter.Convert(input, grammaticalCase); + /// + /// Turns the provided date into ordinal words + /// + /// The date to be made into ordinal words + /// The grammatical case to use for output words + /// The date in ordinal words + public static string ToOrdinalWords(this DateTime input, GrammaticalCase grammaticalCase) => + Configurator.DateToOrdinalWordsConverter.Convert(input, grammaticalCase); #if NET6_0_OR_GREATER - /// - /// Turns the provided date into ordinal words - /// - /// The date to be made into ordinal words - /// The date in ordinal words - public static string ToOrdinalWords(this DateOnly input) => - Configurator.DateOnlyToOrdinalWordsConverter.Convert(input); + /// + /// Turns the provided date into ordinal words + /// + /// The date to be made into ordinal words + /// The date in ordinal words + public static string ToOrdinalWords(this DateOnly input) => + Configurator.DateOnlyToOrdinalWordsConverter.Convert(input); - /// - /// Turns the provided date into ordinal words - /// - /// The date to be made into ordinal words - /// The grammatical case to use for output words - /// The date in ordinal words - public static string ToOrdinalWords(this DateOnly input, GrammaticalCase grammaticalCase) => - Configurator.DateOnlyToOrdinalWordsConverter.Convert(input, grammaticalCase); + /// + /// Turns the provided date into ordinal words + /// + /// The date to be made into ordinal words + /// The grammatical case to use for output words + /// The date in ordinal words + public static string ToOrdinalWords(this DateOnly input, GrammaticalCase grammaticalCase) => + Configurator.DateOnlyToOrdinalWordsConverter.Convert(input, grammaticalCase); #endif - } -} +} \ No newline at end of file diff --git a/src/Humanizer/FluentDate/In.cs b/src/Humanizer/FluentDate/In.cs index baf2c4ec7..04bcc1312 100644 --- a/src/Humanizer/FluentDate/In.cs +++ b/src/Humanizer/FluentDate/In.cs @@ -1,11 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +public partial class In { - public partial class In - { - /// - /// Returns the first of January of the provided year - /// - public static DateTime TheYear(int year) => - new(year, 1, 1); - } -} + /// + /// Returns the first of January of the provided year + /// + public static DateTime TheYear(int year) => + new(year, 1, 1); +} \ No newline at end of file diff --git a/src/Humanizer/FluentDate/PrepositionsExtensions.cs b/src/Humanizer/FluentDate/PrepositionsExtensions.cs index 85b94a4c4..749612f7c 100644 --- a/src/Humanizer/FluentDate/PrepositionsExtensions.cs +++ b/src/Humanizer/FluentDate/PrepositionsExtensions.cs @@ -1,33 +1,32 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// extensions related to spatial or temporal relations +/// +public static class PrepositionsExtensions { /// - /// extensions related to spatial or temporal relations + /// Returns a new with the specified hour and, optionally + /// provided minutes, seconds, and milliseconds. /// - public static class PrepositionsExtensions - { - /// - /// Returns a new with the specified hour and, optionally - /// provided minutes, seconds, and milliseconds. - /// - public static DateTime At(this DateTime date, int hour, int min = 0, int second = 0, int millisecond = 0) => - new(date.Year, date.Month, date.Day, hour, min, second, millisecond); + public static DateTime At(this DateTime date, int hour, int min = 0, int second = 0, int millisecond = 0) => + new(date.Year, date.Month, date.Day, hour, min, second, millisecond); - /// - /// Returns a new instance of DateTime based on the provided date where the time is set to midnight - /// - public static DateTime AtMidnight(this DateTime date) => - date.At(0); + /// + /// Returns a new instance of DateTime based on the provided date where the time is set to midnight + /// + public static DateTime AtMidnight(this DateTime date) => + date.At(0); - /// - /// Returns a new instance of DateTime based on the provided date where the time is set to noon - /// - public static DateTime AtNoon(this DateTime date) => - date.At(12); + /// + /// Returns a new instance of DateTime based on the provided date where the time is set to noon + /// + public static DateTime AtNoon(this DateTime date) => + date.At(12); - /// - /// Returns a new instance of DateTime based on the provided date where the year is set to the provided year - /// - public static DateTime In(this DateTime date, int year) => - new(year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond); - } -} + /// + /// Returns a new instance of DateTime based on the provided date where the year is set to the provided year + /// + public static DateTime In(this DateTime date, int year) => + new(year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond); +} \ No newline at end of file diff --git a/src/Humanizer/GrammaticalCase.cs b/src/Humanizer/GrammaticalCase.cs index 029035eb2..9639b06f5 100644 --- a/src/Humanizer/GrammaticalCase.cs +++ b/src/Humanizer/GrammaticalCase.cs @@ -1,33 +1,32 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Options for specifying the desired grammatical case for the output words +/// +public enum GrammaticalCase { /// - /// Options for specifying the desired grammatical case for the output words + /// Indicates the subject of a finite verb /// - public enum GrammaticalCase - { - /// - /// Indicates the subject of a finite verb - /// - Nominative, - /// - /// Indicates the possessor of another noun - /// - Genitive, - /// - /// Indicates the indirect object of a verb - /// - Dative, - /// - /// Indicates the direct object of a verb - /// - Accusative, - /// - /// Indicates an object used in performing an action - /// - Instrumental, - /// - /// Indicates the object of a preposition - /// - Prepositional, - } + Nominative, + /// + /// Indicates the possessor of another noun + /// + Genitive, + /// + /// Indicates the indirect object of a verb + /// + Dative, + /// + /// Indicates the direct object of a verb + /// + Accusative, + /// + /// Indicates an object used in performing an action + /// + Instrumental, + /// + /// Indicates the object of a preposition + /// + Prepositional, } \ No newline at end of file diff --git a/src/Humanizer/GrammaticalGender.cs b/src/Humanizer/GrammaticalGender.cs index 9c14c599b..0a28eac91 100644 --- a/src/Humanizer/GrammaticalGender.cs +++ b/src/Humanizer/GrammaticalGender.cs @@ -1,21 +1,20 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Options for specifying the desired grammatical gender for the output words +/// +public enum GrammaticalGender { /// - /// Options for specifying the desired grammatical gender for the output words + /// Indicates masculine grammatical gender /// - public enum GrammaticalGender - { - /// - /// Indicates masculine grammatical gender - /// - Masculine, - /// - /// Indicates feminine grammatical gender - /// - Feminine, - /// - /// Indicates neuter grammatical gender - /// - Neuter - } + Masculine, + /// + /// Indicates feminine grammatical gender + /// + Feminine, + /// + /// Indicates neuter grammatical gender + /// + Neuter } \ No newline at end of file diff --git a/src/Humanizer/HeadingExtensions.cs b/src/Humanizer/HeadingExtensions.cs index ef1c460fd..4d2b2e845 100644 --- a/src/Humanizer/HeadingExtensions.cs +++ b/src/Humanizer/HeadingExtensions.cs @@ -1,42 +1,42 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Style for the cardinal direction humanization +/// +public enum HeadingStyle { /// - /// Style for the cardinal direction humanization + /// Returns an abbreviated format /// - public enum HeadingStyle - { - /// - /// Returns an abbreviated format - /// - Abbreviated, + Abbreviated, + + /// + /// Returns the full format + /// + Full +} - /// - /// Returns the full format - /// - Full - } +/// +/// Contains extensions to transform a number indicating a heading into the +/// textual representation of the heading. +/// +public static class HeadingExtensions +{ + internal static readonly string[] Headings = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]; + internal static readonly char[] HeadingArrows = ['↑', '↗', '→', '↘', '↓', '↙', '←', '↖']; + // https://stackoverflow.com/a/7490772/1720761 /// - /// Contains extensions to transform a number indicating a heading into the - /// textual representation of the heading. + /// Returns a textual representation of the heading. + /// + /// This representation has a maximum deviation of 11.25 degrees. /// - public static class HeadingExtensions + /// A textual representation of the heading + /// The heading value + /// Whether to return a short result or not. + /// The culture to return the textual representation in + public static string ToHeading(this double heading, HeadingStyle style = HeadingStyle.Abbreviated, CultureInfo? culture = null) { - internal static readonly string[] Headings = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]; - internal static readonly char[] HeadingArrows = ['↑', '↗', '→', '↘', '↓', '↙', '←', '↖']; - - // https://stackoverflow.com/a/7490772/1720761 - /// - /// Returns a textual representation of the heading. - /// - /// This representation has a maximum deviation of 11.25 degrees. - /// - /// A textual representation of the heading - /// The heading value - /// Whether to return a short result or not. - /// The culture to return the textual representation in - public static string ToHeading(this double heading, HeadingStyle style = HeadingStyle.Abbreviated, CultureInfo? culture = null) - { var val = (int)(heading / 22.5 + .5); var result = Headings[val % 16]; @@ -49,35 +49,35 @@ public static string ToHeading(this double heading, HeadingStyle style = Heading return Resources.GetResource(result, culture); } - /// - /// Returns a char arrow indicating the heading. - /// - /// This representation has a maximum deviation of 22.5 degrees. - /// - /// The heading arrow. - public static char ToHeadingArrow(this double heading) - { + /// + /// Returns a char arrow indicating the heading. + /// + /// This representation has a maximum deviation of 22.5 degrees. + /// + /// The heading arrow. + public static char ToHeadingArrow(this double heading) + { var val = (int)(heading / 45 + .5); return HeadingArrows[val % 8]; } - /// - /// Returns a heading based on the short textual representation of the heading. - /// - /// The short textual representation of a heading - /// The heading. -1 if the heading could not be parsed. - public static double FromAbbreviatedHeading(this string heading) => - heading.FromAbbreviatedHeading(null); - - /// - /// Returns a heading based on the short textual representation of the heading. - /// - /// The short textual representation of a heading - /// The culture of the heading - /// The heading. -1 if the heading could not be parsed. - public static double FromAbbreviatedHeading(this string heading, CultureInfo? culture = null) - { + /// + /// Returns a heading based on the short textual representation of the heading. + /// + /// The short textual representation of a heading + /// The heading. -1 if the heading could not be parsed. + public static double FromAbbreviatedHeading(this string heading) => + heading.FromAbbreviatedHeading(null); + + /// + /// Returns a heading based on the short textual representation of the heading. + /// + /// The short textual representation of a heading + /// The culture of the heading + /// The heading. -1 if the heading could not be parsed. + public static double FromAbbreviatedHeading(this string heading, CultureInfo? culture = null) + { if (heading == null) { throw new ArgumentNullException(nameof(heading)); @@ -98,11 +98,11 @@ public static double FromAbbreviatedHeading(this string heading, CultureInfo? cu return -1; } - /// - /// Returns a heading based on the heading arrow. - /// - public static double FromHeadingArrow(this char heading) - { + /// + /// Returns a heading based on the heading arrow. + /// + public static double FromHeadingArrow(this char heading) + { var index = Array.IndexOf(HeadingArrows, heading); if (index == -1) @@ -113,11 +113,11 @@ public static double FromHeadingArrow(this char heading) return index * 45.0; } - /// - /// Returns a heading based on the heading arrow. - /// - public static double FromHeadingArrow(this string heading) - { + /// + /// Returns a heading based on the heading arrow. + /// + public static double FromHeadingArrow(this string heading) + { if (heading == null) { throw new ArgumentNullException(nameof(heading)); @@ -130,5 +130,4 @@ public static double FromHeadingArrow(this string heading) return heading[0].FromHeadingArrow(); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Inflections/Vocabularies.cs b/src/Humanizer/Inflections/Vocabularies.cs index 143eb4fb7..84432d200 100644 --- a/src/Humanizer/Inflections/Vocabularies.cs +++ b/src/Humanizer/Inflections/Vocabularies.cs @@ -1,24 +1,24 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Container for registered Vocabularies. At present, only a single vocabulary is supported: Default. +/// +public static class Vocabularies { - /// - /// Container for registered Vocabularies. At present, only a single vocabulary is supported: Default. - /// - public static class Vocabularies - { - static readonly Lazy Instance; + static readonly Lazy Instance; - static Vocabularies() => - Instance = new(BuildDefault, LazyThreadSafetyMode.PublicationOnly); + static Vocabularies() => + Instance = new(BuildDefault, LazyThreadSafetyMode.PublicationOnly); - /// - /// The default vocabulary used for singular/plural irregularities. - /// Rules can be added to this vocabulary and will be picked up by called to Singularize() and Pluralize(). - /// At this time, multiple vocabularies and removing existing rules are not supported. - /// - public static Vocabulary Default => Instance.Value; + /// + /// The default vocabulary used for singular/plural irregularities. + /// Rules can be added to this vocabulary and will be picked up by called to Singularize() and Pluralize(). + /// At this time, multiple vocabularies and removing existing rules are not supported. + /// + public static Vocabulary Default => Instance.Value; - static Vocabulary BuildDefault() - { + static Vocabulary BuildDefault() + { var _default = new Vocabulary(); _default.AddPlural("$", "s"); @@ -151,5 +151,4 @@ static Vocabulary BuildDefault() return _default; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/InflectorExtensions.cs b/src/Humanizer/InflectorExtensions.cs index cd5fdb685..493bbf422 100644 --- a/src/Humanizer/InflectorExtensions.cs +++ b/src/Humanizer/InflectorExtensions.cs @@ -21,75 +21,74 @@ //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -namespace Humanizer +namespace Humanizer; + +public static class InflectorExtensions { - public static class InflectorExtensions - { - /// - /// Pluralizes the provided input considering irregular words - /// - /// Word to be pluralized - /// Normally you call Pluralize on singular words; but if you're unsure call it with false - [return: NotNullIfNotNull(nameof(word))] - public static string? Pluralize(this string? word, bool inputIsKnownToBeSingular = true) => - Vocabularies.Default.Pluralize(word, inputIsKnownToBeSingular); + /// + /// Pluralizes the provided input considering irregular words + /// + /// Word to be pluralized + /// Normally you call Pluralize on singular words; but if you're unsure call it with false + [return: NotNullIfNotNull(nameof(word))] + public static string? Pluralize(this string? word, bool inputIsKnownToBeSingular = true) => + Vocabularies.Default.Pluralize(word, inputIsKnownToBeSingular); - /// - /// Singularizes the provided input considering irregular words - /// - /// Word to be singularized - /// Normally you call Singularize on plural words; but if you're unsure call it with false - /// Skip singularizing single words that have an 's' on the end - public static string Singularize(this string word, bool inputIsKnownToBePlural = true, bool skipSimpleWords = false) => - Vocabularies.Default.Singularize(word, inputIsKnownToBePlural, skipSimpleWords); + /// + /// Singularizes the provided input considering irregular words + /// + /// Word to be singularized + /// Normally you call Singularize on plural words; but if you're unsure call it with false + /// Skip singularizing single words that have an 's' on the end + public static string Singularize(this string word, bool inputIsKnownToBePlural = true, bool skipSimpleWords = false) => + Vocabularies.Default.Singularize(word, inputIsKnownToBePlural, skipSimpleWords); - /// - /// Humanizes the input with Title casing - /// - /// The string to be titleized - public static string Titleize(this string input) => - input.Humanize(LetterCasing.Title); + /// + /// Humanizes the input with Title casing + /// + /// The string to be titleized + public static string Titleize(this string input) => + input.Humanize(LetterCasing.Title); - /// - /// By default, pascalize converts strings to UpperCamelCase also removing underscores - /// - public static string Pascalize(this string input) => - Regex.Replace(input, @"(?:[ _-]+|^)([a-zA-Z])", match => match.Groups[1].Value.ToUpper()); + /// + /// By default, pascalize converts strings to UpperCamelCase also removing underscores + /// + public static string Pascalize(this string input) => + Regex.Replace(input, @"(?:[ _-]+|^)([a-zA-Z])", match => match.Groups[1].Value.ToUpper()); - /// - /// Same as Pascalize except that the first character is lower case - /// - public static string Camelize(this string input) - { + /// + /// Same as Pascalize except that the first character is lower case + /// + public static string Camelize(this string input) + { var word = input.Pascalize(); return word.Length > 0 ? word.Substring(0, 1).ToLower() + word.Substring(1) : word; } - /// - /// Separates the input words with underscore - /// - /// The string to be underscored - public static string Underscore(this string input) => + /// + /// Separates the input words with underscore + /// + /// The string to be underscored + public static string Underscore(this string input) => + Regex.Replace( Regex.Replace( - Regex.Replace( - Regex.Replace(input, @"([\p{Lu}]+)([\p{Lu}][\p{Ll}])", "$1_$2"), @"([\p{Ll}\d])([\p{Lu}])", "$1_$2"), @"[-\s]", "_").ToLower(); + Regex.Replace(input, @"([\p{Lu}]+)([\p{Lu}][\p{Ll}])", "$1_$2"), @"([\p{Ll}\d])([\p{Lu}])", "$1_$2"), @"[-\s]", "_").ToLower(); - /// - /// Replaces underscores with dashes in the string - /// - public static string Dasherize(this string underscoredWord) => - underscoredWord.Replace('_', '-'); + /// + /// Replaces underscores with dashes in the string + /// + public static string Dasherize(this string underscoredWord) => + underscoredWord.Replace('_', '-'); - /// - /// Replaces underscores with hyphens in the string - /// - public static string Hyphenate(this string underscoredWord) => - Dasherize(underscoredWord); + /// + /// Replaces underscores with hyphens in the string + /// + public static string Hyphenate(this string underscoredWord) => + Dasherize(underscoredWord); - /// - /// Separates the input words with hyphens and all the words are converted to lowercase - /// - public static string Kebaberize(this string input) => - Underscore(input).Dasherize(); - } -} + /// + /// Separates the input words with hyphens and all the words are converted to lowercase + /// + public static string Kebaberize(this string input) => + Underscore(input).Dasherize(); +} \ No newline at end of file diff --git a/src/Humanizer/LetterCasing.cs b/src/Humanizer/LetterCasing.cs index beb13a92c..0fad59b43 100644 --- a/src/Humanizer/LetterCasing.cs +++ b/src/Humanizer/LetterCasing.cs @@ -1,25 +1,24 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Options for specifying the desired letter casing for the output string +/// +public enum LetterCasing { /// - /// Options for specifying the desired letter casing for the output string + /// SomeString -> Some String /// - public enum LetterCasing - { - /// - /// SomeString -> Some String - /// - Title, - /// - /// SomeString -> SOME STRING - /// - AllCaps, - /// - /// SomeString -> some string - /// - LowerCase, - /// - /// SomeString -> Some string - /// - Sentence, - } + Title, + /// + /// SomeString -> SOME STRING + /// + AllCaps, + /// + /// SomeString -> some string + /// + LowerCase, + /// + /// SomeString -> Some string + /// + Sentence, } \ No newline at end of file diff --git a/src/Humanizer/Localisation/CollectionFormatters/DefaultCollectionFormatter.cs b/src/Humanizer/Localisation/CollectionFormatters/DefaultCollectionFormatter.cs index 78bae6ee2..1daf9ee11 100644 --- a/src/Humanizer/Localisation/CollectionFormatters/DefaultCollectionFormatter.cs +++ b/src/Humanizer/Localisation/CollectionFormatters/DefaultCollectionFormatter.cs @@ -1,26 +1,26 @@ -namespace Humanizer +namespace Humanizer; + +class DefaultCollectionFormatter : ICollectionFormatter { - class DefaultCollectionFormatter : ICollectionFormatter - { - protected string DefaultSeparator = ""; + protected string DefaultSeparator = ""; - public DefaultCollectionFormatter(string defaultSeparator) => - DefaultSeparator = defaultSeparator; + public DefaultCollectionFormatter(string defaultSeparator) => + DefaultSeparator = defaultSeparator; - public virtual string Humanize(IEnumerable collection) => - Humanize(collection, o => o?.ToString(), DefaultSeparator); + public virtual string Humanize(IEnumerable collection) => + Humanize(collection, o => o?.ToString(), DefaultSeparator); - public virtual string Humanize(IEnumerable collection, Func objectFormatter) => - Humanize(collection, objectFormatter, DefaultSeparator); + public virtual string Humanize(IEnumerable collection, Func objectFormatter) => + Humanize(collection, objectFormatter, DefaultSeparator); - public string Humanize(IEnumerable collection, Func objectFormatter) => - Humanize(collection, objectFormatter, DefaultSeparator); + public string Humanize(IEnumerable collection, Func objectFormatter) => + Humanize(collection, objectFormatter, DefaultSeparator); - public virtual string Humanize(IEnumerable collection, string separator) => - Humanize(collection, o => o?.ToString(), separator); + public virtual string Humanize(IEnumerable collection, string separator) => + Humanize(collection, o => o?.ToString(), separator); - public virtual string Humanize(IEnumerable collection, Func objectFormatter, string separator) - { + public virtual string Humanize(IEnumerable collection, Func objectFormatter, string separator) + { if (collection == null) { throw new ArgumentNullException(nameof(collection)); @@ -36,8 +36,8 @@ public virtual string Humanize(IEnumerable collection, Func ob separator); } - public string Humanize(IEnumerable collection, Func objectFormatter, string separator) - { + public string Humanize(IEnumerable collection, Func objectFormatter, string separator) + { if (collection == null) { throw new ArgumentNullException(nameof(collection)); @@ -53,8 +53,8 @@ public string Humanize(IEnumerable collection, Func objectForma separator); } - string HumanizeDisplayStrings(IEnumerable strings, string separator) - { + string HumanizeDisplayStrings(IEnumerable strings, string separator) + { var itemsArray = strings .Select(item => item == null ? string.Empty : item.Trim()) .Where(item => !string.IsNullOrWhiteSpace(item)) @@ -81,6 +81,5 @@ string HumanizeDisplayStrings(IEnumerable strings, string separator) lastItem); } - protected virtual string GetConjunctionFormatString(int itemCount) => "{0} {1} {2}"; - } -} + protected virtual string GetConjunctionFormatString(int itemCount) => "{0} {1} {2}"; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/CollectionFormatters/ICollectionFormatter.cs b/src/Humanizer/Localisation/CollectionFormatters/ICollectionFormatter.cs index c4f791693..c1bfc6fb9 100644 --- a/src/Humanizer/Localisation/CollectionFormatters/ICollectionFormatter.cs +++ b/src/Humanizer/Localisation/CollectionFormatters/ICollectionFormatter.cs @@ -1,41 +1,40 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// An interface you should implement to localize Humanize for collections +/// +public interface ICollectionFormatter { /// - /// An interface you should implement to localize Humanize for collections + /// Formats the collection for display, calling ToString() on each object. /// - public interface ICollectionFormatter - { - /// - /// Formats the collection for display, calling ToString() on each object. - /// - string Humanize(IEnumerable collection); + string Humanize(IEnumerable collection); - /// - /// Formats the collection for display, calling on each element. - /// - string Humanize(IEnumerable collection, Func objectFormatter); + /// + /// Formats the collection for display, calling on each element. + /// + string Humanize(IEnumerable collection, Func objectFormatter); - /// - /// Formats the collection for display, calling on each element. - /// - string Humanize(IEnumerable collection, Func objectFormatter); + /// + /// Formats the collection for display, calling on each element. + /// + string Humanize(IEnumerable collection, Func objectFormatter); - /// - /// Formats the collection for display, calling ToString() on each object - /// and using before the final item. - /// - string Humanize(IEnumerable collection, string separator); + /// + /// Formats the collection for display, calling ToString() on each object + /// and using before the final item. + /// + string Humanize(IEnumerable collection, string separator); - /// - /// Formats the collection for display, calling on each element. - /// and using before the final item. - /// - string Humanize(IEnumerable collection, Func objectFormatter, string separator); + /// + /// Formats the collection for display, calling on each element. + /// and using before the final item. + /// + string Humanize(IEnumerable collection, Func objectFormatter, string separator); - /// - /// Formats the collection for display, calling on each element. - /// and using before the final item. - /// - string Humanize(IEnumerable collection, Func objectFormatter, string separator); - } -} + /// + /// Formats the collection for display, calling on each element. + /// and using before the final item. + /// + string Humanize(IEnumerable collection, Func objectFormatter, string separator); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/CollectionFormatters/OxfordStyleCollectionFormatter.cs b/src/Humanizer/Localisation/CollectionFormatters/OxfordStyleCollectionFormatter.cs index 423c712c3..08eb4c3d1 100644 --- a/src/Humanizer/Localisation/CollectionFormatters/OxfordStyleCollectionFormatter.cs +++ b/src/Humanizer/Localisation/CollectionFormatters/OxfordStyleCollectionFormatter.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class OxfordStyleCollectionFormatter() : + DefaultCollectionFormatter("and") { - class OxfordStyleCollectionFormatter() : - DefaultCollectionFormatter("and") - { - protected override string GetConjunctionFormatString(int itemCount) => itemCount > 2 ? "{0}, {1} {2}" : "{0} {1} {2}"; - } -} + protected override string GetConjunctionFormatString(int itemCount) => itemCount > 2 ? "{0}, {1} {2}" : "{0} {1} {2}"; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DataUnit.cs b/src/Humanizer/Localisation/DataUnit.cs index fb1144cc4..f336284c9 100644 --- a/src/Humanizer/Localisation/DataUnit.cs +++ b/src/Humanizer/Localisation/DataUnit.cs @@ -1,12 +1,11 @@ -namespace Humanizer +namespace Humanizer; + +public enum DataUnit { - public enum DataUnit - { - Bit, - Byte, - Kilobyte, - Megabyte, - Gigabyte, - Terabyte - } -} + Bit, + Byte, + Kilobyte, + Megabyte, + Gigabyte, + Terabyte +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs index 66588d9b2..7874a96f2 100644 --- a/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs +++ b/src/Humanizer/Localisation/DateToOrdinalWords/DefaultDateToOrdinalWordConverter.cs @@ -1,11 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +class DefaultDateToOrdinalWordConverter : IDateToOrdinalWordConverter { - class DefaultDateToOrdinalWordConverter : IDateToOrdinalWordConverter - { - public virtual string Convert(DateTime date) => - date.Day.Ordinalize() + date.ToString(" MMMM yyyy"); + public virtual string Convert(DateTime date) => + date.Day.Ordinalize() + date.ToString(" MMMM yyyy"); - public virtual string Convert(DateTime date, GrammaticalCase grammaticalCase) => - Convert(date); - } -} + public virtual string Convert(DateTime date, GrammaticalCase grammaticalCase) => + Convert(date); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/EsDateToOrdinalWordsConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/EsDateToOrdinalWordsConverter.cs index fac0da3f6..f9b48bf86 100644 --- a/src/Humanizer/Localisation/DateToOrdinalWords/EsDateToOrdinalWordsConverter.cs +++ b/src/Humanizer/Localisation/DateToOrdinalWords/EsDateToOrdinalWordsConverter.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class EsDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter { - class EsDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter - { - public override string Convert(DateTime date) => - date.ToString("d 'de' MMMM 'de' yyyy"); - } -} + public override string Convert(DateTime date) => + date.ToString("d 'de' MMMM 'de' yyyy"); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/FrDateToOrdinalWordsConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/FrDateToOrdinalWordsConverter.cs index b0c7ce4b1..c2333c466 100644 --- a/src/Humanizer/Localisation/DateToOrdinalWords/FrDateToOrdinalWordsConverter.cs +++ b/src/Humanizer/Localisation/DateToOrdinalWords/FrDateToOrdinalWordsConverter.cs @@ -1,11 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +class FrDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter { - class FrDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter + public override string Convert(DateTime date) { - public override string Convert(DateTime date) - { var day = date.Day > 1 ? date.Day.ToString() : date.Day.Ordinalize(); return day + date.ToString(" MMMM yyyy"); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs index df887740a..f46ec7644 100644 --- a/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs +++ b/src/Humanizer/Localisation/DateToOrdinalWords/IDateToOrdinalWordConverter.cs @@ -1,18 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// The interface used to localise the ToOrdinalWords method. +/// +public interface IDateToOrdinalWordConverter { /// - /// The interface used to localise the ToOrdinalWords method. + /// Converts the date to Ordinal Words /// - public interface IDateToOrdinalWordConverter - { - /// - /// Converts the date to Ordinal Words - /// - string Convert(DateTime date); + string Convert(DateTime date); - /// - /// Converts the date to Ordinal Words using the provided grammatical case - /// - string Convert(DateTime date, GrammaticalCase grammaticalCase); - } -} + /// + /// Converts the date to Ordinal Words using the provided grammatical case + /// + string Convert(DateTime date, GrammaticalCase grammaticalCase); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/LtDateToOrdinalWordsConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/LtDateToOrdinalWordsConverter.cs index ecf28d1ec..f6a81d798 100644 --- a/src/Humanizer/Localisation/DateToOrdinalWords/LtDateToOrdinalWordsConverter.cs +++ b/src/Humanizer/Localisation/DateToOrdinalWords/LtDateToOrdinalWordsConverter.cs @@ -1,11 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +class LtDateToOrdinalWordsConverter : IDateToOrdinalWordConverter { - class LtDateToOrdinalWordsConverter : IDateToOrdinalWordConverter - { - public string Convert(DateTime date) => - date.ToString("yyyy 'm.' MMMM d 'd.'"); + public string Convert(DateTime date) => + date.ToString("yyyy 'm.' MMMM d 'd.'"); - public string Convert(DateTime date, GrammaticalCase grammaticalCase) => - Convert(date); - } -} + public string Convert(DateTime date, GrammaticalCase grammaticalCase) => + Convert(date); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs b/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs index 795174ba1..732e61845 100644 --- a/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs +++ b/src/Humanizer/Localisation/DateToOrdinalWords/UsDateToOrdinalWordsConverter.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class UsDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter { - class UsDateToOrdinalWordsConverter : DefaultDateToOrdinalWordConverter - { - public override string Convert(DateTime date) => - date.ToString("MMMM ") + date.Day.Ordinalize() + date.ToString(", yyyy"); - } -} + public override string Convert(DateTime date) => + date.ToString("MMMM ") + date.Day.Ordinalize() + date.ToString(", yyyy"); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/ArabicFormatter.cs b/src/Humanizer/Localisation/Formatters/ArabicFormatter.cs index 288ee4358..390151db6 100644 --- a/src/Humanizer/Localisation/Formatters/ArabicFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/ArabicFormatter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class ArabicFormatter() : + DefaultFormatter("ar") { - class ArabicFormatter() : - DefaultFormatter("ar") - { - const string DualPostfix = "_Dual"; - const string PluralPostfix = "_Plural"; + const string DualPostfix = "_Dual"; + const string PluralPostfix = "_Plural"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { //In Arabic pluralization 2 entities gets a different word. if (number == 2) { @@ -22,5 +22,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/CroatianFormatter.cs b/src/Humanizer/Localisation/Formatters/CroatianFormatter.cs index 2a0c21fe6..d99e79236 100644 --- a/src/Humanizer/Localisation/Formatters/CroatianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/CroatianFormatter.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class CroatianFormatter() : + DefaultFormatter("hr") { - class CroatianFormatter() : - DefaultFormatter("hr") - { - const string PaucalPostfix = "_Paucal"; + const string PaucalPostfix = "_Paucal"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { var mod10 = number % 10; if (mod10 is > 1 and < 5 && number != 12 && number != 13 && number != 14) { @@ -15,5 +15,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/CzechSlovakPolishFormatter.cs b/src/Humanizer/Localisation/Formatters/CzechSlovakPolishFormatter.cs index 83a7f0f4b..65ca8f415 100644 --- a/src/Humanizer/Localisation/Formatters/CzechSlovakPolishFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/CzechSlovakPolishFormatter.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class CzechSlovakPolishFormatter(string localeCode) : + DefaultFormatter(localeCode) { - class CzechSlovakPolishFormatter(string localeCode) : - DefaultFormatter(localeCode) - { - const string PaucalPostfix = "_Paucal"; + const string PaucalPostfix = "_Paucal"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { if (number is > 1 and < 5) { return resourceKey + PaucalPostfix; @@ -14,5 +14,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs b/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs index 3331621fd..2c1df2c01 100644 --- a/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/DefaultFormatter.cs @@ -1,54 +1,54 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Default implementation of IFormatter interface. +/// +public class DefaultFormatter : IFormatter { + readonly CultureInfo _culture; + + /// Name of the culture to use. + public DefaultFormatter(string localeCode) => + _culture = new(localeCode); + + public virtual string DateHumanize_Now() => + GetResourceForDate(TimeUnit.Millisecond, Tense.Past, 0); + + public virtual string DateHumanize_Never() => + Format(ResourceKeys.DateHumanize.Never); + + /// + /// Returns the string representation of the provided DateTime + /// + public virtual string DateHumanize(TimeUnit timeUnit, Tense timeUnitTense, int unit) => + GetResourceForDate(timeUnit, timeUnitTense, unit); + + /// + /// 0 seconds + /// + /// Returns 0 seconds as the string representation of Zero TimeSpan + public virtual string TimeSpanHumanize_Zero() => + GetResourceForTimeSpan(TimeUnit.Millisecond, 0, true); + /// - /// Default implementation of IFormatter interface. + /// Returns the string representation of the provided TimeSpan /// - public class DefaultFormatter : IFormatter + /// A time unit to represent. + /// Is thrown when timeUnit is larger than TimeUnit.Week + public virtual string TimeSpanHumanize(TimeUnit timeUnit, int unit, bool toWords = false) => + GetResourceForTimeSpan(timeUnit, unit, toWords); + + /// + public virtual string TimeSpanHumanize_Age() { - readonly CultureInfo _culture; - - /// Name of the culture to use. - public DefaultFormatter(string localeCode) => - _culture = new(localeCode); - - public virtual string DateHumanize_Now() => - GetResourceForDate(TimeUnit.Millisecond, Tense.Past, 0); - - public virtual string DateHumanize_Never() => - Format(ResourceKeys.DateHumanize.Never); - - /// - /// Returns the string representation of the provided DateTime - /// - public virtual string DateHumanize(TimeUnit timeUnit, Tense timeUnitTense, int unit) => - GetResourceForDate(timeUnit, timeUnitTense, unit); - - /// - /// 0 seconds - /// - /// Returns 0 seconds as the string representation of Zero TimeSpan - public virtual string TimeSpanHumanize_Zero() => - GetResourceForTimeSpan(TimeUnit.Millisecond, 0, true); - - /// - /// Returns the string representation of the provided TimeSpan - /// - /// A time unit to represent. - /// Is thrown when timeUnit is larger than TimeUnit.Week - public virtual string TimeSpanHumanize(TimeUnit timeUnit, int unit, bool toWords = false) => - GetResourceForTimeSpan(timeUnit, unit, toWords); - - /// - public virtual string TimeSpanHumanize_Age() - { if (Resources.TryGetResource("TimeSpanHumanize_Age", _culture, out var ageFormat)) return ageFormat; return "{0}"; } - /// - public virtual string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) - { + /// + public virtual string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) + { var resourceKey = toSymbol ? $"DataUnit_{dataUnit}Symbol" : $"DataUnit_{dataUnit}"; var resourceValue = Format(resourceKey); @@ -58,44 +58,44 @@ public virtual string DataUnitHumanize(DataUnit dataUnit, double count, bool toS return resourceValue; } - /// - public virtual string TimeUnitHumanize(TimeUnit timeUnit) - { + /// + public virtual string TimeUnitHumanize(TimeUnit timeUnit) + { var resourceKey = ResourceKeys.TimeUnitSymbol.GetResourceKey(timeUnit); return Format(resourceKey); } - string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count) - { + string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count) + { var resourceKey = ResourceKeys.DateHumanize.GetResourceKey(unit, timeUnitTense: timeUnitTense, count: count); return count == 1 ? Format(resourceKey) : Format(resourceKey, count); } - string GetResourceForTimeSpan(TimeUnit unit, int count, bool toWords = false) - { + string GetResourceForTimeSpan(TimeUnit unit, int count, bool toWords = false) + { var resourceKey = ResourceKeys.TimeSpanHumanize.GetResourceKey(unit, count, toWords); return count == 1 ? Format(resourceKey + (toWords ? "_Words" : "")) : Format(resourceKey, count, toWords); } - /// - /// Formats the specified resource key. - /// - /// The resource key. - /// If the resource not exists on the specified culture. - protected virtual string Format(string resourceKey) - { + /// + /// Formats the specified resource key. + /// + /// The resource key. + /// If the resource not exists on the specified culture. + protected virtual string Format(string resourceKey) + { var resolvedKey = GetResourceKey(resourceKey); return Resources.GetResource(resolvedKey, _culture); } - /// - /// Formats the specified resource key. - /// - /// The resource key. - /// The number. - /// If the resource not exists on the specified culture. - protected virtual string Format(string resourceKey, int number, bool toWords = false) - { + /// + /// Formats the specified resource key. + /// + /// The resource key. + /// The number. + /// If the resource not exists on the specified culture. + protected virtual string Format(string resourceKey, int number, bool toWords = false) + { var resolvedKey = GetResourceKey(resourceKey, number); var resourceString = Resources.GetResource(resolvedKey, _culture); @@ -107,15 +107,14 @@ protected virtual string Format(string resourceKey, int number, bool toWords = f return string.Format(resourceString, number); } - /// - /// Override this method if your locale has complex rules around multiple units; e.g. Arabic, Russian - /// - /// The resource key that's being in formatting - /// The number of the units being used in formatting - protected virtual string GetResourceKey(string resourceKey, int number) => - resourceKey; - - protected virtual string GetResourceKey(string resourceKey) => - resourceKey; - } -} + /// + /// Override this method if your locale has complex rules around multiple units; e.g. Arabic, Russian + /// + /// The resource key that's being in formatting + /// The number of the units being used in formatting + protected virtual string GetResourceKey(string resourceKey, int number) => + resourceKey; + + protected virtual string GetResourceKey(string resourceKey) => + resourceKey; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/FrenchFormatter.cs b/src/Humanizer/Localisation/Formatters/FrenchFormatter.cs index 22e44da1a..5fb21b85c 100644 --- a/src/Humanizer/Localisation/Formatters/FrenchFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/FrenchFormatter.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class FrenchFormatter(string localeCode) : + DefaultFormatter(localeCode) { - class FrenchFormatter(string localeCode) : - DefaultFormatter(localeCode) - { - const string DualPostfix = "_Dual"; + const string DualPostfix = "_Dual"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { if (number == 2 && resourceKey is "DateHumanize_MultipleDaysAgo" or "DateHumanize_MultipleDaysFromNow") { return resourceKey + DualPostfix; @@ -19,5 +19,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/GermanFormatter.cs b/src/Humanizer/Localisation/Formatters/GermanFormatter.cs index ea3b735cf..8d603aef4 100644 --- a/src/Humanizer/Localisation/Formatters/GermanFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/GermanFormatter.cs @@ -1,10 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class GermanFormatter() : + DefaultFormatter("de") { - class GermanFormatter() : - DefaultFormatter("de") - { - /// - public override string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) => - base.DataUnitHumanize(dataUnit, count, toSymbol).TrimEnd('s'); - } -} + /// + public override string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true) => + base.DataUnitHumanize(dataUnit, count, toSymbol).TrimEnd('s'); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/HebrewFormatter.cs b/src/Humanizer/Localisation/Formatters/HebrewFormatter.cs index f630ff99d..a3e38ca6a 100644 --- a/src/Humanizer/Localisation/Formatters/HebrewFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/HebrewFormatter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class HebrewFormatter() : + DefaultFormatter("he") { - class HebrewFormatter() : - DefaultFormatter("he") - { - const string DualPostfix = "_Dual"; - const string PluralPostfix = "_Plural"; + const string DualPostfix = "_Dual"; + const string PluralPostfix = "_Plural"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { //In Hebrew pluralization 2 entities gets a different word. if (number == 2) { @@ -23,5 +23,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/IFormatter.cs b/src/Humanizer/Localisation/Formatters/IFormatter.cs index 79afb4c8a..a259c5e83 100644 --- a/src/Humanizer/Localisation/Formatters/IFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/IFormatter.cs @@ -1,53 +1,52 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Implement this interface if your language has complex rules around dealing with numbers. +/// For example in Romanian "5 days" is "5 zile", while "24 days" is "24 de zile" and +/// in Arabic 2 days is يومين not 2 يوم +/// +public interface IFormatter { + string DateHumanize_Now(); + + string DateHumanize_Never(); + + /// + /// Returns the string representation of the provided DateTime + /// + string DateHumanize(TimeUnit timeUnit, Tense timeUnitTense, int unit); + + /// + /// 0 seconds + /// + /// Returns 0 seconds as the string representation of Zero TimeSpan + string TimeSpanHumanize_Zero(); + + /// + /// Returns the string representation of the provided TimeSpan + /// + string TimeSpanHumanize(TimeUnit timeUnit, int unit, bool toWords = false); + + /// + /// Returns the age format that converts a humanized TimeSpan string to an age expression. + /// For instance, in English that format adds the " old" suffix, so that "40 years" becomes "40 years old". + /// + /// Age format + string TimeSpanHumanize_Age(); + + /// + /// Returns the string representation of the provided DataUnit, either as a symbol or full word + /// + /// Data unit + /// Number of said units, to adjust for singular/plural forms + /// Indicates whether the data unit should be expressed as symbol or full word + /// String representation of the provided DataUnit + string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true); + /// - /// Implement this interface if your language has complex rules around dealing with numbers. - /// For example in Romanian "5 days" is "5 zile", while "24 days" is "24 de zile" and - /// in Arabic 2 days is يومين not 2 يوم + /// Returns the symbol for the given TimeUnit /// - public interface IFormatter - { - string DateHumanize_Now(); - - string DateHumanize_Never(); - - /// - /// Returns the string representation of the provided DateTime - /// - string DateHumanize(TimeUnit timeUnit, Tense timeUnitTense, int unit); - - /// - /// 0 seconds - /// - /// Returns 0 seconds as the string representation of Zero TimeSpan - string TimeSpanHumanize_Zero(); - - /// - /// Returns the string representation of the provided TimeSpan - /// - string TimeSpanHumanize(TimeUnit timeUnit, int unit, bool toWords = false); - - /// - /// Returns the age format that converts a humanized TimeSpan string to an age expression. - /// For instance, in English that format adds the " old" suffix, so that "40 years" becomes "40 years old". - /// - /// Age format - string TimeSpanHumanize_Age(); - - /// - /// Returns the string representation of the provided DataUnit, either as a symbol or full word - /// - /// Data unit - /// Number of said units, to adjust for singular/plural forms - /// Indicates whether the data unit should be expressed as symbol or full word - /// String representation of the provided DataUnit - string DataUnitHumanize(DataUnit dataUnit, double count, bool toSymbol = true); - - /// - /// Returns the symbol for the given TimeUnit - /// - /// Time unit - /// String representation of the provided TimeUnit - string TimeUnitHumanize(TimeUnit timeUnit); - } -} + /// Time unit + /// String representation of the provided TimeUnit + string TimeUnitHumanize(TimeUnit timeUnit); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/LithuanianFormatter.cs b/src/Humanizer/Localisation/Formatters/LithuanianFormatter.cs index 0cfbdcf6e..12ddffe20 100644 --- a/src/Humanizer/Localisation/Formatters/LithuanianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/LithuanianFormatter.cs @@ -1,10 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +class LithuanianFormatter() : + DefaultFormatter("lt") { - class LithuanianFormatter() : - DefaultFormatter("lt") + protected override string GetResourceKey(string resourceKey, int number) { - protected override string GetResourceKey(string resourceKey, int number) - { if (resourceKey == "TimeSpanHumanize_Zero") { return resourceKey; @@ -15,8 +15,8 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey + suffix; } - static string GetSuffix(LithuanianNumberForm form) - { + static string GetSuffix(LithuanianNumberForm form) + { if (form == LithuanianNumberForm.Singular) { return "_Singular"; @@ -29,5 +29,4 @@ static string GetSuffix(LithuanianNumberForm form) return ""; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/MalteseFormatter.cs b/src/Humanizer/Localisation/Formatters/MalteseFormatter.cs index b9eeaa117..a260b58ed 100644 --- a/src/Humanizer/Localisation/Formatters/MalteseFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/MalteseFormatter.cs @@ -1,20 +1,20 @@ -namespace Humanizer +namespace Humanizer; + +class MalteseFormatter(string localeCode) : + DefaultFormatter(localeCode) { - class MalteseFormatter(string localeCode) : - DefaultFormatter(localeCode) - { - const string DualPostfix = "_Dual"; + const string DualPostfix = "_Dual"; - static readonly string[] DualResourceKeys = - [ - "DateHumanize_MultipleDaysAgo", "DateHumanize_MultipleDaysFromNow", "DateHumanize_MultipleHoursAgo", "DateHumanize_MultipleHoursFromNow" , - "DateHumanize_MultipleMonthsAgo", "DateHumanize_MultipleMonthsFromNow", "DateHumanize_MultipleYearsAgo", "DateHumanize_MultipleYearsFromNow", - "TimeSpanHumanize_MultipleDays", "TimeSpanHumanize_MultipleYears", "TimeSpanHumanize_MultipleMonths", "TimeSpanHumanize_MultipleHours", - "TimeSpanHumanize_MultipleWeeks" - ]; + static readonly string[] DualResourceKeys = + [ + "DateHumanize_MultipleDaysAgo", "DateHumanize_MultipleDaysFromNow", "DateHumanize_MultipleHoursAgo", "DateHumanize_MultipleHoursFromNow" , + "DateHumanize_MultipleMonthsAgo", "DateHumanize_MultipleMonthsFromNow", "DateHumanize_MultipleYearsAgo", "DateHumanize_MultipleYearsFromNow", + "TimeSpanHumanize_MultipleDays", "TimeSpanHumanize_MultipleYears", "TimeSpanHumanize_MultipleMonths", "TimeSpanHumanize_MultipleHours", + "TimeSpanHumanize_MultipleWeeks" + ]; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { if (number == 2 && DualResourceKeys.Contains(resourceKey)) { return resourceKey + DualPostfix; @@ -22,5 +22,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/RomanianFormatter.cs b/src/Humanizer/Localisation/Formatters/RomanianFormatter.cs index 032b10363..efa29fe31 100644 --- a/src/Humanizer/Localisation/Formatters/RomanianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/RomanianFormatter.cs @@ -1,32 +1,31 @@ -namespace Humanizer +namespace Humanizer; + +class RomanianFormatter() : + DefaultFormatter(RomanianCultureCode) { - class RomanianFormatter() : - DefaultFormatter(RomanianCultureCode) - { - const int PrepositionIndicatingDecimals = 2; - const int MaxNumeralWithNoPreposition = 19; - const int MinNumeralWithNoPreposition = 1; - const string UnitPreposition = " de"; - const string RomanianCultureCode = "ro"; + const int PrepositionIndicatingDecimals = 2; + const int MaxNumeralWithNoPreposition = 19; + const int MinNumeralWithNoPreposition = 1; + const string UnitPreposition = " de"; + const string RomanianCultureCode = "ro"; - static readonly double Divider = Math.Pow(10, PrepositionIndicatingDecimals); + static readonly double Divider = Math.Pow(10, PrepositionIndicatingDecimals); - readonly CultureInfo _romanianCulture = new(RomanianCultureCode); + readonly CultureInfo _romanianCulture = new(RomanianCultureCode); - protected override string Format(string resourceKey, int number, bool toWords = false) - { - var format = Resources.GetResource(GetResourceKey(resourceKey, number), _romanianCulture); - var preposition = ShouldUsePreposition(number) - ? UnitPreposition - : string.Empty; + protected override string Format(string resourceKey, int number, bool toWords = false) + { + var format = Resources.GetResource(GetResourceKey(resourceKey, number), _romanianCulture); + var preposition = ShouldUsePreposition(number) + ? UnitPreposition + : string.Empty; - return string.Format(format, number, preposition); - } + return string.Format(format, number, preposition); + } - static bool ShouldUsePreposition(int number) - { - var prepositionIndicatingNumeral = Math.Abs(number % Divider); - return prepositionIndicatingNumeral is < MinNumeralWithNoPreposition or > MaxNumeralWithNoPreposition; - } + static bool ShouldUsePreposition(int number) + { + var prepositionIndicatingNumeral = Math.Abs(number % Divider); + return prepositionIndicatingNumeral is < MinNumeralWithNoPreposition or > MaxNumeralWithNoPreposition; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/RussianFormatter.cs b/src/Humanizer/Localisation/Formatters/RussianFormatter.cs index 6623ff715..8e0d75117 100644 --- a/src/Humanizer/Localisation/Formatters/RussianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/RussianFormatter.cs @@ -1,17 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +class RussianFormatter() : + DefaultFormatter("ru") { - class RussianFormatter() : - DefaultFormatter("ru") + protected override string GetResourceKey(string resourceKey, int number) { - protected override string GetResourceKey(string resourceKey, int number) - { var grammaticalNumber = RussianGrammaticalNumberDetector.Detect(number); var suffix = GetSuffix(grammaticalNumber); return resourceKey + suffix; } - static string GetSuffix(RussianGrammaticalNumber grammaticalNumber) - { + static string GetSuffix(RussianGrammaticalNumber grammaticalNumber) + { if (grammaticalNumber == RussianGrammaticalNumber.Singular) { return "_Singular"; @@ -24,5 +24,4 @@ static string GetSuffix(RussianGrammaticalNumber grammaticalNumber) return ""; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/SerbianFormatter.cs b/src/Humanizer/Localisation/Formatters/SerbianFormatter.cs index c0888b152..5805a9daa 100644 --- a/src/Humanizer/Localisation/Formatters/SerbianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/SerbianFormatter.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class SerbianFormatter(string localeCode) : + DefaultFormatter(localeCode) { - class SerbianFormatter(string localeCode) : - DefaultFormatter(localeCode) - { - const string PaucalPostfix = "_Paucal"; + const string PaucalPostfix = "_Paucal"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { var mod10 = number % 10; if (mod10 is > 1 and < 5) { @@ -15,5 +15,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/SlovenianFormatter.cs b/src/Humanizer/Localisation/Formatters/SlovenianFormatter.cs index 752957d57..15aea4f05 100644 --- a/src/Humanizer/Localisation/Formatters/SlovenianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/SlovenianFormatter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class SlovenianFormatter() : + DefaultFormatter("sl") { - class SlovenianFormatter() : - DefaultFormatter("sl") - { - const string DualPostfix = "_Dual"; - const string TrialQuadralPostfix = "_Paucal"; + const string DualPostfix = "_Dual"; + const string TrialQuadralPostfix = "_Paucal"; - protected override string GetResourceKey(string resourceKey, int number) - { + protected override string GetResourceKey(string resourceKey, int number) + { if (number == 2) { return resourceKey + DualPostfix; @@ -21,5 +21,4 @@ protected override string GetResourceKey(string resourceKey, int number) return resourceKey; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Formatters/UkrainianFormatter.cs b/src/Humanizer/Localisation/Formatters/UkrainianFormatter.cs index 25fecc69c..ab7da5176 100644 --- a/src/Humanizer/Localisation/Formatters/UkrainianFormatter.cs +++ b/src/Humanizer/Localisation/Formatters/UkrainianFormatter.cs @@ -1,16 +1,16 @@ -namespace Humanizer +namespace Humanizer; + +class UkrainianFormatter() : DefaultFormatter("uk") { - class UkrainianFormatter() : DefaultFormatter("uk") + protected override string GetResourceKey(string resourceKey, int number) { - protected override string GetResourceKey(string resourceKey, int number) - { var grammaticalNumber = RussianGrammaticalNumberDetector.Detect(number); var suffix = GetSuffix(grammaticalNumber); return resourceKey + suffix; } - static string GetSuffix(RussianGrammaticalNumber grammaticalNumber) - { + static string GetSuffix(RussianGrammaticalNumber grammaticalNumber) + { if (grammaticalNumber == RussianGrammaticalNumber.Singular) { return "_Singular"; @@ -23,5 +23,4 @@ static string GetSuffix(RussianGrammaticalNumber grammaticalNumber) return ""; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberForm.cs b/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberForm.cs index 4c41a2c9c..3d33b2349 100644 --- a/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberForm.cs +++ b/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberForm.cs @@ -1,9 +1,8 @@ -namespace Humanizer +namespace Humanizer; + +enum LithuanianNumberForm { - enum LithuanianNumberForm - { - Singular, - Plural, - GenitivePlural - } -} + Singular, + Plural, + GenitivePlural +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberFormDetector.cs b/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberFormDetector.cs index 3e3e3715a..96912f1f4 100644 --- a/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberFormDetector.cs +++ b/src/Humanizer/Localisation/GrammaticalNumber/LithuanianNumberFormDetector.cs @@ -1,24 +1,23 @@ -namespace Humanizer +namespace Humanizer; + +static class LithuanianNumberFormDetector { - static class LithuanianNumberFormDetector + public static LithuanianNumberForm Detect(long number) { - public static LithuanianNumberForm Detect(long number) - { - var tens = number % 100 / 10; - var units = number % 10; + var tens = number % 100 / 10; + var units = number % 10; - if (tens == 1 || units == 0) // 10-19, 20, 30, 40 ... 100, 110 .. - { - return LithuanianNumberForm.GenitivePlural; - } - - if (units == 1) // 1, 21, 31, 41 ... 91, 101, 121 ... - { - return LithuanianNumberForm.Singular; - } + if (tens == 1 || units == 0) // 10-19, 20, 30, 40 ... 100, 110 .. + { + return LithuanianNumberForm.GenitivePlural; + } - // 2-9, 22-29, 32 ... - return LithuanianNumberForm.Plural; + if (units == 1) // 1, 21, 31, 41 ... 91, 101, 121 ... + { + return LithuanianNumberForm.Singular; } + + // 2-9, 22-29, 32 ... + return LithuanianNumberForm.Plural; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumber.cs b/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumber.cs index c862dd072..8a91707f6 100644 --- a/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumber.cs +++ b/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumber.cs @@ -1,9 +1,8 @@ -namespace Humanizer +namespace Humanizer; + +enum RussianGrammaticalNumber { - enum RussianGrammaticalNumber - { - Singular, - Paucal, - Plural - } -} + Singular, + Paucal, + Plural +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumberDetector.cs b/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumberDetector.cs index 2fe677b9c..648b1d896 100644 --- a/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumberDetector.cs +++ b/src/Humanizer/Localisation/GrammaticalNumber/RussianGrammaticalNumberDetector.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +static class RussianGrammaticalNumberDetector { - static class RussianGrammaticalNumberDetector + public static RussianGrammaticalNumber Detect(long number) { - public static RussianGrammaticalNumber Detect(long number) - { var tens = number % 100 / 10; if (tens != 1) { @@ -22,5 +22,4 @@ public static RussianGrammaticalNumber Detect(long number) return RussianGrammaticalNumber.Plural; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs index 94c0198c1..44b3ab395 100644 --- a/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs @@ -1,27 +1,27 @@ -namespace Humanizer +namespace Humanizer; + +class AfrikaansNumberToWordsConverter : + GenderlessNumberToWordsConverter { - class AfrikaansNumberToWordsConverter : - GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["nul", "een", "twee", "drie", "vier", "vyf", "ses", "sewe", "agt", "nege", "tien", "elf", "twaalf", "dertien", "veertien", "vyftien", "sestien", "sewentien", "agtien", "negentien"]; + static readonly string[] TensMap = ["nul", "tien", "twintig", "dertig", "veertig", "vyftig", "sestig", "sewentig", "tagtig", "negentig"]; + + static readonly Dictionary OrdinalExceptions = new() + { + {0, "nulste"}, + {1, "eerste"}, + {3, "derde"}, + {7, "sewende"}, + {8, "agste"}, + {9, "negende"}, + {10, "tiende"}, + {14, "veertiende"}, + {17, "sewentiende"}, + {19, "negentiende"} + }; + + public override string Convert(long number) { - static readonly string[] UnitsMap = ["nul", "een", "twee", "drie", "vier", "vyf", "ses", "sewe", "agt", "nege", "tien", "elf", "twaalf", "dertien", "veertien", "vyftien", "sestien", "sewentien", "agtien", "negentien"]; - static readonly string[] TensMap = ["nul", "tien", "twintig", "dertig", "veertig", "vyftig", "sestig", "sewentig", "tagtig", "negentig"]; - - static readonly Dictionary OrdinalExceptions = new() - { - {0, "nulste"}, - {1, "eerste"}, - {3, "derde"}, - {7, "sewende"}, - {8, "agste"}, - {9, "negende"}, - {10, "tiende"}, - {14, "veertiende"}, - {17, "sewentiende"}, - {19, "negentiende"} - }; - - public override string Convert(long number) - { if (number is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -29,11 +29,11 @@ public override string Convert(long number) return Convert((int)number, false); } - public override string ConvertToOrdinal(int number) => - Convert(number, true); + public override string ConvertToOrdinal(int number) => + Convert(number, true); - string Convert(int number, bool isOrdinal) - { + string Convert(int number, bool isOrdinal) + { if (number == 0) { return GetUnitValue(0, isOrdinal); @@ -119,8 +119,8 @@ string Convert(int number, bool isOrdinal) return toWords; } - static string GetUnitValue(int number, bool isOrdinal) - { + static string GetUnitValue(int number, bool isOrdinal) + { if (isOrdinal) { if (ExceptionNumbersToWords(number, out var exceptionString)) @@ -138,8 +138,8 @@ static string GetUnitValue(int number, bool isOrdinal) return UnitsMap[number]; } - static string RemoveOnePrefix(string toWords) - { + static string RemoveOnePrefix(string toWords) + { // one hundred => hundredth if (toWords.StartsWith("een", StringComparison.Ordinal)) { @@ -152,7 +152,6 @@ static string RemoveOnePrefix(string toWords) return toWords; } - static bool ExceptionNumbersToWords(int number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); - } -} + static bool ExceptionNumbersToWords(int number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs index f61ed6808..fffd79ba1 100644 --- a/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ArabicNumberToWordsConverter.cs @@ -1,21 +1,21 @@ -namespace Humanizer +namespace Humanizer; + +class ArabicNumberToWordsConverter : + GenderedNumberToWordsConverter { - class ArabicNumberToWordsConverter : - GenderedNumberToWordsConverter + static readonly string[] Groups = ["مئة", "ألف", "مليون", "مليار", "تريليون", "كوادريليون", "كوينتليون", "سكستيليون"]; + static readonly string[] AppendedGroups = ["", "ألفاً", "مليوناً", "ملياراً", "تريليوناً", "كوادريليوناً", "كوينتليوناً", "سكستيليوناً"]; + static readonly string[] PluralGroups = ["", "آلاف", "ملايين", "مليارات", "تريليونات", "كوادريليونات", "كوينتليونات", "سكستيليونات"]; + static readonly string[] OnesGroup = ["", "واحد", "اثنان", "ثلاثة", "أربعة", "خمسة", "ستة", "سبعة", "ثمانية", "تسعة", "عشرة", "أحد عشر", "اثنا عشر", "ثلاثة عشر", "أربعة عشر", "خمسة عشر", "ستة عشر", "سبعة عشر", "ثمانية عشر", "تسعة عشر"]; + static readonly string[] TensGroup = ["", "عشرة", "عشرون", "ثلاثون", "أربعون", "خمسون", "ستون", "سبعون", "ثمانون", "تسعون"]; + static readonly string[] HundredsGroup = ["", "مئة", "مئتان", "ثلاث مئة", "أربع مئة", "خمس مئة", "ست مئة", "سبع مئة", "ثمان مئة", "تسع مئة"]; + static readonly string[] AppendedTwos = ["مئتان", "ألفان", "مليونان", "ملياران", "تريليونان", "كوادريليونان", "كوينتليونان", "سكستيليونلن"]; + static readonly string[] Twos = ["مئتان", "ألفان", "مليونان", "ملياران", "تريليونان", "كوادريليونان", "كوينتليونان", "سكستيليونان"]; + + static readonly string[] FeminineOnesGroup = ["", "واحدة", "اثنتان", "ثلاث", "أربع", "خمس", "ست", "سبع", "ثمان", "تسع", "عشر", "إحدى عشرة", "اثنتا عشرة", "ثلاث عشرة", "أربع عشرة", "خمس عشرة", "ست عشرة", "سبع عشرة", "ثمان عشرة", "تسع عشرة"]; + + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] Groups = ["مئة", "ألف", "مليون", "مليار", "تريليون", "كوادريليون", "كوينتليون", "سكستيليون"]; - static readonly string[] AppendedGroups = ["", "ألفاً", "مليوناً", "ملياراً", "تريليوناً", "كوادريليوناً", "كوينتليوناً", "سكستيليوناً"]; - static readonly string[] PluralGroups = ["", "آلاف", "ملايين", "مليارات", "تريليونات", "كوادريليونات", "كوينتليونات", "سكستيليونات"]; - static readonly string[] OnesGroup = ["", "واحد", "اثنان", "ثلاثة", "أربعة", "خمسة", "ستة", "سبعة", "ثمانية", "تسعة", "عشرة", "أحد عشر", "اثنا عشر", "ثلاثة عشر", "أربعة عشر", "خمسة عشر", "ستة عشر", "سبعة عشر", "ثمانية عشر", "تسعة عشر"]; - static readonly string[] TensGroup = ["", "عشرة", "عشرون", "ثلاثون", "أربعون", "خمسون", "ستون", "سبعون", "ثمانون", "تسعون"]; - static readonly string[] HundredsGroup = ["", "مئة", "مئتان", "ثلاث مئة", "أربع مئة", "خمس مئة", "ست مئة", "سبع مئة", "ثمان مئة", "تسع مئة"]; - static readonly string[] AppendedTwos = ["مئتان", "ألفان", "مليونان", "ملياران", "تريليونان", "كوادريليونان", "كوينتليونان", "سكستيليونلن"]; - static readonly string[] Twos = ["مئتان", "ألفان", "مليونان", "ملياران", "تريليونان", "كوادريليونان", "كوينتليونان", "سكستيليونان"]; - - static readonly string[] FeminineOnesGroup = ["", "واحدة", "اثنتان", "ثلاث", "أربع", "خمس", "ست", "سبع", "ثمان", "تسع", "عشر", "إحدى عشرة", "اثنتا عشرة", "ثلاث عشرة", "أربع عشرة", "خمس عشرة", "ست عشرة", "سبع عشرة", "ثمان عشرة", "تسع عشرة"]; - - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) - { if (number == 0) { return "صفر"; @@ -144,40 +144,40 @@ public override string Convert(long number, GrammaticalGender gender, bool addAn return result.Trim(); } - static readonly Dictionary OrdinalExceptions = new() - { - {"واحد", "الحادي"}, - {"أحد", "الحادي"}, - {"اثنان", "الثاني"}, - {"اثنا", "الثاني"}, - {"ثلاثة", "الثالث"}, - {"أربعة", "الرابع"}, - {"خمسة", "الخامس"}, - {"ستة", "السادس"}, - {"سبعة", "السابع"}, - {"ثمانية", "الثامن"}, - {"تسعة", "التاسع"}, - {"عشرة", "العاشر"}, - }; - - static readonly Dictionary FeminineOrdinalExceptions = new() - { - {"واحدة", "الحادية"}, - {"إحدى", "الحادية"}, - {"اثنتان", "الثانية"}, - {"اثنتا", "الثانية"}, - {"ثلاث", "الثالثة"}, - {"أربع", "الرابعة"}, - {"خمس", "الخامسة"}, - {"ست", "السادسة"}, - {"سبع", "السابعة"}, - {"ثمان", "الثامنة"}, - {"تسع", "التاسعة"}, - {"عشر", "العاشرة"}, - }; - - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + static readonly Dictionary OrdinalExceptions = new() + { + {"واحد", "الحادي"}, + {"أحد", "الحادي"}, + {"اثنان", "الثاني"}, + {"اثنا", "الثاني"}, + {"ثلاثة", "الثالث"}, + {"أربعة", "الرابع"}, + {"خمسة", "الخامس"}, + {"ستة", "السادس"}, + {"سبعة", "السابع"}, + {"ثمانية", "الثامن"}, + {"تسعة", "التاسع"}, + {"عشرة", "العاشر"}, + }; + + static readonly Dictionary FeminineOrdinalExceptions = new() + { + {"واحدة", "الحادية"}, + {"إحدى", "الحادية"}, + {"اثنتان", "الثانية"}, + {"اثنتا", "الثانية"}, + {"ثلاث", "الثالثة"}, + {"أربع", "الرابعة"}, + {"خمس", "الخامسة"}, + {"ست", "السادسة"}, + {"سبع", "السابعة"}, + {"ثمان", "الثامنة"}, + {"تسع", "التاسعة"}, + {"عشر", "العاشرة"}, + }; + + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { if (number == 0) { return "الصفر"; @@ -207,8 +207,8 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender) return word.Trim(); } - static string ParseNumber(string word, int number, GrammaticalGender gender) - { + static string ParseNumber(string word, int number, GrammaticalGender gender) + { if (number == 1) { return gender == GrammaticalGender.Feminine ? "الأولى" : "الأول"; @@ -258,5 +258,4 @@ static string ParseNumber(string word, int number, GrammaticalGender gender) return word; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/ArmenianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ArmenianNumberToWordsConverter.cs index a0b405732..fcb5c6f5b 100644 --- a/src/Humanizer/Localisation/NumberToWords/ArmenianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ArmenianNumberToWordsConverter.cs @@ -1,25 +1,25 @@ -namespace Humanizer +namespace Humanizer; + +class ArmenianNumberToWordsConverter : + GenderlessNumberToWordsConverter { - class ArmenianNumberToWordsConverter : - GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["զրո", "մեկ", "երկու", "երեք", "չորս", "հինգ", "վեց", "յոթ", "ութ", "ինը", "տաս", "տասնմեկ", "տասներկու", "տասներեք", "տասնչորս", "տասնհինգ", "տասնվեց", "տասնյոթ", "տասնութ", "տասնինը"]; + static readonly string[] TensMap = ["զրո", "տաս", "քսան", "երեսուն", "քառասուն", "հիսուն", "վաթսուն", "յոթանասուն", "ութսուն", "իննսուն"]; + + static readonly Dictionary OrdinalExceptions = new() + { + {0, "զրոյական"}, + {1, "առաջին"}, + {2, "երկրորդ"}, + {3, "երրորդ"}, + {4, "չորրորդ"} + }; + + public override string Convert(long number) => + ConvertImpl(number, false); + + public override string ConvertToOrdinal(int number) { - static readonly string[] UnitsMap = ["զրո", "մեկ", "երկու", "երեք", "չորս", "հինգ", "վեց", "յոթ", "ութ", "ինը", "տաս", "տասնմեկ", "տասներկու", "տասներեք", "տասնչորս", "տասնհինգ", "տասնվեց", "տասնյոթ", "տասնութ", "տասնինը"]; - static readonly string[] TensMap = ["զրո", "տաս", "քսան", "երեսուն", "քառասուն", "հիսուն", "վաթսուն", "յոթանասուն", "ութսուն", "իննսուն"]; - - static readonly Dictionary OrdinalExceptions = new() - { - {0, "զրոյական"}, - {1, "առաջին"}, - {2, "երկրորդ"}, - {3, "երրորդ"}, - {4, "չորրորդ"} - }; - - public override string Convert(long number) => - ConvertImpl(number, false); - - public override string ConvertToOrdinal(int number) - { if (ExceptionNumbersToWords(number, out var exceptionString)) { return exceptionString; @@ -28,8 +28,8 @@ public override string ConvertToOrdinal(int number) return ConvertImpl(number, true); } - string ConvertImpl(long number, bool isOrdinal) - { + string ConvertImpl(long number, bool isOrdinal) + { if (number == 0) { return GetUnitValue(0, isOrdinal); @@ -148,8 +148,8 @@ string ConvertImpl(long number, bool isOrdinal) return toWords; } - static string GetUnitValue(long number, bool isOrdinal) - { + static string GetUnitValue(long number, bool isOrdinal) + { if (isOrdinal) { return UnitsMap[number] + "երորդ"; @@ -158,8 +158,8 @@ static string GetUnitValue(long number, bool isOrdinal) return UnitsMap[number]; } - static string RemoveOnePrefix(string toWords) - { + static string RemoveOnePrefix(string toWords) + { // one hundred => hundredth if (toWords.StartsWith("մեկ", StringComparison.Ordinal)) { @@ -169,7 +169,6 @@ static string RemoveOnePrefix(string toWords) return toWords; } - static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); - } -} + static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/AzerbaijaniNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/AzerbaijaniNumberToWordsConverter.cs index 3a4a105c5..7851f8a3d 100644 --- a/src/Humanizer/Localisation/NumberToWords/AzerbaijaniNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/AzerbaijaniNumberToWordsConverter.cs @@ -1,26 +1,26 @@ -namespace Humanizer +namespace Humanizer; + +class AzerbaijaniNumberToWordsConverter : + GenderlessNumberToWordsConverter { - class AzerbaijaniNumberToWordsConverter : - GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["sıfır", "bir", "iki", "üç", "dörd", "beş", "altı", "yeddi", "səkkiz", "doqquz"]; + static readonly string[] TensMap = ["sıfır", "on", "iyirmi", "otuz", "qırx", "əlli", "altmış", "yetmiş", "səksən", "doxsan"]; + + static readonly Dictionary OrdinalSuffix = new() + { + {'ı', "ıncı"}, + {'i', "inci"}, + {'u', "uncu"}, + {'ü', "üncü"}, + {'o', "uncu"}, + {'ö', "üncü"}, + {'e', "inci"}, + {'a', "ıncı"}, + {'ə', "inci"}, + }; + + public override string Convert(long input) { - static readonly string[] UnitsMap = ["sıfır", "bir", "iki", "üç", "dörd", "beş", "altı", "yeddi", "səkkiz", "doqquz"]; - static readonly string[] TensMap = ["sıfır", "on", "iyirmi", "otuz", "qırx", "əlli", "altmış", "yetmiş", "səksən", "doxsan"]; - - static readonly Dictionary OrdinalSuffix = new() - { - {'ı', "ıncı"}, - {'i', "inci"}, - {'u', "uncu"}, - {'ü', "üncü"}, - {'o', "uncu"}, - {'ö', "üncü"}, - {'e', "inci"}, - {'a', "ıncı"}, - {'ə', "inci"}, - }; - - public override string Convert(long input) - { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -80,8 +80,8 @@ public override string Convert(long input) return toWords; } - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var word = Convert(number); var wordSuffix = string.Empty; var suffixFoundOnLastVowel = false; @@ -107,5 +107,4 @@ public override string ConvertToOrdinal(int number) return $"{word}{wordSuffix}"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs index 1df5580ef..73c222ff8 100644 --- a/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/BanglaNumberToWordsConverter.cs @@ -1,55 +1,55 @@ -namespace Humanizer +namespace Humanizer; + +class BanglaNumberToWordsConverter : + GenderlessNumberToWordsConverter { - class BanglaNumberToWordsConverter : - GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = + [ + "শূন্য", "এক", "দুই", "তিন", "চার", "পাঁচ", "ছয়", "সাত", "আট", "নয়", "দশ", + "এগারো", "বারো", "তেরো", "চোদ্দ", "পনেরো", "ষোল", "সতেরো", "আঠারো", "উনিশ", "বিশ", + "একুশ", "বাইশ", "তেইশ", "চব্বিশ", "পঁচিশ", "ছাব্বিশ", "সাতাশ", "আঠাশ", "উনতিরিশ", "তিরিশ", + "একতিরিশ", "বত্রিশ", "তেত্রিশ", "চৌঁতিরিশ", "পঁয়তিরিশ", "ছত্রিশ", "সাঁইতিরিশ", "আটতিরিশ", "উনচল্লিশ","চল্লিশ", + "একচল্লিশ", "বিয়াল্লিশ", "তেতাল্লিশ", "চুয়াল্লিশ", "পঁয়তাল্লিশ", "ছেচাল্লিশ", "সাতচল্লিশ", "আটচল্লিশ","উনপঞ্চাশ", "পঞ্চাশ", + "একান্ন", "বাহান্ন", "তিপ্পান্ন", "চুয়ান্ন", "পঞ্চান্ন", "ছাপ্পান্ন", "সাতান্ন", "আটান্ন", "উনষাট","ষাট", + "একষট্টি", "বাষট্টি", "তেষট্টি", "চৌষট্টি", "পঁয়ষট্টি", "ছেষট্টি", "সাতষট্টি", "আটষট্টি", "উনসত্তর","সত্তর", + "একাত্তর", "বাহাত্তর", "তিয়াত্তর", "চুয়াত্তর", "পঁচাত্তর", "ছিয়াত্তর", "সাতাত্তর", "আটাত্তর", "উনআশি", "আশি", + "একাশি", "বিরাশি", "তিরাশি", "চুরাশি", "পঁচাশি", "ছিয়াশি", "সাতাশি", "আটাশি", "উননব্বই", "নব্বই", + "একানব্বই", "বিরানব্বই", "তিরানব্বিই", "চুরানব্বই", "পঁচানব্বই", "ছিয়ানব্বই", "সাতানব্বই", "আটানব্বই","নিরানব্বই" + ]; + + static readonly string[] HundredsMap = + [ + "শূন্য", "একশ", "দুইশ", "তিনশ", "চারশ", "পাঁচশ", "ছয়শ", "সাতশ","আটশ", "নয়শ" + ]; + + static readonly Dictionary OrdinalExceptions = new() + { + {1, "প্রথম"}, + {2, "দ্বিতীয়"}, + {3, "তৃতীয়"}, + {4, "চতুর্থ"}, + {5, "পঞ্চম"}, + {6, "ষষ্ট"}, + {7, "সপ্তম"}, + {8, "অষ্টম"}, + {9, "নবম"}, + {10, "দশম"}, + {11, "একাদশ"}, + {12, "দ্বাদশ"}, + {13, "ত্রয়োদশ"}, + {14, "চতুর্দশ"}, + {15, "পঞ্চদশ"}, + {16, "ষোড়শ"}, + {17, "সপ্তদশ"}, + {18, "অষ্টাদশ"}, + {100, "শত তম"}, + {1000, "হাজার তম"}, + {100000, "লক্ষ তম"}, + {10000000, "কোটি তম"}, + }; + + public override string ConvertToOrdinal(int number) { - static readonly string[] UnitsMap = - [ - "শূন্য", "এক", "দুই", "তিন", "চার", "পাঁচ", "ছয়", "সাত", "আট", "নয়", "দশ", - "এগারো", "বারো", "তেরো", "চোদ্দ", "পনেরো", "ষোল", "সতেরো", "আঠারো", "উনিশ", "বিশ", - "একুশ", "বাইশ", "তেইশ", "চব্বিশ", "পঁচিশ", "ছাব্বিশ", "সাতাশ", "আঠাশ", "উনতিরিশ", "তিরিশ", - "একতিরিশ", "বত্রিশ", "তেত্রিশ", "চৌঁতিরিশ", "পঁয়তিরিশ", "ছত্রিশ", "সাঁইতিরিশ", "আটতিরিশ", "উনচল্লিশ","চল্লিশ", - "একচল্লিশ", "বিয়াল্লিশ", "তেতাল্লিশ", "চুয়াল্লিশ", "পঁয়তাল্লিশ", "ছেচাল্লিশ", "সাতচল্লিশ", "আটচল্লিশ","উনপঞ্চাশ", "পঞ্চাশ", - "একান্ন", "বাহান্ন", "তিপ্পান্ন", "চুয়ান্ন", "পঞ্চান্ন", "ছাপ্পান্ন", "সাতান্ন", "আটান্ন", "উনষাট","ষাট", - "একষট্টি", "বাষট্টি", "তেষট্টি", "চৌষট্টি", "পঁয়ষট্টি", "ছেষট্টি", "সাতষট্টি", "আটষট্টি", "উনসত্তর","সত্তর", - "একাত্তর", "বাহাত্তর", "তিয়াত্তর", "চুয়াত্তর", "পঁচাত্তর", "ছিয়াত্তর", "সাতাত্তর", "আটাত্তর", "উনআশি", "আশি", - "একাশি", "বিরাশি", "তিরাশি", "চুরাশি", "পঁচাশি", "ছিয়াশি", "সাতাশি", "আটাশি", "উননব্বই", "নব্বই", - "একানব্বই", "বিরানব্বই", "তিরানব্বিই", "চুরানব্বই", "পঁচানব্বই", "ছিয়ানব্বই", "সাতানব্বই", "আটানব্বই","নিরানব্বই" - ]; - - static readonly string[] HundredsMap = - [ - "শূন্য", "একশ", "দুইশ", "তিনশ", "চারশ", "পাঁচশ", "ছয়শ", "সাতশ","আটশ", "নয়শ" - ]; - - static readonly Dictionary OrdinalExceptions = new() - { - {1, "প্রথম"}, - {2, "দ্বিতীয়"}, - {3, "তৃতীয়"}, - {4, "চতুর্থ"}, - {5, "পঞ্চম"}, - {6, "ষষ্ট"}, - {7, "সপ্তম"}, - {8, "অষ্টম"}, - {9, "নবম"}, - {10, "দশম"}, - {11, "একাদশ"}, - {12, "দ্বাদশ"}, - {13, "ত্রয়োদশ"}, - {14, "চতুর্দশ"}, - {15, "পঞ্চদশ"}, - {16, "ষোড়শ"}, - {17, "সপ্তদশ"}, - {18, "অষ্টাদশ"}, - {100, "শত তম"}, - {1000, "হাজার তম"}, - {100000, "লক্ষ তম"}, - {10000000, "কোটি তম"}, - }; - - public override string ConvertToOrdinal(int number) - { if (ExceptionNumbersToWords(number, out var exceptionString)) { return exceptionString; @@ -58,8 +58,8 @@ public override string ConvertToOrdinal(int number) return Convert(number) + " তম"; } - public override string Convert(long input) - { + public override string Convert(long input) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -110,7 +110,6 @@ public override string Convert(long input) return string.Join(" ", parts); } - static bool ExceptionNumbersToWords(int number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); - } -} + static bool ExceptionNumbersToWords(int number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs index 30c4a9dab..673a59e54 100644 --- a/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/BrazilianPortugueseNumberToWordsConverter.cs @@ -1,18 +1,18 @@ -namespace Humanizer +namespace Humanizer; + +class BrazilianPortugueseNumberToWordsConverter : + GenderedNumberToWordsConverter { - class BrazilianPortugueseNumberToWordsConverter : - GenderedNumberToWordsConverter - { - static readonly string[] PortugueseUnitsMap = ["zero", "um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezessete", "dezoito", "dezenove"]; - static readonly string[] PortugueseTensMap = ["zero", "dez", "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa"]; - static readonly string[] PortugueseHundredsMap = ["zero", "cento", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos"]; + static readonly string[] PortugueseUnitsMap = ["zero", "um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezessete", "dezoito", "dezenove"]; + static readonly string[] PortugueseTensMap = ["zero", "dez", "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa"]; + static readonly string[] PortugueseHundredsMap = ["zero", "cento", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos"]; - static readonly string[] PortugueseOrdinalUnitsMap = ["zero", "primeiro", "segundo", "terceiro", "quarto", "quinto", "sexto", "sétimo", "oitavo", "nono"]; - static readonly string[] PortugueseOrdinalTensMap = ["zero", "décimo", "vigésimo", "trigésimo", "quadragésimo", "quinquagésimo", "sexagésimo", "septuagésimo", "octogésimo", "nonagésimo"]; - static readonly string[] PortugueseOrdinalHundredsMap = ["zero", "centésimo", "ducentésimo", "trecentésimo", "quadringentésimo", "quingentésimo", "sexcentésimo", "septingentésimo", "octingentésimo", "noningentésimo"]; + static readonly string[] PortugueseOrdinalUnitsMap = ["zero", "primeiro", "segundo", "terceiro", "quarto", "quinto", "sexto", "sétimo", "oitavo", "nono"]; + static readonly string[] PortugueseOrdinalTensMap = ["zero", "décimo", "vigésimo", "trigésimo", "quadragésimo", "quinquagésimo", "sexagésimo", "septuagésimo", "octogésimo", "nonagésimo"]; + static readonly string[] PortugueseOrdinalHundredsMap = ["zero", "centésimo", "ducentésimo", "trecentésimo", "quadringentésimo", "quingentésimo", "sexcentésimo", "septingentésimo", "octingentésimo", "noningentésimo"]; - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) + { if (input is > 999999999999 or < -999999999999) { throw new NotImplementedException(); @@ -100,8 +100,8 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { // N/A in Portuguese ordinal if (number == 0) { @@ -157,8 +157,8 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender) return string.Join(" ", parts); } - static string ApplyGender(string toWords, GrammaticalGender gender) - { + static string ApplyGender(string toWords, GrammaticalGender gender) + { if (gender != GrammaticalGender.Feminine) { return toWords; @@ -182,8 +182,8 @@ static string ApplyGender(string toWords, GrammaticalGender gender) return toWords; } - static string ApplyOrdinalGender(string toWords, GrammaticalGender gender) - { + static string ApplyOrdinalGender(string toWords, GrammaticalGender gender) + { if (gender == GrammaticalGender.Feminine) { return toWords.TrimEnd('o') + 'a'; @@ -191,5 +191,4 @@ static string ApplyOrdinalGender(string toWords, GrammaticalGender gender) return toWords; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/BulgarianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/BulgarianNumberToWordsConverter.cs index 3d5b090d7..841aa3693 100644 --- a/src/Humanizer/Localisation/NumberToWords/BulgarianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/BulgarianNumberToWordsConverter.cs @@ -1,44 +1,44 @@ -namespace Humanizer +namespace Humanizer; + +class BulgarianNumberToWordsConverter : GenderedNumberToWordsConverter { - class BulgarianNumberToWordsConverter : GenderedNumberToWordsConverter + static readonly string[] UnitsMap = + [ + "нула", "едно", "две", "три", "четири", "пет", "шест", "седем", "осем", "девет", "десет", "единадесет", + "дванадесет", "тринадесет", "четиринадесет", "петнадесет", "шестнадесет", "седемнадесет", "осемнадесет", + "деветнадесет" + ]; + + static readonly string[] TensMap = + [ + "нула", "десет", "двадесет", "тридесет", "четиридесет", "петдесет", "шестдесет", "седемдесет", + "осемдесет", "деветдесет" + ]; + + static readonly string[] HundredsMap = + [ + "нула", "сто", "двеста", "триста", "четиристотин", "петстотин", "шестстотин", "седемстотин", + "осемстотин", "деветстотин" + ]; + + static readonly string[] HundredsOrdinalMap = + [ + string.Empty, "стот", "двест", "трист", "четиристот", "петстот", "шестстот", "седемстот", "осемстот", + "деветстот" + ]; + + static readonly string[] UnitsOrdinal = + [ + string.Empty, "първ", "втор", "трет", "четвърт", "пет", "шест", "седм", "осм", "девeт", "десeт", + "единадесет", "дванадесет", "тринадесет", "четиринадесет", "петнадесет", "шестнадесет", "седемнадесет", + "осемнадесет", "деветнадесет" + ]; + + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) => + InnerConvert(input, gender, false); + + static string InnerConvert(long input, GrammaticalGender gender, bool isOrdinal) { - static readonly string[] UnitsMap = - [ - "нула", "едно", "две", "три", "четири", "пет", "шест", "седем", "осем", "девет", "десет", "единадесет", - "дванадесет", "тринадесет", "четиринадесет", "петнадесет", "шестнадесет", "седемнадесет", "осемнадесет", - "деветнадесет" - ]; - - static readonly string[] TensMap = - [ - "нула", "десет", "двадесет", "тридесет", "четиридесет", "петдесет", "шестдесет", "седемдесет", - "осемдесет", "деветдесет" - ]; - - static readonly string[] HundredsMap = - [ - "нула", "сто", "двеста", "триста", "четиристотин", "петстотин", "шестстотин", "седемстотин", - "осемстотин", "деветстотин" - ]; - - static readonly string[] HundredsOrdinalMap = - [ - string.Empty, "стот", "двест", "трист", "четиристот", "петстот", "шестстот", "седемстот", "осемстот", - "деветстот" - ]; - - static readonly string[] UnitsOrdinal = - [ - string.Empty, "първ", "втор", "трет", "четвърт", "пет", "шест", "седм", "осм", "девeт", "десeт", - "единадесет", "дванадесет", "тринадесет", "четиринадесет", "петнадесет", "шестнадесет", "седемнадесет", - "осемнадесет", "деветнадесет" - ]; - - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) => - InnerConvert(input, gender, false); - - static string InnerConvert(long input, GrammaticalGender gender, bool isOrdinal) - { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -135,11 +135,11 @@ static string InnerConvert(long input, GrammaticalGender gender, bool isOrdinal) return string.Join(" ", parts); } - public override string ConvertToOrdinal(int input, GrammaticalGender gender) => - InnerConvert(input, gender, true); + public override string ConvertToOrdinal(int input, GrammaticalGender gender) => + InnerConvert(input, gender, true); - static string GetEndingForGender(GrammaticalGender gender, long input) - { + static string GetEndingForGender(GrammaticalGender gender, long input) + { if (input == 0) { return gender switch @@ -170,5 +170,4 @@ static string GetEndingForGender(GrammaticalGender gender, long input) _ => throw new ArgumentOutOfRangeException(nameof(gender)) }; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs index 75467a5a2..0e87e6689 100644 --- a/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class CentralKurdishNumberToWordsConverter : GenderlessNumberToWordsConverter { - class CentralKurdishNumberToWordsConverter : GenderlessNumberToWordsConverter - { - static readonly string[] KurdishHundredsMap = ["سفر", "سەد", "دوو سەد", "سێ سەد", "چوار سەد", "پێنج سەد", "شەش سەد", "حەوت سەد", "هەشت سەد", "نۆ سەد"]; - static readonly string[] KurdishTensMap = ["سفر", "دە", "بیست", "سی", "چل", "پەنجا", "شەست", "حەفتا", "هەشتا", "نەوەد"]; - static readonly string[] KurdishUnitsMap = ["سفر", "یەک", "دوو", "سێ", "چوار", "پێنج", "شەش", "حەوت", "هەشت", "نۆ", "دە", "یازدە", "دوازدە", "سێزدە", "چواردە", "پازدە", "شازدە", "حەڤدە", "هەژدە", "نۆزدە"]; + static readonly string[] KurdishHundredsMap = ["سفر", "سەد", "دوو سەد", "سێ سەد", "چوار سەد", "پێنج سەد", "شەش سەد", "حەوت سەد", "هەشت سەد", "نۆ سەد"]; + static readonly string[] KurdishTensMap = ["سفر", "دە", "بیست", "سی", "چل", "پەنجا", "شەست", "حەفتا", "هەشتا", "نەوەد"]; + static readonly string[] KurdishUnitsMap = ["سفر", "یەک", "دوو", "سێ", "چوار", "پێنج", "شەش", "حەوت", "هەشت", "نۆ", "دە", "یازدە", "دوازدە", "سێزدە", "چواردە", "پازدە", "شازدە", "حەڤدە", "هەژدە", "نۆزدە"]; - public override string Convert(long number) - { + public override string Convert(long number) + { var largestNumber = Math.Pow(10, 15) * 1000 - 1; if (number > largestNumber || number < -largestNumber) { @@ -61,13 +61,12 @@ public override string Convert(long number) return sentence; } - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var word = Convert(number); return $"{word}{(IsVowel(word[^1]) ? "یەم" : "ەم")}"; } - static bool IsVowel(char c) => - c is 'ا' or 'ێ' or 'ۆ' or 'ە' or 'ی'; - } -} + static bool IsVowel(char c) => + c is 'ا' or 'ێ' or 'ۆ' or 'ە' or 'ی'; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/ChineseNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ChineseNumberToWordsConverter.cs index 9ab7f8714..11b40575a 100644 --- a/src/Humanizer/Localisation/NumberToWords/ChineseNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ChineseNumberToWordsConverter.cs @@ -1,19 +1,19 @@ -namespace Humanizer +namespace Humanizer; + +class ChineseNumberToWordsConverter : GenderlessNumberToWordsConverter { - class ChineseNumberToWordsConverter : GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]; + static readonly string[] UnitsMap = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]; - public override string Convert(long number) => - Convert(number, false, IsSpecial(number)); + public override string Convert(long number) => + Convert(number, false, IsSpecial(number)); - public override string ConvertToOrdinal(int number) => - Convert(number, true, IsSpecial(number)); + public override string ConvertToOrdinal(int number) => + Convert(number, true, IsSpecial(number)); - static bool IsSpecial(long number) => number is > 10 and < 20; + static bool IsSpecial(long number) => number is > 10 and < 20; - static string Convert(long number, bool isOrdinal, bool isSpecial) - { + static string Convert(long number, bool isOrdinal, bool isSpecial) + { if (number == 0) { return UnitsMap[0]; @@ -118,5 +118,4 @@ static string Convert(long number, bool isOrdinal, bool isSpecial) return toWords; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/CzechNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/CzechNumberToWordsConverter.cs index ab39ab84f..8c6cb0aa7 100644 --- a/src/Humanizer/Localisation/NumberToWords/CzechNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/CzechNumberToWordsConverter.cs @@ -1,22 +1,22 @@ -namespace Humanizer +namespace Humanizer; + +class CzechNumberToWordsConverter(CultureInfo? culture) : + GenderedNumberToWordsConverter { - class CzechNumberToWordsConverter(CultureInfo? culture) : - GenderedNumberToWordsConverter + static readonly string[] BillionsMap = ["miliarda", "miliardy", "miliard"]; + static readonly string[] MillionsMap = ["milion", "miliony", "milionů"]; + static readonly string[] ThousandsMap = ["tisíc", "tisíce", "tisíc"]; + static readonly string[] HundredsMap = ["nula", "sto", "dvě stě", "tři sta", "čtyři sta", "pět set", "šest set", "sedm set", "osm set", "devět set"]; + static readonly string[] TensMap = ["nula", "deset", "dvacet", "třicet", "čtyřicet", "padesát", "šedesát", "sedmdesát", "osmdesát", "devadesát"]; + static readonly string[] UnitsMap = ["nula", "jeden", "dva", "tři", "čtyři", "pět", "šest", "sedm", "osm", "devět", "deset", "jedenáct", "dvanáct", "třináct", "čtrnáct", "patnáct", "šestnáct", "sedmnáct", "osmnáct", "devatenáct"]; + + static readonly string[] UnitsMasculineOverrideMap = ["jeden", "dva"]; + static readonly string[] UnitsFeminineOverrideMap = ["jedna", "dvě"]; + static readonly string[] UnitsNeuterOverride = ["jedno", "dvě"]; + static readonly string[] UnitsIntraOverride = ["jedna", "dva"]; + + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] BillionsMap = ["miliarda", "miliardy", "miliard"]; - static readonly string[] MillionsMap = ["milion", "miliony", "milionů"]; - static readonly string[] ThousandsMap = ["tisíc", "tisíce", "tisíc"]; - static readonly string[] HundredsMap = ["nula", "sto", "dvě stě", "tři sta", "čtyři sta", "pět set", "šest set", "sedm set", "osm set", "devět set"]; - static readonly string[] TensMap = ["nula", "deset", "dvacet", "třicet", "čtyřicet", "padesát", "šedesát", "sedmdesát", "osmdesát", "devadesát"]; - static readonly string[] UnitsMap = ["nula", "jeden", "dva", "tři", "čtyři", "pět", "šest", "sedm", "osm", "devět", "deset", "jedenáct", "dvanáct", "třináct", "čtrnáct", "patnáct", "šestnáct", "sedmnáct", "osmnáct", "devatenáct"]; - - static readonly string[] UnitsMasculineOverrideMap = ["jeden", "dva"]; - static readonly string[] UnitsFeminineOverrideMap = ["jedna", "dvě"]; - static readonly string[] UnitsNeuterOverride = ["jedno", "dvě"]; - static readonly string[] UnitsIntraOverride = ["jedna", "dva"]; - - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) - { if (number == 0) { return UnitByGender(number, gender); @@ -38,11 +38,11 @@ public override string Convert(long number, GrammaticalGender gender, bool addAn return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) => - number.ToString(culture); + public override string ConvertToOrdinal(int number, GrammaticalGender gender) => + number.ToString(culture); - static string UnitByGender(long number, GrammaticalGender? gender) - { + static string UnitByGender(long number, GrammaticalGender? gender) + { if (number != 1 && number != 2) { return UnitsMap[number]; @@ -58,8 +58,8 @@ static string UnitByGender(long number, GrammaticalGender? gender) }; } - static void CollectLessThanThousand(List parts, long number, GrammaticalGender? gender) - { + static void CollectLessThanThousand(List parts, long number, GrammaticalGender? gender) + { if (number >= 100) { parts.Add(HundredsMap[number / 100]); @@ -78,8 +78,8 @@ static void CollectLessThanThousand(List parts, long number, Grammatical } } - static void CollectThousandAndAbove(List parts, ref long number, long divisor, GrammaticalGender gender, string[] map) - { + static void CollectThousandAndAbove(List parts, ref long number, long divisor, GrammaticalGender gender, string[] map) + { var n = number / divisor; if (n <= 0) @@ -106,5 +106,4 @@ static void CollectThousandAndAbove(List parts, ref long number, long di number %= divisor; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs index f5619c34d..639056ea5 100644 --- a/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/DefaultNumberToWordsConverter.cs @@ -1,28 +1,27 @@ -namespace Humanizer +namespace Humanizer; + +class DefaultNumberToWordsConverter : GenderlessNumberToWordsConverter { - class DefaultNumberToWordsConverter : GenderlessNumberToWordsConverter - { - readonly CultureInfo? _culture; + readonly CultureInfo? _culture; - /// - /// Constructor. - /// - /// Culture to use. - public DefaultNumberToWordsConverter(CultureInfo? culture) => - _culture = culture; + /// + /// Constructor. + /// + /// Culture to use. + public DefaultNumberToWordsConverter(CultureInfo? culture) => + _culture = culture; - /// - /// 3501.ToWords() -> "three thousand five hundred and one" - /// - /// Number to be turned to words - public override string Convert(long number) => - number.ToString(_culture); + /// + /// 3501.ToWords() -> "three thousand five hundred and one" + /// + /// Number to be turned to words + public override string Convert(long number) => + number.ToString(_culture); - /// - /// 1.ToOrdinalWords() -> "first" - /// - /// Number to be turned to ordinal words - public override string ConvertToOrdinal(int number) => - number.ToString(_culture); - } -} + /// + /// 1.ToOrdinalWords() -> "first" + /// + /// Number to be turned to ordinal words + public override string ConvertToOrdinal(int number) => + number.ToString(_culture); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs index 8a3f7f515..36d3b61f0 100644 --- a/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/DutchNumberToWordsConverter.cs @@ -1,39 +1,39 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Dutch spelling of numbers is not really officially regulated. +/// There are a few different rules that can be applied. +/// Used the rules as stated here. +/// http://www.beterspellen.nl/website/?pag=110 +/// +class DutchNumberToWordsConverter : + GenderlessNumberToWordsConverter { - /// - /// Dutch spelling of numbers is not really officially regulated. - /// There are a few different rules that can be applied. - /// Used the rules as stated here. - /// http://www.beterspellen.nl/website/?pag=110 - /// - class DutchNumberToWordsConverter : - GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["nul", "een", "twee", "drie", "vier", "vijf", "zes", "zeven", "acht", "negen", "tien", "elf", "twaalf", "dertien", "veertien", "vijftien", "zestien", "zeventien", "achttien", "negentien"]; + static readonly string[] TensMap = ["nul", "tien", "twintig", "dertig", "veertig", "vijftig", "zestig", "zeventig", "tachtig", "negentig"]; + + class Fact { - static readonly string[] UnitsMap = ["nul", "een", "twee", "drie", "vier", "vijf", "zes", "zeven", "acht", "negen", "tien", "elf", "twaalf", "dertien", "veertien", "vijftien", "zestien", "zeventien", "achttien", "negentien"]; - static readonly string[] TensMap = ["nul", "tien", "twintig", "dertig", "veertig", "vijftig", "zestig", "zeventig", "tachtig", "negentig"]; - - class Fact - { - public long Value { get; set; } - public required string Name { get; set; } - public required string Prefix { get; set; } - public required string Postfix { get; set; } - public bool DisplayOneUnit { get; set; } - } + public long Value { get; set; } + public required string Name { get; set; } + public required string Prefix { get; set; } + public required string Postfix { get; set; } + public bool DisplayOneUnit { get; set; } + } - static readonly Fact[] Hunderds = - [ - new() {Value = 1_000_000_000_000_000_000L, Name = "triljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, - new() {Value = 1_000_000_000_000_000L, Name = "biljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, - new() {Value = 1_000_000_000_000L, Name = "biljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, - new() {Value = 1000000000, Name = "miljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, - new() {Value = 1000000, Name = "miljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, - new() {Value = 1000, Name = "duizend", Prefix = "", Postfix = " ", DisplayOneUnit = false}, - new() {Value = 100, Name = "honderd", Prefix = "", Postfix = "", DisplayOneUnit = false} - ]; - - public override string Convert(long input) - { + static readonly Fact[] Hunderds = + [ + new() {Value = 1_000_000_000_000_000_000L, Name = "triljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, + new() {Value = 1_000_000_000_000_000L, Name = "biljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, + new() {Value = 1_000_000_000_000L, Name = "biljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, + new() {Value = 1000000000, Name = "miljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, + new() {Value = 1000000, Name = "miljoen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, + new() {Value = 1000, Name = "duizend", Prefix = "", Postfix = " ", DisplayOneUnit = false}, + new() {Value = 100, Name = "honderd", Prefix = "", Postfix = "", DisplayOneUnit = false} + ]; + + public override string Convert(long input) + { var number = input; if (number == 0) @@ -99,17 +99,17 @@ public override string Convert(long input) return word; } - static readonly Dictionary OrdinalExceptions = new() - { - {"een", "eerste"}, - {"drie", "derde"}, - {"miljoen", "miljoenste"}, - }; + static readonly Dictionary OrdinalExceptions = new() + { + {"een", "eerste"}, + {"drie", "derde"}, + {"miljoen", "miljoenste"}, + }; - static readonly char[] EndingCharForSte = ['t', 'g', 'd']; + static readonly char[] EndingCharForSte = ['t', 'g', 'd']; - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var word = Convert(number); foreach (var kv in OrdinalExceptions.Where(kv => word.EndsWith(kv.Key))) @@ -128,5 +128,4 @@ public override string ConvertToOrdinal(int number) return word + "de"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs index 4068c2bc3..dfcb2843b 100644 --- a/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs @@ -1,33 +1,33 @@ -namespace Humanizer +namespace Humanizer; + +class EnglishNumberToWordsConverter : GenderlessNumberToWordsConverter { - class EnglishNumberToWordsConverter : GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; + static readonly string[] TensMap = ["zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; + + static readonly Dictionary OrdinalExceptions = new() + { + {1, "first"}, + {2, "second"}, + {3, "third"}, + {4, "fourth"}, + {5, "fifth"}, + {8, "eighth"}, + {9, "ninth"}, + {12, "twelfth"}, + }; + + public override string Convert(long number) => + Convert(number, false); + + public override string Convert(long number, bool addAnd = true) => + Convert(number, false, addAnd); + + public override string ConvertToOrdinal(int number) => + Convert(number, true); + + string Convert(long number, bool isOrdinal, bool addAnd = true) { - static readonly string[] UnitsMap = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; - static readonly string[] TensMap = ["zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; - - static readonly Dictionary OrdinalExceptions = new() - { - {1, "first"}, - {2, "second"}, - {3, "third"}, - {4, "fourth"}, - {5, "fifth"}, - {8, "eighth"}, - {9, "ninth"}, - {12, "twelfth"}, - }; - - public override string Convert(long number) => - Convert(number, false); - - public override string Convert(long number, bool addAnd = true) => - Convert(number, false, addAnd); - - public override string ConvertToOrdinal(int number) => - Convert(number, true); - - string Convert(long number, bool isOrdinal, bool addAnd = true) - { if (number == 0) { return GetUnitValue(0, isOrdinal); @@ -123,8 +123,8 @@ string Convert(long number, bool isOrdinal, bool addAnd = true) return toWords; } - static string GetUnitValue(long number, bool isOrdinal) - { + static string GetUnitValue(long number, bool isOrdinal) + { if (isOrdinal) { if (ExceptionNumbersToWords(number, out var exceptionString)) @@ -138,8 +138,8 @@ static string GetUnitValue(long number, bool isOrdinal) return UnitsMap[number]; } - static string RemoveOnePrefix(string toWords) - { + static string RemoveOnePrefix(string toWords) + { // one hundred => hundredth if (toWords.StartsWith("one", StringComparison.Ordinal)) { @@ -149,11 +149,11 @@ static string RemoveOnePrefix(string toWords) return toWords; } - static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); + static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); - public override string ConvertToTuple(int number) - { + public override string ConvertToTuple(int number) + { switch (number) { case 1: @@ -184,5 +184,4 @@ public override string ConvertToTuple(int number) return $"{number}-tuple"; } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs index 1e2d0f081..54af41c61 100644 --- a/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FarsiNumberToWordsConverter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class FarsiNumberToWordsConverter : GenderlessNumberToWordsConverter { - class FarsiNumberToWordsConverter : GenderlessNumberToWordsConverter - { - static readonly string[] FarsiHundredsMap = ["صفر", "صد", "دویست", "سیصد", "چهارصد", "پانصد", "ششصد", "هفتصد", "هشتصد", "نهصد"]; - static readonly string[] FarsiTensMap = ["صفر", "ده", "بیست", "سی", "چهل", "پنجاه", "شصت", "هفتاد", "هشتاد", "نود"]; - static readonly string[] FarsiUnitsMap = ["صفر", "یک", "دو", "سه", "چهار", "پنج", "شش", "هفت", "هشت", "نه", "ده", "یازده", "دوازده", "سیزده", "چهارده", "پانزده", "شانزده", "هفده", "هجده", "نوزده"]; + static readonly string[] FarsiHundredsMap = ["صفر", "صد", "دویست", "سیصد", "چهارصد", "پانصد", "ششصد", "هفتصد", "هشتصد", "نهصد"]; + static readonly string[] FarsiTensMap = ["صفر", "ده", "بیست", "سی", "چهل", "پنجاه", "شصت", "هفتاد", "هشتاد", "نود"]; + static readonly string[] FarsiUnitsMap = ["صفر", "یک", "دو", "سه", "چهار", "پنج", "شش", "هفت", "هشت", "نه", "ده", "یازده", "دوازده", "سیزده", "چهارده", "پانزده", "شانزده", "هفده", "هجده", "نوزده"]; - public override string Convert(long number) - { + public override string Convert(long number) + { if (number < 0) { return $"منفی {Convert(-number)}"; @@ -53,8 +53,8 @@ public override string Convert(long number) return string.Join(" و ", parts); } - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { if (number == 1) { return "اول"; @@ -73,5 +73,4 @@ public override string ConvertToOrdinal(int number) var word = Convert(number); return $"{word}{(word.EndsWith("ی") ? " ام" : "م")}"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs index ebff81760..5dd488c2e 100644 --- a/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FinnishNumberToWordsConverter.cs @@ -1,152 +1,151 @@ -namespace Humanizer +namespace Humanizer; + +class FinnishNumberToWordsConverter : GenderlessNumberToWordsConverter { - class FinnishNumberToWordsConverter : GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["nolla", "yksi", "kaksi", "kolme", "neljä", "viisi", "kuusi", "seitsemän", "kahdeksan", "yhdeksän", "kymmenen"]; + static readonly string[] OrdinalUnitsMap = ["nollas", "ensimmäinen", "toinen", "kolmas", "neljäs", "viides", "kuudes", "seitsemäs", "kahdeksas", "yhdeksäs", "kymmenes"]; + + static readonly Dictionary OrdinalExceptions = new() + { + {1, "yhdes" }, + {2, "kahdes" } + }; + + public override string Convert(long input) + { + if (input is > int.MaxValue or < int.MinValue) + { + throw new NotImplementedException(); + } + var number = (int)input; + + if (number < 0) + { + return $"miinus {Convert(-number)}"; + } + + if (number == 0) + { + return UnitsMap[0]; + } + + var parts = new List(); + + if (number / 1000000000 > 0) + { + parts.Add(number / 1000000000 == 1 + ? "miljardi " + : $"{Convert(number / 1000000000)}miljardia "); + + number %= 1000000000; + } + + if (number / 1000000 > 0) + { + parts.Add(number / 1000000 == 1 + ? "miljoona " + : $"{Convert(number / 1000000)}miljoonaa "); + + number %= 1000000; + } + + if (number / 1000 > 0) + { + parts.Add(number / 1000 == 1 + ? "tuhat " + : $"{Convert(number / 1000)}tuhatta "); + + number %= 1000; + } + + if (number / 100 > 0) + { + parts.Add(number / 100 == 1 + ? "sata" + : $"{Convert(number / 100)}sataa"); + + number %= 100; + } + + if (number >= 20) + { + parts.Add($"{Convert(number / 10)}kymmentä"); + number %= 10; + } + else if (number is > 10 and < 20) + { + parts.Add($"{UnitsMap[number % 10]}toista"); + } + + if (number is > 0 and <= 10) + { + parts.Add(UnitsMap[number]); + } + + return string.Concat( parts).Trim(); + } + + static string GetOrdinalUnit(int number, bool useExceptions) + { + if (useExceptions && OrdinalExceptions.TryGetValue(number, out var unit)) + { + return unit; + } + + return OrdinalUnitsMap[number]; + } + + static string ToOrdinal(int number, bool useExceptions) { - static readonly string[] UnitsMap = ["nolla", "yksi", "kaksi", "kolme", "neljä", "viisi", "kuusi", "seitsemän", "kahdeksan", "yhdeksän", "kymmenen"]; - static readonly string[] OrdinalUnitsMap = ["nollas", "ensimmäinen", "toinen", "kolmas", "neljäs", "viides", "kuudes", "seitsemäs", "kahdeksas", "yhdeksäs", "kymmenes"]; + if (number == 0) + { + return OrdinalUnitsMap[0]; + } + + var parts = new List(); + + if (number / 1000000000 > 0) + { + parts.Add($"{(number / 1000000000 == 1 ? "" : ToOrdinal(number / 1000000000, true))}miljardis"); + number %= 1000000000; + } - static readonly Dictionary OrdinalExceptions = new() + if (number / 1000000 > 0) { - {1, "yhdes" }, - {2, "kahdes" } - }; + parts.Add($"{(number / 1000000 == 1 ? "" : ToOrdinal(number / 1000000, true))}miljoonas"); + number %= 1000000; + } - public override string Convert(long input) + if (number / 1000 > 0) { - if (input is > int.MaxValue or < int.MinValue) - { - throw new NotImplementedException(); - } - var number = (int)input; + parts.Add($"{(number / 1000 == 1 ? "" : ToOrdinal(number / 1000, true))}tuhannes"); + number %= 1000; + } - if (number < 0) - { - return $"miinus {Convert(-number)}"; - } + if (number / 100 > 0) + { + parts.Add($"{(number / 100 == 1 ? "" : ToOrdinal(number / 100, true))}sadas"); + number %= 100; + } - if (number == 0) - { - return UnitsMap[0]; - } + if (number >= 20) + { + parts.Add($"{ToOrdinal(number / 10, true)}kymmenes"); + number %= 10; + } + else if (number is > 10 and < 20) + { + parts.Add($"{GetOrdinalUnit(number % 10, true)}toista"); + } - var parts = new List(); - - if (number / 1000000000 > 0) - { - parts.Add(number / 1000000000 == 1 - ? "miljardi " - : $"{Convert(number / 1000000000)}miljardia "); - - number %= 1000000000; - } - - if (number / 1000000 > 0) - { - parts.Add(number / 1000000 == 1 - ? "miljoona " - : $"{Convert(number / 1000000)}miljoonaa "); - - number %= 1000000; - } - - if (number / 1000 > 0) - { - parts.Add(number / 1000 == 1 - ? "tuhat " - : $"{Convert(number / 1000)}tuhatta "); - - number %= 1000; - } - - if (number / 100 > 0) - { - parts.Add(number / 100 == 1 - ? "sata" - : $"{Convert(number / 100)}sataa"); - - number %= 100; - } - - if (number >= 20) - { - parts.Add($"{Convert(number / 10)}kymmentä"); - number %= 10; - } - else if (number is > 10 and < 20) - { - parts.Add($"{UnitsMap[number % 10]}toista"); - } - - if (number is > 0 and <= 10) - { - parts.Add(UnitsMap[number]); - } - - return string.Concat( parts).Trim(); - } - - static string GetOrdinalUnit(int number, bool useExceptions) - { - if (useExceptions && OrdinalExceptions.TryGetValue(number, out var unit)) - { - return unit; - } - - return OrdinalUnitsMap[number]; - } - - static string ToOrdinal(int number, bool useExceptions) - { - if (number == 0) - { - return OrdinalUnitsMap[0]; - } - - var parts = new List(); - - if (number / 1000000000 > 0) - { - parts.Add($"{(number / 1000000000 == 1 ? "" : ToOrdinal(number / 1000000000, true))}miljardis"); - number %= 1000000000; - } - - if (number / 1000000 > 0) - { - parts.Add($"{(number / 1000000 == 1 ? "" : ToOrdinal(number / 1000000, true))}miljoonas"); - number %= 1000000; - } - - if (number / 1000 > 0) - { - parts.Add($"{(number / 1000 == 1 ? "" : ToOrdinal(number / 1000, true))}tuhannes"); - number %= 1000; - } - - if (number / 100 > 0) - { - parts.Add($"{(number / 100 == 1 ? "" : ToOrdinal(number / 100, true))}sadas"); - number %= 100; - } - - if (number >= 20) - { - parts.Add($"{ToOrdinal(number / 10, true)}kymmenes"); - number %= 10; - } - else if (number is > 10 and < 20) - { - parts.Add($"{GetOrdinalUnit(number % 10, true)}toista"); - } - - if (number is > 0 and <= 10) - { - parts.Add(GetOrdinalUnit(number, useExceptions)); - } - - return string.Concat(parts); - } + if (number is > 0 and <= 10) + { + parts.Add(GetOrdinalUnit(number, useExceptions)); + } - public override string ConvertToOrdinal(int number) => - ToOrdinal(number, false); + return string.Concat(parts); } -} + + public override string ConvertToOrdinal(int number) => + ToOrdinal(number, false); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/FrenchBelgianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FrenchBelgianNumberToWordsConverter.cs index a211e3a23..6e7950693 100644 --- a/src/Humanizer/Localisation/NumberToWords/FrenchBelgianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FrenchBelgianNumberToWordsConverter.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class FrenchBelgianNumberToWordsConverter : FrenchNumberToWordsConverterBase { - class FrenchBelgianNumberToWordsConverter : FrenchNumberToWordsConverterBase + protected override void CollectPartsUnderAHundred(ICollection parts, ref long number, GrammaticalGender gender, bool pluralize) { - protected override void CollectPartsUnderAHundred(ICollection parts, ref long number, GrammaticalGender gender, bool pluralize) - { if (number == 80) { parts.Add(pluralize ? "quatre-vingts" : "quatre-vingt"); @@ -18,8 +18,8 @@ protected override void CollectPartsUnderAHundred(ICollection parts, ref } } - protected override string GetTens(long tens) - { + protected override string GetTens(long tens) + { if (tens == 8) { return "quatre-vingt"; @@ -27,5 +27,4 @@ protected override string GetTens(long tens) return base.GetTens(tens); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs index 84948f240..dba930d1a 100644 --- a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverter.cs @@ -1,38 +1,37 @@ -namespace Humanizer +namespace Humanizer; + +class FrenchNumberToWordsConverter : FrenchNumberToWordsConverterBase { - class FrenchNumberToWordsConverter : FrenchNumberToWordsConverterBase + protected override void CollectPartsUnderAHundred(ICollection parts, ref long number, GrammaticalGender gender, bool pluralize) { - protected override void CollectPartsUnderAHundred(ICollection parts, ref long number, GrammaticalGender gender, bool pluralize) + if (number == 71) { - if (number == 71) - { - parts.Add("soixante et onze"); - } - else if (number == 80) - { - parts.Add(pluralize ? "quatre-vingts" : "quatre-vingt"); - } - else if (number >= 70) - { - var @base = number < 80 ? 60 : 80; - var units = number - @base; - var tens = @base / 10; - parts.Add($"{GetTens(tens)}-{GetUnits(units, gender)}"); - } - else - { - base.CollectPartsUnderAHundred(parts, ref number, gender, pluralize); - } + parts.Add("soixante et onze"); } - - protected override string GetTens(long tens) + else if (number == 80) + { + parts.Add(pluralize ? "quatre-vingts" : "quatre-vingt"); + } + else if (number >= 70) + { + var @base = number < 80 ? 60 : 80; + var units = number - @base; + var tens = @base / 10; + parts.Add($"{GetTens(tens)}-{GetUnits(units, gender)}"); + } + else { - if (tens == 8) - { - return "quatre-vingt"; - } + base.CollectPartsUnderAHundred(parts, ref number, gender, pluralize); + } + } - return base.GetTens(tens); + protected override string GetTens(long tens) + { + if (tens == 8) + { + return "quatre-vingt"; } + + return base.GetTens(tens); } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs index 0f2562b05..7a08a98b8 100644 --- a/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs +++ b/src/Humanizer/Localisation/NumberToWords/FrenchNumberToWordsConverterBase.cs @@ -1,191 +1,190 @@ -namespace Humanizer +namespace Humanizer; + +abstract class FrenchNumberToWordsConverterBase : GenderedNumberToWordsConverter { - abstract class FrenchNumberToWordsConverterBase : GenderedNumberToWordsConverter + static readonly string[] UnitsMap = ["zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf"]; + static readonly string[] TensMap = ["zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "septante", "octante", "nonante"]; + + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] UnitsMap = ["zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf"]; - static readonly string[] TensMap = ["zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "septante", "octante", "nonante"]; + if (number == 0) + { + return UnitsMap[0]; + } + + var parts = new List(); - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) + if (number < 0) { - if (number == 0) - { - return UnitsMap[0]; - } + parts.Add("moins"); + number = -number; + } - var parts = new List(); + CollectParts(parts, ref number, 1000000000000000000, "trillion"); + CollectParts(parts, ref number, 1000000000000000, "billiard"); + CollectParts(parts, ref number, 1000000000000, "billion"); + CollectParts(parts, ref number, 1000000000, "milliard"); + CollectParts(parts, ref number, 1000000, "million"); + CollectThousands(parts, ref number, 1000, "mille"); - if (number < 0) - { - parts.Add("moins"); - number = -number; - } + CollectPartsUnderAThousand(parts, number, gender, true); + + return string.Join(" ", parts); + } - CollectParts(parts, ref number, 1000000000000000000, "trillion"); - CollectParts(parts, ref number, 1000000000000000, "billiard"); - CollectParts(parts, ref number, 1000000000000, "billion"); - CollectParts(parts, ref number, 1000000000, "milliard"); - CollectParts(parts, ref number, 1000000, "million"); - CollectThousands(parts, ref number, 1000, "mille"); + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { + if (number == 1) + { + return gender == GrammaticalGender.Feminine ? "première" : "premier"; + } - CollectPartsUnderAThousand(parts, number, gender, true); + var convertedNumber = Convert(number); - return string.Join(" ", parts); + if (convertedNumber.EndsWith("s") && !convertedNumber.EndsWith("trois")) + { + convertedNumber = convertedNumber.TrimEnd('s'); + } + else if (convertedNumber.EndsWith("cinq")) + { + convertedNumber += "u"; + } + else if (convertedNumber.EndsWith("neuf")) + { + convertedNumber = convertedNumber.TrimEnd('f') + "v"; } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) + if (convertedNumber.StartsWith("un ")) { - if (number == 1) - { - return gender == GrammaticalGender.Feminine ? "première" : "premier"; - } + convertedNumber = convertedNumber.Remove(0, 3); + } - var convertedNumber = Convert(number); + if (number == 0) + { + convertedNumber += "t"; + } - if (convertedNumber.EndsWith("s") && !convertedNumber.EndsWith("trois")) - { - convertedNumber = convertedNumber.TrimEnd('s'); - } - else if (convertedNumber.EndsWith("cinq")) - { - convertedNumber += "u"; - } - else if (convertedNumber.EndsWith("neuf")) - { - convertedNumber = convertedNumber.TrimEnd('f') + "v"; - } + convertedNumber = convertedNumber.TrimEnd('e'); + convertedNumber += "ième"; + return convertedNumber; + } - if (convertedNumber.StartsWith("un ")) - { - convertedNumber = convertedNumber.Remove(0, 3); - } + protected static string GetUnits(long number, GrammaticalGender gender) + { + if (number == 1 && gender == GrammaticalGender.Feminine) + { + return "une"; + } - if (number == 0) - { - convertedNumber += "t"; - } + return UnitsMap[number]; + } - convertedNumber = convertedNumber.TrimEnd('e'); - convertedNumber += "ième"; - return convertedNumber; + static void CollectHundreds(ICollection parts, ref long number, long d, string form, bool pluralize) + { + if (number < d) + { + return; } - protected static string GetUnits(long number, GrammaticalGender gender) + var result = number / d; + if (result == 1) { - if (number == 1 && gender == GrammaticalGender.Feminine) - { - return "une"; - } - - return UnitsMap[number]; + parts.Add(form); } - - static void CollectHundreds(ICollection parts, ref long number, long d, string form, bool pluralize) + else { - if (number < d) - { - return; - } - - var result = number / d; - if (result == 1) + parts.Add(GetUnits(result, GrammaticalGender.Masculine)); + if (number % d == 0 && pluralize) { - parts.Add(form); + parts.Add(form + "s"); } else { - parts.Add(GetUnits(result, GrammaticalGender.Masculine)); - if (number % d == 0 && pluralize) - { - parts.Add(form + "s"); - } - else - { - parts.Add(form); - } + parts.Add(form); } - - number %= d; } - void CollectParts(ICollection parts, ref long number, long d, string form) - { - if (number < d) - { - return; - } + number %= d; + } - var result = number / d; + void CollectParts(ICollection parts, ref long number, long d, string form) + { + if (number < d) + { + return; + } - CollectPartsUnderAThousand(parts, result, GrammaticalGender.Masculine, true); + var result = number / d; - if (result == 1) - { - parts.Add(form); - } - else - { - parts.Add(form + "s"); - } + CollectPartsUnderAThousand(parts, result, GrammaticalGender.Masculine, true); - number %= d; + if (result == 1) + { + parts.Add(form); + } + else + { + parts.Add(form + "s"); } - void CollectPartsUnderAThousand(ICollection parts, long number, GrammaticalGender gender, bool pluralize) + number %= d; + } + + void CollectPartsUnderAThousand(ICollection parts, long number, GrammaticalGender gender, bool pluralize) + { + CollectHundreds(parts, ref number, 100, "cent", pluralize); + + if (number > 0) { - CollectHundreds(parts, ref number, 100, "cent", pluralize); + CollectPartsUnderAHundred(parts, ref number, gender, pluralize); + } + } - if (number > 0) - { - CollectPartsUnderAHundred(parts, ref number, gender, pluralize); - } + void CollectThousands(ICollection parts, ref long number, int d, string form) + { + if (number < d) + { + return; } - void CollectThousands(ICollection parts, ref long number, int d, string form) + var result = number / d; + if (result > 1) { - if (number < d) - { - return; - } + CollectPartsUnderAThousand(parts, result, GrammaticalGender.Masculine, false); + } - var result = number / d; - if (result > 1) - { - CollectPartsUnderAThousand(parts, result, GrammaticalGender.Masculine, false); - } + parts.Add(form); - parts.Add(form); + number %= d; + } - number %= d; + protected virtual void CollectPartsUnderAHundred(ICollection parts, ref long number, GrammaticalGender gender, bool pluralize) + { + if (number < 20) + { + parts.Add(GetUnits(number, gender)); } - - protected virtual void CollectPartsUnderAHundred(ICollection parts, ref long number, GrammaticalGender gender, bool pluralize) + else { - if (number < 20) + var units = number % 10; + var tens = GetTens(number / 10); + if (units == 0) + { + parts.Add(tens); + } + else if (units == 1) { - parts.Add(GetUnits(number, gender)); + parts.Add(tens); + parts.Add("et"); + parts.Add(GetUnits(1, gender)); } else { - var units = number % 10; - var tens = GetTens(number / 10); - if (units == 0) - { - parts.Add(tens); - } - else if (units == 1) - { - parts.Add(tens); - parts.Add("et"); - parts.Add(GetUnits(1, gender)); - } - else - { - parts.Add($"{tens}-{GetUnits(units, gender)}"); - } + parts.Add($"{tens}-{GetUnits(units, gender)}"); } } - - protected virtual string GetTens(long tens) => - TensMap[tens]; } -} + + protected virtual string GetTens(long tens) => + TensMap[tens]; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs index 25b5645d7..b616af754 100644 --- a/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GenderedNumberToWordsConverter.cs @@ -1,52 +1,51 @@ -namespace Humanizer +namespace Humanizer; + +abstract class GenderedNumberToWordsConverter : INumberToWordsConverter { - abstract class GenderedNumberToWordsConverter : INumberToWordsConverter - { - readonly GrammaticalGender _defaultGender; + readonly GrammaticalGender _defaultGender; - protected GenderedNumberToWordsConverter(GrammaticalGender defaultGender = GrammaticalGender.Masculine) => - _defaultGender = defaultGender; + protected GenderedNumberToWordsConverter(GrammaticalGender defaultGender = GrammaticalGender.Masculine) => + _defaultGender = defaultGender; - /// - public string Convert(long number) => - Convert(number, _defaultGender); + /// + public string Convert(long number) => + Convert(number, _defaultGender); - /// - public string Convert(long number, WordForm wordForm) => - Convert(number, wordForm, _defaultGender); + /// + public string Convert(long number, WordForm wordForm) => + Convert(number, wordForm, _defaultGender); - /// - public string Convert(long number, bool addAnd) => - Convert(number, _defaultGender); + /// + public string Convert(long number, bool addAnd) => + Convert(number, _defaultGender); - /// - public string Convert(long number, bool addAnd, WordForm wordForm) => - Convert(number, wordForm, _defaultGender, addAnd); + /// + public string Convert(long number, bool addAnd, WordForm wordForm) => + Convert(number, wordForm, _defaultGender, addAnd); - /// - public abstract string Convert(long number, GrammaticalGender gender, bool addAnd = true); + /// + public abstract string Convert(long number, GrammaticalGender gender, bool addAnd = true); - /// - public virtual string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true) => - Convert(number, gender, addAnd); + /// + public virtual string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true) => + Convert(number, gender, addAnd); - /// - public string ConvertToOrdinal(int number) => - ConvertToOrdinal(number, _defaultGender); + /// + public string ConvertToOrdinal(int number) => + ConvertToOrdinal(number, _defaultGender); - /// - public abstract string ConvertToOrdinal(int number, GrammaticalGender gender); + /// + public abstract string ConvertToOrdinal(int number, GrammaticalGender gender); - /// - public string ConvertToOrdinal(int number, WordForm wordForm) => - ConvertToOrdinal(number, _defaultGender, wordForm); + /// + public string ConvertToOrdinal(int number, WordForm wordForm) => + ConvertToOrdinal(number, _defaultGender, wordForm); - /// - public virtual string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm) => - ConvertToOrdinal(number, gender); + /// + public virtual string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm) => + ConvertToOrdinal(number, gender); - /// - public virtual string ConvertToTuple(int number) => - Convert(number); - } -} + /// + public virtual string ConvertToTuple(int number) => + Convert(number); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs index 2b5ae4b79..f96026e49 100644 --- a/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GenderlessNumberToWordsConverter.cs @@ -1,37 +1,36 @@ -namespace Humanizer +namespace Humanizer; + +abstract class GenderlessNumberToWordsConverter : INumberToWordsConverter { - abstract class GenderlessNumberToWordsConverter : INumberToWordsConverter - { - /// - public abstract string Convert(long number); + /// + public abstract string Convert(long number); - public string Convert(long number, WordForm wordForm) => - Convert(number); + public string Convert(long number, WordForm wordForm) => + Convert(number); - public virtual string Convert(long number, bool addAnd) => - Convert(number); + public virtual string Convert(long number, bool addAnd) => + Convert(number); - public string Convert(long number, bool addAnd, WordForm wordForm) => - Convert(number, wordForm); + public string Convert(long number, bool addAnd, WordForm wordForm) => + Convert(number, wordForm); - public virtual string Convert(long number, GrammaticalGender gender, bool addAnd = true) => - Convert(number); + public virtual string Convert(long number, GrammaticalGender gender, bool addAnd = true) => + Convert(number); - public virtual string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true) => - Convert(number, addAnd, wordForm); + public virtual string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true) => + Convert(number, addAnd, wordForm); - public abstract string ConvertToOrdinal(int number); + public abstract string ConvertToOrdinal(int number); - public string ConvertToOrdinal(int number, GrammaticalGender gender) => - ConvertToOrdinal(number); + public string ConvertToOrdinal(int number, GrammaticalGender gender) => + ConvertToOrdinal(number); - public virtual string ConvertToOrdinal(int number, WordForm wordForm) => - ConvertToOrdinal(number); + public virtual string ConvertToOrdinal(int number, WordForm wordForm) => + ConvertToOrdinal(number); - public virtual string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm) => - ConvertToOrdinal(number, wordForm); + public virtual string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm) => + ConvertToOrdinal(number, wordForm); - public virtual string ConvertToTuple(int number) => - Convert(number); - } -} + public virtual string ConvertToTuple(int number) => + Convert(number); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverterBase.cs b/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverterBase.cs index 92a4b4b06..bba41e8f1 100644 --- a/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverterBase.cs +++ b/src/Humanizer/Localisation/NumberToWords/GermanNumberToWordsConverterBase.cs @@ -1,155 +1,154 @@ -namespace Humanizer +namespace Humanizer; + +abstract class GermanNumberToWordsConverterBase : GenderedNumberToWordsConverter { - abstract class GermanNumberToWordsConverterBase : GenderedNumberToWordsConverter + readonly string[] UnitsMap = ["null", "ein", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"]; + readonly string[] TensMap = ["null", "zehn", "zwanzig", "dreißig", "vierzig", "fünfzig", "sechzig", "siebzig", "achtzig", "neunzig"]; + readonly string[] UnitsOrdinal = [string.Empty, "ers", "zwei", "drit", "vier", "fünf", "sechs", "sieb", "ach", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"]; + readonly string[] HundredOrdinalSingular = ["einhundert"]; + readonly string[] HundredOrdinalPlural = ["{0}hundert"]; + readonly string[] ThousandOrdinalSingular = ["eintausend"]; + readonly string[] ThousandOrdinalPlural = ["{0}tausend"]; + readonly string[] MillionOrdinalSingular = ["einmillion", "einemillion"]; + readonly string[] MillionOrdinalPlural = ["{0}million", "{0}millionen"]; + readonly string[] BillionOrdinalSingular = ["einmilliard", "einemilliarde"]; + readonly string[] BillionOrdinalPlural = ["{0}milliard", "{0}milliarden"]; + + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) { - readonly string[] UnitsMap = ["null", "ein", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"]; - readonly string[] TensMap = ["null", "zehn", "zwanzig", "dreißig", "vierzig", "fünfzig", "sechzig", "siebzig", "achtzig", "neunzig"]; - readonly string[] UnitsOrdinal = [string.Empty, "ers", "zwei", "drit", "vier", "fünf", "sechs", "sieb", "ach", "neun", "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn"]; - readonly string[] HundredOrdinalSingular = ["einhundert"]; - readonly string[] HundredOrdinalPlural = ["{0}hundert"]; - readonly string[] ThousandOrdinalSingular = ["eintausend"]; - readonly string[] ThousandOrdinalPlural = ["{0}tausend"]; - readonly string[] MillionOrdinalSingular = ["einmillion", "einemillion"]; - readonly string[] MillionOrdinalPlural = ["{0}million", "{0}millionen"]; - readonly string[] BillionOrdinalSingular = ["einmilliard", "einemilliarde"]; - readonly string[] BillionOrdinalPlural = ["{0}milliard", "{0}milliarden"]; - - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) + if (number == 0) { - if (number == 0) - { - return UnitsMap[number]; - } + return UnitsMap[number]; + } - var parts = new List(); - if (number < 0) - { - parts.Add("minus "); - number = -number; - } + var parts = new List(); + if (number < 0) + { + parts.Add("minus "); + number = -number; + } - CollectParts(parts, ref number, 1000000000000000000, true, "{0} Trillionen", "eine Trillion"); - CollectParts(parts, ref number, 1000000000000000, true, "{0} Billiarden", "eine Billiarde"); - CollectParts(parts, ref number, 1000000000000, true, "{0} Billionen", "eine Billion"); - CollectParts(parts, ref number, 1000000000, true, "{0} Milliarden", "eine Milliarde"); - CollectParts(parts, ref number, 1000000, true, "{0} Millionen", "eine Million"); - CollectParts(parts, ref number, 1000, false, "{0}tausend", "eintausend"); - CollectParts(parts, ref number, 100, false, "{0}hundert", "einhundert"); + CollectParts(parts, ref number, 1000000000000000000, true, "{0} Trillionen", "eine Trillion"); + CollectParts(parts, ref number, 1000000000000000, true, "{0} Billiarden", "eine Billiarde"); + CollectParts(parts, ref number, 1000000000000, true, "{0} Billionen", "eine Billion"); + CollectParts(parts, ref number, 1000000000, true, "{0} Milliarden", "eine Milliarde"); + CollectParts(parts, ref number, 1000000, true, "{0} Millionen", "eine Million"); + CollectParts(parts, ref number, 1000, false, "{0}tausend", "eintausend"); + CollectParts(parts, ref number, 100, false, "{0}hundert", "einhundert"); - if (number > 0) + if (number > 0) + { + if (number < 20) { - if (number < 20) + if (number == 1 && gender == GrammaticalGender.Feminine) { - if (number == 1 && gender == GrammaticalGender.Feminine) - { - parts.Add("eine"); - } - else - { - parts.Add(UnitsMap[number]); - } + parts.Add("eine"); } else { - var units = number % 10; - if (units > 0) - { - parts.Add($"{UnitsMap[units]}und"); - } - - parts.Add(GetTens(number / 10)); + parts.Add(UnitsMap[number]); } } - - return string.Concat(parts); - } - - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { - if (number == 0) + else { - return UnitsMap[number] + GetEndingForGender(gender); - } + var units = number % 10; + if (units > 0) + { + parts.Add($"{UnitsMap[units]}und"); + } - var parts = new List(); - if (number < 0) - { - parts.Add("minus "); - number = -number; + parts.Add(GetTens(number / 10)); } + } - CollectOrdinalParts(parts, ref number, 1000000000, true, BillionOrdinalPlural, BillionOrdinalSingular); - CollectOrdinalParts(parts, ref number, 1000000, true, MillionOrdinalPlural, MillionOrdinalSingular); - CollectOrdinalParts(parts, ref number, 1000, false, ThousandOrdinalPlural, ThousandOrdinalSingular); - CollectOrdinalParts(parts, ref number, 100, false, HundredOrdinalPlural, HundredOrdinalSingular); + return string.Concat(parts); + } - if (number > 0) - { - parts.Add(number < 20 ? UnitsOrdinal[number] : Convert(number)); - } + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { + if (number == 0) + { + return UnitsMap[number] + GetEndingForGender(gender); + } - if (number is 0 or >= 20) - { - parts.Add("s"); - } + var parts = new List(); + if (number < 0) + { + parts.Add("minus "); + number = -number; + } - parts.Add(GetEndingForGender(gender)); + CollectOrdinalParts(parts, ref number, 1000000000, true, BillionOrdinalPlural, BillionOrdinalSingular); + CollectOrdinalParts(parts, ref number, 1000000, true, MillionOrdinalPlural, MillionOrdinalSingular); + CollectOrdinalParts(parts, ref number, 1000, false, ThousandOrdinalPlural, ThousandOrdinalSingular); + CollectOrdinalParts(parts, ref number, 100, false, HundredOrdinalPlural, HundredOrdinalSingular); - return string.Concat(parts); + if (number > 0) + { + parts.Add(number < 20 ? UnitsOrdinal[number] : Convert(number)); } - void CollectParts(ICollection parts, ref long number, long divisor, bool addSpaceBeforeNextPart, string pluralFormat, string singular) + if (number is 0 or >= 20) { - if (number / divisor > 0) - { - parts.Add(Part(pluralFormat, singular, number / divisor)); - number %= divisor; - if (addSpaceBeforeNextPart && number > 0) - { - parts.Add(" "); - } - } + parts.Add("s"); } - void CollectOrdinalParts(ICollection parts, ref int number, int divisor, bool evaluateNoRest, string[] pluralFormats, string[] singulars) + parts.Add(GetEndingForGender(gender)); + + return string.Concat(parts); + } + + void CollectParts(ICollection parts, ref long number, long divisor, bool addSpaceBeforeNextPart, string pluralFormat, string singular) + { + if (number / divisor > 0) { - if (number / divisor > 0) + parts.Add(Part(pluralFormat, singular, number / divisor)); + number %= divisor; + if (addSpaceBeforeNextPart && number > 0) { - var noRest = evaluateNoRest ? NoRestIndex(number % divisor) : 0; - parts.Add(Part(pluralFormats[noRest], singulars[noRest], number / divisor)); - number %= divisor; + parts.Add(" "); } } + } - string Part(string pluralFormat, string singular, long number) + void CollectOrdinalParts(ICollection parts, ref int number, int divisor, bool evaluateNoRest, string[] pluralFormats, string[] singulars) + { + if (number / divisor > 0) { - if (number == 1) - { - return singular; - } + var noRest = evaluateNoRest ? NoRestIndex(number % divisor) : 0; + parts.Add(Part(pluralFormats[noRest], singulars[noRest], number / divisor)); + number %= divisor; + } + } - return string.Format(pluralFormat, Convert(number)); + string Part(string pluralFormat, string singular, long number) + { + if (number == 1) + { + return singular; } - static int NoRestIndex(int number) => - number == 0 ? 0 : 1; + return string.Format(pluralFormat, Convert(number)); + } - static string GetEndingForGender(GrammaticalGender gender) + static int NoRestIndex(int number) => + number == 0 ? 0 : 1; + + static string GetEndingForGender(GrammaticalGender gender) + { + switch (gender) { - switch (gender) - { - case GrammaticalGender.Masculine: - return "ter"; - case GrammaticalGender.Feminine: - return "te"; - case GrammaticalGender.Neuter: - return "tes"; - default: - throw new ArgumentOutOfRangeException(nameof(gender)); - } + case GrammaticalGender.Masculine: + return "ter"; + case GrammaticalGender.Feminine: + return "te"; + case GrammaticalGender.Neuter: + return "tes"; + default: + throw new ArgumentOutOfRangeException(nameof(gender)); } - - protected virtual string GetTens(long tens) => - TensMap[tens]; } -} + + protected virtual string GetTens(long tens) => + TensMap[tens]; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/GermanSwissLiechtensteinNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GermanSwissLiechtensteinNumberToWordsConverter.cs index 568ea2574..8db0c9e2a 100644 --- a/src/Humanizer/Localisation/NumberToWords/GermanSwissLiechtensteinNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GermanSwissLiechtensteinNumberToWordsConverter.cs @@ -1,15 +1,14 @@ -namespace Humanizer +namespace Humanizer; + +class GermanSwissLiechtensteinNumberToWordsConverter : GermanNumberToWordsConverterBase { - class GermanSwissLiechtensteinNumberToWordsConverter : GermanNumberToWordsConverterBase + protected override string GetTens(long tens) { - protected override string GetTens(long tens) + if (tens == 3) { - if (tens == 3) - { - return "dreissig"; - } - - return base.GetTens(tens); + return "dreissig"; } + + return base.GetTens(tens); } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/GreekNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/GreekNumberToWordsConverter.cs index 9ff03413c..2ce5f9fbc 100644 --- a/src/Humanizer/Localisation/NumberToWords/GreekNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/GreekNumberToWordsConverter.cs @@ -1,57 +1,57 @@ -namespace Humanizer +namespace Humanizer; + +class GreekNumberToWordsConverter : GenderlessNumberToWordsConverter { - class GreekNumberToWordsConverter : GenderlessNumberToWordsConverter + readonly string[] UnitMap = ["μηδέν", "ένα", "δύο", "τρία", "τέσσερα", "πέντε", "έξι", "επτά", "οκτώ", "εννέα", "δέκα", "έντεκα", "δώδεκα"]; + + readonly string[] UnitsMap = ["μηδέν", "ένα", "δύο", "τρείς", "τέσσερις", "πέντε", "έξι", "επτά", "οκτώ", "εννέα", "δέκα", "έντεκα", "δώδεκα"]; + + readonly string[] TensMap = ["", "δέκα", "είκοσι", "τριάντα", "σαράντα", "πενήντα", "εξήντα", "εβδομήντα", "ογδόντα", "ενενήντα"]; + + readonly string[] TensNoDiacriticsMap = ["", "δεκα", "εικοσι", "τριαντα", "σαραντα", "πενηντα", "εξηντα", "εβδομηντα", "ογδοντα", "ενενηντα"]; + + readonly string[] HundredMap = ["", "εκατό", "διακόσια", "τριακόσια", "τετρακόσια", "πεντακόσια", "εξακόσια", "επτακόσια", "οκτακόσια", "εννιακόσια"]; + + readonly string[] HundredsMap = ["", "εκατόν", "διακόσιες", "τριακόσιες", "τετρακόσιες", "πεντακόσιες", "εξακόσιες", "επτακόσιες", "οκτακόσιες", "εννιακόσιες"]; + + static readonly Dictionary ΟrdinalMap = new() + { + { 0, string.Empty }, + { 1, "πρώτος" }, + { 2, "δεύτερος" }, + { 3, "τρίτος" }, + { 4, "τέταρτος" }, + { 5, "πέμπτος" }, + { 6, "έκτος" }, + { 7, "έβδομος" }, + { 8, "όγδοος" }, + { 9, "ένατος" }, + { 10, "δέκατος" }, + { 20, "εικοστός" }, + { 30, "τριακοστός" }, + { 40, "τεσσαρακοστός" }, + { 50, "πεντηκοστός" }, + { 60, "εξηκοστός" }, + { 70, "εβδομηκοστός" }, + { 80, "ογδοηκοστός" }, + { 90, "ενενηκοστός" }, + { 100, "εκατοστός" }, + { 200, "διακοσιοστός" }, + { 300, "τριακοσιοστός" }, + { 400, "τετρακοσιστός" }, + { 500, "πεντακοσιοστός" }, + { 600, "εξακοσιοστός" }, + { 700, "εφτακοσιοστός" }, + { 800, "οχτακοσιοστός" }, + { 900, "εννιακοσιοστός" }, + { 1000, "χιλιοστός" } + }; + + public override string Convert(long number) => + ConvertImpl(number, false); + + public override string ConvertToOrdinal(int number) { - readonly string[] UnitMap = ["μηδέν", "ένα", "δύο", "τρία", "τέσσερα", "πέντε", "έξι", "επτά", "οκτώ", "εννέα", "δέκα", "έντεκα", "δώδεκα"]; - - readonly string[] UnitsMap = ["μηδέν", "ένα", "δύο", "τρείς", "τέσσερις", "πέντε", "έξι", "επτά", "οκτώ", "εννέα", "δέκα", "έντεκα", "δώδεκα"]; - - readonly string[] TensMap = ["", "δέκα", "είκοσι", "τριάντα", "σαράντα", "πενήντα", "εξήντα", "εβδομήντα", "ογδόντα", "ενενήντα"]; - - readonly string[] TensNoDiacriticsMap = ["", "δεκα", "εικοσι", "τριαντα", "σαραντα", "πενηντα", "εξηντα", "εβδομηντα", "ογδοντα", "ενενηντα"]; - - readonly string[] HundredMap = ["", "εκατό", "διακόσια", "τριακόσια", "τετρακόσια", "πεντακόσια", "εξακόσια", "επτακόσια", "οκτακόσια", "εννιακόσια"]; - - readonly string[] HundredsMap = ["", "εκατόν", "διακόσιες", "τριακόσιες", "τετρακόσιες", "πεντακόσιες", "εξακόσιες", "επτακόσιες", "οκτακόσιες", "εννιακόσιες"]; - - static readonly Dictionary ΟrdinalMap = new() - { - { 0, string.Empty }, - { 1, "πρώτος" }, - { 2, "δεύτερος" }, - { 3, "τρίτος" }, - { 4, "τέταρτος" }, - { 5, "πέμπτος" }, - { 6, "έκτος" }, - { 7, "έβδομος" }, - { 8, "όγδοος" }, - { 9, "ένατος" }, - { 10, "δέκατος" }, - { 20, "εικοστός" }, - { 30, "τριακοστός" }, - { 40, "τεσσαρακοστός" }, - { 50, "πεντηκοστός" }, - { 60, "εξηκοστός" }, - { 70, "εβδομηκοστός" }, - { 80, "ογδοηκοστός" }, - { 90, "ενενηκοστός" }, - { 100, "εκατοστός" }, - { 200, "διακοσιοστός" }, - { 300, "τριακοσιοστός" }, - { 400, "τετρακοσιστός" }, - { 500, "πεντακοσιοστός" }, - { 600, "εξακοσιοστός" }, - { 700, "εφτακοσιοστός" }, - { 800, "οχτακοσιοστός" }, - { 900, "εννιακοσιοστός" }, - { 1000, "χιλιοστός" } - }; - - public override string Convert(long number) => - ConvertImpl(number, false); - - public override string ConvertToOrdinal(int number) - { if (number / 10 == 0) { return GetOneDigitOrdinal(number); @@ -76,8 +76,8 @@ public override string ConvertToOrdinal(int number) return string.Empty; } - static string GetOneDigitOrdinal(int number) - { + static string GetOneDigitOrdinal(int number) + { if (ΟrdinalMap.TryGetValue(number, out var output)) { return output; @@ -86,8 +86,8 @@ static string GetOneDigitOrdinal(int number) return string.Empty; } - static string GetTwoDigitOrdinal(int number) - { + static string GetTwoDigitOrdinal(int number) + { if (number == 11) return "ενδέκατος"; if (number == 12) return "δωδέκατος"; @@ -103,8 +103,8 @@ static string GetTwoDigitOrdinal(int number) return decadesString; } - static string GetThreeDigitOrdinal(int number) - { + static string GetThreeDigitOrdinal(int number) + { var hundreds = number / 100; if (!ΟrdinalMap.TryGetValue(hundreds*100, out var hundredsString)) return string.Empty; @@ -122,8 +122,8 @@ static string GetThreeDigitOrdinal(int number) return hundredsString; } - static string GetFourDigitOrdinal(int number) - { + static string GetFourDigitOrdinal(int number) + { var thousands = number / 1000; if (!ΟrdinalMap.TryGetValue(thousands*1000, out var thousandsString)) return string.Empty; @@ -146,8 +146,8 @@ static string GetFourDigitOrdinal(int number) return thousandsString; } - string ConvertImpl(long number, bool returnPluralized) - { + string ConvertImpl(long number, bool returnPluralized) + { if (number < 13) { return ConvertIntB13(number, returnPluralized); @@ -177,11 +177,11 @@ string ConvertImpl(long number, bool returnPluralized) return ""; } - string ConvertIntB13(long number, bool returnPluralized) => - returnPluralized ? UnitsMap[number] : UnitMap[number]; + string ConvertIntB13(long number, bool returnPluralized) => + returnPluralized ? UnitsMap[number] : UnitMap[number]; - string ConvertIntBH(long number, bool returnPluralized) - { + string ConvertIntBH(long number, bool returnPluralized) + { var result = number / 10 == 1 ? TensNoDiacriticsMap[number / 10] : TensMap[number / 10]; if (number % 10 != 0) @@ -197,8 +197,8 @@ string ConvertIntBH(long number, bool returnPluralized) return result; } - string ConvertIntBT(long number, bool returnPluralized) - { + string ConvertIntBT(long number, bool returnPluralized) + { string result; if (number / 100 == 1) @@ -223,8 +223,8 @@ string ConvertIntBT(long number, bool returnPluralized) return result; } - string ConvertIntBM(long number) - { + string ConvertIntBM(long number) + { if (number / 1000 == 1) { if (number % 1000 == 0) @@ -245,8 +245,8 @@ string ConvertIntBM(long number) return result; } - string ConvertIntBB(long number) - { + string ConvertIntBB(long number) + { if (number / 1000000 == 1) { if (number % 1000000 == 0) @@ -267,8 +267,8 @@ string ConvertIntBB(long number) return result; } - string ConvertIntBTR(long number) - { + string ConvertIntBTR(long number) + { if (number / 1000000000 == 1) { if (number % 1000000000 == 0) @@ -288,5 +288,4 @@ string ConvertIntBTR(long number) return result; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs index 22018e576..789bde7d8 100644 --- a/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/HebrewNumberToWordsConverter.cs @@ -1,30 +1,30 @@ -namespace Humanizer +namespace Humanizer; + +class HebrewNumberToWordsConverter(CultureInfo? culture) : + GenderedNumberToWordsConverter(GrammaticalGender.Feminine) { - class HebrewNumberToWordsConverter(CultureInfo? culture) : - GenderedNumberToWordsConverter(GrammaticalGender.Feminine) + static readonly string[] UnitsFeminine = ["אפס", "אחת", "שתיים", "שלוש", "ארבע", "חמש", "שש", "שבע", "שמונה", "תשע", "עשר"]; + static readonly string[] UnitsMasculine = ["אפס", "אחד", "שניים", "שלושה", "ארבעה", "חמישה", "שישה", "שבעה", "שמונה", "תשעה", "עשרה"]; + static readonly string[] TensUnit = ["עשר", "עשרים", "שלושים", "ארבעים", "חמישים", "שישים", "שבעים", "שמונים", "תשעים"]; + + class DescriptionAttribute(string description) : + Attribute { - static readonly string[] UnitsFeminine = ["אפס", "אחת", "שתיים", "שלוש", "ארבע", "חמש", "שש", "שבע", "שמונה", "תשע", "עשר"]; - static readonly string[] UnitsMasculine = ["אפס", "אחד", "שניים", "שלושה", "ארבעה", "חמישה", "שישה", "שבעה", "שמונה", "תשעה", "עשרה"]; - static readonly string[] TensUnit = ["עשר", "עשרים", "שלושים", "ארבעים", "חמישים", "שישים", "שבעים", "שמונים", "תשעים"]; - - class DescriptionAttribute(string description) : - Attribute - { - public string Description { get; set; } = description; - } + public string Description { get; set; } = description; + } - enum Group - { - Hundreds = 100, - Thousands = 1000, - [Description("מיליון")] - Millions = 1000000, - [Description("מיליארד")] - Billions = 1000000000 - } + enum Group + { + Hundreds = 100, + Thousands = 1000, + [Description("מיליון")] + Millions = 1000000, + [Description("מיליארד")] + Billions = 1000000000 + } - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -110,11 +110,11 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) => - number.ToString(culture); + public override string ConvertToOrdinal(int number, GrammaticalGender gender) => + number.ToString(culture); - void ToBigNumber(int number, Group group, List parts) - { + void ToBigNumber(int number, Group group, List parts) + { // Big numbers (million and above) always use the masculine form // See https://www.safa-ivrit.org/dikduk/numbers.php @@ -131,8 +131,8 @@ void ToBigNumber(int number, Group group, List parts) parts.Add(group.Humanize()); } - void ToThousands(int number, List parts) - { + void ToThousands(int number, List parts) + { var thousands = number / (int)Group.Thousands; if (thousands == 1) @@ -157,8 +157,8 @@ void ToThousands(int number, List parts) } } - static void ToHundreds(int number, List parts) - { + static void ToHundreds(int number, List parts) + { // For hundreds, Hebrew is using the feminine form // See https://www.safa-ivrit.org/dikduk/numbers.php @@ -177,5 +177,4 @@ static void ToHundreds(int number, List parts) parts.Add(UnitsFeminine[hundreds] + " מאות"); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs index 2dc2b858d..6e7450610 100644 --- a/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/INumberToWordsConverter.cs @@ -1,64 +1,63 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// An interface you should implement to localise ToWords and ToOrdinalWords methods +/// +public interface INumberToWordsConverter { /// - /// An interface you should implement to localise ToWords and ToOrdinalWords methods + /// Converts the number to string using the locale's default grammatical gender /// - public interface INumberToWordsConverter - { - /// - /// Converts the number to string using the locale's default grammatical gender - /// - string Convert(long number); + string Convert(long number); - /// - /// Converts the number to a specific string form using the locale's default grammatical gender. - /// - string Convert(long number, WordForm wordForm); + /// + /// Converts the number to a specific string form using the locale's default grammatical gender. + /// + string Convert(long number, WordForm wordForm); - /// - /// Converts the number to string using the locale's default grammatical gender with or without adding 'And' - /// - /// Specify with our without adding "And" - string Convert(long number, bool addAnd); + /// + /// Converts the number to string using the locale's default grammatical gender with or without adding 'And' + /// + /// Specify with our without adding "And" + string Convert(long number, bool addAnd); - /// - /// Converts the number to a specific string form using the locale's default grammatical gender with or without adding 'And' - /// - string Convert(long number, bool addAnd, WordForm wordForm); + /// + /// Converts the number to a specific string form using the locale's default grammatical gender with or without adding 'And' + /// + string Convert(long number, bool addAnd, WordForm wordForm); - /// - /// Converts the number to string using the provided grammatical gender - /// - string Convert(long number, GrammaticalGender gender, bool addAnd = true); + /// + /// Converts the number to string using the provided grammatical gender + /// + string Convert(long number, GrammaticalGender gender, bool addAnd = true); - /// - /// Converts the number to a specific string form using the provided grammatical gender. - /// - string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true); + /// + /// Converts the number to a specific string form using the provided grammatical gender. + /// + string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true); - /// - /// Converts the number to ordinal string using the locale's default grammatical gender - /// - string ConvertToOrdinal(int number); + /// + /// Converts the number to ordinal string using the locale's default grammatical gender + /// + string ConvertToOrdinal(int number); - /// - /// Converts the number to a specific ordinal string form using the locale's default grammatical gender. - /// - string ConvertToOrdinal(int number, WordForm wordForm); + /// + /// Converts the number to a specific ordinal string form using the locale's default grammatical gender. + /// + string ConvertToOrdinal(int number, WordForm wordForm); - /// - /// Converts the number to ordinal string using the provided grammatical gender - /// - string ConvertToOrdinal(int number, GrammaticalGender gender); + /// + /// Converts the number to ordinal string using the provided grammatical gender + /// + string ConvertToOrdinal(int number, GrammaticalGender gender); - /// - /// Converts the number to a specific ordinal string form using the provided grammatical gender. - /// - string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm); + /// + /// Converts the number to a specific ordinal string form using the provided grammatical gender. + /// + string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm); - /// - /// Converts integer to named tuple (e.g. 'single', 'double' etc.). - /// - string ConvertToTuple(int number); - } -} + /// + /// Converts integer to named tuple (e.g. 'single', 'double' etc.). + /// + string ConvertToTuple(int number); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/IcelandicNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/IcelandicNumberToWordsConverter.cs index 8048d9663..eb719842f 100644 --- a/src/Humanizer/Localisation/NumberToWords/IcelandicNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/IcelandicNumberToWordsConverter.cs @@ -1,43 +1,43 @@ -namespace Humanizer +namespace Humanizer; + +class IcelandicNumberToWordsConverter : GenderedNumberToWordsConverter { - class IcelandicNumberToWordsConverter : GenderedNumberToWordsConverter + static readonly string[] UnitsMap = ["núll", string.Empty, string.Empty, string.Empty, string.Empty, "fimm", "sex", "sjö", "átta", "níu", "tíu", "ellefu", "tólf", "þrettán", "fjórtán", "fimmtán", "sextán", "sautján", "átján", "nítján"]; + static readonly string[] FeminineUnitsMap = [string.Empty, "ein", "tvær", "þrjár", "fjórar"]; + static readonly string[] MasculineUnitsMap = [string.Empty, "einn", "tveir", "þrír", "fjórir"]; + static readonly string[] NeuterUnitsMap = [string.Empty, "eitt", "tvö", "þrjú", "fjögur"]; + static readonly string[] TensMap = [string.Empty, "tíu", "tuttugu", "þrjátíu", "fjörutíu", "fimmtíu", "sextíu", "sjötíu", "áttatíu", "níutíu"]; + static readonly string[] UnitsOrdinalPrefixes = ["núllt", "fyrst", string.Empty, "þriðj", "fjórð", "fimmt", "sjött", "sjöund", "áttund", "níund", "tíund", "elleft", "tólft", "þrettánd", "fjórtánd", "fimmtánd", "sextánd", "sautjánd", "átjánd", "nítjánd"]; + static readonly string[] TensOrdinalPrefixes = [string.Empty, "tíund", "tuttugast", "þrítugast", "fertugast", "fimmtugast", "sextugast", "sjötugast", "áttugast", "nítugast"]; + const string AndSplit = "og"; + class Fact { - static readonly string[] UnitsMap = ["núll", string.Empty, string.Empty, string.Empty, string.Empty, "fimm", "sex", "sjö", "átta", "níu", "tíu", "ellefu", "tólf", "þrettán", "fjórtán", "fimmtán", "sextán", "sautján", "átján", "nítján"]; - static readonly string[] FeminineUnitsMap = [string.Empty, "ein", "tvær", "þrjár", "fjórar"]; - static readonly string[] MasculineUnitsMap = [string.Empty, "einn", "tveir", "þrír", "fjórir"]; - static readonly string[] NeuterUnitsMap = [string.Empty, "eitt", "tvö", "þrjú", "fjögur"]; - static readonly string[] TensMap = [string.Empty, "tíu", "tuttugu", "þrjátíu", "fjörutíu", "fimmtíu", "sextíu", "sjötíu", "áttatíu", "níutíu"]; - static readonly string[] UnitsOrdinalPrefixes = ["núllt", "fyrst", string.Empty, "þriðj", "fjórð", "fimmt", "sjött", "sjöund", "áttund", "níund", "tíund", "elleft", "tólft", "þrettánd", "fjórtánd", "fimmtánd", "sextánd", "sautjánd", "átjánd", "nítjánd"]; - static readonly string[] TensOrdinalPrefixes = [string.Empty, "tíund", "tuttugast", "þrítugast", "fertugast", "fimmtugast", "sextugast", "sjötugast", "áttugast", "nítugast"]; - const string AndSplit = "og"; - class Fact - { - public long Power { get; set; } - public GrammaticalGender Gender { get; set; } - public required string Plural { get; set; } - public required string Single { get; set; } - public required string OrdinalPrefix { get; set; } - } - static readonly Dictionary PowerOfTenMap = new() - { - {0, new(){Power = 0 , Single = string.Empty, Plural = string.Empty, OrdinalPrefix = string.Empty, Gender = GrammaticalGender.Neuter }}, - {2, new(){Power = 2 , Single = "hundrað", Plural = "hundruð", OrdinalPrefix = "hundruðast", Gender = GrammaticalGender.Neuter }}, - {3, new(){Power = 1000 , Single = "eitt þúsund", Plural = "þúsund", OrdinalPrefix = "þúsundast", Gender = GrammaticalGender.Neuter }}, - {6, new(){Power = 1000000 , Single = "ein milljón", Plural = "milljónir", OrdinalPrefix = "milljónast", Gender = GrammaticalGender.Feminine }}, - {9, new(){Power = 1000000000 , Single = "einn milljarður", Plural = "milljarðar", OrdinalPrefix = "milljarðast", Gender = GrammaticalGender.Masculine }}, - {12, new(){Power = 1000000000000 , Single = "ein billjón", Plural = "billjónir", OrdinalPrefix = "billjónast", Gender = GrammaticalGender.Feminine }}, - {15, new(){Power = 1000000000000000 , Single = "einn billjarður", Plural = "billjarðar", OrdinalPrefix = "billjarðast", Gender = GrammaticalGender.Masculine }}, - {18, new(){Power = 1000000000000000000 , Single = "ein trilljón", Plural = "trilljónir", OrdinalPrefix = "trilljónast", Gender = GrammaticalGender.Feminine }} - }; + public long Power { get; set; } + public GrammaticalGender Gender { get; set; } + public required string Plural { get; set; } + public required string Single { get; set; } + public required string OrdinalPrefix { get; set; } + } + static readonly Dictionary PowerOfTenMap = new() + { + {0, new(){Power = 0 , Single = string.Empty, Plural = string.Empty, OrdinalPrefix = string.Empty, Gender = GrammaticalGender.Neuter }}, + {2, new(){Power = 2 , Single = "hundrað", Plural = "hundruð", OrdinalPrefix = "hundruðast", Gender = GrammaticalGender.Neuter }}, + {3, new(){Power = 1000 , Single = "eitt þúsund", Plural = "þúsund", OrdinalPrefix = "þúsundast", Gender = GrammaticalGender.Neuter }}, + {6, new(){Power = 1000000 , Single = "ein milljón", Plural = "milljónir", OrdinalPrefix = "milljónast", Gender = GrammaticalGender.Feminine }}, + {9, new(){Power = 1000000000 , Single = "einn milljarður", Plural = "milljarðar", OrdinalPrefix = "milljarðast", Gender = GrammaticalGender.Masculine }}, + {12, new(){Power = 1000000000000 , Single = "ein billjón", Plural = "billjónir", OrdinalPrefix = "billjónast", Gender = GrammaticalGender.Feminine }}, + {15, new(){Power = 1000000000000000 , Single = "einn billjarður", Plural = "billjarðar", OrdinalPrefix = "billjarðast", Gender = GrammaticalGender.Masculine }}, + {18, new(){Power = 1000000000000000000 , Single = "ein trilljón", Plural = "trilljónir", OrdinalPrefix = "trilljónast", Gender = GrammaticalGender.Feminine }} + }; - static bool IsAndSplitNeeded(int number) => - number <= 20 || number % 10 == 0 && number < 100 || number % 100 == 0; + static bool IsAndSplitNeeded(int number) => + number <= 20 || number % 10 == 0 && number < 100 || number % 100 == 0; - static string GetOrdinalEnding(GrammaticalGender gender) => - gender == GrammaticalGender.Masculine ? "i" : "a"; + static string GetOrdinalEnding(GrammaticalGender gender) => + gender == GrammaticalGender.Masculine ? "i" : "a"; - static void GetUnits(ICollection builder, long number, GrammaticalGender gender) - { + static void GetUnits(ICollection builder, long number, GrammaticalGender gender) + { if (number is > 0 and < 5) { var genderedForm = gender switch @@ -55,8 +55,8 @@ static void GetUnits(ICollection builder, long number, GrammaticalGende } } - static void CollectOrdinalParts(ICollection builder, int threeDigitPart, Fact conversionRule, GrammaticalGender partGender, GrammaticalGender ordinalGender) - { + static void CollectOrdinalParts(ICollection builder, int threeDigitPart, Fact conversionRule, GrammaticalGender partGender, GrammaticalGender ordinalGender) + { var hundreds = threeDigitPart / 100; var hundredRemainder = threeDigitPart % 100; var units = hundredRemainder % 10; @@ -121,8 +121,8 @@ static void CollectOrdinalParts(ICollection builder, int threeDigitPart } } - static string? CollectOrdinalPartsUnderAHundred(int number, GrammaticalGender gender) - { + static string? CollectOrdinalPartsUnderAHundred(int number, GrammaticalGender gender) + { if (number is >= 0 and < 20) { if (number == 2) @@ -149,8 +149,8 @@ static void CollectOrdinalParts(ICollection builder, int threeDigitPart return null; } - static void CollectParts(IList parts, ref long number, ref bool needsAnd, Fact rule) - { + static void CollectParts(IList parts, ref long number, ref bool needsAnd, Fact rule) + { var remainder = number / rule.Power; if (remainder > 0) { @@ -165,8 +165,8 @@ static void CollectParts(IList parts, ref long number, ref bool needsAn } } - static void CollectPart(ICollection parts, long number, Fact rule) - { + static void CollectPart(ICollection parts, long number, Fact rule) + { if (number == 1) { parts.Add(rule.Single); @@ -178,8 +178,8 @@ static void CollectPart(ICollection parts, long number, Fact rule) } } - static void CollectPartUnderOneThousand(ICollection builder, long number, GrammaticalGender gender) - { + static void CollectPartUnderOneThousand(ICollection builder, long number, GrammaticalGender gender) + { var hundreds = number / 100; var hundredRemainder = number % 100; var units = hundredRemainder % 10; @@ -219,8 +219,8 @@ static void CollectPartUnderOneThousand(ICollection builder, long numbe } } - static void CollectOrdinal(IList parts, ref int number, ref bool needsAnd, Fact rule, GrammaticalGender gender) - { + static void CollectOrdinal(IList parts, ref int number, ref bool needsAnd, Fact rule, GrammaticalGender gender) + { var remainder = number / rule.Power; if (remainder > 0) { @@ -254,8 +254,8 @@ static void CollectOrdinal(IList parts, ref int number, ref bool needsA needsAnd = true; } } - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) - { + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) + { if (number == 0) { return UnitsMap[number]; @@ -286,8 +286,8 @@ public override string Convert(long number, GrammaticalGender gender, bool addAn } return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { if (number == 0) { return UnitsOrdinalPrefixes[number] + GetOrdinalEnding(gender); @@ -310,5 +310,4 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender) } return string.Join(" ", parts); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/IndianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/IndianNumberToWordsConverter.cs index 9b111cc16..9a4ebf0ec 100644 --- a/src/Humanizer/Localisation/NumberToWords/IndianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/IndianNumberToWordsConverter.cs @@ -1,42 +1,42 @@ -namespace Humanizer +namespace Humanizer; + +class IndianNumberToWordsConverter : GenderlessNumberToWordsConverter { - class IndianNumberToWordsConverter : GenderlessNumberToWordsConverter + static readonly Dictionary OrdinalExceptions = new() { - static readonly Dictionary OrdinalExceptions = new() - { - {1, "first"}, - {2, "second"}, - {3, "third"}, - {4, "fourth"}, - {5, "fifth"}, - {8, "eighth"}, - {9, "ninth"}, - {12, "twelfth"}, - }; - static readonly string[] Tillnineteen = - [ - "one", "two", "three", "four", "five", "six", "seven", "eight", - "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", - "seventeen", "eighteen", "nineteen" - ]; + {1, "first"}, + {2, "second"}, + {3, "third"}, + {4, "fourth"}, + {5, "fifth"}, + {8, "eighth"}, + {9, "ninth"}, + {12, "twelfth"}, + }; + static readonly string[] Tillnineteen = + [ + "one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", + "seventeen", "eighteen", "nineteen" + ]; - static readonly string[] Tens = - [ - "twenty", "thirty", "forty", "fifty", "sixty", "seventy", - "eighty", "ninety" - ]; + static readonly string[] Tens = + [ + "twenty", "thirty", "forty", "fifty", "sixty", "seventy", + "eighty", "ninety" + ]; - public override string Convert(long number) => - NumberToText(number).Trim(); + public override string Convert(long number) => + NumberToText(number).Trim(); - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var result = NumberToText(number).Trim(); return result; } - public static string NumberToText( long number) - { + public static string NumberToText( long number) + { if (number < 0) return "(Negative) " + NumberToText(-number); if (number == 0) @@ -62,7 +62,6 @@ public static string NumberToText( long number) return NumberToText(number / 10000000).Trim() + " crore " + NumberToText(number % 10000000); } - static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); - } -} + static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/Italian/ItalianCardinalNumberCruncher.cs b/src/Humanizer/Localisation/NumberToWords/Italian/ItalianCardinalNumberCruncher.cs index 2ebe5a6ec..dee73c59c 100644 --- a/src/Humanizer/Localisation/NumberToWords/Italian/ItalianCardinalNumberCruncher.cs +++ b/src/Humanizer/Localisation/NumberToWords/Italian/ItalianCardinalNumberCruncher.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class ItalianCardinalNumberCruncher(int number, GrammaticalGender gender) { - class ItalianCardinalNumberCruncher(int number, GrammaticalGender gender) + public string Convert() { - public string Convert() - { // it's easier to treat zero as a completely distinct case if (_fullNumber == 0) { @@ -26,20 +26,20 @@ public string Convert() return words.TrimEnd(); } - protected readonly int _fullNumber = number; - protected readonly List _threeDigitParts = SplitEveryThreeDigits(number); - protected readonly GrammaticalGender _gender = gender; + protected readonly int _fullNumber = number; + protected readonly List _threeDigitParts = SplitEveryThreeDigits(number); + protected readonly GrammaticalGender _gender = gender; - protected ThreeDigitSets _nextSet = ThreeDigitSets.Units; + protected ThreeDigitSets _nextSet = ThreeDigitSets.Units; - /// - /// Splits a number into a sequence of three-digits numbers, starting - /// from units, then thousands, millions, and so on. - /// - /// The number to split. - /// The sequence of three-digit numbers. - protected static List SplitEveryThreeDigits(int number) - { + /// + /// Splits a number into a sequence of three-digits numbers, starting + /// from units, then thousands, millions, and so on. + /// + /// The number to split. + /// The sequence of three-digit numbers. + protected static List SplitEveryThreeDigits(int number) + { var parts = new List(); var rest = number; @@ -55,13 +55,13 @@ protected static List SplitEveryThreeDigits(int number) return parts; } - /// - /// During number conversion to text, finds out the converter to use - /// for the next three-digit set. - /// - /// The next conversion function to use. - public Func? GetNextPartConverter() - { + /// + /// During number conversion to text, finds out the converter to use + /// for the next three-digit set. + /// + /// The next conversion function to use. + public Func? GetNextPartConverter() + { Func? converter; switch (_nextSet) @@ -97,14 +97,14 @@ protected static List SplitEveryThreeDigits(int number) return converter; } - /// - /// Converts a three-digit set to text. - /// - /// The three-digit set to convert. - /// True if the current three-digit set is the last in the word. - /// The same three-digit set expressed as text. - static string ThreeDigitSetConverter(int number, bool thisIsLastSet = false) - { + /// + /// Converts a three-digit set to text. + /// + /// The three-digit set to convert. + /// True if the current three-digit set is the last in the word. + /// The same three-digit set expressed as text. + static string ThreeDigitSetConverter(int number, bool thisIsLastSet = false) + { if (number == 0) { return string.Empty; @@ -156,13 +156,13 @@ static string ThreeDigitSetConverter(int number, bool thisIsLastSet = false) return words; } - /// - /// Converts a three-digit number, as units, to text. - /// - /// The three-digit number, as units, to convert. - /// The same three-digit number, as units, expressed as text. - protected string UnitsConverter(int number) - { + /// + /// Converts a three-digit number, as units, to text. + /// + /// The three-digit number, as units, to convert. + /// The same three-digit number, as units, expressed as text. + protected string UnitsConverter(int number) + { // being a unique case, it's easier to treat unity feminine gender as a completely distinct case if (_gender == GrammaticalGender.Feminine && _fullNumber == 1) { @@ -172,13 +172,13 @@ protected string UnitsConverter(int number) return ThreeDigitSetConverter(number, true); } - /// - /// Converts a thousands three-digit number to text. - /// - /// The three-digit number, as thousands, to convert. - /// The same three-digit number of thousands expressed as text. - protected static string ThousandsConverter(int number) - { + /// + /// Converts a thousands three-digit number to text. + /// + /// The three-digit number, as thousands, to convert. + /// The same three-digit number of thousands expressed as text. + protected static string ThousandsConverter(int number) + { if (number == 0) { return string.Empty; @@ -192,13 +192,13 @@ protected static string ThousandsConverter(int number) return ThreeDigitSetConverter(number) + "mila"; } - /// - /// Converts a millions three-digit number to text. - /// - /// The three-digit number, as millions, to convert. - /// The same three-digit number of millions expressed as text. - protected static string MillionsConverter(int number) - { + /// + /// Converts a millions three-digit number to text. + /// + /// The three-digit number, as millions, to convert. + /// The same three-digit number of millions expressed as text. + protected static string MillionsConverter(int number) + { if (number == 0) { return string.Empty; @@ -212,13 +212,13 @@ protected static string MillionsConverter(int number) return ThreeDigitSetConverter(number, true) + " milioni "; } - /// - /// Converts a billions three-digit number to text. - /// - /// The three-digit number, as billions, to convert. - /// The same three-digit number of billions expressed as text. - protected static string BillionsConverter(int number) - { + /// + /// Converts a billions three-digit number to text. + /// + /// The three-digit number, as billions, to convert. + /// The same three-digit number of billions expressed as text. + protected static string BillionsConverter(int number) + { if (number == 1) { return "un miliardo "; @@ -227,104 +227,102 @@ protected static string BillionsConverter(int number) return ThreeDigitSetConverter(number) + " miliardi "; } + /// + /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9. + /// + protected static string[] _unitsNumberToText = + [ + string.Empty, + "uno", + "due", + "tre", + "quattro", + "cinque", + "sei", + "sette", + "otto", + "nove" + ]; + + /// + /// Lookup table converting tens number to text. Index 2 for 20, index 3 for 30, up to index 9 for 90. + /// + protected static string[] _tensOver20NumberToText = + [ + string.Empty, + string.Empty, + "venti", + "trenta", + "quaranta", + "cinquanta", + "sessanta", + "settanta", + "ottanta", + "novanta" + ]; + + /// + /// Lookup table converting teens number to text. Index 0 for 10, index 1 for 11, up to index 9 for 19. + /// + protected static string[] _teensUnder20NumberToText = + [ + "dieci", + "undici", + "dodici", + "tredici", + "quattordici", + "quindici", + "sedici", + "diciassette", + "diciotto", + "diciannove" + ]; + + /// + /// Lookup table converting hundreds number to text. Index 0 for no hundreds, index 1 for 100, up to index 9. + /// + protected static string[] _hundredNumberToText = + [ + string.Empty, + "cento", + "duecento", + "trecento", + "quattrocento", + "cinquecento", + "seicento", + "settecento", + "ottocento", + "novecento" + ]; + + /// + /// Enumerates sets of three-digits having distinct conversion to text. + /// + protected enum ThreeDigitSets + { /// - /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9. + /// Lowest three-digits set, from 1 to 999. /// - protected static string[] _unitsNumberToText = - [ - string.Empty, - "uno", - "due", - "tre", - "quattro", - "cinque", - "sei", - "sette", - "otto", - "nove" - ]; + Units, /// - /// Lookup table converting tens number to text. Index 2 for 20, index 3 for 30, up to index 9 for 90. + /// Three-digits set counting the thousands, from 1'000 to 999'000. /// - protected static string[] _tensOver20NumberToText = - [ - string.Empty, - string.Empty, - "venti", - "trenta", - "quaranta", - "cinquanta", - "sessanta", - "settanta", - "ottanta", - "novanta" - ]; + Thousands, /// - /// Lookup table converting teens number to text. Index 0 for 10, index 1 for 11, up to index 9 for 19. + /// Three-digits set counting millions, from 1'000'000 to 999'000'000. /// - protected static string[] _teensUnder20NumberToText = - [ - "dieci", - "undici", - "dodici", - "tredici", - "quattordici", - "quindici", - "sedici", - "diciassette", - "diciotto", - "diciannove" - ]; + Millions, /// - /// Lookup table converting hundreds number to text. Index 0 for no hundreds, index 1 for 100, up to index 9. + /// Three-digits set counting billions, from 1'000'000'000 to 999'000'000'000. /// - protected static string[] _hundredNumberToText = - [ - string.Empty, - "cento", - "duecento", - "trecento", - "quattrocento", - "cinquecento", - "seicento", - "settecento", - "ottocento", - "novecento" - ]; + Billions, /// - /// Enumerates sets of three-digits having distinct conversion to text. + /// Three-digits set beyond 999 billions, from 1'000'000'000'000 onward. /// - protected enum ThreeDigitSets - { - /// - /// Lowest three-digits set, from 1 to 999. - /// - Units, - - /// - /// Three-digits set counting the thousands, from 1'000 to 999'000. - /// - Thousands, - - /// - /// Three-digits set counting millions, from 1'000'000 to 999'000'000. - /// - Millions, - - /// - /// Three-digits set counting billions, from 1'000'000'000 to 999'000'000'000. - /// - Billions, - - /// - /// Three-digits set beyond 999 billions, from 1'000'000'000'000 onward. - /// - More - } + More } -} - +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/Italian/ItalianOrdinalNumberCruncher.cs b/src/Humanizer/Localisation/NumberToWords/Italian/ItalianOrdinalNumberCruncher.cs index f97383ffc..701e9b1be 100644 --- a/src/Humanizer/Localisation/NumberToWords/Italian/ItalianOrdinalNumberCruncher.cs +++ b/src/Humanizer/Localisation/NumberToWords/Italian/ItalianOrdinalNumberCruncher.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class ItalianOrdinalNumberCruncher(int number, GrammaticalGender gender) { - class ItalianOrdinalNumberCruncher(int number, GrammaticalGender gender) + public string Convert() { - public string Convert() - { // it's easier to treat zero as a completely distinct case if (_fullNumber == 0) { @@ -83,27 +83,26 @@ public string Convert() return words; } - protected readonly int _fullNumber = number; - protected readonly GrammaticalGender _gender = gender; - readonly string _genderSuffix = gender == GrammaticalGender.Feminine ? "a" : "o"; - - /// - /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9. - /// - protected static string[] _unitsUnder10NumberToText = - [ - string.Empty, - "prim", - "second", - "terz", - "quart", - "quint", - "sest", - "settim", - "ottav", - "non" - ]; - - protected static int _lengthOf10AsCardinal = "dieci".Length; - } -} + protected readonly int _fullNumber = number; + protected readonly GrammaticalGender _gender = gender; + readonly string _genderSuffix = gender == GrammaticalGender.Feminine ? "a" : "o"; + + /// + /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9. + /// + protected static string[] _unitsUnder10NumberToText = + [ + string.Empty, + "prim", + "second", + "terz", + "quart", + "quint", + "sest", + "settim", + "ottav", + "non" + ]; + + protected static int _lengthOf10AsCardinal = "dieci".Length; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs index dceecd758..683f10446 100644 --- a/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ItalianNumberToWordsConverter.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class ItalianNumberToWordsConverter : GenderedNumberToWordsConverter { - class ItalianNumberToWordsConverter : GenderedNumberToWordsConverter + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) { - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -20,11 +20,10 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return cruncher.Convert(); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { var cruncher = new ItalianOrdinalNumberCruncher(number, gender); return cruncher.Convert(); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/JapaneseNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/JapaneseNumberToWordsConverter.cs index 6ac635d54..74df6e1c5 100644 --- a/src/Humanizer/Localisation/NumberToWords/JapaneseNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/JapaneseNumberToWordsConverter.cs @@ -1,23 +1,23 @@ -namespace Humanizer +namespace Humanizer; + +class JapaneseNumberToWordsConverter : GenderlessNumberToWordsConverter { - class JapaneseNumberToWordsConverter : GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap1 = ["", "", "二", "三", "四", "五", "六", "七", "八", "九"]; - static readonly string[] UnitsMap2 = ["", "十", "百", "千"]; - static readonly string[] UnitsMap3 = - [ - "", "万", "億", "兆", "京", "垓", "𥝱", "穣", "溝", "澗", "正", "載", "極", - "恒河沙", "阿僧祇", "那由他", "不可思議", "無量大数" - ]; + static readonly string[] UnitsMap1 = ["", "", "二", "三", "四", "五", "六", "七", "八", "九"]; + static readonly string[] UnitsMap2 = ["", "十", "百", "千"]; + static readonly string[] UnitsMap3 = + [ + "", "万", "億", "兆", "京", "垓", "𥝱", "穣", "溝", "澗", "正", "載", "極", + "恒河沙", "阿僧祇", "那由他", "不可思議", "無量大数" + ]; - public override string Convert(long number) => - ConvertImpl(number, false); + public override string Convert(long number) => + ConvertImpl(number, false); - public override string ConvertToOrdinal(int number) => - ConvertImpl(number, true); + public override string ConvertToOrdinal(int number) => + ConvertImpl(number, true); - static string ConvertImpl(long number, bool isOrdinal) - { + static string ConvertImpl(long number, bool isOrdinal) + { if (number == 0) { return isOrdinal ? "〇番目" : "〇"; @@ -61,5 +61,4 @@ static string ConvertImpl(long number, bool isOrdinal) return toWords; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/KoreanNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/KoreanNumberToWordsConverter.cs index d2fa4abcc..93439f28d 100644 --- a/src/Humanizer/Localisation/NumberToWords/KoreanNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/KoreanNumberToWordsConverter.cs @@ -1,43 +1,43 @@ -namespace Humanizer +namespace Humanizer; + +class KoreanNumberToWordsConverter : GenderlessNumberToWordsConverter { - class KoreanNumberToWordsConverter : GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap1 = ["", "", "이", "삼", "사", "오", "육", "칠", "팔", "구"]; - static readonly string[] UnitsMap2 = ["", "십", "백", "천"]; - static readonly string[] UnitsMap3 = ["", "만", "억", "조", "경", "해", "자", "양", "구", "간", "정", "재", "극", "항하사", "아승기", "나유타", "불가사의", "무량대수"]; + static readonly string[] UnitsMap1 = ["", "", "이", "삼", "사", "오", "육", "칠", "팔", "구"]; + static readonly string[] UnitsMap2 = ["", "십", "백", "천"]; + static readonly string[] UnitsMap3 = ["", "만", "억", "조", "경", "해", "자", "양", "구", "간", "정", "재", "극", "항하사", "아승기", "나유타", "불가사의", "무량대수"]; - static readonly Dictionary OrdinalExceptions = new() - { - {0, "영번째"}, - {1, "첫번째"}, - {2, "두번째"}, - {3, "세번째"}, - {4, "네번째"}, - {5, "다섯번째"}, - {6, "여섯번째"}, - {7, "일곱번째"}, - {8, "여덟번째"}, - {9, "아홉번째"}, - {10, "열번째"}, - {11, "열한번째"}, - {12, "열두번째"}, - {13, "열세번째"}, - {14, "열네번째"}, - {15, "열다섯번째"}, - {16, "열여섯번째"}, - {17, "열일곱번째"}, - {18, "열여덟번째"}, - {19, "열아홉째"}, - }; + static readonly Dictionary OrdinalExceptions = new() + { + {0, "영번째"}, + {1, "첫번째"}, + {2, "두번째"}, + {3, "세번째"}, + {4, "네번째"}, + {5, "다섯번째"}, + {6, "여섯번째"}, + {7, "일곱번째"}, + {8, "여덟번째"}, + {9, "아홉번째"}, + {10, "열번째"}, + {11, "열한번째"}, + {12, "열두번째"}, + {13, "열세번째"}, + {14, "열네번째"}, + {15, "열다섯번째"}, + {16, "열여섯번째"}, + {17, "열일곱번째"}, + {18, "열여덟번째"}, + {19, "열아홉째"}, + }; - public override string Convert(long number) => - ConvertImpl(number, false); + public override string Convert(long number) => + ConvertImpl(number, false); - public override string ConvertToOrdinal(int number) => - ConvertImpl(number, true); + public override string ConvertToOrdinal(int number) => + ConvertImpl(number, true); - static string ConvertImpl(long number, bool isOrdinal) - { + static string ConvertImpl(long number, bool isOrdinal) + { if (isOrdinal && number < 20) { if (OrdinalExceptions.TryGetValue(number, out var words)) @@ -87,5 +87,4 @@ static string ConvertImpl(long number, bool isOrdinal) return toWords; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/LithuanianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/LithuanianNumberToWordsConverter.cs index acfb0304d..9096740ba 100644 --- a/src/Humanizer/Localisation/NumberToWords/LithuanianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/LithuanianNumberToWordsConverter.cs @@ -1,17 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +class LithuanianNumberToWordsConverter : GenderedNumberToWordsConverter { - class LithuanianNumberToWordsConverter : GenderedNumberToWordsConverter - { - static readonly string[] UnitsMap = ["nulis", "vienas", "du", "trys", "keturi", "penki", "šeši", "septyni", "aštuoni", "devyni", "dešimt", "vienuolika", "dvylika", "trylika", "keturiolika", "penkiolika", "šešiolika", "septyniolika", "aštuoniolika", "devyniolika"]; - static readonly string[] TensMap = [string.Empty, "dešimt", "dvidešimt", "trisdešimt", "keturiasdešimt", "penkiasdešimt", "šešiasdešimt", "septyniasdešimt", "aštuoniasdešimt", "devyniasdešimt"]; - static readonly string[] HundredsMap = [string.Empty, "šimtas", "du šimtai", "trys šimtai", "keturi šimtai", "penki šimtai", "šeši šimtai", "septyni šimtai", "aštuoni šimtai", "devyni šimtai"]; + static readonly string[] UnitsMap = ["nulis", "vienas", "du", "trys", "keturi", "penki", "šeši", "septyni", "aštuoni", "devyni", "dešimt", "vienuolika", "dvylika", "trylika", "keturiolika", "penkiolika", "šešiolika", "septyniolika", "aštuoniolika", "devyniolika"]; + static readonly string[] TensMap = [string.Empty, "dešimt", "dvidešimt", "trisdešimt", "keturiasdešimt", "penkiasdešimt", "šešiasdešimt", "septyniasdešimt", "aštuoniasdešimt", "devyniasdešimt"]; + static readonly string[] HundredsMap = [string.Empty, "šimtas", "du šimtai", "trys šimtai", "keturi šimtai", "penki šimtai", "šeši šimtai", "septyni šimtai", "aštuoni šimtai", "devyni šimtai"]; - static readonly string[] OrdinalUnitsMap = [string.Empty, "pirm", "antr", "treči", "ketvirt", "penkt", "šešt", "septint", "aštunt", "devint", "dešimt", "vienuolikt", "dvylikt", "trylikt", "keturiolikt", "penkiolikt", "šešiolikt", "septyniolikt", "aštuoniolikt", "devyniolikt", "dvidešimt"]; - static readonly string[] OrdinalTensMap = [string.Empty, "dešimt", "dvidešimt", "trisdešimt", "keturiasdešimt", "penkiasdešimt", "šešiasdešimt", "septyniasdešimt", "aštuoniasdešimt", "devyniasdešimt"]; - static readonly string[] OrdinalHundredsMap = [string.Empty, "šimt", "du šimt", "trys šimt", "keturi šimt", "penki šimt", "šeši šimt", "septyni šimt", "aštuoni šimt", "devyni šimt"]; + static readonly string[] OrdinalUnitsMap = [string.Empty, "pirm", "antr", "treči", "ketvirt", "penkt", "šešt", "septint", "aštunt", "devint", "dešimt", "vienuolikt", "dvylikt", "trylikt", "keturiolikt", "penkiolikt", "šešiolikt", "septyniolikt", "aštuoniolikt", "devyniolikt", "dvidešimt"]; + static readonly string[] OrdinalTensMap = [string.Empty, "dešimt", "dvidešimt", "trisdešimt", "keturiasdešimt", "penkiasdešimt", "šešiasdešimt", "septyniasdešimt", "aštuoniasdešimt", "devyniasdešimt"]; + static readonly string[] OrdinalHundredsMap = [string.Empty, "šimt", "du šimt", "trys šimt", "keturi šimt", "penki šimt", "šeši šimt", "septyni šimt", "aštuoni šimt", "devyni šimt"]; - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) + { if (gender == GrammaticalGender.Neuter) { throw new NotSupportedException(); @@ -32,8 +32,8 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int input, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int input, GrammaticalGender gender) + { if (gender == GrammaticalGender.Neuter) { throw new NotSupportedException(); @@ -51,8 +51,8 @@ public override string ConvertToOrdinal(int input, GrammaticalGender gender) return string.Join(" ", parts); } - static void HandleNegative(List parts, ref long number) - { + static void HandleNegative(List parts, ref long number) + { if (number < 0) { parts.Add("minus"); @@ -60,9 +60,9 @@ static void HandleNegative(List parts, ref long number) } } - static void CollectParts(ICollection parts, ref long number, long divisor, - GrammaticalGender gender, params string[] forms) - { + static void CollectParts(ICollection parts, ref long number, long divisor, + GrammaticalGender gender, params string[] forms) + { var result = number / divisor; if (result == 0) { @@ -79,9 +79,9 @@ static void CollectParts(ICollection parts, ref long number, long diviso parts.Add(ChooseForm(result, forms)); } - static void CollectOrdinalParts(ICollection parts, ref long number, long divisor, - GrammaticalGender gender, string ordinalForm, params string[] forms) - { + static void CollectOrdinalParts(ICollection parts, ref long number, long divisor, + GrammaticalGender gender, string ordinalForm, params string[] forms) + { var result = number / divisor; if (result == 0) { @@ -98,8 +98,8 @@ static void CollectOrdinalParts(ICollection parts, ref long number, long parts.Add(ChooseCardinalOrOrdinalForm(result, ordinalForm, forms, useOrdinalForm: number == 0)); } - static void CollectPartsUnderOneThousand(ICollection parts, long number, GrammaticalGender gender) - { + static void CollectPartsUnderOneThousand(ICollection parts, long number, GrammaticalGender gender) + { if (number >= 100) { var hundreds = number / 100; @@ -120,9 +120,9 @@ static void CollectPartsUnderOneThousand(ICollection parts, long number, } } - static void CollectOrdinalPartsUnderOneThousand(ICollection parts, long number, - GrammaticalGender gender, bool lastNumber = false) - { + static void CollectOrdinalPartsUnderOneThousand(ICollection parts, long number, + GrammaticalGender gender, bool lastNumber = false) + { if (number >= 100) { var hundreds = number / 100; @@ -155,12 +155,12 @@ static void CollectOrdinalPartsUnderOneThousand(ICollection parts, long } } - static string ChooseForm(long number, string[] forms) => - forms[GetFormIndex(number)]; + static string ChooseForm(long number, string[] forms) => + forms[GetFormIndex(number)]; - static string ChooseCardinalOrOrdinalForm(long number, string ordinalForm, string[] cardinalForms, - bool useOrdinalForm = false) - { + static string ChooseCardinalOrOrdinalForm(long number, string ordinalForm, string[] cardinalForms, + bool useOrdinalForm = false) + { if (useOrdinalForm) { return ordinalForm; @@ -169,8 +169,8 @@ static string ChooseCardinalOrOrdinalForm(long number, string ordinalForm, strin return ChooseForm(number, cardinalForms); } - static int GetFormIndex(long number) - { + static int GetFormIndex(long number) + { var form = LithuanianNumberFormDetector.Detect(number); switch (form) @@ -192,8 +192,8 @@ static int GetFormIndex(long number) } } - static string GetCardinalNumberForGender(string number, GrammaticalGender gender) - { + static string GetCardinalNumberForGender(string number, GrammaticalGender gender) + { if (gender == GrammaticalGender.Masculine) { return number; @@ -222,8 +222,8 @@ static string GetCardinalNumberForGender(string number, GrammaticalGender gender throw new ArgumentOutOfRangeException(nameof(gender)); } - static string GetOrdinalEndingForGender(GrammaticalGender gender) - { + static string GetOrdinalEndingForGender(GrammaticalGender gender) + { switch (gender) { case GrammaticalGender.Masculine: @@ -238,5 +238,4 @@ static string GetOrdinalEndingForGender(GrammaticalGender gender) throw new ArgumentOutOfRangeException(nameof(gender)); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/MalteseNumberToWordsConvertor.cs b/src/Humanizer/Localisation/NumberToWords/MalteseNumberToWordsConvertor.cs index ffe021da4..5495fe926 100644 --- a/src/Humanizer/Localisation/NumberToWords/MalteseNumberToWordsConvertor.cs +++ b/src/Humanizer/Localisation/NumberToWords/MalteseNumberToWordsConvertor.cs @@ -1,236 +1,235 @@ -namespace Humanizer +namespace Humanizer; + +class MalteseNumberToWordsConvertor : GenderedNumberToWordsConverter { - class MalteseNumberToWordsConvertor : GenderedNumberToWordsConverter + static readonly string[] OrdinalOverrideMap = + [ + "0", "l-ewwel", "it-tieni", "it-tielet", "ir-raba'", "il-ħames", "is-sitt", "is-seba'", "it-tmien", "id-disa'", + "l-għaxar", "il-ħdax", "it-tnax", "it-tlettax", "l-erbatax", "il-ħmistax", "is-sittax", "is-sbatax", + "it-tmintax", "id-dsatax", "l-għoxrin" + ]; + + static readonly string[] UnitsMap = + [ + "żero", "wieħed", "tnejn", "tlieta", "erbgħa", "ħamsa", "sitta", "sebgħa", "tmienja", "disgħa", "għaxra", + "ħdax", "tnax", "tlettax", "erbatax", "ħmistax", "sittax", "sbatax", "tmintax", "dsatax" + ]; + + static readonly string[] TensMap = + ["zero", "għaxra", "għoxrin", "tletin", "erbgħin", "ħamsin", "sittin", "sebgħin", "tmenin", "disgħin"]; + + static readonly string[] HundredsMap = + [ + string.Empty, string.Empty, string.Empty, "tlett", "erbgħa", "ħames", "sitt", "sebgħa", "tminn", "disgħa", + "għaxar" + ]; + + static readonly string[] PrefixMap = + [ + string.Empty, string.Empty, string.Empty, "tlett", "erbat", "ħamest", "sitt", "sebat", "tmint", "disat", + "għaxart", "ħdax-il", "tnax-il", "tletax-il", "erbatax-il", "ħmistax-il", "sittax-il", "sbatax-il", + "tmintax-il", "dsatax-il" + ]; + + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] OrdinalOverrideMap = - [ - "0", "l-ewwel", "it-tieni", "it-tielet", "ir-raba'", "il-ħames", "is-sitt", "is-seba'", "it-tmien", "id-disa'", - "l-għaxar", "il-ħdax", "it-tnax", "it-tlettax", "l-erbatax", "il-ħmistax", "is-sittax", "is-sbatax", - "it-tmintax", "id-dsatax", "l-għoxrin" - ]; - - static readonly string[] UnitsMap = - [ - "żero", "wieħed", "tnejn", "tlieta", "erbgħa", "ħamsa", "sitta", "sebgħa", "tmienja", "disgħa", "għaxra", - "ħdax", "tnax", "tlettax", "erbatax", "ħmistax", "sittax", "sbatax", "tmintax", "dsatax" - ]; - - static readonly string[] TensMap = - ["zero", "għaxra", "għoxrin", "tletin", "erbgħin", "ħamsin", "sittin", "sebgħin", "tmenin", "disgħin"]; - - static readonly string[] HundredsMap = - [ - string.Empty, string.Empty, string.Empty, "tlett", "erbgħa", "ħames", "sitt", "sebgħa", "tminn", "disgħa", - "għaxar" - ]; - - static readonly string[] PrefixMap = - [ - string.Empty, string.Empty, string.Empty, "tlett", "erbat", "ħamest", "sitt", "sebat", "tmint", "disat", - "għaxart", "ħdax-il", "tnax-il", "tletax-il", "erbatax-il", "ħmistax-il", "sittax-il", "sbatax-il", - "tmintax-il", "dsatax-il" - ]; - - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { - var negativeNumber = false; - - if (input < 0) - { - negativeNumber = true; - input *= -1; - } - - if (input < 1000000000) - { - return GetMillions(input, gender) + (negativeNumber ? " inqas minn żero" : string.Empty); - } - - var billions = input / 1000000000; - var tensInBillions = billions % 100; - var millions = input % 1000000000; - - var billionsText = GetPrefixText(billions, tensInBillions, "biljun", "żewġ biljuni", "biljuni", false, gender); - var millionsText = GetMillions(millions, gender); - - if (millions == 0) - { - return billionsText; - } - - return $"{billionsText} u {millionsText}" + (negativeNumber ? " inqas minn żero" : string.Empty); - } - - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { - if (number <= 20) - { - return OrdinalOverrideMap[number]; - } - - var ordinal = Convert(number, gender); - - if (ordinal.StartsWith("d")) - { - return $"id-{Convert(number, gender)}"; - } - if (ordinal.StartsWith("s")) - { - return $"is-{Convert(number, gender)}"; - } - if (ordinal.StartsWith("t")) - { - return $"it-{Convert(number, gender)}"; - } - if (ordinal.StartsWith("e")) - { - return $"l-{Convert(number, gender)}"; - } - return $"il-{Convert(number, gender)}"; - } - - static string GetTens(long value, bool usePrefixMap, bool usePrefixMapForLowerDigits, GrammaticalGender gender) - { - if (value == 1 && gender == GrammaticalGender.Feminine) - { - return "waħda"; - } - - if (value < 11 && usePrefixMap && usePrefixMapForLowerDigits) - { - return PrefixMap[value]; - } - - if (value < 11 && usePrefixMap && !usePrefixMapForLowerDigits) - { - return HundredsMap[value]; - } + var negativeNumber = false; + + if (input < 0) + { + negativeNumber = true; + input *= -1; + } + + if (input < 1000000000) + { + return GetMillions(input, gender) + (negativeNumber ? " inqas minn żero" : string.Empty); + } + + var billions = input / 1000000000; + var tensInBillions = billions % 100; + var millions = input % 1000000000; + + var billionsText = GetPrefixText(billions, tensInBillions, "biljun", "żewġ biljuni", "biljuni", false, gender); + var millionsText = GetMillions(millions, gender); - if (value is > 10 and < 20 && usePrefixMap) - { - return PrefixMap[value]; - } + if (millions == 0) + { + return billionsText; + } - if (value < 20) - { - return UnitsMap[value]; - } + return $"{billionsText} u {millionsText}" + (negativeNumber ? " inqas minn żero" : string.Empty); + } - var single = value % 10; - var numberOfTens = value / 10; - if (single == 0) - { - return TensMap[numberOfTens]; - } + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { + if (number <= 20) + { + return OrdinalOverrideMap[number]; + } + + var ordinal = Convert(number, gender); - return $"{UnitsMap[single]} u {TensMap[numberOfTens]}"; + if (ordinal.StartsWith("d")) + { + return $"id-{Convert(number, gender)}"; + } + if (ordinal.StartsWith("s")) + { + return $"is-{Convert(number, gender)}"; + } + if (ordinal.StartsWith("t")) + { + return $"it-{Convert(number, gender)}"; + } + if (ordinal.StartsWith("e")) + { + return $"l-{Convert(number, gender)}"; } + return $"il-{Convert(number, gender)}"; + } - static string GetHundreds(long value, bool usePrefixMap, bool usePrefixMapForLowerValueDigits, GrammaticalGender gender) + static string GetTens(long value, bool usePrefixMap, bool usePrefixMapForLowerDigits, GrammaticalGender gender) + { + if (value == 1 && gender == GrammaticalGender.Feminine) { - if (value < 100) - { - return GetTens(value, usePrefixMap, usePrefixMapForLowerValueDigits, gender); - } + return "waħda"; + } - var tens = value % 100; - var numberOfHundreds = value / 100; + if (value < 11 && usePrefixMap && usePrefixMapForLowerDigits) + { + return PrefixMap[value]; + } - string hundredsText; - if (numberOfHundreds == 1) - { - hundredsText = "mija"; - } - else if (numberOfHundreds == 2) - { - hundredsText = "mitejn"; - } - else - { - hundredsText = HundredsMap[numberOfHundreds] + " mija"; - } + if (value < 11 && usePrefixMap && !usePrefixMapForLowerDigits) + { + return HundredsMap[value]; + } - if (tens == 0) - { - return hundredsText; - } + if (value is > 10 and < 20 && usePrefixMap) + { + return PrefixMap[value]; + } - return $"{hundredsText} u {GetTens(tens, usePrefixMap, usePrefixMapForLowerValueDigits, gender)}"; + if (value < 20) + { + return UnitsMap[value]; } - static string GetThousands(long value, GrammaticalGender gender) + var single = value % 10; + var numberOfTens = value / 10; + if (single == 0) { - if (value < 1000) - { - return GetHundreds(value, false, false, gender); - } + return TensMap[numberOfTens]; + } - var thousands = value / 1000; - var tensInThousands = thousands % 100; - var hundreds = value % 1000; + return $"{UnitsMap[single]} u {TensMap[numberOfTens]}"; + } - var thousandsInText = GetPrefixText(thousands, tensInThousands, "elf", "elfejn", "elef", true, gender); + static string GetHundreds(long value, bool usePrefixMap, bool usePrefixMapForLowerValueDigits, GrammaticalGender gender) + { + if (value < 100) + { + return GetTens(value, usePrefixMap, usePrefixMapForLowerValueDigits, gender); + } - var hundredsInText = GetHundreds(hundreds, false, false, gender); + var tens = value % 100; + var numberOfHundreds = value / 100; - if (hundreds == 0) - { - return thousandsInText; - } + string hundredsText; + if (numberOfHundreds == 1) + { + hundredsText = "mija"; + } + else if (numberOfHundreds == 2) + { + hundredsText = "mitejn"; + } + else + { + hundredsText = HundredsMap[numberOfHundreds] + " mija"; + } - return $"{thousandsInText} u {hundredsInText}"; + if (tens == 0) + { + return hundredsText; } - static string GetMillions(long value, GrammaticalGender gender) + return $"{hundredsText} u {GetTens(tens, usePrefixMap, usePrefixMapForLowerValueDigits, gender)}"; + } + + static string GetThousands(long value, GrammaticalGender gender) + { + if (value < 1000) { - if (value < 1000000) - { - return GetThousands(value, gender); - } + return GetHundreds(value, false, false, gender); + } + + var thousands = value / 1000; + var tensInThousands = thousands % 100; + var hundreds = value % 1000; - var millions = value / 1000000; - var tensInMillions = millions % 100; - var thousands = value % 1000000; + var thousandsInText = GetPrefixText(thousands, tensInThousands, "elf", "elfejn", "elef", true, gender); - var millionsText = GetPrefixText(millions, tensInMillions, "miljun", "żewġ miljuni", "miljuni", false, gender); - var thousandsText = GetThousands(thousands, gender); + var hundredsInText = GetHundreds(hundreds, false, false, gender); - if (thousands == 0) - { - return millionsText; - } + if (hundreds == 0) + { + return thousandsInText; + } + + return $"{thousandsInText} u {hundredsInText}"; + } - return $"{millionsText} u {thousandsText}"; + static string GetMillions(long value, GrammaticalGender gender) + { + if (value < 1000000) + { + return GetThousands(value, gender); } - static string GetPrefixText(long thousands, long tensInThousands, string singular, string dual, string plural, bool usePrefixMapForLowerValueDigits, GrammaticalGender gender) + var millions = value / 1000000; + var tensInMillions = millions % 100; + var thousands = value % 1000000; + + var millionsText = GetPrefixText(millions, tensInMillions, "miljun", "żewġ miljuni", "miljuni", false, gender); + var thousandsText = GetThousands(thousands, gender); + + if (thousands == 0) { - if (thousands == 1) - { - return singular; - } + return millionsText; + } - if (thousands == 2) - { - return dual; - } + return $"{millionsText} u {thousandsText}"; + } + + static string GetPrefixText(long thousands, long tensInThousands, string singular, string dual, string plural, bool usePrefixMapForLowerValueDigits, GrammaticalGender gender) + { + if (thousands == 1) + { + return singular; + } - if (tensInThousands > 10) - { - return $"{GetHundreds(thousands, true, usePrefixMapForLowerValueDigits, gender)} {singular}"; - } + if (thousands == 2) + { + return dual; + } - if (thousands == 100) - { - return $"mitt {singular}"; - } + if (tensInThousands > 10) + { + return $"{GetHundreds(thousands, true, usePrefixMapForLowerValueDigits, gender)} {singular}"; + } - if (thousands == 101) - { - return $"mija u {singular}"; - } + if (thousands == 100) + { + return $"mitt {singular}"; + } - return $"{GetHundreds(thousands, true, usePrefixMapForLowerValueDigits, gender)} {plural}"; + if (thousands == 101) + { + return $"mija u {singular}"; } + + return $"{GetHundreds(thousands, true, usePrefixMapForLowerValueDigits, gender)} {plural}"; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs index ab333fc2d..aca7f52c1 100644 --- a/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs @@ -1,25 +1,25 @@ -namespace Humanizer +namespace Humanizer; + +class NorwegianBokmalNumberToWordsConverter : GenderedNumberToWordsConverter { - class NorwegianBokmalNumberToWordsConverter : GenderedNumberToWordsConverter + static readonly string[] UnitsMap = ["null", "en", "to", "tre", "fire", "fem", "seks", "sju", "åtte", "ni", "ti", "elleve", "tolv", "tretten", "fjorten", "femten", "seksten", "sytten", "atten", "nitten"]; + static readonly string[] TensMap = ["null", "ti", "tjue", "tretti", "førti", "femti", "seksti", "sytti", "åtti", "nitti"]; + + static readonly Dictionary OrdinalExceptions = new() + { + {0, "nullte"}, + {1, "første"}, + {2, "andre"}, + {3, "tredje"}, + {4, "fjerde"}, + {5, "femte"}, + {6, "sjette"}, + {11, "ellevte"}, + {12, "tolvte"} + }; + + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] UnitsMap = ["null", "en", "to", "tre", "fire", "fem", "seks", "sju", "åtte", "ni", "ti", "elleve", "tolv", "tretten", "fjorten", "femten", "seksten", "sytten", "atten", "nitten"]; - static readonly string[] TensMap = ["null", "ti", "tjue", "tretti", "førti", "femti", "seksti", "sytti", "åtti", "nitti"]; - - static readonly Dictionary OrdinalExceptions = new() - { - {0, "nullte"}, - {1, "første"}, - {2, "andre"}, - {3, "tredje"}, - {4, "fjerde"}, - {5, "femte"}, - {6, "sjette"}, - {11, "ellevte"}, - {12, "tolvte"} - }; - - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) - { if (number is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -28,11 +28,11 @@ public override string Convert(long number, GrammaticalGender gender, bool addAn return Convert((int)number, false, gender); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) => - Convert(number, true, gender); + public override string ConvertToOrdinal(int number, GrammaticalGender gender) => + Convert(number, true, gender); - string Convert(int number, bool isOrdinal, GrammaticalGender gender) - { + string Convert(int number, bool isOrdinal, GrammaticalGender gender) + { if (number == 0) { return GetUnitValue(0, isOrdinal); @@ -135,8 +135,8 @@ string Convert(int number, bool isOrdinal, GrammaticalGender gender) return toWords; } - static string GetUnitValue(int number, bool isOrdinal) - { + static string GetUnitValue(int number, bool isOrdinal) + { if (isOrdinal) { if (ExceptionNumbersToWords(number, out var exceptionString)) @@ -155,11 +155,11 @@ static string GetUnitValue(int number, bool isOrdinal) return UnitsMap[number]; } - static bool ExceptionNumbersToWords(int number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); + static bool ExceptionNumbersToWords(int number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); - string Part(string pluralFormat, string singular, int number, bool postfixSpace = false) - { + string Part(string pluralFormat, string singular, int number, bool postfixSpace = false) + { var postfix = postfixSpace ? " " : ""; if (number == 1) { @@ -168,5 +168,4 @@ string Part(string pluralFormat, string singular, int number, bool postfixSpace return string.Format(pluralFormat, Convert(number)) + postfix; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs index 3fdbe6e98..a5953d71a 100644 --- a/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/PolishNumberToWordsConverter.cs @@ -1,40 +1,40 @@ -namespace Humanizer +namespace Humanizer; + +class PolishNumberToWordsConverter(CultureInfo? culture) : + GenderedNumberToWordsConverter { - class PolishNumberToWordsConverter(CultureInfo? culture) : - GenderedNumberToWordsConverter + static readonly string[] HundredsMap = + [ + "zero", "sto", "dwieście", "trzysta", "czterysta", "pięćset", "sześćset", "siedemset", "osiemset", "dziewięćset" + ]; + + static readonly string[] TensMap = + [ + "zero", "dziesięć", "dwadzieścia", "trzydzieści", "czterdzieści", "pięćdziesiąt", "sześćdziesiąt", + "siedemdziesiąt", "osiemdziesiąt", "dziewięćdziesiąt" + ]; + + static readonly string[] UnitsMap = + [ + "zero", "jeden", "dwa", "trzy", "cztery", "pięć", "sześć", "siedem", "osiem", "dziewięć", "dziesięć", + "jedenaście", "dwanaście", "trzynaście", "czternaście", "piętnaście", "szesnaście", "siedemnaście", + "osiemnaście", "dziewiętnaście" + ]; + + static readonly string[][] PowersOfThousandMap = + [ + ["tysiąc", "tysiące", "tysięcy"], + ["milion", "miliony", "milionów"], + ["miliard", "miliardy", "miliardów"], + ["bilion", "biliony", "bilionów"], + ["biliard", "biliardy", "biliardów"], + ["trylion", "tryliony", "trylionów"] + ]; + + const long MaxPossibleDivisor = 1_000_000_000_000_000_000; + + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] HundredsMap = - [ - "zero", "sto", "dwieście", "trzysta", "czterysta", "pięćset", "sześćset", "siedemset", "osiemset", "dziewięćset" - ]; - - static readonly string[] TensMap = - [ - "zero", "dziesięć", "dwadzieścia", "trzydzieści", "czterdzieści", "pięćdziesiąt", "sześćdziesiąt", - "siedemdziesiąt", "osiemdziesiąt", "dziewięćdziesiąt" - ]; - - static readonly string[] UnitsMap = - [ - "zero", "jeden", "dwa", "trzy", "cztery", "pięć", "sześć", "siedem", "osiem", "dziewięć", "dziesięć", - "jedenaście", "dwanaście", "trzynaście", "czternaście", "piętnaście", "szesnaście", "siedemnaście", - "osiemnaście", "dziewiętnaście" - ]; - - static readonly string[][] PowersOfThousandMap = - [ - ["tysiąc", "tysiące", "tysięcy"], - ["milion", "miliony", "milionów"], - ["miliard", "miliardy", "miliardów"], - ["bilion", "biliony", "bilionów"], - ["biliard", "biliardy", "biliardów"], - ["trylion", "tryliony", "trylionów"] - ]; - - const long MaxPossibleDivisor = 1_000_000_000_000_000_000; - - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { if (input == 0) { return "zero"; @@ -46,11 +46,11 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) => - number.ToString(culture); + public override string ConvertToOrdinal(int number, GrammaticalGender gender) => + number.ToString(culture); - static void CollectParts(ICollection parts, long input, GrammaticalGender gender) - { + static void CollectParts(ICollection parts, long input, GrammaticalGender gender) + { var inputSign = 1; if (input < 0) { @@ -91,8 +91,8 @@ static void CollectParts(ICollection parts, long input, GrammaticalGende } } - static void CollectPartsUnderThousand(ICollection parts, int number, GrammaticalGender gender) - { + static void CollectPartsUnderThousand(ICollection parts, int number, GrammaticalGender gender) + { var hundredsDigit = number / 100; var tensDigit = number % 100 / 10; var unitsDigit = number % 10; @@ -133,8 +133,8 @@ static void CollectPartsUnderThousand(ICollection parts, int number, Gra } } - static string GetPowerOfThousandNameForm(int multiplier, int power) - { + static string GetPowerOfThousandNameForm(int multiplier, int power) + { const int singularIndex = 0; const int pluralIndex = 1; const int genitiveIndex = 2; @@ -151,5 +151,4 @@ static string GetPowerOfThousandNameForm(int multiplier, int power) } return PowersOfThousandMap[power][pluralIndex]; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/PortugueseNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/PortugueseNumberToWordsConverter.cs index 56382d1be..ecc1a3f55 100644 --- a/src/Humanizer/Localisation/NumberToWords/PortugueseNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/PortugueseNumberToWordsConverter.cs @@ -1,17 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +class PortugueseNumberToWordsConverter : GenderedNumberToWordsConverter { - class PortugueseNumberToWordsConverter : GenderedNumberToWordsConverter - { - static readonly string[] PortugueseUnitsMap = ["zero", "um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezessete", "dezoito", "dezenove"]; - static readonly string[] PortugueseTensMap = ["zero", "dez", "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa"]; - static readonly string[] PortugueseHundredsMap = ["zero", "cento", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos"]; + static readonly string[] PortugueseUnitsMap = ["zero", "um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezessete", "dezoito", "dezenove"]; + static readonly string[] PortugueseTensMap = ["zero", "dez", "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa"]; + static readonly string[] PortugueseHundredsMap = ["zero", "cento", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos"]; - static readonly string[] PortugueseOrdinalUnitsMap = ["zero", "primeiro", "segundo", "terceiro", "quarto", "quinto", "sexto", "sétimo", "oitavo", "nono"]; - static readonly string[] PortugueseOrdinalTensMap = ["zero", "décimo", "vigésimo", "trigésimo", "quadragésimo", "quinquagésimo", "sexagésimo", "septuagésimo", "octogésimo", "nonagésimo"]; - static readonly string[] PortugueseOrdinalHundredsMap = ["zero", "centésimo", "ducentésimo", "trecentésimo", "quadringentésimo", "quingentésimo", "sexcentésimo", "septingentésimo", "octingentésimo", "noningentésimo"]; + static readonly string[] PortugueseOrdinalUnitsMap = ["zero", "primeiro", "segundo", "terceiro", "quarto", "quinto", "sexto", "sétimo", "oitavo", "nono"]; + static readonly string[] PortugueseOrdinalTensMap = ["zero", "décimo", "vigésimo", "trigésimo", "quadragésimo", "quinquagésimo", "sexagésimo", "septuagésimo", "octogésimo", "nonagésimo"]; + static readonly string[] PortugueseOrdinalHundredsMap = ["zero", "centésimo", "ducentésimo", "trecentésimo", "quadringentésimo", "quingentésimo", "sexcentésimo", "septingentésimo", "octingentésimo", "noningentésimo"]; - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) + { if (input is > 999999999999 or < -999999999999) { throw new NotImplementedException(); @@ -99,8 +99,8 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { // N/A in Portuguese ordinal if (number == 0) { @@ -156,8 +156,8 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender) return string.Join(" ", parts); } - static string ApplyGender(string toWords, GrammaticalGender gender) - { + static string ApplyGender(string toWords, GrammaticalGender gender) + { if (gender != GrammaticalGender.Feminine) { return toWords; @@ -181,8 +181,8 @@ static string ApplyGender(string toWords, GrammaticalGender gender) return toWords; } - static string ApplyOrdinalGender(string toWords, GrammaticalGender gender) - { + static string ApplyOrdinalGender(string toWords, GrammaticalGender gender) + { if (gender == GrammaticalGender.Feminine) { return toWords.TrimEnd('o') + 'a'; @@ -190,5 +190,4 @@ static string ApplyOrdinalGender(string toWords, GrammaticalGender gender) return toWords; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianCardinalNumberConverter.cs b/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianCardinalNumberConverter.cs index 9db3d61cf..203c6eb92 100644 --- a/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianCardinalNumberConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianCardinalNumberConverter.cs @@ -1,98 +1,98 @@ -namespace Humanizer +namespace Humanizer; + +class RomanianCardinalNumberConverter { - class RomanianCardinalNumberConverter + /// + /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9 for 9. + /// + readonly string[] _units = + [ + string.Empty, + "unu|una|unu", + "doi|două|două", + "trei", + "patru", + "cinci", + "șase", + "șapte", + "opt", + "nouă" + ]; + + /// + /// Lookup table converting teens number to text. Index 0 for 10, index 1 for 11, up to index 9 for 19. + /// + readonly string[] _teensUnder20NumberToText = + [ + "zece", + "unsprezece", + "doisprezece|douăsprezece|douăsprezece", + "treisprezece", + "paisprezece", + "cincisprezece", + "șaisprezece", + "șaptesprezece", + "optsprezece", + "nouăsprezece" + ]; + + /// + /// Lookup table converting tens number to text. Index 2 for 20, index 3 for 30, up to index 9 for 90. + /// + readonly string[] _tensOver20NumberToText = + [ + string.Empty, + string.Empty, + "douăzeci", + "treizeci", + "patruzeci", + "cincizeci", + "șaizeci", + "șaptezeci", + "optzeci", + "nouăzeci" + ]; + + readonly string _feminineSingular = "o"; + readonly string _masculineSingular = "un"; + + readonly string _joinGroups = "și"; + readonly string _joinAbove20 = "de"; + readonly string _minusSign = "minus"; + + /// + /// Enumerates sets of three-digits having distinct conversion to text. + /// + enum ThreeDigitSets { /// - /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9 for 9. + /// Lowest three-digits set, from 1 to 999. /// - readonly string[] _units = - [ - string.Empty, - "unu|una|unu", - "doi|două|două", - "trei", - "patru", - "cinci", - "șase", - "șapte", - "opt", - "nouă" - ]; + Units = 0, /// - /// Lookup table converting teens number to text. Index 0 for 10, index 1 for 11, up to index 9 for 19. + /// Three-digits set counting the thousands, from 1'000 to 999'000. /// - readonly string[] _teensUnder20NumberToText = - [ - "zece", - "unsprezece", - "doisprezece|douăsprezece|douăsprezece", - "treisprezece", - "paisprezece", - "cincisprezece", - "șaisprezece", - "șaptesprezece", - "optsprezece", - "nouăsprezece" - ]; + Thousands = 1, /// - /// Lookup table converting tens number to text. Index 2 for 20, index 3 for 30, up to index 9 for 90. + /// Three-digits set counting millions, from 1'000'000 to 999'000'000. /// - readonly string[] _tensOver20NumberToText = - [ - string.Empty, - string.Empty, - "douăzeci", - "treizeci", - "patruzeci", - "cincizeci", - "șaizeci", - "șaptezeci", - "optzeci", - "nouăzeci" - ]; - - readonly string _feminineSingular = "o"; - readonly string _masculineSingular = "un"; - - readonly string _joinGroups = "și"; - readonly string _joinAbove20 = "de"; - readonly string _minusSign = "minus"; + Millions = 2, /// - /// Enumerates sets of three-digits having distinct conversion to text. + /// Three-digits set counting billions, from 1'000'000'000 to 999'000'000'000. /// - enum ThreeDigitSets - { - /// - /// Lowest three-digits set, from 1 to 999. - /// - Units = 0, - - /// - /// Three-digits set counting the thousands, from 1'000 to 999'000. - /// - Thousands = 1, - - /// - /// Three-digits set counting millions, from 1'000'000 to 999'000'000. - /// - Millions = 2, - - /// - /// Three-digits set counting billions, from 1'000'000'000 to 999'000'000'000. - /// - Billions = 3, - - /// - /// Three-digits set beyond 999 billions, from 1'000'000'000'000 onward. - /// - More = 4 - } + Billions = 3, + + /// + /// Three-digits set beyond 999 billions, from 1'000'000'000'000 onward. + /// + More = 4 + } - public string Convert(int number, GrammaticalGender gender) - { + public string Convert(int number, GrammaticalGender gender) + { if (number == 0) { return "zero"; @@ -132,14 +132,14 @@ public string Convert(int number, GrammaticalGender gender) return words.TrimEnd().Replace(" ", " "); } - /// - /// Splits a number into a sequence of three-digits numbers, - /// starting from units, then thousands, millions, and so on. - /// - /// The number to split. - /// The sequence of three-digit numbers. - static List SplitEveryThreeDigits(int number) - { + /// + /// Splits a number into a sequence of three-digits numbers, + /// starting from units, then thousands, millions, and so on. + /// + /// The number to split. + /// The sequence of three-digit numbers. + static List SplitEveryThreeDigits(int number) + { var parts = new List(); var rest = number; @@ -155,13 +155,13 @@ static List SplitEveryThreeDigits(int number) return parts; } - /// - /// During number conversion to text, finds out the converter - /// to use for the next three-digit set. - /// - /// The next conversion function to use. - Func? GetNextPartConverter(ThreeDigitSets currentSet) - { + /// + /// During number conversion to text, finds out the converter + /// to use for the next three-digit set. + /// + /// The next conversion function to use. + Func? GetNextPartConverter(ThreeDigitSets currentSet) + { Func? converter; switch (currentSet) @@ -193,14 +193,14 @@ static List SplitEveryThreeDigits(int number) return converter; } - /// - /// Converts a three-digit set to text. - /// - /// The three-digit set to convert. - /// The grammatical gender to convert to. - /// The same three-digit set expressed as text. - string ThreeDigitSetConverter(int number, GrammaticalGender gender) - { + /// + /// Converts a three-digit set to text. + /// + /// The three-digit set to convert. + /// The grammatical gender to convert to. + /// The same three-digit set expressed as text. + string ThreeDigitSetConverter(int number, GrammaticalGender gender) + { if (number == 0) { return string.Empty; @@ -244,8 +244,8 @@ string ThreeDigitSetConverter(int number, GrammaticalGender gender) return words; } - static string GetPartByGender(string multiGenderPart, GrammaticalGender gender) - { + static string GetPartByGender(string multiGenderPart, GrammaticalGender gender) + { if (multiGenderPart.Contains("|")) { var parts = multiGenderPart.Split('|'); @@ -265,11 +265,11 @@ static string GetPartByGender(string multiGenderPart, GrammaticalGender gender) return multiGenderPart; } - static bool IsAbove20(int number) => - number >= 20; + static bool IsAbove20(int number) => + number >= 20; - string HundredsToText(int hundreds) - { + string HundredsToText(int hundreds) + { if (hundreds == 0) { return string.Empty; @@ -283,23 +283,23 @@ string HundredsToText(int hundreds) return GetPartByGender(_units[hundreds], GrammaticalGender.Feminine) + " sute"; } - /// - /// Converts a three-digit number, as units, to text. - /// - /// The three-digit number, as units, to convert. - /// The grammatical gender to convert to. - /// The same three-digit number, as units, expressed as text. - string UnitsConverter(int number, GrammaticalGender gender) => - ThreeDigitSetConverter(number, gender); - - /// - /// Converts a thousands three-digit number to text. - /// - /// The three-digit number, as thousands, to convert. - /// The grammatical gender to convert to. - /// The same three-digit number of thousands expressed as text. - string ThousandsConverter(int number, GrammaticalGender gender) - { + /// + /// Converts a three-digit number, as units, to text. + /// + /// The three-digit number, as units, to convert. + /// The grammatical gender to convert to. + /// The same three-digit number, as units, expressed as text. + string UnitsConverter(int number, GrammaticalGender gender) => + ThreeDigitSetConverter(number, gender); + + /// + /// Converts a thousands three-digit number to text. + /// + /// The three-digit number, as thousands, to convert. + /// The grammatical gender to convert to. + /// The same three-digit number of thousands expressed as text. + string ThousandsConverter(int number, GrammaticalGender gender) + { if (number == 0) { return string.Empty; @@ -313,26 +313,26 @@ string ThousandsConverter(int number, GrammaticalGender gender) return ThreeDigitSetConverter(number, GrammaticalGender.Feminine) + (IsAbove20(number) ? " " + _joinAbove20 : string.Empty) + " mii"; } - // Large numbers (above 10^6) use a combined form of the long and short scales. - /* - Singular Plural Order Scale - ----------------------------------------------- - zece zeci 10^1 - - sută sute 10^2 - - mie mii 10^3 - - milion milioane 10^6 short/long - miliard miliarde 10^9 long - trilion trilioane 10^12 short - */ - - /// - /// Converts a millions three-digit number to text. - /// - /// The three-digit number, as millions, to convert. - /// The grammatical gender to convert to. - /// The same three-digit number of millions expressed as text. - string MillionsConverter(int number, GrammaticalGender gender) - { + // Large numbers (above 10^6) use a combined form of the long and short scales. + /* + Singular Plural Order Scale + ----------------------------------------------- + zece zeci 10^1 - + sută sute 10^2 - + mie mii 10^3 - + milion milioane 10^6 short/long + miliard miliarde 10^9 long + trilion trilioane 10^12 short + */ + + /// + /// Converts a millions three-digit number to text. + /// + /// The three-digit number, as millions, to convert. + /// The grammatical gender to convert to. + /// The same three-digit number of millions expressed as text. + string MillionsConverter(int number, GrammaticalGender gender) + { if (number == 0) { return string.Empty; @@ -346,14 +346,14 @@ string MillionsConverter(int number, GrammaticalGender gender) return ThreeDigitSetConverter(number, GrammaticalGender.Feminine) + (IsAbove20(number) ? " " + _joinAbove20 : string.Empty) + " milioane"; } - /// - /// Converts a billions three-digit number to text. - /// - /// The three-digit number, as billions, to convert. - /// The grammatical gender to convert to. - /// The same three-digit number of billions expressed as text. - string BillionsConverter(int number, GrammaticalGender gender) - { + /// + /// Converts a billions three-digit number to text. + /// + /// The three-digit number, as billions, to convert. + /// The grammatical gender to convert to. + /// The same three-digit number of billions expressed as text. + string BillionsConverter(int number, GrammaticalGender gender) + { if (number == 1) { return _masculineSingular + " miliard"; @@ -361,5 +361,4 @@ string BillionsConverter(int number, GrammaticalGender gender) return ThreeDigitSetConverter(number, GrammaticalGender.Feminine) + (IsAbove20(number) ? " " + _joinAbove20 : string.Empty) + " miliarde"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianOrdinalNumberConverter.cs b/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianOrdinalNumberConverter.cs index cc12e6129..9fd119b24 100644 --- a/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianOrdinalNumberConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/Romanian/RomanianOrdinalNumberConverter.cs @@ -1,30 +1,30 @@ -namespace Humanizer +namespace Humanizer; + +class RomanianOrdinalNumberConverter { - class RomanianOrdinalNumberConverter + /// + /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9. + /// + readonly Dictionary _ordinalsUnder10 = new() + { + {1, "primul|prima"}, + {2, "doilea|doua"}, + {3, "treilea|treia"}, + {4, "patrulea|patra"}, + {5, "cincilea|cincea"}, + {6, "șaselea|șasea"}, + {7, "șaptelea|șaptea"}, + {8, "optulea|opta"}, + {9, "nouălea|noua"}, + }; + + readonly string _femininePrefix = "a"; + readonly string _masculinePrefix = "al"; + readonly string _feminineSuffix = "a"; + readonly string _masculineSuffix = "lea"; + + public string Convert(int number, GrammaticalGender gender) { - /// - /// Lookup table converting units number to text. Index 1 for 1, index 2 for 2, up to index 9. - /// - readonly Dictionary _ordinalsUnder10 = new() - { - {1, "primul|prima"}, - {2, "doilea|doua"}, - {3, "treilea|treia"}, - {4, "patrulea|patra"}, - {5, "cincilea|cincea"}, - {6, "șaselea|șasea"}, - {7, "șaptelea|șaptea"}, - {8, "optulea|opta"}, - {9, "nouălea|noua"}, - }; - - readonly string _femininePrefix = "a"; - readonly string _masculinePrefix = "al"; - readonly string _feminineSuffix = "a"; - readonly string _masculineSuffix = "lea"; - - public string Convert(int number, GrammaticalGender gender) - { // it's easier to treat zero as a completely distinct case if (number == 0) { @@ -111,8 +111,8 @@ public string Convert(int number, GrammaticalGender gender) ); } - static string GetPartByGender(string multiGenderPart, GrammaticalGender gender) - { + static string GetPartByGender(string multiGenderPart, GrammaticalGender gender) + { if (multiGenderPart.Contains("|")) { var parts = multiGenderPart.Split('|'); @@ -126,5 +126,4 @@ static string GetPartByGender(string multiGenderPart, GrammaticalGender gender) return multiGenderPart; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs index b8ef26687..b36539005 100644 --- a/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/RomanianNumberToWordsConverter.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class RomanianNumberToWordsConverter : GenderedNumberToWordsConverter { - class RomanianNumberToWordsConverter : GenderedNumberToWordsConverter + public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) { - public override string Convert(long number, GrammaticalGender gender, bool addAnd = true) - { if (number is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -12,10 +12,9 @@ public override string Convert(long number, GrammaticalGender gender, bool addAn return converter.Convert((int)number, gender); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { var converter = new RomanianOrdinalNumberConverter(); return converter.Convert(number, gender); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs index a9cbd1107..11641c4b8 100644 --- a/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/RussianNumberToWordsConverter.cs @@ -1,17 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +class RussianNumberToWordsConverter : GenderedNumberToWordsConverter { - class RussianNumberToWordsConverter : GenderedNumberToWordsConverter + static readonly string[] HundredsMap = ["ноль", "сто", "двести", "триста", "четыреста", "пятьсот", "шестьсот", "семьсот", "восемьсот", "девятьсот"]; + static readonly string[] TensMap = ["ноль", "десять", "двадцать", "тридцать", "сорок", "пятьдесят", "шестьдесят", "семьдесят", "восемьдесят", "девяносто"]; + static readonly string[] UnitsMap = ["ноль", "один", "два", "три", "четыре", "пять", "шесть", "семь", "восемь", "девять", "десять", "одиннадцать", "двенадцать", "тринадцать", "четырнадцать", "пятнадцать", "шестнадцать", "семнадцать", "восемнадцать", "девятнадцать"]; + static readonly string[] UnitsOrdinalPrefixes = [string.Empty, string.Empty, "двух", "трёх", "четырёх", "пяти", "шести", "семи", "восьми", "девяти", "десяти", "одиннадцати", "двенадцати", "тринадцати", "четырнадцати", "пятнадцати", "шестнадцати", "семнадцати", "восемнадцати", "девятнадцати"]; + static readonly string[] TensOrdinalPrefixes = [string.Empty, "десяти", "двадцати", "тридцати", "сорока", "пятидесяти", "шестидесяти", "семидесяти", "восьмидесяти", "девяносто"]; + static readonly string[] TensOrdinal = [string.Empty, "десят", "двадцат", "тридцат", "сороков", "пятидесят", "шестидесят", "семидесят", "восьмидесят", "девяност"]; + static readonly string[] UnitsOrdinal = [string.Empty, "перв", "втор", "трет", "четверт", "пят", "шест", "седьм", "восьм", "девят", "десят", "одиннадцат", "двенадцат", "тринадцат", "четырнадцат", "пятнадцат", "шестнадцат", "семнадцат", "восемнадцат", "девятнадцат"]; + + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] HundredsMap = ["ноль", "сто", "двести", "триста", "четыреста", "пятьсот", "шестьсот", "семьсот", "восемьсот", "девятьсот"]; - static readonly string[] TensMap = ["ноль", "десять", "двадцать", "тридцать", "сорок", "пятьдесят", "шестьдесят", "семьдесят", "восемьдесят", "девяносто"]; - static readonly string[] UnitsMap = ["ноль", "один", "два", "три", "четыре", "пять", "шесть", "семь", "восемь", "девять", "десять", "одиннадцать", "двенадцать", "тринадцать", "четырнадцать", "пятнадцать", "шестнадцать", "семнадцать", "восемнадцать", "девятнадцать"]; - static readonly string[] UnitsOrdinalPrefixes = [string.Empty, string.Empty, "двух", "трёх", "четырёх", "пяти", "шести", "семи", "восьми", "девяти", "десяти", "одиннадцати", "двенадцати", "тринадцати", "четырнадцати", "пятнадцати", "шестнадцати", "семнадцати", "восемнадцати", "девятнадцати"]; - static readonly string[] TensOrdinalPrefixes = [string.Empty, "десяти", "двадцати", "тридцати", "сорока", "пятидесяти", "шестидесяти", "семидесяти", "восьмидесяти", "девяносто"]; - static readonly string[] TensOrdinal = [string.Empty, "десят", "двадцат", "тридцат", "сороков", "пятидесят", "шестидесят", "семидесят", "восьмидесят", "девяност"]; - static readonly string[] UnitsOrdinal = [string.Empty, "перв", "втор", "трет", "четверт", "пят", "шест", "седьм", "восьм", "девят", "десят", "одиннадцат", "двенадцат", "тринадцат", "четырнадцат", "пятнадцат", "шестнадцат", "семнадцат", "восемнадцат", "девятнадцат"]; - - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { if (input == 0) { return "ноль"; @@ -39,8 +39,8 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int input, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int input, GrammaticalGender gender) + { if (input == 0) { return "нулев" + GetEndingForGender(gender, input); @@ -97,8 +97,8 @@ public override string ConvertToOrdinal(int input, GrammaticalGender gender) return string.Join(" ", parts); } - static void CollectPartsUnderOneThousand(ICollection parts, long number, GrammaticalGender gender) - { + static void CollectPartsUnderOneThousand(ICollection parts, long number, GrammaticalGender gender) + { if (number >= 100) { var hundreds = number / 100; @@ -134,8 +134,8 @@ static void CollectPartsUnderOneThousand(ICollection parts, long number, } } - static string GetPrefix(long number) - { + static string GetPrefix(long number) + { var parts = new List(); if (number >= 100) @@ -167,8 +167,8 @@ static string GetPrefix(long number) return string.Concat(parts); } - static void CollectParts(ICollection parts, ref long number, long divisor, GrammaticalGender gender, params string[] forms) - { + static void CollectParts(ICollection parts, ref long number, long divisor, GrammaticalGender gender, params string[] forms) + { var result = Math.Abs(number / divisor); if (result == 0) { @@ -181,8 +181,8 @@ static void CollectParts(ICollection parts, ref long number, long diviso parts.Add(ChooseOneForGrammaticalNumber(result, forms)); } - static void CollectOrdinalParts(ICollection parts, ref long number, int divisor, GrammaticalGender gender, string prefixedForm, params string[] forms) - { + static void CollectOrdinalParts(ICollection parts, ref long number, int divisor, GrammaticalGender gender, string prefixedForm, params string[] forms) + { if (number < divisor) { return; @@ -208,8 +208,8 @@ static void CollectOrdinalParts(ICollection parts, ref long number, int } } - static int GetIndex(RussianGrammaticalNumber number) - { + static int GetIndex(RussianGrammaticalNumber number) + { if (number == RussianGrammaticalNumber.Singular) { return 0; @@ -223,11 +223,11 @@ static int GetIndex(RussianGrammaticalNumber number) return 2; } - static string ChooseOneForGrammaticalNumber(long number, string[] forms) => - forms[GetIndex(RussianGrammaticalNumberDetector.Detect(number))]; + static string ChooseOneForGrammaticalNumber(long number, string[] forms) => + forms[GetIndex(RussianGrammaticalNumberDetector.Detect(number))]; - static string GetEndingForGender(GrammaticalGender gender, long number) - { + static string GetEndingForGender(GrammaticalGender gender, long number) + { switch (gender) { case GrammaticalGender.Masculine: @@ -260,5 +260,4 @@ static string GetEndingForGender(GrammaticalGender gender, long number) throw new ArgumentOutOfRangeException(nameof(gender)); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs index b1f19e42b..c9d324195 100644 --- a/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SerbianCyrlNumberToWordsConverter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class SerbianCyrlNumberToWordsConverter(CultureInfo? culture) : + GenderlessNumberToWordsConverter { - class SerbianCyrlNumberToWordsConverter(CultureInfo? culture) : - GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap = ["нула", "један", "два", "три", "четири", "пет", "шест", "седам", "осам", "девет", "десет", "једанест", "дванаест", "тринаест", "четрнаест", "петнаест", "шеснаест", "седамнаест", "осамнаест", "деветнаест"]; - static readonly string[] TensMap = ["нула", "десет", "двадесет", "тридесет", "четрдесет", "петдесет", "шестдесет", "седамдесет", "осамдесет", "деветдесет"]; + static readonly string[] UnitsMap = ["нула", "један", "два", "три", "четири", "пет", "шест", "седам", "осам", "девет", "десет", "једанест", "дванаест", "тринаест", "четрнаест", "петнаест", "шеснаест", "седамнаест", "осамнаест", "деветнаест"]; + static readonly string[] TensMap = ["нула", "десет", "двадесет", "тридесет", "четрдесет", "петдесет", "шестдесет", "седамдесет", "осамдесет", "деветдесет"]; - public override string Convert(long input) - { + public override string Convert(long input) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -99,12 +99,12 @@ public override string Convert(long input) return string.Concat(parts); } - public override string ConvertToOrdinal(int number) => - //TODO: In progress - number.ToString(culture); + public override string ConvertToOrdinal(int number) => + //TODO: In progress + number.ToString(culture); - string Part(string singular, string dual, string trialQuadral, string plural, int number) - { + string Part(string singular, string dual, string trialQuadral, string plural, int number) + { switch (number) { case 1: @@ -118,5 +118,4 @@ string Part(string singular, string dual, string trialQuadral, string plural, in return string.Format(plural, Convert(number)); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs index c8003d0bb..f13f971e8 100644 --- a/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SerbianNumberToWordsConverter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class SerbianNumberToWordsConverter(CultureInfo? culture) : + GenderlessNumberToWordsConverter { - class SerbianNumberToWordsConverter(CultureInfo? culture) : - GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap = ["nula", "jedan", "dva", "tri", "četiri", "pet", "šest", "sedam", "osam", "devet", "deset", "jedanaest", "dvanaest", "trinaest", "četrnaest", "petnaest", "šestnaest", "sedemnaest", "osemnaest", "devetnaest"]; - static readonly string[] TensMap = ["nula", "deset", "dvadeset", "trideset", "četrdeset", "petdeset", "šestdeset", "sedamdeset", "osamdeset", "devetdeset"]; + static readonly string[] UnitsMap = ["nula", "jedan", "dva", "tri", "četiri", "pet", "šest", "sedam", "osam", "devet", "deset", "jedanaest", "dvanaest", "trinaest", "četrnaest", "petnaest", "šestnaest", "sedemnaest", "osemnaest", "devetnaest"]; + static readonly string[] TensMap = ["nula", "deset", "dvadeset", "trideset", "četrdeset", "petdeset", "šestdeset", "sedamdeset", "osamdeset", "devetdeset"]; - public override string Convert(long input) - { + public override string Convert(long input) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -97,12 +97,12 @@ public override string Convert(long input) return string.Concat(parts); } - public override string ConvertToOrdinal(int number) => - //TODO: In progress - number.ToString(culture); + public override string ConvertToOrdinal(int number) => + //TODO: In progress + number.ToString(culture); - string Part(string singular, string dual, string trialQuadral, string plural, int number) - { + string Part(string singular, string dual, string trialQuadral, string plural, int number) + { switch (number) { case 1: @@ -116,5 +116,4 @@ string Part(string singular, string dual, string trialQuadral, string plural, in return string.Format(plural, Convert(number)); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs index b94b233d7..493761473 100644 --- a/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SlovenianNumberToWordsConverter.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +class SlovenianNumberToWordsConverter(CultureInfo? culture) : + GenderlessNumberToWordsConverter { - class SlovenianNumberToWordsConverter(CultureInfo? culture) : - GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap = ["nič", "ena", "dva", "tri", "štiri", "pet", "šest", "sedem", "osem", "devet", "deset", "enajst", "dvanajst", "trinajst", "štirinajst", "petnajst", "šestnajst", "sedemnajst", "osemnajst", "devetnajst"]; - static readonly string[] TensMap = ["nič", "deset", "dvajset", "trideset", "štirideset", "petdeset", "šestdeset", "sedemdeset", "osemdeset", "devetdeset"]; + static readonly string[] UnitsMap = ["nič", "ena", "dva", "tri", "štiri", "pet", "šest", "sedem", "osem", "devet", "deset", "enajst", "dvanajst", "trinajst", "štirinajst", "petnajst", "šestnajst", "sedemnajst", "osemnajst", "devetnajst"]; + static readonly string[] TensMap = ["nič", "deset", "dvajset", "trideset", "štirideset", "petdeset", "šestdeset", "sedemdeset", "osemdeset", "devetdeset"]; - public override string Convert(long input) - { + public override string Convert(long input) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -97,11 +97,11 @@ public override string Convert(long input) return string.Concat(parts); } - public override string ConvertToOrdinal(int number) => - number.ToString(culture); + public override string ConvertToOrdinal(int number) => + number.ToString(culture); - string Part(string singular, string dual, string trialQuadral, string plural, int number) - { + string Part(string singular, string dual, string trialQuadral, string plural, int number) + { if (number == 1) { return singular; @@ -119,5 +119,4 @@ string Part(string singular, string dual, string trialQuadral, string plural, in return string.Format(plural, Convert(number)); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs index c570f95f6..003402c6c 100644 --- a/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SpanishNumberToWordsConverter.cs @@ -1,60 +1,60 @@ -namespace Humanizer +namespace Humanizer; + +class SpanishNumberToWordsConverter : GenderedNumberToWordsConverter { - class SpanishNumberToWordsConverter : GenderedNumberToWordsConverter + static readonly string[] HundredsRootMap = + [ + "cero", "ciento", "doscient", "trescient", "cuatrocient", "quinient", "seiscient", "setecient", + "ochocient", "novecient" + ]; + + static readonly string[] HundredthsRootMap = + [ + "", "centésim", "ducentésim", "tricentésim", "cuadringentésim", "quingentésim", "sexcentésim", + "septingentésim", "octingentésim", "noningentésim" + ]; + + static readonly string[] OrdinalsRootMap = + [ + "" , "primer", "segund", "tercer", "cuart", "quint", "sext", + "séptim", "octav", "noven" + ]; + + static readonly string[] TensMap = + [ + "cero", "diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa" + ]; + + static readonly string[] TenthsRootMap = + [ + "", "décim", "vigésim", "trigésim", "cuadragésim", "quincuagésim", "sexagésim", "septuagésim", + "octogésim", "nonagésim" + ]; + + static readonly string[] ThousandthsRootMap = + [ + "", "milésim", "dosmilésim", "tresmilésim", "cuatromilésim", "cincomilésim", "seismilésim", + "sietemilésim", "ochomilésim", "nuevemilésim" + ]; + + static readonly string[] TupleMap = + [ + "cero veces", "una vez", "doble", "triple", "cuádruple", "quíntuple", "séxtuple", "séptuple", "óctuple", + "nonuplo", "décuplo", "undécuplo", "duodécuplo", "terciodécuplo" + ]; + + static readonly string[] UnitsMap = + [ + "cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", + "trece", "catorce", "quince", "dieciséis", "diecisiete", "dieciocho", "diecinueve", "veinte", "veintiuno", + "veintidós", "veintitrés", "veinticuatro", "veinticinco", "veintiséis", "veintisiete", "veintiocho", "veintinueve" + ]; + + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) => + Convert(input, WordForm.Normal, gender, addAnd); + + public override string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] HundredsRootMap = - [ - "cero", "ciento", "doscient", "trescient", "cuatrocient", "quinient", "seiscient", "setecient", - "ochocient", "novecient" - ]; - - static readonly string[] HundredthsRootMap = - [ - "", "centésim", "ducentésim", "tricentésim", "cuadringentésim", "quingentésim", "sexcentésim", - "septingentésim", "octingentésim", "noningentésim" - ]; - - static readonly string[] OrdinalsRootMap = - [ - "" , "primer", "segund", "tercer", "cuart", "quint", "sext", - "séptim", "octav", "noven" - ]; - - static readonly string[] TensMap = - [ - "cero", "diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa" - ]; - - static readonly string[] TenthsRootMap = - [ - "", "décim", "vigésim", "trigésim", "cuadragésim", "quincuagésim", "sexagésim", "septuagésim", - "octogésim", "nonagésim" - ]; - - static readonly string[] ThousandthsRootMap = - [ - "", "milésim", "dosmilésim", "tresmilésim", "cuatromilésim", "cincomilésim", "seismilésim", - "sietemilésim", "ochomilésim", "nuevemilésim" - ]; - - static readonly string[] TupleMap = - [ - "cero veces", "una vez", "doble", "triple", "cuádruple", "quíntuple", "séxtuple", "séptuple", "óctuple", - "nonuplo", "décuplo", "undécuplo", "duodécuplo", "terciodécuplo" - ]; - - static readonly string[] UnitsMap = - [ - "cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", - "trece", "catorce", "quince", "dieciséis", "diecisiete", "dieciocho", "diecinueve", "veinte", "veintiuno", - "veintidós", "veintitrés", "veinticuatro", "veinticinco", "veintiséis", "veintisiete", "veintiocho", "veintinueve" - ]; - - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) => - Convert(input, WordForm.Normal, gender, addAnd); - - public override string Convert(long number, WordForm wordForm, GrammaticalGender gender, bool addAnd = true) - { List wordBuilder = []; if (number == 0) @@ -82,11 +82,11 @@ public override string Convert(long number, WordForm wordForm, GrammaticalGender return BuildWord(wordBuilder); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) => - ConvertToOrdinal(number, gender, WordForm.Normal); + public override string ConvertToOrdinal(int number, GrammaticalGender gender) => + ConvertToOrdinal(number, gender, WordForm.Normal); - public override string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender, WordForm wordForm) + { List wordBuilder = []; if (number is 0 or int.MinValue) @@ -118,8 +118,8 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender, Wo return BuildWord(wordBuilder); } - public override string ConvertToTuple(int number) - { + public override string ConvertToTuple(int number) + { number = Math.Abs(number); if (number < TupleMap.Length) @@ -128,15 +128,15 @@ public override string ConvertToTuple(int number) return Convert(number) + " veces"; } - static string BuildWord(IReadOnlyList wordParts) - { + static string BuildWord(IReadOnlyList wordParts) + { var parts = wordParts.ToList(); parts.RemoveAll(string.IsNullOrEmpty); return string.Join(" ", parts); } - static string ConvertHundreds(in long inputNumber, out long remainder, GrammaticalGender gender) - { + static string ConvertHundreds(in long inputNumber, out long remainder, GrammaticalGender gender) + { var wordPart = string.Empty; remainder = inputNumber; @@ -152,16 +152,16 @@ static string ConvertHundreds(in long inputNumber, out long remainder, Grammatic return wordPart; } - static string ConvertHundredths(in int number, out int remainder, GrammaticalGender gender) => - ConvertMappedOrdinalNumber(number, 100, HundredthsRootMap, out remainder, gender); + static string ConvertHundredths(in int number, out int remainder, GrammaticalGender gender) => + ConvertMappedOrdinalNumber(number, 100, HundredthsRootMap, out remainder, gender); - static string ConvertMappedOrdinalNumber( - in int number, - in int divisor, - IReadOnlyList map, - out int remainder, - GrammaticalGender gender) - { + static string ConvertMappedOrdinalNumber( + in int number, + in int divisor, + IReadOnlyList map, + out int remainder, + GrammaticalGender gender) + { var wordPart = string.Empty; remainder = number; @@ -175,8 +175,8 @@ static string ConvertMappedOrdinalNumber( return wordPart; } - static string ConvertOrdinalUnits(in int number, GrammaticalGender gender, WordForm wordForm) - { + static string ConvertOrdinalUnits(in int number, GrammaticalGender gender, WordForm wordForm) + { if (number is <= 0 or >= 10) { return string.Empty; @@ -199,14 +199,14 @@ static string ConvertOrdinalUnits(in int number, GrammaticalGender gender, WordF } } - static string ConvertTenths(in int number, out int remainder, GrammaticalGender gender) => - ConvertMappedOrdinalNumber(number, 10, TenthsRootMap, out remainder, gender); + static string ConvertTenths(in int number, out int remainder, GrammaticalGender gender) => + ConvertMappedOrdinalNumber(number, 10, TenthsRootMap, out remainder, gender); - static string ConvertThousandths(in int number, out int remainder, GrammaticalGender gender) => - ConvertMappedOrdinalNumber(number, 1000, ThousandthsRootMap, out remainder, gender); + static string ConvertThousandths(in int number, out int remainder, GrammaticalGender gender) => + ConvertMappedOrdinalNumber(number, 1000, ThousandthsRootMap, out remainder, gender); - static string ConvertUnits(long inputNumber, GrammaticalGender gender, WordForm wordForm = WordForm.Normal) - { + static string ConvertUnits(long inputNumber, GrammaticalGender gender, WordForm wordForm = WordForm.Normal) + { if (inputNumber <= 0) { return string.Empty; @@ -229,8 +229,8 @@ static string ConvertUnits(long inputNumber, GrammaticalGender gender, WordForm return wordPart + $" y {UnitsMap[inputNumber % 10]}"; } - static IReadOnlyList GetGenderedHundredsMap(GrammaticalGender gender) - { + static IReadOnlyList GetGenderedHundredsMap(GrammaticalGender gender) + { var genderedEnding = gender == GrammaticalGender.Feminine ? "as" : "os"; var map = new List(); map.AddRange(HundredsRootMap.Take(2)); @@ -243,8 +243,8 @@ static IReadOnlyList GetGenderedHundredsMap(GrammaticalGender gender) return map; } - static string GetGenderedOne(GrammaticalGender gender, WordForm wordForm = WordForm.Normal) - { + static string GetGenderedOne(GrammaticalGender gender, WordForm wordForm = WordForm.Normal) + { switch (gender) { case GrammaticalGender.Masculine: @@ -257,8 +257,8 @@ static string GetGenderedOne(GrammaticalGender gender, WordForm wordForm = WordF } } - static string GetGenderedTwentyOne(GrammaticalGender gender, WordForm wordForm = WordForm.Normal) - { + static string GetGenderedTwentyOne(GrammaticalGender gender, WordForm wordForm = WordForm.Normal) + { switch (gender) { case GrammaticalGender.Masculine: @@ -271,27 +271,27 @@ static string GetGenderedTwentyOne(GrammaticalGender gender, WordForm wordForm = } } - static bool HasOrdinalAbbreviation(int number, WordForm wordForm) => - number is 1 or 3 && wordForm == WordForm.Abbreviation; + static bool HasOrdinalAbbreviation(int number, WordForm wordForm) => + number is 1 or 3 && wordForm == WordForm.Abbreviation; - static bool IsRoundBillion(int number) => - number >= 1000_000_000 && number % 1_000_000 == 0; + static bool IsRoundBillion(int number) => + number >= 1000_000_000 && number % 1_000_000 == 0; - static bool IsRoundMillion(int number) => - number >= 1000000 && number % 1000000 == 0; + static bool IsRoundMillion(int number) => + number >= 1000000 && number % 1000000 == 0; - static string PluralizeGreaterThanMillion(string singularWord) => - singularWord.TrimEnd('ó', 'n') + "ones"; + static string PluralizeGreaterThanMillion(string singularWord) => + singularWord.TrimEnd('ó', 'n') + "ones"; - static Dictionary numbersAndWordsDict = new() - { - { "trillón", 1_000_000_000_000_000_000 }, - { "billón", 1_000_000_000_000 }, - { "millón", 1_000_000 } - }; + static Dictionary numbersAndWordsDict = new() + { + { "trillón", 1_000_000_000_000_000_000 }, + { "billón", 1_000_000_000_000 }, + { "millón", 1_000_000 } + }; - string ConvertGreaterThanMillion(in long inputNumber, out long remainder) - { + string ConvertGreaterThanMillion(in long inputNumber, out long remainder) + { List wordBuilder = []; remainder = inputNumber; @@ -317,16 +317,16 @@ string ConvertGreaterThanMillion(in long inputNumber, out long remainder) return BuildWord(wordBuilder); } - string ConvertRoundBillionths(int number, GrammaticalGender gender) - { + string ConvertRoundBillionths(int number, GrammaticalGender gender) + { var cardinalPart = Convert(number / 1_000_000, WordForm.Abbreviation, gender); var sep = number == 1_000_000_000 ? "" : " "; var ordinalPart = ConvertToOrdinal(1_000_000, gender); return cardinalPart + sep + ordinalPart; } - string ConvertTensAndHunderdsOfThousandths(in int number, out int remainder, GrammaticalGender gender) - { + string ConvertTensAndHunderdsOfThousandths(in int number, out int remainder, GrammaticalGender gender) + { var wordPart = string.Empty; remainder = number; @@ -362,8 +362,8 @@ static bool IsRoundNumber(int number) => || (number % 1000000000 == 0 && number < int.MaxValue); } - string ConvertThousands(in long inputNumber, out long remainder, GrammaticalGender gender) - { + string ConvertThousands(in long inputNumber, out long remainder, GrammaticalGender gender) + { var wordPart = string.Empty; remainder = inputNumber; @@ -385,5 +385,4 @@ string ConvertThousands(in long inputNumber, out long remainder, GrammaticalGend return wordPart; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/SwedishNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/SwedishNumberToWordsConverter.cs index 2dc1f2815..e92f71c52 100644 --- a/src/Humanizer/Localisation/NumberToWords/SwedishNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/SwedishNumberToWordsConverter.cs @@ -1,30 +1,30 @@ -namespace Humanizer +namespace Humanizer; + +class SwedishNumberToWordsConverter : GenderlessNumberToWordsConverter { - class SwedishNumberToWordsConverter : GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["noll", "ett", "två", "tre", "fyra", "fem", "sex", "sju", "åtta", "nio", "tio", "elva", "tolv", "tretton", "fjorton", "femton", "sexton", "sjutton", "arton", "nitton"]; + static readonly string[] TensMap = ["noll", "tio", "tjugo", "trettio", "fyrtio", "femtio", "sextio", "sjuttio", "åttio", "nittio", "hundra"]; + + class Fact { - static readonly string[] UnitsMap = ["noll", "ett", "två", "tre", "fyra", "fem", "sex", "sju", "åtta", "nio", "tio", "elva", "tolv", "tretton", "fjorton", "femton", "sexton", "sjutton", "arton", "nitton"]; - static readonly string[] TensMap = ["noll", "tio", "tjugo", "trettio", "fyrtio", "femtio", "sextio", "sjuttio", "åttio", "nittio", "hundra"]; - - class Fact - { - public int Value { get; set; } - public required string Name { get; set; } - public required string Prefix { get; set; } - public required string Postfix { get; set; } - public bool DisplayOneUnit { get; set; } - public GrammaticalGender Gender { get; set; } = GrammaticalGender.Neuter; - } + public int Value { get; set; } + public required string Name { get; set; } + public required string Prefix { get; set; } + public required string Postfix { get; set; } + public bool DisplayOneUnit { get; set; } + public GrammaticalGender Gender { get; set; } = GrammaticalGender.Neuter; + } - static readonly Fact[] Hunderds = - [ - new(){Value = 1000000000, Name = "miljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true, Gender = GrammaticalGender.Masculine}, - new(){Value = 1000000, Name = "miljon", Prefix = " ", Postfix = " ", DisplayOneUnit = true, Gender = GrammaticalGender.Masculine}, - new(){Value = 1000, Name = "tusen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, - new(){Value = 100, Name = "hundra", Prefix = "", Postfix = "", DisplayOneUnit = false} - ]; + static readonly Fact[] Hunderds = + [ + new(){Value = 1000000000, Name = "miljard", Prefix = " ", Postfix = " ", DisplayOneUnit = true, Gender = GrammaticalGender.Masculine}, + new(){Value = 1000000, Name = "miljon", Prefix = " ", Postfix = " ", DisplayOneUnit = true, Gender = GrammaticalGender.Masculine}, + new(){Value = 1000, Name = "tusen", Prefix = " ", Postfix = " ", DisplayOneUnit = true}, + new(){Value = 100, Name = "hundra", Prefix = "", Postfix = "", DisplayOneUnit = false} + ]; - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -105,36 +105,36 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return word; } - public override string Convert(long input) => - Convert(input, GrammaticalGender.Neuter); - - static string[] ordinalNumbers = - [ - "nollte", - "första", - "andra", - "tredje", - "fjärde", - "femte", - "sjätte", - "sjunde", - "åttonde", - "nionde", - "tionde", - "elfte", - "tolfte", - "trettonde", - "fjortonde", - "femtonde", - "sextonde", - "sjuttonde", - "artonde", - "nittonde", - "tjugonde" - ]; - - public override string ConvertToOrdinal(int number) - { + public override string Convert(long input) => + Convert(input, GrammaticalGender.Neuter); + + static string[] ordinalNumbers = + [ + "nollte", + "första", + "andra", + "tredje", + "fjärde", + "femte", + "sjätte", + "sjunde", + "åttonde", + "nionde", + "tionde", + "elfte", + "tolfte", + "trettonde", + "fjortonde", + "femtonde", + "sextonde", + "sjuttonde", + "artonde", + "nittonde", + "tjugonde" + ]; + + public override string ConvertToOrdinal(int number) + { var word = ""; if (number < 0) @@ -210,5 +210,4 @@ public override string ConvertToOrdinal(int number) return word; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs index aef5d920e..e1fe65b02 100644 --- a/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs @@ -1,34 +1,34 @@ -namespace Humanizer +namespace Humanizer; + +class TamilNumberToWordsConverter : GenderlessNumberToWordsConverter { - class TamilNumberToWordsConverter : GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["சுழியம்", "ஒன்று", "இரண்டு", "மூன்று", "நான்கு", "ஐந்து", "ஆறு", "ஏழு", "எட்டு", "ஒன்பது", "பத்து", "பதினொன்று", "பனிரெண்டு", "பதிமூன்று", "பதினான்கு", "பதினைந்து", "பதினாறு", "பதினேழு", "பதினெட்டு", "பத்தொன்பது"]; + static readonly string[] TensMap = ["சுழியம்", "பத்து", "இருப", "முப்ப", "நாற்ப", "ஐம்ப", "அறுப", "எழுப", "எண்ப", "தொண்ணூ"]; + static readonly string[] HundredsMap = ["நூ", "இருநூ", "முன்னூ", "நானூ", "ஐந்நூ", "அறுநூ", "எழுநூ", "எண்ணூ", "தொள்ளாயிர"]; + static readonly string[] ThousandsMap = ["ஆ", "இரண்டா", "மூன்றா", "நான்கா", "ஐந்தா", "ஆறா", "ஏழா", "எட்டா", "ஒன்பதா", "பத்தா", "பதினொன்றா", "பனிரெண்டா", "பதிமூன்றா", "பதினான்கா", "பதினைந்தா", "பதினாறா", "பதினேழா", "பதினெட்டா", "பத்தொன்பதா"]; + + static readonly string[] LakhsMap = ["இலட்ச"]; + + static readonly Dictionary OrdinalExceptions = new() + { + {1, "முதலாவது"}, + {2, "இரண்டாவது"}, + {3, "மூன்றாவது"}, + {4, "நான்காவது"}, + {5, "ஐந்தாவது"}, + {8, "எட்டாவது"}, + {9, "ஒன்பதாவது"}, + {12, "பனிரெண்டாவது"}, + }; + + public override string Convert(long number) => + ConvertImpl(number, false); + + public override string ConvertToOrdinal(int number) => + ConvertImpl(number, true); + + string ConvertImpl(long number, bool isOrdinal) { - static readonly string[] UnitsMap = ["சுழியம்", "ஒன்று", "இரண்டு", "மூன்று", "நான்கு", "ஐந்து", "ஆறு", "ஏழு", "எட்டு", "ஒன்பது", "பத்து", "பதினொன்று", "பனிரெண்டு", "பதிமூன்று", "பதினான்கு", "பதினைந்து", "பதினாறு", "பதினேழு", "பதினெட்டு", "பத்தொன்பது"]; - static readonly string[] TensMap = ["சுழியம்", "பத்து", "இருப", "முப்ப", "நாற்ப", "ஐம்ப", "அறுப", "எழுப", "எண்ப", "தொண்ணூ"]; - static readonly string[] HundredsMap = ["நூ", "இருநூ", "முன்னூ", "நானூ", "ஐந்நூ", "அறுநூ", "எழுநூ", "எண்ணூ", "தொள்ளாயிர"]; - static readonly string[] ThousandsMap = ["ஆ", "இரண்டா", "மூன்றா", "நான்கா", "ஐந்தா", "ஆறா", "ஏழா", "எட்டா", "ஒன்பதா", "பத்தா", "பதினொன்றா", "பனிரெண்டா", "பதிமூன்றா", "பதினான்கா", "பதினைந்தா", "பதினாறா", "பதினேழா", "பதினெட்டா", "பத்தொன்பதா"]; - - static readonly string[] LakhsMap = ["இலட்ச"]; - - static readonly Dictionary OrdinalExceptions = new() - { - {1, "முதலாவது"}, - {2, "இரண்டாவது"}, - {3, "மூன்றாவது"}, - {4, "நான்காவது"}, - {5, "ஐந்தாவது"}, - {8, "எட்டாவது"}, - {9, "ஒன்பதாவது"}, - {12, "பனிரெண்டாவது"}, - }; - - public override string Convert(long number) => - ConvertImpl(number, false); - - public override string ConvertToOrdinal(int number) => - ConvertImpl(number, true); - - string ConvertImpl(long number, bool isOrdinal) - { if (number == 0) return GetUnitValue(0, isOrdinal); @@ -90,8 +90,8 @@ string ConvertImpl(long number, bool isOrdinal) return toWords; } - static string GetUnitValue(long number, bool isOrdinal) - { + static string GetUnitValue(long number, bool isOrdinal) + { if (isOrdinal) { if (ExceptionNumbersToWords(number, out var exceptionString)) @@ -104,8 +104,8 @@ static string GetUnitValue(long number, bool isOrdinal) return UnitsMap[number]; } - static string GetTensValue(long number, bool isOrdinal, bool isThousand = false) - { + static string GetTensValue(long number, bool isOrdinal, bool isThousand = false) + { var local_word = ""; if (number < 20) local_word = GetUnitValue(number, isOrdinal); @@ -148,8 +148,8 @@ static string GetTensValue(long number, bool isOrdinal, bool isThousand = false) } return local_word; } - static string GetLakhsValue(ref long number, bool isOrdinal) - { + static string GetLakhsValue(ref long number, bool isOrdinal) + { var num_above_10 = number / 100000; var local_word = ""; if (num_above_10 >= 20) @@ -169,8 +169,8 @@ static string GetLakhsValue(ref long number, bool isOrdinal) number %= 100000; return local_word; } - static string GetCroresValue(ref long number) - { + static string GetCroresValue(ref long number) + { var local_word = ""; var num_above_10 = number / 10000000; var str_crore = "கோடி"; @@ -211,8 +211,8 @@ static string GetCroresValue(ref long number) return local_word; } - static string GetThousandsValue(ref long number) - { + static string GetThousandsValue(ref long number) + { var num_above_10 = number / 1000; var local_word = ""; if (num_above_10 >= 20) @@ -237,8 +237,8 @@ static string GetThousandsValue(ref long number) return local_word; } - static string GetHundredsValue(ref long number) - { + static string GetHundredsValue(ref long number) + { var local_word = HundredsMap[number / 100 - 1]; if (number / 100 == 9) { @@ -257,8 +257,8 @@ static string GetHundredsValue(ref long number) return local_word; } - static string RemoveOnePrefix(string toWords) - { + static string RemoveOnePrefix(string toWords) + { // one hundred => hundredth if (toWords.StartsWith("one", StringComparison.Ordinal)) toWords = toWords.Remove(0, 4); @@ -266,7 +266,6 @@ static string RemoveOnePrefix(string toWords) return toWords; } - static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => - OrdinalExceptions.TryGetValue(number, out words); - } -} + static bool ExceptionNumbersToWords(long number, [NotNullWhen(true)] out string? words) => + OrdinalExceptions.TryGetValue(number, out words); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/ThaiNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/ThaiNumberToWordsConverter.cs index 735a5e947..45d3d77b3 100644 --- a/src/Humanizer/Localisation/NumberToWords/ThaiNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/ThaiNumberToWordsConverter.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class ThaiNumberToWordsConverter : GenderlessNumberToWordsConverter { - class ThaiNumberToWordsConverter : GenderlessNumberToWordsConverter + public override string Convert(long numbermoney) { - public override string Convert(long numbermoney) - { var Textreturn = ""; if (numbermoney == 0) { @@ -70,7 +70,6 @@ public override string Convert(long numbermoney) return Textreturn; } - public override string ConvertToOrdinal(int number) => - Convert(number); - } -} + public override string ConvertToOrdinal(int number) => + Convert(number); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs index 44e3cd78d..842b5f386 100644 --- a/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs @@ -1,37 +1,37 @@ -namespace Humanizer +namespace Humanizer; + +class TurkishNumberToWordConverter : + GenderlessNumberToWordsConverter { - class TurkishNumberToWordConverter : - GenderlessNumberToWordsConverter + static readonly string[] UnitsMap = ["sıfır", "bir", "iki", "üç", "dört", "beş", "altı", "yedi", "sekiz", "dokuz"]; + static readonly string[] TensMap = ["sıfır", "on", "yirmi", "otuz", "kırk", "elli", "altmış", "yetmiş", "seksen", "doksan"]; + + static readonly Dictionary OrdinalSuffix = new() + { + {'ı', "ıncı"}, + {'i', "inci"}, + {'u', "uncu"}, + {'ü', "üncü"}, + {'o', "uncu"}, + {'ö', "üncü"}, + {'e', "inci"}, + {'a', "ıncı"}, + }; + + static readonly Dictionary TupleSuffix = new() + { + {'ı', "lı"}, + {'i', "li"}, + {'u', "lu"}, + {'ü', "lü"}, + {'o', "lu"}, + {'ö', "lü"}, + {'e', "li"}, + {'a', "lı"}, + }; + + public override string Convert(long input) { - static readonly string[] UnitsMap = ["sıfır", "bir", "iki", "üç", "dört", "beş", "altı", "yedi", "sekiz", "dokuz"]; - static readonly string[] TensMap = ["sıfır", "on", "yirmi", "otuz", "kırk", "elli", "altmış", "yetmiş", "seksen", "doksan"]; - - static readonly Dictionary OrdinalSuffix = new() - { - {'ı', "ıncı"}, - {'i', "inci"}, - {'u', "uncu"}, - {'ü', "üncü"}, - {'o', "uncu"}, - {'ö', "üncü"}, - {'e', "inci"}, - {'a', "ıncı"}, - }; - - static readonly Dictionary TupleSuffix = new() - { - {'ı', "lı"}, - {'i', "li"}, - {'u', "lu"}, - {'ü', "lü"}, - {'o', "lu"}, - {'ö', "lü"}, - {'e', "li"}, - {'a', "lı"}, - }; - - public override string Convert(long input) - { var number = input; if (number == 0) { @@ -105,8 +105,8 @@ public override string Convert(long input) return toWords; } - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var word = Convert(number); var wordSuffix = string.Empty; var suffixFoundOnLastVowel = false; @@ -133,8 +133,8 @@ public override string ConvertToOrdinal(int number) return $"{word}{wordSuffix}"; } - public override string ConvertToTuple(int number) - { + public override string ConvertToTuple(int number) + { switch (number) { case 1: @@ -156,5 +156,4 @@ public override string ConvertToTuple(int number) return $"{word}{wordSuffix}"; } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs index c46056317..e69e00fe2 100644 --- a/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UkrainianNumberToWordsConverter.cs @@ -1,17 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +class UkrainianNumberToWordsConverter : GenderedNumberToWordsConverter { - class UkrainianNumberToWordsConverter : GenderedNumberToWordsConverter + static readonly string[] HundredsMap = ["нуль", "сто", "двісті", "триста", "чотириста", "п'ятсот", "шістсот", "сімсот", "вісімсот", "дев'ятсот"]; + static readonly string[] TensMap = ["нуль", "десять", "двадцять", "тридцять", "сорок", "п'ятдесят", "шістдесят", "сімдесят", "вісімдесят", "дев'яносто"]; + static readonly string[] UnitsMap = ["нуль", "один", "два", "три", "чотири", "п'ять", "шість", "сім", "вісім", "дев'ять", "десять", "одинадцять", "дванадцять", "тринадцять", "чотирнадцять", "п'ятнадцять", "шістнадцять", "сімнадцять", "вісімнадцять", "дев'ятнадцять"]; + static readonly string[] UnitsOrdinalPrefixes = [string.Empty, string.Empty, "двох", "трьох", "чотирьох", "п'яти", "шести", "семи", "восьми", "дев'яти", "десяти", "одинадцяти", "дванадцяти", "тринадцяти", "чотирнадцяти", "п'ятнадцяти", "шістнадцяти", "сімнадцяти", "вісімнадцяти", "дев'ятнадцяти", "двадцяти"]; + static readonly string[] TensOrdinalPrefixes = [string.Empty, "десяти", "двадцяти", "тридцяти", "сорока", "п'ятдесяти", "шістдесяти", "сімдесяти", "вісімдесяти", "дев'яносто"]; + static readonly string[] TensOrdinal = [string.Empty, "десят", "двадцят", "тридцят", "сороков", "п'ятдесят", "шістдесят", "сімдесят", "вісімдесят", "дев'яност"]; + static readonly string[] UnitsOrdinal = ["нульов", "перш", "друг", "трет", "четверт", "п'ят", "шост", "сьом", "восьм", "дев'ят", "десят", "одинадцят", "дванадцят", "тринадцят", "чотирнадцят", "п'ятнадцят", "шістнадцят", "сімнадцят", "вісімнадцят", "дев'ятнадцят"]; + + public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) { - static readonly string[] HundredsMap = ["нуль", "сто", "двісті", "триста", "чотириста", "п'ятсот", "шістсот", "сімсот", "вісімсот", "дев'ятсот"]; - static readonly string[] TensMap = ["нуль", "десять", "двадцять", "тридцять", "сорок", "п'ятдесят", "шістдесят", "сімдесят", "вісімдесят", "дев'яносто"]; - static readonly string[] UnitsMap = ["нуль", "один", "два", "три", "чотири", "п'ять", "шість", "сім", "вісім", "дев'ять", "десять", "одинадцять", "дванадцять", "тринадцять", "чотирнадцять", "п'ятнадцять", "шістнадцять", "сімнадцять", "вісімнадцять", "дев'ятнадцять"]; - static readonly string[] UnitsOrdinalPrefixes = [string.Empty, string.Empty, "двох", "трьох", "чотирьох", "п'яти", "шести", "семи", "восьми", "дев'яти", "десяти", "одинадцяти", "дванадцяти", "тринадцяти", "чотирнадцяти", "п'ятнадцяти", "шістнадцяти", "сімнадцяти", "вісімнадцяти", "дев'ятнадцяти", "двадцяти"]; - static readonly string[] TensOrdinalPrefixes = [string.Empty, "десяти", "двадцяти", "тридцяти", "сорока", "п'ятдесяти", "шістдесяти", "сімдесяти", "вісімдесяти", "дев'яносто"]; - static readonly string[] TensOrdinal = [string.Empty, "десят", "двадцят", "тридцят", "сороков", "п'ятдесят", "шістдесят", "сімдесят", "вісімдесят", "дев'яност"]; - static readonly string[] UnitsOrdinal = ["нульов", "перш", "друг", "трет", "четверт", "п'ят", "шост", "сьом", "восьм", "дев'ят", "десят", "одинадцят", "дванадцят", "тринадцят", "чотирнадцят", "п'ятнадцят", "шістнадцят", "сімнадцят", "вісімнадцят", "дев'ятнадцят"]; - - public override string Convert(long input, GrammaticalGender gender, bool addAnd = true) - { if (input == 0) { return "нуль"; @@ -39,8 +39,8 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd return string.Join(" ", parts); } - public override string ConvertToOrdinal(int number, GrammaticalGender gender) - { + public override string ConvertToOrdinal(int number, GrammaticalGender gender) + { if (number == 0) { return "нульов" + GetEndingForGender(gender, number); @@ -96,8 +96,8 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender) return string.Join(" ", parts); } - static void CollectPartsUnderOneThousand(ICollection parts, long number, GrammaticalGender gender) - { + static void CollectPartsUnderOneThousand(ICollection parts, long number, GrammaticalGender gender) + { if (number >= 100) { var hundreds = number / 100; @@ -133,8 +133,8 @@ static void CollectPartsUnderOneThousand(ICollection parts, long number, } } - static string GetPrefix(int number) - { + static string GetPrefix(int number) + { var parts = new List(); if (number >= 100) @@ -166,8 +166,8 @@ static string GetPrefix(int number) return string.Concat(parts); } - static void CollectParts(ICollection parts, ref long number, long divisor, GrammaticalGender gender, params string[] forms) - { + static void CollectParts(ICollection parts, ref long number, long divisor, GrammaticalGender gender, params string[] forms) + { var result = Math.Abs(number / divisor); if (result == 0) { @@ -180,8 +180,8 @@ static void CollectParts(ICollection parts, ref long number, long diviso parts.Add(ChooseOneForGrammaticalNumber(result, forms)); } - static void CollectOrdinalParts(ICollection parts, ref int number, int divisor, GrammaticalGender gender, string prefixedForm, params string[] forms) - { + static void CollectOrdinalParts(ICollection parts, ref int number, int divisor, GrammaticalGender gender, string prefixedForm, params string[] forms) + { if (number < divisor) { return; @@ -207,8 +207,8 @@ static void CollectOrdinalParts(ICollection parts, ref int number, int d } } - static int GetIndex(RussianGrammaticalNumber number) - { + static int GetIndex(RussianGrammaticalNumber number) + { if (number == RussianGrammaticalNumber.Singular) { return 0; @@ -222,11 +222,11 @@ static int GetIndex(RussianGrammaticalNumber number) return 2; } - static string ChooseOneForGrammaticalNumber(long number, string[] forms) => - forms[GetIndex(RussianGrammaticalNumberDetector.Detect(number))]; + static string ChooseOneForGrammaticalNumber(long number, string[] forms) => + forms[GetIndex(RussianGrammaticalNumberDetector.Detect(number))]; - static string GetEndingForGender(GrammaticalGender gender, int number) - { + static string GetEndingForGender(GrammaticalGender gender, int number) + { switch (gender) { case GrammaticalGender.Masculine: @@ -254,5 +254,4 @@ static string GetEndingForGender(GrammaticalGender gender, int number) throw new ArgumentOutOfRangeException(nameof(gender)); } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs index 50af6f60f..0efd49b7e 100644 --- a/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs @@ -1,14 +1,14 @@ -namespace Humanizer +namespace Humanizer; + +class UzbekCyrlNumberToWordConverter : GenderlessNumberToWordsConverter { - class UzbekCyrlNumberToWordConverter : GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap = ["нол", "бир", "икки", "уч", "тўрт", "беш", "олти", "етти", "саккиз", "тўққиз"]; - static readonly string[] TensMap = ["нол", "ўн", "йигирма", "ўттиз", "қирқ", "эллик", "олтмиш", "етмиш", "саксон", "тўқсон"]; + static readonly string[] UnitsMap = ["нол", "бир", "икки", "уч", "тўрт", "беш", "олти", "етти", "саккиз", "тўққиз"]; + static readonly string[] TensMap = ["нол", "ўн", "йигирма", "ўттиз", "қирқ", "эллик", "олтмиш", "етмиш", "саксон", "тўқсон"]; - static readonly string[] OrdinalSuffixes = ["инчи", "нчи"]; + static readonly string[] OrdinalSuffixes = ["инчи", "нчи"]; - public override string Convert(long input) - { + public override string Convert(long input) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -22,8 +22,8 @@ public override string Convert(long input) return Convert(number, true); } - static string Convert(int number, bool checkForHundredRule) - { + static string Convert(int number, bool checkForHundredRule) + { if (number == 0) { return UnitsMap[0]; @@ -76,8 +76,8 @@ static string Convert(int number, bool checkForHundredRule) return sb.ToString().Trim(); } - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var word = Convert(number); var i = 0; if (string.IsNullOrEmpty(word)) @@ -93,5 +93,4 @@ public override string ConvertToOrdinal(int number) return $"{word}{OrdinalSuffixes[i]}"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs index 6805102db..c9aabf638 100644 --- a/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs @@ -1,14 +1,14 @@ -namespace Humanizer +namespace Humanizer; + +class UzbekLatnNumberToWordConverter : GenderlessNumberToWordsConverter { - class UzbekLatnNumberToWordConverter : GenderlessNumberToWordsConverter - { - static readonly string[] UnitsMap = ["nol", "bir", "ikki", "uch", "to`rt", "besh", "olti", "yetti", "sakkiz", "to`qqiz"]; - static readonly string[] TensMap = ["nol", "o`n", "yigirma", "o`ttiz", "qirq", "ellik", "oltmish", "yetmish", "sakson", "to`qson"]; + static readonly string[] UnitsMap = ["nol", "bir", "ikki", "uch", "to`rt", "besh", "olti", "yetti", "sakkiz", "to`qqiz"]; + static readonly string[] TensMap = ["nol", "o`n", "yigirma", "o`ttiz", "qirq", "ellik", "oltmish", "yetmish", "sakson", "to`qson"]; - static readonly string[] OrdinalSuffixes = ["inchi", "nchi"]; + static readonly string[] OrdinalSuffixes = ["inchi", "nchi"]; - public override string Convert(long input) - { + public override string Convert(long input) + { if (input is > int.MaxValue or < int.MinValue) { throw new NotImplementedException(); @@ -22,8 +22,8 @@ public override string Convert(long input) return Convert(number, true); } - static string Convert(int number, bool checkForHundredRule) - { + static string Convert(int number, bool checkForHundredRule) + { if (number == 0) { return UnitsMap[0]; @@ -76,8 +76,8 @@ static string Convert(int number, bool checkForHundredRule) return sb.ToString().Trim(); } - public override string ConvertToOrdinal(int number) - { + public override string ConvertToOrdinal(int number) + { var word = Convert(number); var i = 0; if (string.IsNullOrEmpty(word)) @@ -93,5 +93,4 @@ public override string ConvertToOrdinal(int number) return $"{word}{OrdinalSuffixes[i]}"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/NumberToWords/VietnameseNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/VietnameseNumberToWordsConverter.cs index 49861987c..3c926ccc5 100644 --- a/src/Humanizer/Localisation/NumberToWords/VietnameseNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/VietnameseNumberToWordsConverter.cs @@ -1,126 +1,125 @@ -namespace Humanizer +namespace Humanizer; + +class VietnameseNumberToWordsConverter : GenderlessNumberToWordsConverter { - class VietnameseNumberToWordsConverter : GenderlessNumberToWordsConverter + const int OneBillion = 1000000000; + const int OneMillion = 1000000; + + static readonly string[] NumberVerbalPairs = + [ + "", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín" + ]; + + public override string Convert(long number) => + number == 0 + ? "không" + : ConvertImpl(number); + + public override string ConvertToOrdinal(int number) => + $"thứ {ConvertToOrdinalImpl(number)}"; + + string ConvertToOrdinalImpl(int number) { - const int OneBillion = 1000000000; - const int OneMillion = 1000000; + switch (number) + { + case 1: + return "nhất"; + case 2: + return "nhì"; + case 4: + return "tư"; + default: + return Convert(number); + } + } - static readonly string[] NumberVerbalPairs = - [ - "", "một", "hai", "ba", "bốn", "năm", "sáu", "bảy", "tám", "chín" - ]; + static string ConvertImpl(long number, bool hasTens = false, bool isGreaterThanOneHundred = false) + { + if (number >= OneBillion) + { + return string.Format( + "{0} tỉ {1}", + ConvertImpl(number / OneBillion), + ConvertImpl(number % OneBillion, isGreaterThanOneHundred: true) + ) + .TrimEnd(); + } - public override string Convert(long number) => - number == 0 - ? "không" - : ConvertImpl(number); + if (number >= OneMillion) + { + return string.Format( + "{0} triệu {1}", + ConvertImpl(number / OneMillion), + ConvertImpl(number % OneMillion, isGreaterThanOneHundred: true) + ) + .TrimEnd(); + } - public override string ConvertToOrdinal(int number) => - $"thứ {ConvertToOrdinalImpl(number)}"; + if (number >= 1000) + { + return string.Format( + "{0} nghìn {1}", + ConvertImpl(number / 1000), + ConvertImpl(number % 1000, isGreaterThanOneHundred: true) + ) + .TrimEnd(); + } - string ConvertToOrdinalImpl(int number) + if (number >= 100) { - switch (number) - { - case 1: - return "nhất"; - case 2: - return "nhì"; - case 4: - return "tư"; - default: - return Convert(number); - } + return string.Format( + "{0} trăm {1}", + NumberVerbalPairs[number / 100], + ConvertImpl(number % 100, isGreaterThanOneHundred: true) + ) + .TrimEnd(); } - static string ConvertImpl(long number, bool hasTens = false, bool isGreaterThanOneHundred = false) + if (number >= 20) { - if (number >= OneBillion) - { - return string.Format( - "{0} tỉ {1}", - ConvertImpl(number / OneBillion), - ConvertImpl(number % OneBillion, isGreaterThanOneHundred: true) - ) - .TrimEnd(); - } - - if (number >= OneMillion) - { - return string.Format( - "{0} triệu {1}", - ConvertImpl(number / OneMillion), - ConvertImpl(number % OneMillion, isGreaterThanOneHundred: true) - ) - .TrimEnd(); - } - - if (number >= 1000) - { - return string.Format( - "{0} nghìn {1}", - ConvertImpl(number / 1000), - ConvertImpl(number % 1000, isGreaterThanOneHundred: true) - ) - .TrimEnd(); - } - - if (number >= 100) - { - return string.Format( - "{0} trăm {1}", - NumberVerbalPairs[number / 100], - ConvertImpl(number % 100, isGreaterThanOneHundred: true) - ) - .TrimEnd(); - } - - if (number >= 20) - { - return string.Format( - "{0} mươi {1}", - NumberVerbalPairs[number / 10], - ConvertImpl(number % 10, hasTens: true) - ) - .TrimEnd(); - } - - if (number == 14) - { - return "mười bốn"; - } - - if (number == 11) - { - return "mười một"; - } - - if (number >= 10) - { - return $"mười {ConvertImpl(number % 10, hasTens: true)}".TrimEnd(); - } - - if (number == 5 && hasTens) - { - return "lăm"; - } - - if (number == 4 && hasTens) - { - return "tư"; - } + return string.Format( + "{0} mươi {1}", + NumberVerbalPairs[number / 10], + ConvertImpl(number % 10, hasTens: true) + ) + .TrimEnd(); + } - if (number == 1 && hasTens) - { - return "mốt"; - } + if (number == 14) + { + return "mười bốn"; + } + + if (number == 11) + { + return "mười một"; + } + + if (number >= 10) + { + return $"mười {ConvertImpl(number % 10, hasTens: true)}".TrimEnd(); + } + + if (number == 5 && hasTens) + { + return "lăm"; + } - if (number > 0 && isGreaterThanOneHundred && !hasTens) - { - return $"linh {NumberVerbalPairs[number]}"; - } + if (number == 4 && hasTens) + { + return "tư"; + } - return NumberVerbalPairs[number]; + if (number == 1 && hasTens) + { + return "mốt"; } + + if (number > 0 && isGreaterThanOneHundred && !hasTens) + { + return $"linh {NumberVerbalPairs[number]}"; + } + + return NumberVerbalPairs[number]; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/ArmenianOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/ArmenianOrdinalizer.cs index 279389f72..bf00948ab 100644 --- a/src/Humanizer/Localisation/Ordinalizers/ArmenianOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/ArmenianOrdinalizer.cs @@ -1,15 +1,14 @@ -namespace Humanizer +namespace Humanizer; + +class ArmenianOrdinalizer : DefaultOrdinalizer { - class ArmenianOrdinalizer : DefaultOrdinalizer + public override string Convert(int number, string numberString) { - public override string Convert(int number, string numberString) + if (number is 1 or -1) { - if (number is 1 or -1) - { - return numberString + "-ին"; - } - - return numberString + "-րդ"; + return numberString + "-ին"; } + + return numberString + "-րդ"; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/AzerbaijaniOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/AzerbaijaniOrdinalizer.cs index 49a7aa323..12e0af684 100644 --- a/src/Humanizer/Localisation/Ordinalizers/AzerbaijaniOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/AzerbaijaniOrdinalizer.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class AzerbaijaniOrdinalizer : DefaultOrdinalizer { - class AzerbaijaniOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - numberString + "."; - } -} + public override string Convert(int number, string numberString) => + numberString + "."; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/DefaultOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/DefaultOrdinalizer.cs index 348a37d70..a117b50a4 100644 --- a/src/Humanizer/Localisation/Ordinalizers/DefaultOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/DefaultOrdinalizer.cs @@ -1,17 +1,16 @@ -namespace Humanizer +namespace Humanizer; + +class DefaultOrdinalizer : IOrdinalizer { - class DefaultOrdinalizer : IOrdinalizer - { - public virtual string Convert(int number, string numberString, GrammaticalGender gender) => - Convert(number, numberString); + public virtual string Convert(int number, string numberString, GrammaticalGender gender) => + Convert(number, numberString); - public virtual string Convert(int number, string numberString) => - numberString; + public virtual string Convert(int number, string numberString) => + numberString; - public virtual string Convert(int number, string numberString, WordForm wordForm) => - Convert(number, numberString, default, wordForm); + public virtual string Convert(int number, string numberString, WordForm wordForm) => + Convert(number, numberString, default, wordForm); - public virtual string Convert(int number, string numberString, GrammaticalGender gender, WordForm wordForm) => - Convert(number, numberString, gender); - } -} + public virtual string Convert(int number, string numberString, GrammaticalGender gender, WordForm wordForm) => + Convert(number, numberString, gender); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/DutchOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/DutchOrdinalizer.cs index 99805c4db..4923d7a47 100644 --- a/src/Humanizer/Localisation/Ordinalizers/DutchOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/DutchOrdinalizer.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class DutchOrdinalizer : DefaultOrdinalizer { - class DutchOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) - { + public override string Convert(int number, string numberString, GrammaticalGender gender) + { // N/A in Dutch if (number == 0) { @@ -15,5 +15,4 @@ public override string Convert(int number, string numberString, GrammaticalGende return numberString + "e"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/EnglishOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/EnglishOrdinalizer.cs index d99829102..01a14c1be 100644 --- a/src/Humanizer/Localisation/Ordinalizers/EnglishOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/EnglishOrdinalizer.cs @@ -1,9 +1,9 @@ -namespace Humanizer +namespace Humanizer; + +class EnglishOrdinalizer : DefaultOrdinalizer { - class EnglishOrdinalizer : DefaultOrdinalizer + public override string Convert(int number, string numberString) { - public override string Convert(int number, string numberString) - { var nMod100 = number % 100; if (nMod100 is >= 11 and <= 20) @@ -26,5 +26,4 @@ public override string Convert(int number, string numberString) return numberString + "th"; } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/FrenchOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/FrenchOrdinalizer.cs index 295b5fa5e..55621dfb4 100644 --- a/src/Humanizer/Localisation/Ordinalizers/FrenchOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/FrenchOrdinalizer.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class FrenchOrdinalizer : DefaultOrdinalizer { - class FrenchOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) - { + public override string Convert(int number, string numberString, GrammaticalGender gender) + { if (number == 1) { if (gender == GrammaticalGender.Feminine) @@ -18,5 +18,4 @@ public override string Convert(int number, string numberString, GrammaticalGende return numberString + "ème"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/GermanOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/GermanOrdinalizer.cs index ddf37819c..2d364cf71 100644 --- a/src/Humanizer/Localisation/Ordinalizers/GermanOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/GermanOrdinalizer.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class GermanOrdinalizer : DefaultOrdinalizer { - class GermanOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - numberString + "."; - } -} + public override string Convert(int number, string numberString) => + numberString + "."; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/IOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/IOrdinalizer.cs index 2d7148cac..67dcd05cb 100644 --- a/src/Humanizer/Localisation/Ordinalizers/IOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/IOrdinalizer.cs @@ -1,28 +1,27 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// The interface used to localise the Ordinalize method +/// +public interface IOrdinalizer { /// - /// The interface used to localise the Ordinalize method + /// Ordinalizes the number /// - public interface IOrdinalizer - { - /// - /// Ordinalizes the number - /// - string Convert(int number, string numberString); + string Convert(int number, string numberString); - /// - /// Ordinalizes the number to a locale's specific form. - /// - string Convert(int number, string numberString, WordForm wordForm); + /// + /// Ordinalizes the number to a locale's specific form. + /// + string Convert(int number, string numberString, WordForm wordForm); - /// - /// Ordinalizes the number using the provided grammatical gender - /// - string Convert(int number, string numberString, GrammaticalGender gender); + /// + /// Ordinalizes the number using the provided grammatical gender + /// + string Convert(int number, string numberString, GrammaticalGender gender); - /// - /// Ordinalizes the number to a locale's specific form using the provided grammatical gender. - /// - string Convert(int number, string numberString, GrammaticalGender gender, WordForm wordForm); - } -} + /// + /// Ordinalizes the number to a locale's specific form using the provided grammatical gender. + /// + string Convert(int number, string numberString, GrammaticalGender gender, WordForm wordForm); +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/IcelandicOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/IcelandicOrdinalizer.cs index efedbd0a1..2758fd454 100644 --- a/src/Humanizer/Localisation/Ordinalizers/IcelandicOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/IcelandicOrdinalizer.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class IcelandicOrdinalizer : DefaultOrdinalizer { - class IcelandicOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - numberString + "."; - } -} + public override string Convert(int number, string numberString) => + numberString + "."; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/ItalianOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/ItalianOrdinalizer.cs index 49b56600c..49bb595f4 100644 --- a/src/Humanizer/Localisation/Ordinalizers/ItalianOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/ItalianOrdinalizer.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class ItalianOrdinalizer : DefaultOrdinalizer { - class ItalianOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) - { + public override string Convert(int number, string numberString, GrammaticalGender gender) + { // No ordinal for 0 in italian (neologism apart) if (number == 0) { @@ -20,5 +20,4 @@ public override string Convert(int number, string numberString, GrammaticalGende return numberString + "°"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/PortugueseOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/PortugueseOrdinalizer.cs index 633f9021e..9598f47ea 100644 --- a/src/Humanizer/Localisation/Ordinalizers/PortugueseOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/PortugueseOrdinalizer.cs @@ -1,24 +1,23 @@ -namespace Humanizer +namespace Humanizer; + +class PortugueseOrdinalizer : DefaultOrdinalizer { - class PortugueseOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) + public override string Convert(int number, string numberString, GrammaticalGender gender) + { + // N/A in Portuguese + if (number == 0) { - // N/A in Portuguese - if (number == 0) - { - return "0"; - } - - if (gender == GrammaticalGender.Feminine) - { - return numberString + "ª"; - } + return "0"; + } - return numberString + "º"; + if (gender == GrammaticalGender.Feminine) + { + return numberString + "ª"; } + + return numberString + "º"; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/RomanianOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/RomanianOrdinalizer.cs index fe2f8c01c..dfeb70512 100644 --- a/src/Humanizer/Localisation/Ordinalizers/RomanianOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/RomanianOrdinalizer.cs @@ -1,35 +1,34 @@ -namespace Humanizer +namespace Humanizer; + +class RomanianOrdinalizer : DefaultOrdinalizer { - class RomanianOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) + public override string Convert(int number, string numberString, GrammaticalGender gender) + { + // No ordinal for 0 (zero) in Romanian. + if (number == 0) { - // No ordinal for 0 (zero) in Romanian. - if (number == 0) - { - return "0"; - } - - // Exception from the rule. - if (number == 1) - { - if (gender == GrammaticalGender.Feminine) - { - return "prima"; // întâia - } - - return "primul"; // întâiul - } + return "0"; + } + // Exception from the rule. + if (number == 1) + { if (gender == GrammaticalGender.Feminine) { - return $"a {numberString}-a"; + return "prima"; // întâia } - return $"al {numberString}-lea"; + return "primul"; // întâiul } + + if (gender == GrammaticalGender.Feminine) + { + return $"a {numberString}-a"; + } + + return $"al {numberString}-lea"; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/RussianOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/RussianOrdinalizer.cs index 327b0e81a..23d1701f7 100644 --- a/src/Humanizer/Localisation/Ordinalizers/RussianOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/RussianOrdinalizer.cs @@ -1,23 +1,22 @@ -namespace Humanizer +namespace Humanizer; + +class RussianOrdinalizer : DefaultOrdinalizer { - class RussianOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) + public override string Convert(int number, string numberString, GrammaticalGender gender) + { + if (gender == GrammaticalGender.Masculine) { - if (gender == GrammaticalGender.Masculine) - { - return numberString + "-й"; - } - - if (gender == GrammaticalGender.Feminine) - { - return numberString + "-я"; - } + return numberString + "-й"; + } - return numberString + "-е"; + if (gender == GrammaticalGender.Feminine) + { + return numberString + "-я"; } + + return numberString + "-е"; } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/SpanishOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/SpanishOrdinalizer.cs index 48fba9c3f..50aa32adf 100644 --- a/src/Humanizer/Localisation/Ordinalizers/SpanishOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/SpanishOrdinalizer.cs @@ -1,15 +1,15 @@ -namespace Humanizer +namespace Humanizer; + +class SpanishOrdinalizer : DefaultOrdinalizer { - class SpanishOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine, WordForm.Normal); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine, WordForm.Normal); - public override string Convert(int number, string numberString, GrammaticalGender gender) => - Convert(number, numberString, gender, WordForm.Normal); + public override string Convert(int number, string numberString, GrammaticalGender gender) => + Convert(number, numberString, gender, WordForm.Normal); - public override string Convert(int number, string numberString, GrammaticalGender gender, WordForm wordForm) - { + public override string Convert(int number, string numberString, GrammaticalGender gender, WordForm wordForm) + { // N/A in Spanish if (number is 0 or int.MinValue) { @@ -33,12 +33,11 @@ public override string Convert(int number, string numberString, GrammaticalGende } } - static CultureInfo _spanishCulture = new("es-ES"); + static CultureInfo _spanishCulture = new("es-ES"); - static string GetNumberString(int number) => - number.ToString(_spanishCulture); + static string GetNumberString(int number) => + number.ToString(_spanishCulture); - static string GetWordForm(int number, WordForm wordForm) => - (number % 10 == 1 || number % 10 == 3) && wordForm == WordForm.Abbreviation ? ".er" : ".º"; - } -} + static string GetWordForm(int number, WordForm wordForm) => + (number % 10 == 1 || number % 10 == 3) && wordForm == WordForm.Abbreviation ? ".er" : ".º"; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/TurkishOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/TurkishOrdinalizer.cs index 4bdc8144e..3b0eb8c15 100644 --- a/src/Humanizer/Localisation/Ordinalizers/TurkishOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/TurkishOrdinalizer.cs @@ -1,8 +1,7 @@ -namespace Humanizer +namespace Humanizer; + +class TurkishOrdinalizer : DefaultOrdinalizer { - class TurkishOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - numberString + "."; - } -} + public override string Convert(int number, string numberString) => + numberString + "."; +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Ordinalizers/UkrainianOrdinalizer.cs b/src/Humanizer/Localisation/Ordinalizers/UkrainianOrdinalizer.cs index cd01189bc..95aa22867 100644 --- a/src/Humanizer/Localisation/Ordinalizers/UkrainianOrdinalizer.cs +++ b/src/Humanizer/Localisation/Ordinalizers/UkrainianOrdinalizer.cs @@ -1,12 +1,12 @@ -namespace Humanizer +namespace Humanizer; + +class UkrainianOrdinalizer : DefaultOrdinalizer { - class UkrainianOrdinalizer : DefaultOrdinalizer - { - public override string Convert(int number, string numberString) => - Convert(number, numberString, GrammaticalGender.Masculine); + public override string Convert(int number, string numberString) => + Convert(number, numberString, GrammaticalGender.Masculine); - public override string Convert(int number, string numberString, GrammaticalGender gender) - { + public override string Convert(int number, string numberString, GrammaticalGender gender) + { if (gender == GrammaticalGender.Masculine) { return numberString + "-й"; @@ -32,5 +32,4 @@ public override string Convert(int number, string numberString, GrammaticalGende return numberString + "-е"; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Resources.cs b/src/Humanizer/Localisation/Resources.cs index 765849689..33c8a828d 100644 --- a/src/Humanizer/Localisation/Resources.cs +++ b/src/Humanizer/Localisation/Resources.cs @@ -1,22 +1,22 @@ using System.Resources; -namespace Humanizer +namespace Humanizer; + +/// +/// Provides access to the resources of Humanizer +/// +public static class Resources { + static readonly ResourceManager ResourceManager = new("Humanizer.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); + /// - /// Provides access to the resources of Humanizer + /// Returns the value of the specified string resource /// - public static class Resources + /// The name of the resource to retrieve. + /// The culture of the resource to retrieve. If not specified, current thread's UI culture is used. + /// The value of the resource localized for the specified culture. + public static string GetResource(string resourceKey, CultureInfo? culture = null) { - static readonly ResourceManager ResourceManager = new("Humanizer.Properties.Resources", typeof(Resources).GetTypeInfo().Assembly); - - /// - /// Returns the value of the specified string resource - /// - /// The name of the resource to retrieve. - /// The culture of the resource to retrieve. If not specified, current thread's UI culture is used. - /// The value of the resource localized for the specified culture. - public static string GetResource(string resourceKey, CultureInfo? culture = null) - { var resource = ResourceManager.GetString(resourceKey, culture); if (resource == null || string.IsNullOrEmpty(resource)) @@ -27,19 +27,18 @@ public static string GetResource(string resourceKey, CultureInfo? culture = null return resource; } - /// - /// Tries to get the value of the specified string resource, without fallback - /// - /// The name of the resource to retrieve. - /// The culture of the resource to retrieve. If not specified, current thread's UI culture is used. - /// The value of the resource localized for the specified culture if found; null otherwise. - /// true if the specified string resource was found for the given culture; otherwise, false. - public static bool TryGetResource(string resourceKey, CultureInfo? culture, [NotNullWhen(true)] out string? result) - { + /// + /// Tries to get the value of the specified string resource, without fallback + /// + /// The name of the resource to retrieve. + /// The culture of the resource to retrieve. If not specified, current thread's UI culture is used. + /// The value of the resource localized for the specified culture if found; null otherwise. + /// true if the specified string resource was found for the given culture; otherwise, false. + public static bool TryGetResource(string resourceKey, CultureInfo? culture, [NotNullWhen(true)] out string? result) + { culture ??= CultureInfo.CurrentUICulture; var resourceSet = ResourceManager.GetResourceSet(culture, createIfNotExists: false, tryParents: false); result = resourceSet?.GetString(resourceKey); return result is not null; } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/Tense.cs b/src/Humanizer/Localisation/Tense.cs index e81c9e14c..935f99cca 100644 --- a/src/Humanizer/Localisation/Tense.cs +++ b/src/Humanizer/Localisation/Tense.cs @@ -1,11 +1,10 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Enumerates the possible time references; past or future. +/// +public enum Tense { - /// - /// Enumerates the possible time references; past or future. - /// - public enum Tense - { - Future, - Past - } -} + Future, + Past +} \ No newline at end of file diff --git a/src/Humanizer/Localisation/TimeUnit.cs b/src/Humanizer/Localisation/TimeUnit.cs index bede6631f..a224f4dcc 100644 --- a/src/Humanizer/Localisation/TimeUnit.cs +++ b/src/Humanizer/Localisation/TimeUnit.cs @@ -1,14 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +public enum TimeUnit { - public enum TimeUnit - { - Millisecond, - Second, - Minute, - Hour, - Day, - Week, - Month, - Year - } -} + Millisecond, + Second, + Minute, + Hour, + Day, + Week, + Month, + Year +} \ No newline at end of file diff --git a/src/Humanizer/MetricNumeralExtensions.cs b/src/Humanizer/MetricNumeralExtensions.cs index 847d39de9..0cd867ebb 100644 --- a/src/Humanizer/MetricNumeralExtensions.cs +++ b/src/Humanizer/MetricNumeralExtensions.cs @@ -21,127 +21,127 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -namespace Humanizer +namespace Humanizer; + +/// +/// Contains extension methods for changing a number to Metric representation (ToMetric) +/// and from Metric representation back to the number (FromMetric) +/// +public static class MetricNumeralExtensions { - /// - /// Contains extension methods for changing a number to Metric representation (ToMetric) - /// and from Metric representation back to the number (FromMetric) - /// - public static class MetricNumeralExtensions - { - static readonly double BigLimit; - static readonly double SmallLimit; + static readonly double BigLimit; + static readonly double SmallLimit; - static MetricNumeralExtensions() - { + static MetricNumeralExtensions() + { const int limit = 27; BigLimit = Math.Pow(10, limit); SmallLimit = Math.Pow(10, -limit); } - /// - /// Symbols is a list of every symbols for the Metric system. - /// - static readonly List[] Symbols = - [ - ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'], - ['m', 'μ', 'n', 'p', 'f', 'a', 'z', 'y'] - ]; + /// + /// Symbols is a list of every symbols for the Metric system. + /// + static readonly List[] Symbols = + [ + ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'], + ['m', 'μ', 'n', 'p', 'f', 'a', 'z', 'y'] + ]; - /// - /// UnitPrefixes link a Metric symbol (as key) to its prefix (as value). - /// - /// - /// We dont support : - /// {'h', "hecto"}, - /// {'da', "deca" }, // !string - /// {'d', "deci" }, - /// {'c', "centi"}, - /// - static readonly Dictionary UnitPrefixes = new() - { - {'Y', new("yotta", "septillion", "quadrillion")}, - {'Z', new("zetta", "sextillion", "trilliard")}, - {'E', new("exa", "quintillion", "trillion")}, - {'P', new("peta", "quadrillion", "billiard")}, - {'T', new("tera", "trillion", "billion")}, - {'G', new("giga", "billion", "milliard")}, - {'M', new("mega", "million")}, - {'k', new("kilo", "thousand")}, + /// + /// UnitPrefixes link a Metric symbol (as key) to its prefix (as value). + /// + /// + /// We dont support : + /// {'h', "hecto"}, + /// {'da', "deca" }, // !string + /// {'d', "deci" }, + /// {'c', "centi"}, + /// + static readonly Dictionary UnitPrefixes = new() + { + {'Y', new("yotta", "septillion", "quadrillion")}, + {'Z', new("zetta", "sextillion", "trilliard")}, + {'E', new("exa", "quintillion", "trillion")}, + {'P', new("peta", "quadrillion", "billiard")}, + {'T', new("tera", "trillion", "billion")}, + {'G', new("giga", "billion", "milliard")}, + {'M', new("mega", "million")}, + {'k', new("kilo", "thousand")}, - {'m', new("milli", "thousandth")}, - {'μ', new("micro", "millionth")}, - {'n', new("nano", "billionth", "milliardth")}, - {'p', new("pico", "trillionth", "billionth")}, - {'f', new("femto", "quadrillionth", "billiardth")}, - {'a', new("atto", "quintillionth", "trillionth")}, - {'z', new("zepto", "sextillionth", "trilliardth")}, - {'y', new("yocto", "septillionth", "quadrillionth")} - }; + {'m', new("milli", "thousandth")}, + {'μ', new("micro", "millionth")}, + {'n', new("nano", "billionth", "milliardth")}, + {'p', new("pico", "trillionth", "billionth")}, + {'f', new("femto", "quadrillionth", "billiardth")}, + {'a', new("atto", "quintillionth", "trillionth")}, + {'z', new("zepto", "sextillionth", "trilliardth")}, + {'y', new("yocto", "septillionth", "quadrillionth")} + }; - /// - /// Converts a Metric representation into a number. - /// - /// - /// We don't support input in the format {number}{name} nor {number} {name}. - /// We only provide a solution for {number}{symbol} and {number} {symbol}. - /// - /// Metric representation to convert to a number - /// - /// - /// "1k".FromMetric() => 1000d - /// "123".FromMetric() => 123d - /// "100m".FromMetric() => 1E-1 - /// - /// - /// A number after a conversion from a Metric representation. - public static double FromMetric(this string input) - { + /// + /// Converts a Metric representation into a number. + /// + /// + /// We don't support input in the format {number}{name} nor {number} {name}. + /// We only provide a solution for {number}{symbol} and {number} {symbol}. + /// + /// Metric representation to convert to a number + /// + /// + /// "1k".FromMetric() => 1000d + /// "123".FromMetric() => 123d + /// "100m".FromMetric() => 1E-1 + /// + /// + /// A number after a conversion from a Metric representation. + public static double FromMetric(this string input) + { input = CleanRepresentation(input); return BuildNumber(input, input[^1]); } - /// - /// Converts a number into a valid and Human-readable Metric representation. - /// - /// - /// Inspired by a snippet from Thom Smith. - /// See this link for more. - /// - /// Number to convert to a Metric representation. - /// A bitwise combination of enumeration values that format the metric representation. - /// If not null it is the numbers of decimals to round the number to - /// - /// - /// 1000.ToMetric() => "1k" - /// 123.ToMetric() => "123" - /// 1E-1.ToMetric() => "100m" - /// - /// - /// A valid Metric representation - public static string ToMetric(this int input, MetricNumeralFormats? formats = null, int? decimals = null) => - ((double)input).ToMetric(formats, decimals); + /// + /// Converts a number into a valid and Human-readable Metric representation. + /// + /// + /// Inspired by a snippet from Thom Smith. + /// See this link for more. + /// + /// Number to convert to a Metric representation. + /// A bitwise combination of enumeration values that format the metric representation. + /// If not null it is the numbers of decimals to round the number to + /// + /// + /// 1000.ToMetric() => "1k" + /// 123.ToMetric() => "123" + /// 1E-1.ToMetric() => "100m" + /// + /// + /// A valid Metric representation + public static string ToMetric(this int input, MetricNumeralFormats? formats = null, int? decimals = null) => + ((double)input).ToMetric(formats, decimals); - /// - /// Converts a number into a valid and Human-readable Metric representation. - /// - /// - /// Inspired by a snippet from Thom Smith. - /// See this link for more. - /// - /// Number to convert to a Metric representation. - /// A bitwise combination of enumeration values that format the metric representation. - /// If not null it is the numbers of decimals to round the number to - /// - /// - /// 1000d.ToMetric() => "1k" - /// 123d.ToMetric() => "123" - /// 1E-1.ToMetric() => "100m" - /// - /// - /// A valid Metric representation - public static string ToMetric(this double input, MetricNumeralFormats? formats = null, int? decimals = null) - { + /// + /// Converts a number into a valid and Human-readable Metric representation. + /// + /// + /// Inspired by a snippet from Thom Smith. + /// See this link for more. + /// + /// Number to convert to a Metric representation. + /// A bitwise combination of enumeration values that format the metric representation. + /// If not null it is the numbers of decimals to round the number to + /// + /// + /// 1000d.ToMetric() => "1k" + /// 123d.ToMetric() => "123" + /// 1E-1.ToMetric() => "100m" + /// + /// + /// A valid Metric representation + public static string ToMetric(this double input, MetricNumeralFormats? formats = null, int? decimals = null) + { if (input.Equals(0)) { return input.ToString(); @@ -155,13 +155,13 @@ public static string ToMetric(this double input, MetricNumeralFormats? formats = return BuildRepresentation(input, formats, decimals); } - /// - /// Clean or handle any wrong input - /// - /// Metric representation to clean - /// A cleaned representation - static string CleanRepresentation(string input) - { + /// + /// Clean or handle any wrong input + /// + /// Metric representation to clean + /// A cleaned representation + static string CleanRepresentation(string input) + { if (input == null) { throw new ArgumentNullException(nameof(input)); @@ -177,25 +177,25 @@ static string CleanRepresentation(string input) return input.Replace(" ", string.Empty); } - /// - /// Build a number from a metric representation or from a number - /// - /// A Metric representation to parse to a number - /// The last character of input - /// A number build from a Metric representation - static double BuildNumber(string input, char last) => - char.IsLetter(last) - ? BuildMetricNumber(input, last) - : double.Parse(input); + /// + /// Build a number from a metric representation or from a number + /// + /// A Metric representation to parse to a number + /// The last character of input + /// A number build from a Metric representation + static double BuildNumber(string input, char last) => + char.IsLetter(last) + ? BuildMetricNumber(input, last) + : double.Parse(input); - /// - /// Build a number from a metric representation - /// - /// A Metric representation to parse to a number - /// The last character of input - /// A number build from a Metric representation - static double BuildMetricNumber(string input, char last) - { + /// + /// Build a number from a metric representation + /// + /// A Metric representation to parse to a number + /// The last character of input + /// A number build from a Metric representation + static double BuildMetricNumber(string input, char last) + { double getExponent(List symbols) => (symbols.IndexOf(last) + 1) * 3; var number = double.Parse(input.Remove(input.Length - 1)); var exponent = Math.Pow(10, Symbols[0].Contains(last) @@ -204,24 +204,24 @@ static double BuildMetricNumber(string input, char last) return number * exponent; } - /// - /// Replace every symbol's name by its symbol representation. - /// - /// Metric representation with a name or a symbol - /// A metric representation with a symbol - static string ReplaceNameBySymbol(string input) => - UnitPrefixes.Aggregate(input, (current, unitPrefix) => - current.Replace(unitPrefix.Value.Name, unitPrefix.Key.ToString())); + /// + /// Replace every symbol's name by its symbol representation. + /// + /// Metric representation with a name or a symbol + /// A metric representation with a symbol + static string ReplaceNameBySymbol(string input) => + UnitPrefixes.Aggregate(input, (current, unitPrefix) => + current.Replace(unitPrefix.Value.Name, unitPrefix.Key.ToString())); - /// - /// Build a Metric representation of the number. - /// - /// Number to convert to a Metric representation. - /// A bitwise combination of enumeration values that format the metric representation. - /// If not null it is the numbers of decimals to round the number to - /// A number in a Metric representation - static string BuildRepresentation(double input, MetricNumeralFormats? formats, int? decimals) - { + /// + /// Build a Metric representation of the number. + /// + /// Number to convert to a Metric representation. + /// A bitwise combination of enumeration values that format the metric representation. + /// If not null it is the numbers of decimals to round the number to + /// A number in a Metric representation + static string BuildRepresentation(double input, MetricNumeralFormats? formats, int? decimals) + { var exponent = (int)Math.Floor(Math.Log10(Math.Abs(input)) / 3); if (!exponent.Equals(0)) return BuildMetricRepresentation(input, exponent, formats, decimals); @@ -233,16 +233,16 @@ static string BuildRepresentation(double input, MetricNumeralFormats? formats, i return representation; } - /// - /// Build a Metric representation of the number. - /// - /// Number to convert to a Metric representation. - /// Exponent of the number in a scientific notation - /// A bitwise combination of enumeration values that format the metric representation. - /// If not null it is the numbers of decimals to round the number to - /// A number in a Metric representation - static string BuildMetricRepresentation(double input, int exponent, MetricNumeralFormats? formats, int? decimals) - { + /// + /// Build a Metric representation of the number. + /// + /// Number to convert to a Metric representation. + /// Exponent of the number in a scientific notation + /// A bitwise combination of enumeration values that format the metric representation. + /// If not null it is the numbers of decimals to round the number to + /// A number in a Metric representation + static string BuildMetricRepresentation(double input, int exponent, MetricNumeralFormats? formats, int? decimals) + { var number = input * Math.Pow(1000, -exponent); if (decimals.HasValue) { @@ -257,14 +257,14 @@ static string BuildMetricRepresentation(double input, int exponent, MetricNumera + GetUnitText(symbol, formats); } - /// - /// Get the unit from a symbol of from the symbol's name. - /// - /// The symbol linked to the unit - /// A bitwise combination of enumeration values that format the metric representation. - /// A symbol, a symbol's name, a symbol's short scale word or a symbol's long scale word - static string GetUnitText(char symbol, MetricNumeralFormats? formats) - { + /// + /// Get the unit from a symbol of from the symbol's name. + /// + /// The symbol linked to the unit + /// A bitwise combination of enumeration values that format the metric representation. + /// A symbol, a symbol's name, a symbol's short scale word or a symbol's long scale word + static string GetUnitText(char symbol, MetricNumeralFormats? formats) + { if (formats.HasValue && formats.Value.HasFlag(MetricNumeralFormats.UseName)) { @@ -283,42 +283,41 @@ static string GetUnitText(char symbol, MetricNumeralFormats? formats) return symbol.ToString(); } - /// - /// Check if a Metric representation is out of the valid range. - /// - /// A Metric representation that may be out of the valid range. - /// True if input is out of the valid range. - static bool IsOutOfRange(this double input) - { + /// + /// Check if a Metric representation is out of the valid range. + /// + /// A Metric representation that may be out of the valid range. + /// True if input is out of the valid range. + static bool IsOutOfRange(this double input) + { bool outside(double min, double max) => !(max > input && input > min); return (Math.Sign(input) == 1 && outside(SmallLimit, BigLimit)) || (Math.Sign(input) == -1 && outside(-BigLimit, -SmallLimit)); } - /// - /// Check if a string is not a valid Metric representation. - /// A valid representation is in the format "{0}{1}" or "{0} {1}" - /// where {0} is a number and {1} is an allowed symbol. - /// - /// - /// ToDo: Performance: Use (string input, out number) to escape the double use of Parse() - /// - /// >A string that may contain an invalid Metric representation. - /// True if input is not a valid Metric representation. - static bool IsInvalidMetricNumeral(this string input) - { + /// + /// Check if a string is not a valid Metric representation. + /// A valid representation is in the format "{0}{1}" or "{0} {1}" + /// where {0} is a number and {1} is an allowed symbol. + /// + /// + /// ToDo: Performance: Use (string input, out number) to escape the double use of Parse() + /// + /// >A string that may contain an invalid Metric representation. + /// True if input is not a valid Metric representation. + static bool IsInvalidMetricNumeral(this string input) + { var index = input.Length - 1; var last = input[index]; var isSymbol = Symbols[0].Contains(last) || Symbols[1].Contains(last); return !double.TryParse(isSymbol ? input.Remove(index) : input, out _); } - struct UnitPrefix(string name, string shortScaleWord, string? longScaleWord = null) - { - public string Name { get; } = name; - public string ShortScaleWord { get; } = shortScaleWord; - public string LongScaleWord => longScaleWord ?? ShortScaleWord; - } + struct UnitPrefix(string name, string shortScaleWord, string? longScaleWord = null) + { + public string Name { get; } = name; + public string ShortScaleWord { get; } = shortScaleWord; + public string LongScaleWord => longScaleWord ?? ShortScaleWord; } -} +} \ No newline at end of file diff --git a/src/Humanizer/MetricNumeralFormats.cs b/src/Humanizer/MetricNumeralFormats.cs index 57d6d0ea5..049abc9dc 100644 --- a/src/Humanizer/MetricNumeralFormats.cs +++ b/src/Humanizer/MetricNumeralFormats.cs @@ -1,29 +1,28 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Flags for formatting the metric representation of numerals. +/// +[Flags] +public enum MetricNumeralFormats { /// - /// Flags for formatting the metric representation of numerals. + /// Use the metric prefix long scale word. /// - [Flags] - public enum MetricNumeralFormats - { - /// - /// Use the metric prefix long scale word. - /// - UseLongScaleWord = 1, + UseLongScaleWord = 1, - /// - /// Use the metric prefix name instead of the symbol. - /// - UseName = 2, + /// + /// Use the metric prefix name instead of the symbol. + /// + UseName = 2, - /// - /// Use the metric prefix short scale word. - /// - UseShortScaleWord = 4, + /// + /// Use the metric prefix short scale word. + /// + UseShortScaleWord = 4, - /// - /// Include a space after the numeral. - /// - WithSpace = 8 - } -} + /// + /// Include a space after the numeral. + /// + WithSpace = 8 +} \ No newline at end of file diff --git a/src/Humanizer/NoMatchFoundException.cs b/src/Humanizer/NoMatchFoundException.cs index b8edc5d7c..d374c468a 100644 --- a/src/Humanizer/NoMatchFoundException.cs +++ b/src/Humanizer/NoMatchFoundException.cs @@ -1,24 +1,23 @@ -namespace Humanizer -{ - /// - /// This is thrown on String.DehumanizeTo enum when the provided string cannot be mapped to the target enum - /// +namespace Humanizer; + +/// +/// This is thrown on String.DehumanizeTo enum when the provided string cannot be mapped to the target enum +/// #pragma warning disable 1591 - public class NoMatchFoundException : Exception +public class NoMatchFoundException : Exception +{ + public NoMatchFoundException() { - public NoMatchFoundException() - { } - public NoMatchFoundException(string message) - : base(message) - { + public NoMatchFoundException(string message) + : base(message) + { } - public NoMatchFoundException(string message, Exception inner) - : base(message, inner) - { + public NoMatchFoundException(string message, Exception inner) + : base(message, inner) + { } - } -#pragma warning restore 1591 -} \ No newline at end of file +} +#pragma warning restore 1591 \ No newline at end of file diff --git a/src/Humanizer/NumberToNumberExtensions.cs b/src/Humanizer/NumberToNumberExtensions.cs index 88a5abc90..075a00c05 100644 --- a/src/Humanizer/NumberToNumberExtensions.cs +++ b/src/Humanizer/NumberToNumberExtensions.cs @@ -1,185 +1,184 @@ using System.Runtime.CompilerServices; -namespace Humanizer +namespace Humanizer; + +/// +/// Number to Number extensions +/// +public static class NumberToNumberExtensions { /// - /// Number to Number extensions - /// - public static class NumberToNumberExtensions - { - /// - /// 5.Tens == 50 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Tens(this int input) => - input * 10; - - /// - /// 5.Tens == 50 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint Tens(this uint input) => - input * 10; - - /// - /// 5.Tens == 50 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long Tens(this long input) => - input * 10; - - /// - /// 5.Tens == 50 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong Tens(this ulong input) => - input * 10; - - /// - /// 5.Tens == 50 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double Tens(this double input) => - input * 10; - - /// - /// 4.Hundreds() == 400 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Hundreds(this int input) => - input * 100; - - /// - /// 4.Hundreds() == 400 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint Hundreds(this uint input) => - input * 100; - - /// - /// 4.Hundreds() == 400 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long Hundreds(this long input) => - input * 100; - - /// - /// 4.Hundreds() == 400 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong Hundreds(this ulong input) => - input * 100; - - /// - /// 4.Hundreds() == 400 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double Hundreds(this double input) => - input * 100; - - /// - /// 3.Thousands() == 3000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Thousands(this int input) => - input * 1000; - - /// - /// 3.Thousands() == 3000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint Thousands(this uint input) => - input * 1000; - - /// - /// 3.Thousands() == 3000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long Thousands(this long input) => - input * 1000; - - /// - /// 3.Thousands() == 3000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong Thousands(this ulong input) => - input * 1000; - - /// - /// 3.Thousands() == 3000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double Thousands(this double input) => - input * 1000; - - /// - /// 2.Millions() == 2000000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Millions(this int input) => - input * 1000000; - - /// - /// 2.Millions() == 2000000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint Millions(this uint input) => - input * 1000000; - - /// - /// 2.Millions() == 2000000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long Millions(this long input) => - input * 1000000; - - /// - /// 2.Millions() == 2000000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong Millions(this ulong input) => - input * 1000000; - - /// - /// 2.Millions() == 2000000 - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double Millions(this double input) => - input * 1000000; - - /// - /// 1.Billions() == 1000000000 (short scale) - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int Billions(this int input) => - input * 1000000000; - - /// - /// 1.Billions() == 1000000000 (short scale) - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint Billions(this uint input) => - input * 1000000000; - - /// - /// 1.Billions() == 1000000000 (short scale) - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long Billions(this long input) => - input * 1000000000; - - /// - /// 1.Billions() == 1000000000 (short scale) - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong Billions(this ulong input) => - input * 1000000000; - - /// - /// 1.Billions() == 1000000000 (short scale) - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double Billions(this double input) => - input * 1000000000; - } -} + /// 5.Tens == 50 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int Tens(this int input) => + input * 10; + + /// + /// 5.Tens == 50 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint Tens(this uint input) => + input * 10; + + /// + /// 5.Tens == 50 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static long Tens(this long input) => + input * 10; + + /// + /// 5.Tens == 50 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong Tens(this ulong input) => + input * 10; + + /// + /// 5.Tens == 50 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static double Tens(this double input) => + input * 10; + + /// + /// 4.Hundreds() == 400 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int Hundreds(this int input) => + input * 100; + + /// + /// 4.Hundreds() == 400 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint Hundreds(this uint input) => + input * 100; + + /// + /// 4.Hundreds() == 400 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static long Hundreds(this long input) => + input * 100; + + /// + /// 4.Hundreds() == 400 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong Hundreds(this ulong input) => + input * 100; + + /// + /// 4.Hundreds() == 400 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static double Hundreds(this double input) => + input * 100; + + /// + /// 3.Thousands() == 3000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int Thousands(this int input) => + input * 1000; + + /// + /// 3.Thousands() == 3000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint Thousands(this uint input) => + input * 1000; + + /// + /// 3.Thousands() == 3000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static long Thousands(this long input) => + input * 1000; + + /// + /// 3.Thousands() == 3000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong Thousands(this ulong input) => + input * 1000; + + /// + /// 3.Thousands() == 3000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static double Thousands(this double input) => + input * 1000; + + /// + /// 2.Millions() == 2000000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int Millions(this int input) => + input * 1000000; + + /// + /// 2.Millions() == 2000000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint Millions(this uint input) => + input * 1000000; + + /// + /// 2.Millions() == 2000000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static long Millions(this long input) => + input * 1000000; + + /// + /// 2.Millions() == 2000000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong Millions(this ulong input) => + input * 1000000; + + /// + /// 2.Millions() == 2000000 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static double Millions(this double input) => + input * 1000000; + + /// + /// 1.Billions() == 1000000000 (short scale) + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int Billions(this int input) => + input * 1000000000; + + /// + /// 1.Billions() == 1000000000 (short scale) + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint Billions(this uint input) => + input * 1000000000; + + /// + /// 1.Billions() == 1000000000 (short scale) + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static long Billions(this long input) => + input * 1000000000; + + /// + /// 1.Billions() == 1000000000 (short scale) + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong Billions(this ulong input) => + input * 1000000000; + + /// + /// 1.Billions() == 1000000000 (short scale) + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static double Billions(this double input) => + input * 1000000000; +} \ No newline at end of file diff --git a/src/Humanizer/NumberToTimeSpanExtensions.cs b/src/Humanizer/NumberToTimeSpanExtensions.cs index d06e1a51e..9c6d59338 100644 --- a/src/Humanizer/NumberToTimeSpanExtensions.cs +++ b/src/Humanizer/NumberToTimeSpanExtensions.cs @@ -1,332 +1,331 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Number to TimeSpan extensions +/// +public static class NumberToTimeSpanExtensions { /// - /// Number to TimeSpan extensions - /// - public static class NumberToTimeSpanExtensions - { - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this byte ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this sbyte ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this short ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this ushort ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this int ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this uint ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this long ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this ulong ms) => - Milliseconds((double)ms); - - /// - /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) - /// - public static TimeSpan Milliseconds(this double ms) => - TimeSpan.FromMilliseconds(ms); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this byte seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this sbyte seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this short seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this ushort seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this int seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this uint seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this long seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this ulong seconds) => - Seconds((double)seconds); - - /// - /// 5.Seconds() == TimeSpan.FromSeconds(5) - /// - public static TimeSpan Seconds(this double seconds) => - TimeSpan.FromSeconds(seconds); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this byte minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this sbyte minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this short minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this ushort minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this int minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this uint minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this long minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this ulong minutes) => - Minutes((double)minutes); - - /// - /// 4.Minutes() == TimeSpan.FromMinutes(4) - /// - public static TimeSpan Minutes(this double minutes) => - TimeSpan.FromMinutes(minutes); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this byte hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this sbyte hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this short hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this ushort hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this int hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this uint hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this long hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this ulong hours) => - Hours((double)hours); - - /// - /// 3.Hours() == TimeSpan.FromHours(3) - /// - public static TimeSpan Hours(this double hours) => - TimeSpan.FromHours(hours); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this byte days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this sbyte days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this short days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this ushort days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this int days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this uint days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this long days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this ulong days) => - Days((double)days); - - /// - /// 2.Days() == TimeSpan.FromDays(2) - /// - public static TimeSpan Days(this double days) => - TimeSpan.FromDays(days); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this byte input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this sbyte input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this short input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this ushort input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this int input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this uint input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this long input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this ulong input) => - Weeks((double)input); - - /// - /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) - /// - public static TimeSpan Weeks(this double input) => - Days(7 * input); - } -} + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this byte ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this sbyte ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this short ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this ushort ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this int ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this uint ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this long ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this ulong ms) => + Milliseconds((double)ms); + + /// + /// 5.Milliseconds() == TimeSpan.FromMilliseconds(5) + /// + public static TimeSpan Milliseconds(this double ms) => + TimeSpan.FromMilliseconds(ms); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this byte seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this sbyte seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this short seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this ushort seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this int seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this uint seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this long seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this ulong seconds) => + Seconds((double)seconds); + + /// + /// 5.Seconds() == TimeSpan.FromSeconds(5) + /// + public static TimeSpan Seconds(this double seconds) => + TimeSpan.FromSeconds(seconds); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this byte minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this sbyte minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this short minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this ushort minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this int minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this uint minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this long minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this ulong minutes) => + Minutes((double)minutes); + + /// + /// 4.Minutes() == TimeSpan.FromMinutes(4) + /// + public static TimeSpan Minutes(this double minutes) => + TimeSpan.FromMinutes(minutes); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this byte hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this sbyte hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this short hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this ushort hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this int hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this uint hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this long hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this ulong hours) => + Hours((double)hours); + + /// + /// 3.Hours() == TimeSpan.FromHours(3) + /// + public static TimeSpan Hours(this double hours) => + TimeSpan.FromHours(hours); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this byte days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this sbyte days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this short days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this ushort days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this int days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this uint days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this long days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this ulong days) => + Days((double)days); + + /// + /// 2.Days() == TimeSpan.FromDays(2) + /// + public static TimeSpan Days(this double days) => + TimeSpan.FromDays(days); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this byte input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this sbyte input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this short input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this ushort input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this int input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this uint input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this long input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this ulong input) => + Weeks((double)input); + + /// + /// 2.Weeks() == new TimeSpan(14, 0, 0, 0) + /// + public static TimeSpan Weeks(this double input) => + Days(7 * input); +} \ No newline at end of file diff --git a/src/Humanizer/NumberToWordsExtension.cs b/src/Humanizer/NumberToWordsExtension.cs index b561d353c..dfbf2bcb0 100644 --- a/src/Humanizer/NumberToWordsExtension.cs +++ b/src/Humanizer/NumberToWordsExtension.cs @@ -1,232 +1,231 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Transform a number into words; e.g. 1 => one +/// +public static class NumberToWordsExtension { /// - /// Transform a number into words; e.g. 1 => one + /// 1.ToOrdinalWords() -> "first" /// - public static class NumberToWordsExtension - { - /// - /// 1.ToOrdinalWords() -> "first" - /// - /// Number to be turned to ordinal words - /// Culture to use. If null, current thread's UI culture is used. - public static string ToOrdinalWords(this int number, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number); + /// Number to be turned to ordinal words + /// Culture to use. If null, current thread's UI culture is used. + public static string ToOrdinalWords(this int number, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number); - /// - /// Converts a number to ordinal words supporting locale's specific variations. - /// - /// - /// In Spanish: - /// - /// 1.ToOrdinalWords(WordForm.Normal) -> "primero" // As in "He llegado el primero". - /// 3.ToOrdinalWords(WordForm.Abbreviation) -> "tercer" // As in "Vivo en el tercer piso" - /// - /// - /// Number to be turned to ordinal words - /// Form of the word, i.e. abbreviation - /// Culture to use. If null, current thread's UI culture is used. - /// The number converted into ordinal words - public static string ToOrdinalWords(this int number, WordForm wordForm, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, wordForm); + /// + /// Converts a number to ordinal words supporting locale's specific variations. + /// + /// + /// In Spanish: + /// + /// 1.ToOrdinalWords(WordForm.Normal) -> "primero" // As in "He llegado el primero". + /// 3.ToOrdinalWords(WordForm.Abbreviation) -> "tercer" // As in "Vivo en el tercer piso" + /// + /// + /// Number to be turned to ordinal words + /// Form of the word, i.e. abbreviation + /// Culture to use. If null, current thread's UI culture is used. + /// The number converted into ordinal words + public static string ToOrdinalWords(this int number, WordForm wordForm, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, wordForm); - /// - /// for Brazilian Portuguese locale - /// 1.ToOrdinalWords(GrammaticalGender.Masculine) -> "primeiro" - /// 1.ToOrdinalWords(GrammaticalGender.Feminine) -> "primeira" - /// - /// Number to be turned to words - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - public static string ToOrdinalWords(this int number, GrammaticalGender gender, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, gender); + /// + /// for Brazilian Portuguese locale + /// 1.ToOrdinalWords(GrammaticalGender.Masculine) -> "primeiro" + /// 1.ToOrdinalWords(GrammaticalGender.Feminine) -> "primeira" + /// + /// Number to be turned to words + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + public static string ToOrdinalWords(this int number, GrammaticalGender gender, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, gender); - /// - /// Converts a number to ordinal words supporting locale's specific variations. - /// - /// - /// In Spanish: - /// - /// 3.ToOrdinalWords(GrammaticalGender.Masculine, WordForm.Normal) -> "tercero" - /// 3.ToOrdinalWords(GrammaticalGender.Masculine, WordForm.Abbreviation) -> "tercer" - /// 3.ToOrdinalWords(GrammaticalGender.Feminine, WordForm.Normal) -> "tercera" - /// 3.ToOrdinalWords(GrammaticalGender.Feminine, WordForm.Abbreviation) -> "tercera" - /// - /// - /// Number to be turned to ordinal words - /// The grammatical gender to use for output words - /// Form of the word, i.e. abbreviation - /// Culture to use. If null, current thread's UI culture is used. - /// The number converted into ordinal words - public static string ToOrdinalWords(this int number, GrammaticalGender gender, WordForm wordForm, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, gender, wordForm); + /// + /// Converts a number to ordinal words supporting locale's specific variations. + /// + /// + /// In Spanish: + /// + /// 3.ToOrdinalWords(GrammaticalGender.Masculine, WordForm.Normal) -> "tercero" + /// 3.ToOrdinalWords(GrammaticalGender.Masculine, WordForm.Abbreviation) -> "tercer" + /// 3.ToOrdinalWords(GrammaticalGender.Feminine, WordForm.Normal) -> "tercera" + /// 3.ToOrdinalWords(GrammaticalGender.Feminine, WordForm.Abbreviation) -> "tercera" + /// + /// + /// Number to be turned to ordinal words + /// The grammatical gender to use for output words + /// Form of the word, i.e. abbreviation + /// Culture to use. If null, current thread's UI culture is used. + /// The number converted into ordinal words + public static string ToOrdinalWords(this int number, GrammaticalGender gender, WordForm wordForm, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, gender, wordForm); - /// - /// 1.ToTuple() -> "single" - /// - /// Number to be turned to tuple - /// Culture to use. If null, current thread's UI culture is used. - public static string ToTuple(this int number, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).ConvertToTuple(number); + /// + /// 1.ToTuple() -> "single" + /// + /// Number to be turned to tuple + /// Culture to use. If null, current thread's UI culture is used. + public static string ToTuple(this int number, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).ConvertToTuple(number); - /// - /// 3501.ToWords() -> "three thousand five hundred and one" - /// - /// Number to be turned to words - /// Culture to use. If null, current thread's UI culture is used. - public static string ToWords(this int number, CultureInfo? culture = null) => - ((long)number).ToWords(culture); + /// + /// 3501.ToWords() -> "three thousand five hundred and one" + /// + /// Number to be turned to words + /// Culture to use. If null, current thread's UI culture is used. + public static string ToWords(this int number, CultureInfo? culture = null) => + ((long)number).ToWords(culture); - /// - /// Converts a number to words supporting specific word variations, including grammatical gender, of some locales. - /// - /// - /// In Spanish, numbers ended in 1 change its form depending on their position in the sentence. - /// - /// 21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno". - /// 21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches" - /// - /// - /// Number to be turned to words - /// Form of the word, i.e. abbreviation - /// Culture to use. If null, current thread's UI culture is used. - /// The number converted to words - public static string ToWords(this int number, WordForm wordForm, CultureInfo? culture = null) => - ((long)number).ToWords(wordForm, culture); + /// + /// Converts a number to words supporting specific word variations, including grammatical gender, of some locales. + /// + /// + /// In Spanish, numbers ended in 1 change its form depending on their position in the sentence. + /// + /// 21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno". + /// 21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches" + /// + /// + /// Number to be turned to words + /// Form of the word, i.e. abbreviation + /// Culture to use. If null, current thread's UI culture is used. + /// The number converted to words + public static string ToWords(this int number, WordForm wordForm, CultureInfo? culture = null) => + ((long)number).ToWords(wordForm, culture); - /// - /// 3501.ToWords(false) -> "three thousand five hundred one" - /// - /// Number to be turned to words - /// To add 'and' before the last number. - /// Culture to use. If null, current thread's UI culture is used. - public static string ToWords(this int number, bool addAnd, CultureInfo? culture = null) => - ((long)number).ToWords(culture, addAnd); + /// + /// 3501.ToWords(false) -> "three thousand five hundred one" + /// + /// Number to be turned to words + /// To add 'and' before the last number. + /// Culture to use. If null, current thread's UI culture is used. + public static string ToWords(this int number, bool addAnd, CultureInfo? culture = null) => + ((long)number).ToWords(culture, addAnd); - /// - /// Converts a number to words supporting specific word variations of some locales. - /// - /// - /// In Spanish, numbers ended in 1 changes its form depending on their position in the sentence. - /// - /// 21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno". - /// 21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches" - /// - /// - /// Number to be turned to words - /// To add 'and' before the last number - /// Form of the word, i.e. abbreviation - /// Culture to use. If null, current thread's UI culture is used. - /// The number converted to words - public static string ToWords(this int number, bool addAnd, WordForm wordForm, CultureInfo? culture = null) => - ((long)number).ToWords(wordForm, culture, addAnd); + /// + /// Converts a number to words supporting specific word variations of some locales. + /// + /// + /// In Spanish, numbers ended in 1 changes its form depending on their position in the sentence. + /// + /// 21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno". + /// 21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches" + /// + /// + /// Number to be turned to words + /// To add 'and' before the last number + /// Form of the word, i.e. abbreviation + /// Culture to use. If null, current thread's UI culture is used. + /// The number converted to words + public static string ToWords(this int number, bool addAnd, WordForm wordForm, CultureInfo? culture = null) => + ((long)number).ToWords(wordForm, culture, addAnd); - /// - /// For locales that support gender-specific forms - /// - /// - /// Russian: - /// - /// 1.ToWords(GrammaticalGender.Masculine) -> "один" - /// 1.ToWords(GrammaticalGender.Feminine) -> "одна" - /// - /// Hebrew: - /// - /// 1.ToWords(GrammaticalGender.Masculine) -> "אחד" - /// 1.ToWords(GrammaticalGender.Feminine) -> "אחת" - /// - /// - /// Number to be turned to words - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - public static string ToWords(this int number, GrammaticalGender gender, CultureInfo? culture = null) => - ((long)number).ToWords(gender, culture); + /// + /// For locales that support gender-specific forms + /// + /// + /// Russian: + /// + /// 1.ToWords(GrammaticalGender.Masculine) -> "один" + /// 1.ToWords(GrammaticalGender.Feminine) -> "одна" + /// + /// Hebrew: + /// + /// 1.ToWords(GrammaticalGender.Masculine) -> "אחד" + /// 1.ToWords(GrammaticalGender.Feminine) -> "אחת" + /// + /// + /// Number to be turned to words + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + public static string ToWords(this int number, GrammaticalGender gender, CultureInfo? culture = null) => + ((long)number).ToWords(gender, culture); - /// - /// Converts a number to words supporting specific word variations, including grammatical gender, of some locales. - /// - /// - /// In Spanish, numbers ended in 1 change its form depending on their position in the sentence. - /// - /// 21.ToWords(WordForm.Normal, GrammaticalGender.Masculine) -> veintiuno // as in "Mi número favorito es el veintiuno". - /// 21.ToWords(WordForm.Abbreviation, GrammaticalGender.Masculine) -> veintiún // as in "En total, conté veintiún coches" - /// 21.ToWords(WordForm.Normal, GrammaticalGender.Feminine) -> veintiuna // as in "veintiuna personas" - /// - /// - /// Number to be turned to words - /// Form of the word, i.e. abbreviation - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - /// The number converted to words - public static string ToWords(this int number, WordForm wordForm, GrammaticalGender gender, CultureInfo? culture = null) => - ((long)number).ToWords(wordForm, gender, culture); + /// + /// Converts a number to words supporting specific word variations, including grammatical gender, of some locales. + /// + /// + /// In Spanish, numbers ended in 1 change its form depending on their position in the sentence. + /// + /// 21.ToWords(WordForm.Normal, GrammaticalGender.Masculine) -> veintiuno // as in "Mi número favorito es el veintiuno". + /// 21.ToWords(WordForm.Abbreviation, GrammaticalGender.Masculine) -> veintiún // as in "En total, conté veintiún coches" + /// 21.ToWords(WordForm.Normal, GrammaticalGender.Feminine) -> veintiuna // as in "veintiuna personas" + /// + /// + /// Number to be turned to words + /// Form of the word, i.e. abbreviation + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + /// The number converted to words + public static string ToWords(this int number, WordForm wordForm, GrammaticalGender gender, CultureInfo? culture = null) => + ((long)number).ToWords(wordForm, gender, culture); - /// - /// 3501.ToWords() -> "three thousand five hundred and one" - /// - /// Number to be turned to words - /// Culture to use. If null, current thread's UI culture is used. - /// Whether "and" should be included or not. - public static string ToWords(this long number, CultureInfo? culture = null, bool addAnd = true) => - Configurator.GetNumberToWordsConverter(culture).Convert(number, addAnd); + /// + /// 3501.ToWords() -> "three thousand five hundred and one" + /// + /// Number to be turned to words + /// Culture to use. If null, current thread's UI culture is used. + /// Whether "and" should be included or not. + public static string ToWords(this long number, CultureInfo? culture = null, bool addAnd = true) => + Configurator.GetNumberToWordsConverter(culture).Convert(number, addAnd); - /// - /// Converts a number to words supporting specific word variations of some locales. - /// - /// - /// In Spanish, numbers ended in 1 changes its form depending on their position in the sentence. - /// - /// 21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno". - /// 21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches" - /// - /// - /// Number to be turned to words - /// Form of the word, i.e. abbreviation - /// Culture to use. If null, current thread's UI culture is used. - /// To add 'and' before the last number - /// The number converted to words - public static string ToWords(this long number, WordForm wordForm, CultureInfo? culture = null, bool addAnd = false) => - Configurator.GetNumberToWordsConverter(culture).Convert(number, addAnd, wordForm); + /// + /// Converts a number to words supporting specific word variations of some locales. + /// + /// + /// In Spanish, numbers ended in 1 changes its form depending on their position in the sentence. + /// + /// 21.ToWords(WordForm.Normal) -> veintiuno // as in "Mi número favorito es el veintiuno". + /// 21.ToWords(WordForm.Abbreviation) -> veintiún // as in "En total, conté veintiún coches" + /// + /// + /// Number to be turned to words + /// Form of the word, i.e. abbreviation + /// Culture to use. If null, current thread's UI culture is used. + /// To add 'and' before the last number + /// The number converted to words + public static string ToWords(this long number, WordForm wordForm, CultureInfo? culture = null, bool addAnd = false) => + Configurator.GetNumberToWordsConverter(culture).Convert(number, addAnd, wordForm); - /// - /// For locales that support gender-specific forms - /// - /// - /// Russian: - /// - /// 1.ToWords(GrammaticalGender.Masculine) -> "один" - /// 1.ToWords(GrammaticalGender.Feminine) -> "одна" - /// - /// Hebrew: - /// - /// 1.ToWords(GrammaticalGender.Masculine) -> "אחד" - /// 1.ToWords(GrammaticalGender.Feminine) -> "אחת" - /// - /// - /// - /// Number to be turned to words - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - public static string ToWords(this long number, GrammaticalGender gender, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).Convert(number, gender); + /// + /// For locales that support gender-specific forms + /// + /// + /// Russian: + /// + /// 1.ToWords(GrammaticalGender.Masculine) -> "один" + /// 1.ToWords(GrammaticalGender.Feminine) -> "одна" + /// + /// Hebrew: + /// + /// 1.ToWords(GrammaticalGender.Masculine) -> "אחד" + /// 1.ToWords(GrammaticalGender.Feminine) -> "אחת" + /// + /// + /// + /// Number to be turned to words + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + public static string ToWords(this long number, GrammaticalGender gender, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).Convert(number, gender); - /// - /// Converts a number to words supporting specific word variations, including grammatical gender, of some locales. - /// - /// - /// In Spanish, numbers ended in 1 changes its form depending on their position in the sentence. - /// - /// 21.ToWords(WordForm.Normal, GrammaticalGender.Masculine) -> veintiuno // as in "Mi número favorito es el veintiuno". - /// 21.ToWords(WordForm.Abbreviation, GrammaticalGender.Masculine) -> veintiún // as in "En total, conté veintiún coches" - /// 21.ToWords(WordForm.Normal, GrammaticalGender.Feminine) -> veintiuna // as in "veintiuna personas" - /// - /// - /// Number to be turned to words - /// Form of the word, i.e. abbreviation - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - /// The number converted to words - public static string ToWords(this long number, WordForm wordForm, GrammaticalGender gender, CultureInfo? culture = null) => - Configurator.GetNumberToWordsConverter(culture).Convert(number, wordForm, gender); - } -} + /// + /// Converts a number to words supporting specific word variations, including grammatical gender, of some locales. + /// + /// + /// In Spanish, numbers ended in 1 changes its form depending on their position in the sentence. + /// + /// 21.ToWords(WordForm.Normal, GrammaticalGender.Masculine) -> veintiuno // as in "Mi número favorito es el veintiuno". + /// 21.ToWords(WordForm.Abbreviation, GrammaticalGender.Masculine) -> veintiún // as in "En total, conté veintiún coches" + /// 21.ToWords(WordForm.Normal, GrammaticalGender.Feminine) -> veintiuna // as in "veintiuna personas" + /// + /// + /// Number to be turned to words + /// Form of the word, i.e. abbreviation + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + /// The number converted to words + public static string ToWords(this long number, WordForm wordForm, GrammaticalGender gender, CultureInfo? culture = null) => + Configurator.GetNumberToWordsConverter(culture).Convert(number, wordForm, gender); +} \ No newline at end of file diff --git a/src/Humanizer/OnNoMatch.cs b/src/Humanizer/OnNoMatch.cs index 3406e7ce2..49521b7da 100644 --- a/src/Humanizer/OnNoMatch.cs +++ b/src/Humanizer/OnNoMatch.cs @@ -1,18 +1,17 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Dictating what should be done when a match is not found - currently used only for DehumanizeTo +/// +public enum OnNoMatch { /// - /// Dictating what should be done when a match is not found - currently used only for DehumanizeTo + /// This is the default behavior which throws a NoMatchFoundException /// - public enum OnNoMatch - { - /// - /// This is the default behavior which throws a NoMatchFoundException - /// - ThrowsException, + ThrowsException, - /// - /// If set to ReturnsNull the method returns null instead of throwing an exception - /// - ReturnsNull - } + /// + /// If set to ReturnsNull the method returns null instead of throwing an exception + /// + ReturnsNull } \ No newline at end of file diff --git a/src/Humanizer/OrdinalizeExtensions.cs b/src/Humanizer/OrdinalizeExtensions.cs index 2655e5a65..5f3eb59bb 100644 --- a/src/Humanizer/OrdinalizeExtensions.cs +++ b/src/Humanizer/OrdinalizeExtensions.cs @@ -1,228 +1,227 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Ordinalize extensions +/// +public static class OrdinalizeExtensions { /// - /// Ordinalize extensions - /// - public static class OrdinalizeExtensions - { - /// - /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// - /// The number, in string, to be ordinalized - public static string Ordinalize(this string numberString) => - Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. - /// - /// - /// In Spanish: - /// - /// "1".Ordinalize(WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// "1".Ordinalize(WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// - /// - /// The number, in string, to be ordinalized - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this string numberString, WordForm wordForm) => - Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, wordForm); - - /// - /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// - /// The number, in string, to be ordinalized - /// Culture to use. If null, current thread's UI culture is used. - public static string Ordinalize(this string numberString, CultureInfo culture) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. - /// - /// - /// In Spanish: - /// - /// "1".Ordinalize(new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// "1".Ordinalize(new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// - /// - /// The number to be ordinalized - /// Culture to use. If null, current thread's UI culture is used. - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this string numberString, CultureInfo culture, WordForm wordForm) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, wordForm); - - /// - /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// Gender for Brazilian Portuguese locale - /// "1".Ordinalize(GrammaticalGender.Masculine) -> "1º" - /// "1".Ordinalize(GrammaticalGender.Feminine) -> "1ª" - /// - /// The number, in string, to be ordinalized - /// The grammatical gender to use for output words - public static string Ordinalize(this string numberString, GrammaticalGender gender) => - Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, gender); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific - /// locale's variations using the grammatical gender provided - /// - /// - /// In Spanish: - /// - /// "1".Ordinalize(GrammaticalGender.Masculine, WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// "1".Ordinalize(GrammaticalGender.Masculine, WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// "1".Ordinalize(GrammaticalGender.Feminine, WordForm.Normal) -> 1.ª // As in "Es 1ª vez que hago esto" - /// - /// - /// The number to be ordinalized - /// The grammatical gender to use for output words - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this string numberString, GrammaticalGender gender, WordForm wordForm) => - Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, gender, wordForm); - - /// - /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// Gender for Brazilian Portuguese locale - /// "1".Ordinalize(GrammaticalGender.Masculine) -> "1º" - /// "1".Ordinalize(GrammaticalGender.Feminine) -> "1ª" - /// - /// The number, in string, to be ordinalized - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - public static string Ordinalize(this string numberString, GrammaticalGender gender, CultureInfo culture) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, gender); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific - /// locale's variations using the grammatical gender provided - /// - /// - /// In Spanish: - /// - /// "1".Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// "1".Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// "1".Ordinalize(GrammaticalGender.Feminine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// - /// - /// The number to be ordinalized - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this string numberString, GrammaticalGender gender, CultureInfo culture, WordForm wordForm) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, gender, wordForm); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// - /// The number to be ordinalized - public static string Ordinalize(this int number) => - Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture)); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. - /// - /// - /// In Spanish: - /// - /// 1.Ordinalize(WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// 1.Ordinalize(WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// - /// - /// The number to be ordinalized - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this int number, WordForm wordForm) => - Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), wordForm); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// - /// The number to be ordinalized - /// Culture to use. If null, current thread's UI culture is used. - public static string Ordinalize(this int number, CultureInfo culture) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture)); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. - /// - /// - /// In Spanish: - /// - /// 1.Ordinalize(new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// 1.Ordinalize(new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// - /// - /// The number to be ordinalized - /// Culture to use. If null, current thread's UI culture is used. - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this int number, CultureInfo culture, WordForm wordForm) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), wordForm); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// Gender for Brazilian Portuguese locale - /// 1.Ordinalize(GrammaticalGender.Masculine) -> "1º" - /// 1.Ordinalize(GrammaticalGender.Feminine) -> "1ª" - /// - /// The number to be ordinalized - /// The grammatical gender to use for output words - public static string Ordinalize(this int number, GrammaticalGender gender) => - Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific - /// locale's variations using the grammatical gender provided - /// - /// - /// In Spanish: - /// - /// 1.Ordinalize(GrammaticalGender.Masculine, WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// 1.Ordinalize(GrammaticalGender.Masculine, WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// 1.Ordinalize(GrammaticalGender.Feminine, WordForm.Normal) -> 1.ª // As in "Es 1ª vez que hago esto" - /// - /// - /// The number to be ordinalized - /// The grammatical gender to use for output words - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this int number, GrammaticalGender gender, WordForm wordForm) => - Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender, wordForm); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. - /// Gender for Brazilian Portuguese locale - /// 1.Ordinalize(GrammaticalGender.Masculine) -> "1º" - /// 1.Ordinalize(GrammaticalGender.Feminine) -> "1ª" - /// - /// The number to be ordinalized - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - public static string Ordinalize(this int number, GrammaticalGender gender, CultureInfo culture) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), gender); - - /// - /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific - /// locale's variations using the grammatical gender provided - /// - /// - /// In Spanish: - /// - /// 1.Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" - /// 1.Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// 1.Ordinalize(GrammaticalGender.Feminine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" - /// - /// - /// The number to be ordinalized - /// The grammatical gender to use for output words - /// Culture to use. If null, current thread's UI culture is used. - /// Form of the word, i.e. abbreviation - /// The number ordinalized - public static string Ordinalize(this int number, GrammaticalGender gender, CultureInfo culture, WordForm wordForm) => - Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), gender, wordForm); - } -} + /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// + /// The number, in string, to be ordinalized + public static string Ordinalize(this string numberString) => + Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. + /// + /// + /// In Spanish: + /// + /// "1".Ordinalize(WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// "1".Ordinalize(WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// + /// + /// The number, in string, to be ordinalized + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this string numberString, WordForm wordForm) => + Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, wordForm); + + /// + /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// + /// The number, in string, to be ordinalized + /// Culture to use. If null, current thread's UI culture is used. + public static string Ordinalize(this string numberString, CultureInfo culture) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. + /// + /// + /// In Spanish: + /// + /// "1".Ordinalize(new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// "1".Ordinalize(new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// + /// + /// The number to be ordinalized + /// Culture to use. If null, current thread's UI culture is used. + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this string numberString, CultureInfo culture, WordForm wordForm) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, wordForm); + + /// + /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// Gender for Brazilian Portuguese locale + /// "1".Ordinalize(GrammaticalGender.Masculine) -> "1º" + /// "1".Ordinalize(GrammaticalGender.Feminine) -> "1ª" + /// + /// The number, in string, to be ordinalized + /// The grammatical gender to use for output words + public static string Ordinalize(this string numberString, GrammaticalGender gender) => + Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, gender); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific + /// locale's variations using the grammatical gender provided + /// + /// + /// In Spanish: + /// + /// "1".Ordinalize(GrammaticalGender.Masculine, WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// "1".Ordinalize(GrammaticalGender.Masculine, WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// "1".Ordinalize(GrammaticalGender.Feminine, WordForm.Normal) -> 1.ª // As in "Es 1ª vez que hago esto" + /// + /// + /// The number to be ordinalized + /// The grammatical gender to use for output words + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this string numberString, GrammaticalGender gender, WordForm wordForm) => + Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, gender, wordForm); + + /// + /// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// Gender for Brazilian Portuguese locale + /// "1".Ordinalize(GrammaticalGender.Masculine) -> "1º" + /// "1".Ordinalize(GrammaticalGender.Feminine) -> "1ª" + /// + /// The number, in string, to be ordinalized + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + public static string Ordinalize(this string numberString, GrammaticalGender gender, CultureInfo culture) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, gender); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific + /// locale's variations using the grammatical gender provided + /// + /// + /// In Spanish: + /// + /// "1".Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// "1".Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// "1".Ordinalize(GrammaticalGender.Feminine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// + /// + /// The number to be ordinalized + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this string numberString, GrammaticalGender gender, CultureInfo culture, WordForm wordForm) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, gender, wordForm); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// + /// The number to be ordinalized + public static string Ordinalize(this int number) => + Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture)); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. + /// + /// + /// In Spanish: + /// + /// 1.Ordinalize(WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// 1.Ordinalize(WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// + /// + /// The number to be ordinalized + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this int number, WordForm wordForm) => + Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), wordForm); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// + /// The number to be ordinalized + /// Culture to use. If null, current thread's UI culture is used. + public static string Ordinalize(this int number, CultureInfo culture) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture)); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific locale's variations. + /// + /// + /// In Spanish: + /// + /// 1.Ordinalize(new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// 1.Ordinalize(new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// + /// + /// The number to be ordinalized + /// Culture to use. If null, current thread's UI culture is used. + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this int number, CultureInfo culture, WordForm wordForm) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), wordForm); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// Gender for Brazilian Portuguese locale + /// 1.Ordinalize(GrammaticalGender.Masculine) -> "1º" + /// 1.Ordinalize(GrammaticalGender.Feminine) -> "1ª" + /// + /// The number to be ordinalized + /// The grammatical gender to use for output words + public static string Ordinalize(this int number, GrammaticalGender gender) => + Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific + /// locale's variations using the grammatical gender provided + /// + /// + /// In Spanish: + /// + /// 1.Ordinalize(GrammaticalGender.Masculine, WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// 1.Ordinalize(GrammaticalGender.Masculine, WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// 1.Ordinalize(GrammaticalGender.Feminine, WordForm.Normal) -> 1.ª // As in "Es 1ª vez que hago esto" + /// + /// + /// The number to be ordinalized + /// The grammatical gender to use for output words + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this int number, GrammaticalGender gender, WordForm wordForm) => + Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender, wordForm); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. + /// Gender for Brazilian Portuguese locale + /// 1.Ordinalize(GrammaticalGender.Masculine) -> "1º" + /// 1.Ordinalize(GrammaticalGender.Feminine) -> "1ª" + /// + /// The number to be ordinalized + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + public static string Ordinalize(this int number, GrammaticalGender gender, CultureInfo culture) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), gender); + + /// + /// Turns a number into an ordinal number used to denote the position in an ordered sequence supporting specific + /// locale's variations using the grammatical gender provided + /// + /// + /// In Spanish: + /// + /// 1.Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"),WordForm.Abbreviation) -> 1.er // As in "Vivo en el 1.er piso" + /// 1.Ordinalize(GrammaticalGender.Masculine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// 1.Ordinalize(GrammaticalGender.Feminine, new CultureInfo("es-ES"), WordForm.Normal) -> 1.º // As in "Fui el 1º de mi promoción" + /// + /// + /// The number to be ordinalized + /// The grammatical gender to use for output words + /// Culture to use. If null, current thread's UI culture is used. + /// Form of the word, i.e. abbreviation + /// The number ordinalized + public static string Ordinalize(this int number, GrammaticalGender gender, CultureInfo culture, WordForm wordForm) => + Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), gender, wordForm); +} \ No newline at end of file diff --git a/src/Humanizer/Plurality.cs b/src/Humanizer/Plurality.cs index 81f07bc4a..63a8dbec8 100644 --- a/src/Humanizer/Plurality.cs +++ b/src/Humanizer/Plurality.cs @@ -1,21 +1,20 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Provides hint for Humanizer as to whether a word is singular, plural or with unknown plurality +/// +public enum Plurality { /// - /// Provides hint for Humanizer as to whether a word is singular, plural or with unknown plurality + /// The word is singular /// - public enum Plurality - { - /// - /// The word is singular - /// - Singular, - /// - /// The word is plural - /// - Plural, - /// - /// I am unsure of the plurality - /// - CouldBeEither - } + Singular, + /// + /// The word is plural + /// + Plural, + /// + /// I am unsure of the plurality + /// + CouldBeEither } \ No newline at end of file diff --git a/src/Humanizer/RomanNumeralExtensions.cs b/src/Humanizer/RomanNumeralExtensions.cs index 306af6bc0..89bd974d9 100644 --- a/src/Humanizer/RomanNumeralExtensions.cs +++ b/src/Humanizer/RomanNumeralExtensions.cs @@ -1,44 +1,44 @@ // Done by Jesse Slicer https://github.com/jslicer -namespace Humanizer +namespace Humanizer; + +/// +/// Contains extension methods for changing a number to Roman representation (ToRoman) and from Roman representation back to the number (FromRoman) +/// +public static class RomanNumeralExtensions { + const int NumberOfRomanNumeralMaps = 13; + + static readonly IDictionary RomanNumerals = + new Dictionary(NumberOfRomanNumeralMaps) + { + { "M", 1000 }, + { "CM", 900 }, + { "D", 500 }, + { "CD", 400 }, + { "C", 100 }, + { "XC", 90 }, + { "L", 50 }, + { "XL", 40 }, + { "X", 10 }, + { "IX", 9 }, + { "V", 5 }, + { "IV", 4 }, + { "I", 1 } + }; + + static readonly Regex ValidRomanNumeral = + new( + "^(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))$", + RegexOptions.Compiled); + /// - /// Contains extension methods for changing a number to Roman representation (ToRoman) and from Roman representation back to the number (FromRoman) + /// Converts Roman numbers into integer /// - public static class RomanNumeralExtensions + /// Roman number + /// Human-readable number + public static int FromRoman(this string input) { - const int NumberOfRomanNumeralMaps = 13; - - static readonly IDictionary RomanNumerals = - new Dictionary(NumberOfRomanNumeralMaps) - { - { "M", 1000 }, - { "CM", 900 }, - { "D", 500 }, - { "CD", 400 }, - { "C", 100 }, - { "XC", 90 }, - { "L", 50 }, - { "XL", 40 }, - { "X", 10 }, - { "IX", 9 }, - { "V", 5 }, - { "IV", 4 }, - { "I", 1 } - }; - - static readonly Regex ValidRomanNumeral = - new( - "^(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))$", - RegexOptions.Compiled); - - /// - /// Converts Roman numbers into integer - /// - /// Roman number - /// Human-readable number - public static int FromRoman(this string input) - { if (input == null) { throw new ArgumentNullException(nameof(input)); @@ -77,14 +77,14 @@ public static int FromRoman(this string input) return total; } - /// - /// Converts the input to Roman number - /// - /// Integer input - /// Roman number - /// Thrown when the input is smaller than 1 or larger than 3999 - public static string ToRoman(this int input) - { + /// + /// Converts the input to Roman number + /// + /// Integer input + /// Roman number + /// Thrown when the input is smaller than 1 or larger than 3999 + public static string ToRoman(this int input) + { const int minValue = 1; const int maxValue = 3999; const int maxRomanNumeralLength = 15; @@ -108,7 +108,6 @@ public static string ToRoman(this int input) return sb.ToString(); } - static bool IsInvalidRomanNumeral(string input) => - !ValidRomanNumeral.IsMatch(input); - } + static bool IsInvalidRomanNumeral(string input) => + !ValidRomanNumeral.IsMatch(input); } \ No newline at end of file diff --git a/src/Humanizer/StringDehumanizeExtensions.cs b/src/Humanizer/StringDehumanizeExtensions.cs index c5242a92d..853d9f8be 100644 --- a/src/Humanizer/StringDehumanizeExtensions.cs +++ b/src/Humanizer/StringDehumanizeExtensions.cs @@ -1,19 +1,18 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Contains extension methods for dehumanizing strings. +/// +public static class StringDehumanizeExtensions { /// - /// Contains extension methods for dehumanizing strings. + /// Dehumanizes a string; e.g. 'some string', 'Some String', 'Some string' -> 'SomeString' + /// If a string is already dehumanized then it leaves it alone 'SomeStringAndAnotherString' -> 'SomeStringAndAnotherString' /// - public static class StringDehumanizeExtensions + /// The string to be dehumanized + public static string Dehumanize(this string input) { - /// - /// Dehumanizes a string; e.g. 'some string', 'Some String', 'Some string' -> 'SomeString' - /// If a string is already dehumanized then it leaves it alone 'SomeStringAndAnotherString' -> 'SomeStringAndAnotherString' - /// - /// The string to be dehumanized - public static string Dehumanize(this string input) - { var pascalizedWords = input.Split(' ').Select(word => word.Humanize().Pascalize()); return string.Concat(pascalizedWords).Replace(" ", ""); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/StringHumanizeExtensions.cs b/src/Humanizer/StringHumanizeExtensions.cs index 4e09bb33e..1e6d2baa5 100644 --- a/src/Humanizer/StringHumanizeExtensions.cs +++ b/src/Humanizer/StringHumanizeExtensions.cs @@ -1,32 +1,32 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Contains extension methods for humanizing string values. +/// +public static class StringHumanizeExtensions { - /// - /// Contains extension methods for humanizing string values. - /// - public static class StringHumanizeExtensions - { - static readonly Regex PascalCaseWordPartsRegex; - static readonly Regex FreestandingSpacingCharRegex; + static readonly Regex PascalCaseWordPartsRegex; + static readonly Regex FreestandingSpacingCharRegex; - const string OptionallyCapitalizedWord = @"\p{Lu}?\p{Ll}+"; - const string IntegerAndOptionalLowercaseLetters = @"[0-9]+\p{Ll}*"; - const string Acronym = @"\p{Lu}+(?=\p{Lu}|[0-9]|\b)"; - const string SequenceOfOtherLetters = @"\p{Lo}+"; - const string MidSentencePunctuation = "[,;]?"; + const string OptionallyCapitalizedWord = @"\p{Lu}?\p{Ll}+"; + const string IntegerAndOptionalLowercaseLetters = @"[0-9]+\p{Ll}*"; + const string Acronym = @"\p{Lu}+(?=\p{Lu}|[0-9]|\b)"; + const string SequenceOfOtherLetters = @"\p{Lo}+"; + const string MidSentencePunctuation = "[,;]?"; - static StringHumanizeExtensions() - { + static StringHumanizeExtensions() + { PascalCaseWordPartsRegex = new( $"({OptionallyCapitalizedWord}|{IntegerAndOptionalLowercaseLetters}|{Acronym}|{SequenceOfOtherLetters}){MidSentencePunctuation}", RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture | RegexOptions.Compiled); FreestandingSpacingCharRegex = new(@"\s[-_]|[-_]\s", RegexOptions.Compiled); } - static string FromUnderscoreDashSeparatedWords(string input) => - string.Join(" ", input.Split(['_', '-'])); + static string FromUnderscoreDashSeparatedWords(string input) => + string.Join(" ", input.Split(['_', '-'])); - static string FromPascalCase(string input) - { + static string FromPascalCase(string input) + { var result = string.Join(" ", PascalCaseWordPartsRegex .Matches(input).Cast() .Select(match => @@ -48,12 +48,12 @@ static string FromPascalCase(string input) result.Substring(1, result.Length - 1) : result; } - /// - /// Humanizes the input string; e.g. Underscored_input_String_is_turned_INTO_sentence -> 'Underscored input String is turned INTO sentence' - /// - /// The string to be humanized - public static string Humanize(this string input) - { + /// + /// Humanizes the input string; e.g. Underscored_input_String_is_turned_INTO_sentence -> 'Underscored input String is turned INTO sentence' + /// + /// The string to be humanized + public static string Humanize(this string input) + { // if input is all capitals (e.g. an acronym) then return it without change if (input.All(char.IsUpper)) { @@ -75,12 +75,11 @@ public static string Humanize(this string input) return FromPascalCase(input); } - /// - /// Humanized the input string based on the provided casing - /// - /// The string to be humanized - /// The desired casing for the output - public static string Humanize(this string input, LetterCasing casing) => - input.Humanize().ApplyCase(casing); - } -} + /// + /// Humanized the input string based on the provided casing + /// + /// The string to be humanized + /// The desired casing for the output + public static string Humanize(this string input, LetterCasing casing) => + input.Humanize().ApplyCase(casing); +} \ No newline at end of file diff --git a/src/Humanizer/TimeSpanHumanizeExtensions.cs b/src/Humanizer/TimeSpanHumanizeExtensions.cs index bf8807bc1..d0ae8244c 100644 --- a/src/Humanizer/TimeSpanHumanizeExtensions.cs +++ b/src/Humanizer/TimeSpanHumanizeExtensions.cs @@ -1,67 +1,67 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Humanizes TimeSpan into human readable form +/// +public static class TimeSpanHumanizeExtensions { + const int _daysInAWeek = 7; + const double _daysInAYear = 365.2425; // see https://en.wikipedia.org/wiki/Gregorian_calendar + const double _daysInAMonth = _daysInAYear / 12; + + static TimeUnit[] _timeUnits = Enum.GetValues(typeof(TimeUnit)) + .Cast() + .Reverse() + .ToArray(); + /// - /// Humanizes TimeSpan into human readable form + /// Turns a TimeSpan into a human readable form. E.g. 1 day. /// - public static class TimeSpanHumanizeExtensions + /// The maximum number of time units to return. Defaulted is 1 which means the largest unit is returned + /// Culture to use. If null, current thread's UI culture is used. + /// The maximum unit of time to output. The default value is . The time units and will give approximations for time spans bigger 30 days by calculating with 365.2425 days a year and 30.4369 days a month. + /// The minimum unit of time to output. + /// The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used. + /// Uses words instead of numbers if true. E.g. one day. + public static string Humanize(this TimeSpan timeSpan, int precision = 1, CultureInfo? culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string? collectionSeparator = ", ", bool toWords = false) => + Humanize(timeSpan, precision, false, culture, maxUnit, minUnit, collectionSeparator, toWords); + + /// + /// Turns a TimeSpan into a human readable form. E.g. 1 day. + /// + /// The maximum number of time units to return. + /// Controls whether empty time units should be counted towards maximum number of time units. Leading empty time units never count. + /// Culture to use. If null, current thread's UI culture is used. + /// The maximum unit of time to output. The default value is . The time units and will give approximations for time spans bigger than 30 days by calculating with 365.2425 days a year and 30.4369 days a month. + /// The minimum unit of time to output. + /// The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used. + /// Uses words instead of numbers if true. E.g. one day. + public static string Humanize(this TimeSpan timeSpan, int precision, bool countEmptyUnits, CultureInfo? culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string? collectionSeparator = ", ", bool toWords = false) { - const int _daysInAWeek = 7; - const double _daysInAYear = 365.2425; // see https://en.wikipedia.org/wiki/Gregorian_calendar - const double _daysInAMonth = _daysInAYear / 12; - - static TimeUnit[] _timeUnits = Enum.GetValues(typeof(TimeUnit)) - .Cast() - .Reverse() - .ToArray(); - - /// - /// Turns a TimeSpan into a human readable form. E.g. 1 day. - /// - /// The maximum number of time units to return. Defaulted is 1 which means the largest unit is returned - /// Culture to use. If null, current thread's UI culture is used. - /// The maximum unit of time to output. The default value is . The time units and will give approximations for time spans bigger 30 days by calculating with 365.2425 days a year and 30.4369 days a month. - /// The minimum unit of time to output. - /// The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used. - /// Uses words instead of numbers if true. E.g. one day. - public static string Humanize(this TimeSpan timeSpan, int precision = 1, CultureInfo? culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string? collectionSeparator = ", ", bool toWords = false) => - Humanize(timeSpan, precision, false, culture, maxUnit, minUnit, collectionSeparator, toWords); - - /// - /// Turns a TimeSpan into a human readable form. E.g. 1 day. - /// - /// The maximum number of time units to return. - /// Controls whether empty time units should be counted towards maximum number of time units. Leading empty time units never count. - /// Culture to use. If null, current thread's UI culture is used. - /// The maximum unit of time to output. The default value is . The time units and will give approximations for time spans bigger than 30 days by calculating with 365.2425 days a year and 30.4369 days a month. - /// The minimum unit of time to output. - /// The separator to use when combining humanized time parts. If null, the default collection formatter for the current culture is used. - /// Uses words instead of numbers if true. E.g. one day. - public static string Humanize(this TimeSpan timeSpan, int precision, bool countEmptyUnits, CultureInfo? culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string? collectionSeparator = ", ", bool toWords = false) - { var timeParts = CreateTheTimePartsWithUpperAndLowerLimits(timeSpan, culture, maxUnit, minUnit, toWords); timeParts = SetPrecisionOfTimeSpan(timeParts, precision, countEmptyUnits); return ConcatenateTimeSpanParts(timeParts, culture, collectionSeparator); } - /// - /// Turns a TimeSpan into an age expression, e.g. "40 years old" - /// - /// Elapsed time - /// Culture to use. If null, current thread's UI culture is used. - /// The maximum unit of time to output. The default value is . - /// Uses words instead of numbers if true. E.g. "forty years old". - /// Age expression in the given culture/language - public static string ToAge(this TimeSpan timeSpan, CultureInfo? culture = null, TimeUnit maxUnit = TimeUnit.Year, bool toWords = false) - { + /// + /// Turns a TimeSpan into an age expression, e.g. "40 years old" + /// + /// Elapsed time + /// Culture to use. If null, current thread's UI culture is used. + /// The maximum unit of time to output. The default value is . + /// Uses words instead of numbers if true. E.g. "forty years old". + /// Age expression in the given culture/language + public static string ToAge(this TimeSpan timeSpan, CultureInfo? culture = null, TimeUnit maxUnit = TimeUnit.Year, bool toWords = false) + { var timeSpanExpression = timeSpan.Humanize(culture: culture, maxUnit: maxUnit, toWords: toWords); var cultureFormatter = Configurator.GetFormatter(culture); return string.Format(cultureFormatter.TimeSpanHumanize_Age(), timeSpanExpression); } - static IEnumerable CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan timespan, CultureInfo? culture, TimeUnit maxUnit, TimeUnit minUnit, bool toWords = false) - { + static IEnumerable CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan timespan, CultureInfo? culture, TimeUnit maxUnit, TimeUnit minUnit, bool toWords = false) + { var cultureFormatter = Configurator.GetFormatter(culture); var firstValueFound = false; var timeParts = new List(); @@ -85,8 +85,8 @@ public static string ToAge(this TimeSpan timeSpan, CultureInfo? culture = null, return timeParts; } - static string? GetTimeUnitPart(TimeUnit timeUnitToGet, TimeSpan timespan, TimeUnit maximumTimeUnit, TimeUnit minimumTimeUnit, IFormatter cultureFormatter, bool toWords = false) - { + static string? GetTimeUnitPart(TimeUnit timeUnitToGet, TimeSpan timespan, TimeUnit maximumTimeUnit, TimeUnit minimumTimeUnit, IFormatter cultureFormatter, bool toWords = false) + { if (timeUnitToGet <= maximumTimeUnit && timeUnitToGet >= minimumTimeUnit) { var numberOfTimeUnits = GetTimeUnitNumericalValue(timeUnitToGet, timespan, maximumTimeUnit); @@ -95,8 +95,8 @@ public static string ToAge(this TimeSpan timeSpan, CultureInfo? culture = null, return null; } - static int GetTimeUnitNumericalValue(TimeUnit timeUnitToGet, TimeSpan timespan, TimeUnit maximumTimeUnit) - { + static int GetTimeUnitNumericalValue(TimeUnit timeUnitToGet, TimeSpan timespan, TimeUnit maximumTimeUnit) + { var isTimeUnitToGetTheMaximumTimeUnit = timeUnitToGet == maximumTimeUnit; switch (timeUnitToGet) { @@ -121,8 +121,8 @@ static int GetTimeUnitNumericalValue(TimeUnit timeUnitToGet, TimeSpan timespan, } } - static int GetSpecialCaseMonthAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) - { + static int GetSpecialCaseMonthAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) + { if (isTimeUnitToGetTheMaximumTimeUnit) { return (int)(timespan.Days / _daysInAMonth); @@ -132,11 +132,11 @@ static int GetSpecialCaseMonthAsInteger(TimeSpan timespan, bool isTimeUnitToGetT return (int)(remainingDays / _daysInAMonth); } - static int GetSpecialCaseYearAsInteger(TimeSpan timespan) => - (int)(timespan.Days / _daysInAYear); + static int GetSpecialCaseYearAsInteger(TimeSpan timespan) => + (int)(timespan.Days / _daysInAYear); - static int GetSpecialCaseWeeksAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) - { + static int GetSpecialCaseWeeksAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) + { if (isTimeUnitToGetTheMaximumTimeUnit || timespan.Days < _daysInAMonth) { return timespan.Days / _daysInAWeek; @@ -144,8 +144,8 @@ static int GetSpecialCaseWeeksAsInteger(TimeSpan timespan, bool isTimeUnitToGetT return 0; } - static int GetSpecialCaseDaysAsInteger(TimeSpan timespan, TimeUnit maximumTimeUnit) - { + static int GetSpecialCaseDaysAsInteger(TimeSpan timespan, TimeUnit maximumTimeUnit) + { if (maximumTimeUnit == TimeUnit.Day) { return timespan.Days; @@ -158,8 +158,8 @@ static int GetSpecialCaseDaysAsInteger(TimeSpan timespan, TimeUnit maximumTimeUn return (int)(timespan.Days % _daysInAMonth); } - static int GetNormalCaseTimeAsInteger(int timeNumberOfUnits, double totalTimeNumberOfUnits, bool isTimeUnitToGetTheMaximumTimeUnit) - { + static int GetNormalCaseTimeAsInteger(int timeNumberOfUnits, double totalTimeNumberOfUnits, bool isTimeUnitToGetTheMaximumTimeUnit) + { if (isTimeUnitToGetTheMaximumTimeUnit) { try @@ -175,20 +175,20 @@ static int GetNormalCaseTimeAsInteger(int timeNumberOfUnits, double totalTimeNum return timeNumberOfUnits; } - static string? BuildFormatTimePart(IFormatter cultureFormatter, TimeUnit timeUnitType, int amountOfTimeUnits, bool toWords = false) => - // Always use positive units to account for negative timespans - amountOfTimeUnits != 0 - ? cultureFormatter.TimeSpanHumanize(timeUnitType, Math.Abs(amountOfTimeUnits), toWords) - : null; + static string? BuildFormatTimePart(IFormatter cultureFormatter, TimeUnit timeUnitType, int amountOfTimeUnits, bool toWords = false) => + // Always use positive units to account for negative timespans + amountOfTimeUnits != 0 + ? cultureFormatter.TimeSpanHumanize(timeUnitType, Math.Abs(amountOfTimeUnits), toWords) + : null; - static List CreateTimePartsWithNoTimeValue(string noTimeValue) => - [noTimeValue]; + static List CreateTimePartsWithNoTimeValue(string noTimeValue) => + [noTimeValue]; - static bool IsContainingOnlyNullValue(IEnumerable timeParts) => - timeParts.Count(x => x != null) == 0; + static bool IsContainingOnlyNullValue(IEnumerable timeParts) => + timeParts.Count(x => x != null) == 0; - static IEnumerable SetPrecisionOfTimeSpan(IEnumerable timeParts, int precision, bool countEmptyUnits) - { + static IEnumerable SetPrecisionOfTimeSpan(IEnumerable timeParts, int precision, bool countEmptyUnits) + { if (!countEmptyUnits) { timeParts = timeParts.Where(x => x != null); @@ -203,8 +203,8 @@ static bool IsContainingOnlyNullValue(IEnumerable timeParts) => return timeParts; } - static string ConcatenateTimeSpanParts(IEnumerable timeSpanParts, CultureInfo? culture, string? collectionSeparator) - { + static string ConcatenateTimeSpanParts(IEnumerable timeSpanParts, CultureInfo? culture, string? collectionSeparator) + { if (collectionSeparator == null) { return Configurator.CollectionFormatters.ResolveForCulture(culture).Humanize(timeSpanParts); @@ -212,5 +212,4 @@ static string ConcatenateTimeSpanParts(IEnumerable timeSpanParts, Cultu return string.Join(collectionSeparator, timeSpanParts); } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/TimeUnitToSymbolExtensions.cs b/src/Humanizer/TimeUnitToSymbolExtensions.cs index 6657436cf..de27305ab 100644 --- a/src/Humanizer/TimeUnitToSymbolExtensions.cs +++ b/src/Humanizer/TimeUnitToSymbolExtensions.cs @@ -1,16 +1,15 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Transform a time unit into a symbol; e.g. => "a" +/// +public static class TimeUnitToSymbolExtensions { /// - /// Transform a time unit into a symbol; e.g. => "a" + /// TimeUnit.Day.ToSymbol() -> "d" /// - public static class TimeUnitToSymbolExtensions - { - /// - /// TimeUnit.Day.ToSymbol() -> "d" - /// - /// Unit of time to be turned to a symbol - /// Culture to use. If null, current thread's UI culture is used. - public static string ToSymbol(this TimeUnit unit, CultureInfo? culture = null) => - Configurator.GetFormatter(culture).TimeUnitHumanize(unit); - } -} + /// Unit of time to be turned to a symbol + /// Culture to use. If null, current thread's UI culture is used. + public static string ToSymbol(this TimeUnit unit, CultureInfo? culture = null) => + Configurator.GetFormatter(culture).TimeUnitHumanize(unit); +} \ No newline at end of file diff --git a/src/Humanizer/ToQuantityExtensions.cs b/src/Humanizer/ToQuantityExtensions.cs index 14637b484..11680a6a6 100644 --- a/src/Humanizer/ToQuantityExtensions.cs +++ b/src/Humanizer/ToQuantityExtensions.cs @@ -1,67 +1,67 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Enumerates the ways of displaying a quantity value when converting +/// a word to a quantity string. +/// +public enum ShowQuantityAs { /// - /// Enumerates the ways of displaying a quantity value when converting - /// a word to a quantity string. + /// Indicates that no quantity will be included in the formatted string. /// - public enum ShowQuantityAs - { - /// - /// Indicates that no quantity will be included in the formatted string. - /// - None = 0, + None = 0, - /// - /// Indicates that the quantity will be included in the output, formatted - /// as its numeric value (e.g. "1"). - /// - Numeric, + /// + /// Indicates that the quantity will be included in the output, formatted + /// as its numeric value (e.g. "1"). + /// + Numeric, - /// - /// Incidates that the quantity will be included in the output, formatted as - /// words (e.g. 123 => "one hundred and twenty three"). - /// - Words - } + /// + /// Incidates that the quantity will be included in the output, formatted as + /// words (e.g. 123 => "one hundred and twenty three"). + /// + Words +} +/// +/// Provides extensions for formatting a word as a quantity. +/// +public static class ToQuantityExtensions +{ /// - /// Provides extensions for formatting a word as a quantity. + /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word /// - public static class ToQuantityExtensions - { - /// - /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word - /// - /// The word to be prefixed - /// The quantity of the word - /// How to show the quantity. Numeric by default - /// - /// "request".ToQuantity(0) => "0 requests" - /// "request".ToQuantity(1) => "1 request" - /// "request".ToQuantity(2) => "2 requests" - /// "men".ToQuantity(2) => "2 men" - /// "process".ToQuantity(1200, ShowQuantityAs.Words) => "one thousand two hundred processes" - /// - public static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric) => - input.ToQuantity(quantity, showQuantityAs, format: null, formatProvider: null); + /// The word to be prefixed + /// The quantity of the word + /// How to show the quantity. Numeric by default + /// + /// "request".ToQuantity(0) => "0 requests" + /// "request".ToQuantity(1) => "1 request" + /// "request".ToQuantity(2) => "2 requests" + /// "men".ToQuantity(2) => "2 men" + /// "process".ToQuantity(1200, ShowQuantityAs.Words) => "one thousand two hundred processes" + /// + public static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric) => + input.ToQuantity(quantity, showQuantityAs, format: null, formatProvider: null); - /// - /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word - /// - /// The word to be prefixed - /// The quantity of the word - /// A standard or custom numeric format string. - /// An object that supplies culture-specific formatting information. - /// - /// "request".ToQuantity(0) => "0 requests" - /// "request".ToQuantity(10000, format: "N0") => "10,000 requests" - /// "request".ToQuantity(1, format: "N0") => "1 request" - /// - public static string ToQuantity(this string input, long quantity, string? format, IFormatProvider? formatProvider = null) => - input.ToQuantity(quantity, showQuantityAs: ShowQuantityAs.Numeric, format: format, formatProvider: formatProvider); + /// + /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word + /// + /// The word to be prefixed + /// The quantity of the word + /// A standard or custom numeric format string. + /// An object that supplies culture-specific formatting information. + /// + /// "request".ToQuantity(0) => "0 requests" + /// "request".ToQuantity(10000, format: "N0") => "10,000 requests" + /// "request".ToQuantity(1, format: "N0") => "1 request" + /// + public static string ToQuantity(this string input, long quantity, string? format, IFormatProvider? formatProvider = null) => + input.ToQuantity(quantity, showQuantityAs: ShowQuantityAs.Numeric, format: format, formatProvider: formatProvider); - static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric, string? format = null, IFormatProvider? formatProvider = null) - { + static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric, string? format = null, IFormatProvider? formatProvider = null) + { var transformedInput = quantity == 1 ? input.Singularize(inputIsKnownToBePlural: false) : input.Pluralize(inputIsKnownToBeSingular: false); @@ -79,20 +79,20 @@ static string ToQuantity(this string input, long quantity, ShowQuantityAs showQu return $"{quantity.ToWords()} {transformedInput}"; } - /// - /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word - /// - /// The word to be prefixed - /// The quantity of the word - /// A standard or custom numeric format string. - /// An object that supplies culture-specific formatting information. - /// - /// "request".ToQuantity(0.2) => "0.2 requests" - /// "request".ToQuantity(10.6, format: "N0") => "10.6 requests" - /// "request".ToQuantity(1.0, format: "N0") => "1 request" - /// - public static string ToQuantity(this string input, double quantity, string? format = null, IFormatProvider? formatProvider = null) - { + /// + /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word + /// + /// The word to be prefixed + /// The quantity of the word + /// A standard or custom numeric format string. + /// An object that supplies culture-specific formatting information. + /// + /// "request".ToQuantity(0.2) => "0.2 requests" + /// "request".ToQuantity(10.6, format: "N0") => "10.6 requests" + /// "request".ToQuantity(1.0, format: "N0") => "1 request" + /// + public static string ToQuantity(this string input, double quantity, string? format = null, IFormatProvider? formatProvider = null) + { var transformedInput = quantity == 1 ? input.Singularize(inputIsKnownToBePlural: false) : input.Pluralize(inputIsKnownToBeSingular: false); @@ -100,15 +100,14 @@ public static string ToQuantity(this string input, double quantity, string? form return string.Format(formatProvider, "{0} {1}", quantity.ToString(format, formatProvider), transformedInput); } - /// - /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word - /// - /// The word to be prefixed - /// The quantity of the word - /// - /// "request".ToQuantity(0.2) => "0.2 requests" - /// - public static string ToQuantity(this string input, double quantity) => - ToQuantity(input, quantity, null, null); - } -} + /// + /// Prefixes the provided word with the number and accordingly pluralizes or singularizes the word + /// + /// The word to be prefixed + /// The quantity of the word + /// + /// "request".ToQuantity(0.2) => "0.2 requests" + /// + public static string ToQuantity(this string input, double quantity) => + ToQuantity(input, quantity, null, null); +} \ No newline at end of file diff --git a/src/Humanizer/Transformer/ICulturedStringTransformer.cs b/src/Humanizer/Transformer/ICulturedStringTransformer.cs index acfeba711..be27682ef 100644 --- a/src/Humanizer/Transformer/ICulturedStringTransformer.cs +++ b/src/Humanizer/Transformer/ICulturedStringTransformer.cs @@ -1,14 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Can transform a string with the given culture +/// +public interface ICulturedStringTransformer : IStringTransformer { /// - /// Can transform a string with the given culture + /// Transform the input /// - public interface ICulturedStringTransformer : IStringTransformer - { - /// - /// Transform the input - /// - /// String to be transformed - string Transform(string input, CultureInfo culture); - } -} + /// String to be transformed + string Transform(string input, CultureInfo culture); +} \ No newline at end of file diff --git a/src/Humanizer/Transformer/IStringTransformer.cs b/src/Humanizer/Transformer/IStringTransformer.cs index cbb893463..fb9594d1a 100644 --- a/src/Humanizer/Transformer/IStringTransformer.cs +++ b/src/Humanizer/Transformer/IStringTransformer.cs @@ -1,14 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Can transform a string +/// +public interface IStringTransformer { /// - /// Can transform a string + /// Transform the input /// - public interface IStringTransformer - { - /// - /// Transform the input - /// - /// String to be transformed - string Transform(string input); - } -} + /// String to be transformed + string Transform(string input); +} \ No newline at end of file diff --git a/src/Humanizer/Transformer/To.cs b/src/Humanizer/Transformer/To.cs index b5df34817..2ced01eba 100644 --- a/src/Humanizer/Transformer/To.cs +++ b/src/Humanizer/Transformer/To.cs @@ -1,52 +1,51 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// A portal to string transformation using IStringTransformer +/// +public static class To { /// - /// A portal to string transformation using IStringTransformer + /// Transforms a string using the provided transformers. Transformations are applied in the provided order. /// - public static class To - { - /// - /// Transforms a string using the provided transformers. Transformations are applied in the provided order. - /// - public static string Transform(this string input, params IStringTransformer[] transformers) => - transformers.Aggregate(input, (current, stringTransformer) => stringTransformer.Transform(current)); + public static string Transform(this string input, params IStringTransformer[] transformers) => + transformers.Aggregate(input, (current, stringTransformer) => stringTransformer.Transform(current)); - /// - /// Transforms a string using the provided transformers. Transformations are applied in the provided order. - /// - public static string Transform(this string input, CultureInfo culture, params ICulturedStringTransformer[] transformers) => - transformers.Aggregate(input, (current, stringTransformer) => stringTransformer.Transform(current, culture)); + /// + /// Transforms a string using the provided transformers. Transformations are applied in the provided order. + /// + public static string Transform(this string input, CultureInfo culture, params ICulturedStringTransformer[] transformers) => + transformers.Aggregate(input, (current, stringTransformer) => stringTransformer.Transform(current, culture)); - /// - /// Changes string to title case - /// - /// - /// "INvalid caSEs arE corrected" -> "Invalid Cases Are Corrected" - /// - public static ICulturedStringTransformer TitleCase { get; } = new ToTitleCase(); + /// + /// Changes string to title case + /// + /// + /// "INvalid caSEs arE corrected" -> "Invalid Cases Are Corrected" + /// + public static ICulturedStringTransformer TitleCase { get; } = new ToTitleCase(); - /// - /// Changes the string to lower case - /// - /// - /// "Sentence casing" -> "sentence casing" - /// - public static ICulturedStringTransformer LowerCase { get; } = new ToLowerCase(); + /// + /// Changes the string to lower case + /// + /// + /// "Sentence casing" -> "sentence casing" + /// + public static ICulturedStringTransformer LowerCase { get; } = new ToLowerCase(); - /// - /// Changes the string to upper case - /// - /// - /// "lower case statement" -> "LOWER CASE STATEMENT" - /// - public static ICulturedStringTransformer UpperCase { get; } = new ToUpperCase(); + /// + /// Changes the string to upper case + /// + /// + /// "lower case statement" -> "LOWER CASE STATEMENT" + /// + public static ICulturedStringTransformer UpperCase { get; } = new ToUpperCase(); - /// - /// Changes the string to sentence case - /// - /// - /// "lower case statement" -> "Lower case statement" - /// - public static ICulturedStringTransformer SentenceCase { get; } = new ToSentenceCase(); - } -} + /// + /// Changes the string to sentence case + /// + /// + /// "lower case statement" -> "Lower case statement" + /// + public static ICulturedStringTransformer SentenceCase { get; } = new ToSentenceCase(); +} \ No newline at end of file diff --git a/src/Humanizer/Transformer/ToLowerCase.cs b/src/Humanizer/Transformer/ToLowerCase.cs index 81c99766c..3b7f7fb45 100644 --- a/src/Humanizer/Transformer/ToLowerCase.cs +++ b/src/Humanizer/Transformer/ToLowerCase.cs @@ -1,15 +1,14 @@ -namespace Humanizer +namespace Humanizer; + +class ToLowerCase : ICulturedStringTransformer { - class ToLowerCase : ICulturedStringTransformer - { - public string Transform(string input) => - Transform(input, null); + public string Transform(string input) => + Transform(input, null); - public string Transform(string input, CultureInfo? culture) - { + public string Transform(string input, CultureInfo? culture) + { culture ??= CultureInfo.CurrentCulture; return culture.TextInfo.ToLower(input); } - } } \ No newline at end of file diff --git a/src/Humanizer/Transformer/ToSentenceCase.cs b/src/Humanizer/Transformer/ToSentenceCase.cs index 3376edece..db5dbfcac 100644 --- a/src/Humanizer/Transformer/ToSentenceCase.cs +++ b/src/Humanizer/Transformer/ToSentenceCase.cs @@ -1,20 +1,19 @@ -namespace Humanizer +namespace Humanizer; + +class ToSentenceCase : ICulturedStringTransformer { - class ToSentenceCase : ICulturedStringTransformer + public string Transform(string input) => + Transform(input, null); + + public string Transform(string input, CultureInfo? culture) { - public string Transform(string input) => - Transform(input, null); + culture ??= CultureInfo.CurrentCulture; - public string Transform(string input, CultureInfo? culture) + if (input.Length >= 1) { - culture ??= CultureInfo.CurrentCulture; - - if (input.Length >= 1) - { - return culture.TextInfo.ToUpper(input[0]) + input.Substring(1); - } - - return culture.TextInfo.ToUpper(input); + return culture.TextInfo.ToUpper(input[0]) + input.Substring(1); } + + return culture.TextInfo.ToUpper(input); } } \ No newline at end of file diff --git a/src/Humanizer/Transformer/ToUpperCase.cs b/src/Humanizer/Transformer/ToUpperCase.cs index 67246a9de..f91e7264c 100644 --- a/src/Humanizer/Transformer/ToUpperCase.cs +++ b/src/Humanizer/Transformer/ToUpperCase.cs @@ -1,15 +1,14 @@ -namespace Humanizer +namespace Humanizer; + +class ToUpperCase : ICulturedStringTransformer { - class ToUpperCase : ICulturedStringTransformer - { - public string Transform(string input) => - Transform(input, null); + public string Transform(string input) => + Transform(input, null); - public string Transform(string input, CultureInfo? culture) - { + public string Transform(string input, CultureInfo? culture) + { culture ??= CultureInfo.CurrentCulture; return culture.TextInfo.ToUpper(input); } - } } \ No newline at end of file diff --git a/src/Humanizer/TruncateExtensions.cs b/src/Humanizer/TruncateExtensions.cs index 380b52799..31c782968 100644 --- a/src/Humanizer/TruncateExtensions.cs +++ b/src/Humanizer/TruncateExtensions.cs @@ -1,56 +1,56 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Allow strings to be truncated +/// +public static class TruncateExtensions { /// - /// Allow strings to be truncated + /// Truncate the string /// - public static class TruncateExtensions - { - /// - /// Truncate the string - /// - /// The string to be truncated - /// The length to truncate to - /// The truncated string - [return: NotNullIfNotNull(nameof(input))] - public static string? Truncate(this string? input, int length) => - input.Truncate(length, "…", Truncator.FixedLength); + /// The string to be truncated + /// The length to truncate to + /// The truncated string + [return: NotNullIfNotNull(nameof(input))] + public static string? Truncate(this string? input, int length) => + input.Truncate(length, "…", Truncator.FixedLength); - /// - /// Truncate the string - /// - /// The string to be truncated - /// The length to truncate to - /// The truncate to use - /// The enum value used to determine from where to truncate the string - /// The truncated string - [return: NotNullIfNotNull(nameof(input))] - public static string? Truncate(this string? input, int length, ITruncator truncator, TruncateFrom from = TruncateFrom.Right) => - input.Truncate(length, "…", truncator, from); + /// + /// Truncate the string + /// + /// The string to be truncated + /// The length to truncate to + /// The truncate to use + /// The enum value used to determine from where to truncate the string + /// The truncated string + [return: NotNullIfNotNull(nameof(input))] + public static string? Truncate(this string? input, int length, ITruncator truncator, TruncateFrom from = TruncateFrom.Right) => + input.Truncate(length, "…", truncator, from); - /// - /// Truncate the string - /// - /// The string to be truncated - /// The length to truncate to - /// The string used to truncate with - /// The enum value used to determine from where to truncate the string - /// The truncated string - [return: NotNullIfNotNull(nameof(input))] - public static string? Truncate(this string? input, int length, string? truncationString, TruncateFrom from = TruncateFrom.Right) => - input.Truncate(length, truncationString, Truncator.FixedLength, from); + /// + /// Truncate the string + /// + /// The string to be truncated + /// The length to truncate to + /// The string used to truncate with + /// The enum value used to determine from where to truncate the string + /// The truncated string + [return: NotNullIfNotNull(nameof(input))] + public static string? Truncate(this string? input, int length, string? truncationString, TruncateFrom from = TruncateFrom.Right) => + input.Truncate(length, truncationString, Truncator.FixedLength, from); - /// - /// Truncate the string - /// - /// The string to be truncated - /// The length to truncate to - /// The string used to truncate with - /// The truncator to use - /// The enum value used to determine from where to truncate the string - /// The truncated string - [return: NotNullIfNotNull(nameof(input))] - public static string? Truncate(this string? input, int length, string? truncationString, ITruncator truncator, TruncateFrom from = TruncateFrom.Right) - { + /// + /// Truncate the string + /// + /// The string to be truncated + /// The length to truncate to + /// The string used to truncate with + /// The truncator to use + /// The enum value used to determine from where to truncate the string + /// The truncated string + [return: NotNullIfNotNull(nameof(input))] + public static string? Truncate(this string? input, int length, string? truncationString, ITruncator truncator, TruncateFrom from = TruncateFrom.Right) + { if (truncator == null) { throw new ArgumentNullException(nameof(truncator)); @@ -63,20 +63,19 @@ public static class TruncateExtensions return truncator.Truncate(input, length, truncationString, from); } - } +} +/// +/// Truncation location for humanizer +/// +public enum TruncateFrom +{ /// - /// Truncation location for humanizer + /// Truncate letters from the left (start) of the string /// - public enum TruncateFrom - { - /// - /// Truncate letters from the left (start) of the string - /// - Left, - /// - /// Truncate letters from the right (end) of the string - /// - Right - } -} + Left, + /// + /// Truncate letters from the right (end) of the string + /// + Right +} \ No newline at end of file diff --git a/src/Humanizer/Truncation/FixedLengthTruncator.cs b/src/Humanizer/Truncation/FixedLengthTruncator.cs index eaf20f84a..d9707e420 100644 --- a/src/Humanizer/Truncation/FixedLengthTruncator.cs +++ b/src/Humanizer/Truncation/FixedLengthTruncator.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Truncate a string to a fixed length +/// +class FixedLengthTruncator : ITruncator { - /// - /// Truncate a string to a fixed length - /// - class FixedLengthTruncator : ITruncator + [return: NotNullIfNotNull(nameof(value))] + public string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right) { - [return: NotNullIfNotNull(nameof(value))] - public string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right) - { if (value == null) { return null; @@ -36,5 +36,4 @@ class FixedLengthTruncator : ITruncator ? value.Substring(0, length - truncationString.Length) + truncationString : value; } - } } \ No newline at end of file diff --git a/src/Humanizer/Truncation/FixedNumberOfCharactersTruncator.cs b/src/Humanizer/Truncation/FixedNumberOfCharactersTruncator.cs index b353664c6..b3680102f 100644 --- a/src/Humanizer/Truncation/FixedNumberOfCharactersTruncator.cs +++ b/src/Humanizer/Truncation/FixedNumberOfCharactersTruncator.cs @@ -1,13 +1,13 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Truncate a string to a fixed number of letters or digits +/// +class FixedNumberOfCharactersTruncator : ITruncator { - /// - /// Truncate a string to a fixed number of letters or digits - /// - class FixedNumberOfCharactersTruncator : ITruncator + [return: NotNullIfNotNull(nameof(value))] + public string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right) { - [return: NotNullIfNotNull(nameof(value))] - public string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right) - { if (value == null) { return null; @@ -63,5 +63,4 @@ class FixedNumberOfCharactersTruncator : ITruncator return value; } - } } \ No newline at end of file diff --git a/src/Humanizer/Truncation/FixedNumberOfWordsTruncator.cs b/src/Humanizer/Truncation/FixedNumberOfWordsTruncator.cs index d32e012ae..4cb6b7e4b 100644 --- a/src/Humanizer/Truncation/FixedNumberOfWordsTruncator.cs +++ b/src/Humanizer/Truncation/FixedNumberOfWordsTruncator.cs @@ -1,88 +1,87 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Truncate a string to a fixed number of words +/// +class FixedNumberOfWordsTruncator : ITruncator { - /// - /// Truncate a string to a fixed number of words - /// - class FixedNumberOfWordsTruncator : ITruncator + [return: NotNullIfNotNull(nameof(value))] + public string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right) { - [return: NotNullIfNotNull(nameof(value))] - public string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right) + if (value == null) { - if (value == null) - { - return null; - } - - if (value.Length == 0) - { - return value; - } + return null; + } - var numberOfWords = value.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries).Count(); - if (numberOfWords <= length) - { - return value; - } + if (value.Length == 0) + { + return value; + } - return truncateFrom == TruncateFrom.Left - ? TruncateFromLeft(value, length, truncationString) - : TruncateFromRight(value, length, truncationString); + var numberOfWords = value.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries).Count(); + if (numberOfWords <= length) + { + return value; } - static string TruncateFromRight(string value, int length, string? truncationString) + return truncateFrom == TruncateFrom.Left + ? TruncateFromLeft(value, length, truncationString) + : TruncateFromRight(value, length, truncationString); + } + + static string TruncateFromRight(string value, int length, string? truncationString) + { + var lastCharactersWasWhiteSpace = true; + var numberOfWordsProcessed = 0; + for (var i = 0; i < value.Length; i++) { - var lastCharactersWasWhiteSpace = true; - var numberOfWordsProcessed = 0; - for (var i = 0; i < value.Length; i++) + if (char.IsWhiteSpace(value[i])) { - if (char.IsWhiteSpace(value[i])) + if (!lastCharactersWasWhiteSpace) { - if (!lastCharactersWasWhiteSpace) - { - numberOfWordsProcessed++; - } + numberOfWordsProcessed++; + } - lastCharactersWasWhiteSpace = true; + lastCharactersWasWhiteSpace = true; - if (numberOfWordsProcessed == length) - { - return value.Substring(0, i) + truncationString; - } - } - else + if (numberOfWordsProcessed == length) { - lastCharactersWasWhiteSpace = false; + return value.Substring(0, i) + truncationString; } } - return value + truncationString; + else + { + lastCharactersWasWhiteSpace = false; + } } + return value + truncationString; + } - static string TruncateFromLeft(string value, int length, string? truncationString) + static string TruncateFromLeft(string value, int length, string? truncationString) + { + var lastCharactersWasWhiteSpace = true; + var numberOfWordsProcessed = 0; + for (var i = value.Length - 1; i > 0; i--) { - var lastCharactersWasWhiteSpace = true; - var numberOfWordsProcessed = 0; - for (var i = value.Length - 1; i > 0; i--) + if (char.IsWhiteSpace(value[i])) { - if (char.IsWhiteSpace(value[i])) + if (!lastCharactersWasWhiteSpace) { - if (!lastCharactersWasWhiteSpace) - { - numberOfWordsProcessed++; - } + numberOfWordsProcessed++; + } - lastCharactersWasWhiteSpace = true; + lastCharactersWasWhiteSpace = true; - if (numberOfWordsProcessed == length) - { - return truncationString + value.Substring(i + 1).TrimEnd(); - } - } - else + if (numberOfWordsProcessed == length) { - lastCharactersWasWhiteSpace = false; + return truncationString + value.Substring(i + 1).TrimEnd(); } } - return truncationString + value; + else + { + lastCharactersWasWhiteSpace = false; + } } + return truncationString + value; } } \ No newline at end of file diff --git a/src/Humanizer/Truncation/ITruncator.cs b/src/Humanizer/Truncation/ITruncator.cs index fc6d89efb..9016f14d3 100644 --- a/src/Humanizer/Truncation/ITruncator.cs +++ b/src/Humanizer/Truncation/ITruncator.cs @@ -1,19 +1,18 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Can truncate a string. +/// +public interface ITruncator { /// - /// Can truncate a string. + /// Truncate a string /// - public interface ITruncator - { - /// - /// Truncate a string - /// - /// The string to truncate - /// The length to truncate to - /// The string used to truncate with - /// The enum value used to determine from where to truncate the string - /// The truncated string - [return: NotNullIfNotNull(nameof(value))] - string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right); - } -} + /// The string to truncate + /// The length to truncate to + /// The string used to truncate with + /// The enum value used to determine from where to truncate the string + /// The truncated string + [return: NotNullIfNotNull(nameof(value))] + string? Truncate(string? value, int length, string? truncationString, TruncateFrom truncateFrom = TruncateFrom.Right); +} \ No newline at end of file diff --git a/src/Humanizer/Truncation/Truncator.cs b/src/Humanizer/Truncation/Truncator.cs index b60da2ecb..b92c932d8 100644 --- a/src/Humanizer/Truncation/Truncator.cs +++ b/src/Humanizer/Truncation/Truncator.cs @@ -1,23 +1,22 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Gets a ITruncator +/// +public static class Truncator { /// - /// Gets a ITruncator + /// Fixed length truncator /// - public static class Truncator - { - /// - /// Fixed length truncator - /// - public static ITruncator FixedLength => new FixedLengthTruncator(); + public static ITruncator FixedLength => new FixedLengthTruncator(); - /// - /// Fixed number of characters truncator - /// - public static ITruncator FixedNumberOfCharacters => new FixedNumberOfCharactersTruncator(); + /// + /// Fixed number of characters truncator + /// + public static ITruncator FixedNumberOfCharacters => new FixedNumberOfCharactersTruncator(); - /// - /// Fixed number of words truncator - /// - public static ITruncator FixedNumberOfWords => new FixedNumberOfWordsTruncator(); - } -} + /// + /// Fixed number of words truncator + /// + public static ITruncator FixedNumberOfWords => new FixedNumberOfWordsTruncator(); +} \ No newline at end of file diff --git a/src/Humanizer/TupleizeExtensions.cs b/src/Humanizer/TupleizeExtensions.cs index 36cd0bcbb..f5256a7d8 100644 --- a/src/Humanizer/TupleizeExtensions.cs +++ b/src/Humanizer/TupleizeExtensions.cs @@ -1,20 +1,20 @@ // ReSharper disable IdentifierTypo // ReSharper disable StringLiteralTypo -namespace Humanizer +namespace Humanizer; + +/// +/// Convert int to named tuple strings (1 -> 'single', 2-> 'double' etc.). +/// Only values 1-10, 100, and 1000 have specific names. All others will return 'n-tuple'. +/// +public static class TupleizeExtensions { /// - /// Convert int to named tuple strings (1 -> 'single', 2-> 'double' etc.). - /// Only values 1-10, 100, and 1000 have specific names. All others will return 'n-tuple'. + /// Converts integer to named tuple (e.g. 'single', 'double' etc.). /// - public static class TupleizeExtensions + /// Integer + /// Named tuple + public static string Tupleize(this int input) { - /// - /// Converts integer to named tuple (e.g. 'single', 'double' etc.). - /// - /// Integer - /// Named tuple - public static string Tupleize(this int input) - { switch (input) { case 1: @@ -45,5 +45,4 @@ public static string Tupleize(this int input) return $"{input}-tuple"; } } - } -} +} \ No newline at end of file diff --git a/src/Humanizer/WordForm.cs b/src/Humanizer/WordForm.cs index 0976a2f9f..c72379d11 100644 --- a/src/Humanizer/WordForm.cs +++ b/src/Humanizer/WordForm.cs @@ -1,24 +1,23 @@ -namespace Humanizer +namespace Humanizer; + +/// +/// Options for specifying the form of the word when different variations of the same word exists. +/// +public enum WordForm { /// - /// Options for specifying the form of the word when different variations of the same word exists. + /// Indicates the normal form of a written word. /// - public enum WordForm - { - /// - /// Indicates the normal form of a written word. - /// - Normal, + Normal, - /// - /// Indicates the shortened form of a written word. - /// - Abbreviation, + /// + /// Indicates the shortened form of a written word. + /// + Abbreviation, - /// - /// Indicates the Eifeler Rule form of a word. - /// https://lb.wikipedia.org/wiki/Eifeler_Reegel - /// - Eifeler, - } -} + /// + /// Indicates the Eifeler Rule form of a word. + /// https://lb.wikipedia.org/wiki/Eifeler_Reegel + /// + Eifeler, +} \ No newline at end of file