-
Notifications
You must be signed in to change notification settings - Fork 966
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register Portuguese TimeSpan localisation as "pt".
According to #601, the localisation is good for Portuguese in general, not just for Brazilian Portuguese. I copied the unit test, so that we can prove that there's no regression. Additionally, I copied the `OrginalizeTests`, because those were already registered as "pt", not "pt-BR". Note that `NumberToWords` is still only valid for pt-BR unless confirmed otherwise.
- Loading branch information
Showing
4 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/Humanizer.Tests.Shared/Localisation/pt/OrdinalizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Xunit; | ||
|
||
namespace Humanizer.Tests.Localisation.pt | ||
{ | ||
[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 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 OrdinalizeNumberFeminine(int number, string ordinalized) | ||
{ | ||
Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized); | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
src/Humanizer.Tests.Shared/Localisation/pt/TimeSpanHumanizeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace Humanizer.Tests.Localisation.pt | ||
{ | ||
[UseCulture("pt")] | ||
public class TimeSpanHumanizeTests | ||
{ | ||
[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() | ||
{ | ||
// This one doesn't make a lot of sense but ... w/e | ||
Assert.Equal("sem horário", TimeSpan.Zero.Humanize()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters