-
Notifications
You must be signed in to change notification settings - Fork 965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hungarian localization and tests #179
Changes from 4 commits
ff0a61f
8c5a9d7
b246872
09f9955
db3bfa7
9b4ced8
ab02f19
34c0cc9
912833d
9335c06
3e9e978
da8b00a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using Humanizer.Localisation; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.hu | ||
{ | ||
public class DateHumanizeTests : AmbientCulture | ||
{ | ||
public DateHumanizeTests() | ||
: base("hu-HU") | ||
{ | ||
} | ||
|
||
[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 perce")] | ||
[InlineData(10, "10 perce")] | ||
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 ó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, "tegnap")] | ||
[InlineData(10, "10 napja")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for checking multiple values. Just check it for 1 and 2. This applies to all the tests you've written. |
||
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, "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 é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); | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.hu | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
{ | ||
public TimeSpanHumanizeTests() : base("hu-HU") { } | ||
|
||
[Theory] | ||
[InlineData(14, "2 hét")] | ||
[InlineData(7, "1 hét")] | ||
public void Weeks(int days, string expected) | ||
{ | ||
var actual = TimeSpan.FromDays(days).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(6, "6 nap")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for 6 |
||
[InlineData(2, "2 nap")] | ||
[InlineData(1, "1 nap")] | ||
public void Days(int days, string expected) | ||
{ | ||
var actual = TimeSpan.FromDays(days).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 óra")] | ||
[InlineData(1, "1 óra")] | ||
public void Hours(int hours, string expected) | ||
{ | ||
var actual = TimeSpan.FromHours(hours).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(2, "2 perc")] | ||
[InlineData(1, "1 perc")] | ||
public void Minutes(int minutes, string expected) | ||
{ | ||
var actual = TimeSpan.FromMinutes(minutes).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(135, "2 perc")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for 135 and 60 |
||
[InlineData(60, "1 perc")] | ||
[InlineData(2, "2 másodperc")] | ||
[InlineData(1, "1 másodperc")] | ||
public void Seconds(int seconds, string expected) | ||
{ | ||
var actual = TimeSpan.FromSeconds(seconds).Humanize(); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, 3, "nincs idő")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this test. This has been covered by the English test and the tests you wrote above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is still here! o_O |
||
[InlineData(0, 2, "nincs idő")] | ||
[InlineData(10, 2, "10 ezredmásodperc")] | ||
[InlineData(1400, 2, "1 másodperc, 400 ezredmásodperc")] | ||
[InlineData(2500, 2, "2 másodperc, 500 ezredmásodperc")] | ||
[InlineData(120000, 2, "2 perc")] | ||
[InlineData(62000, 2, "1 perc, 2 másodperc")] | ||
[InlineData(62020, 2, "1 perc, 2 másodperc")] | ||
[InlineData(62020, 3, "1 perc, 2 másodperc, 20 ezredmásodperc")] | ||
[InlineData(3600020, 4, "1 óra, 20 ezredmásodperc")] | ||
[InlineData(3600020, 3, "1 óra, 20 ezredmásodperc")] | ||
[InlineData(3600020, 2, "1 óra, 20 ezredmásodperc")] | ||
[InlineData(3600020, 1, "1 óra")] | ||
[InlineData(3603001, 2, "1 óra, 3 másodperc")] | ||
[InlineData(3603001, 3, "1 óra, 3 másodperc, 1 ezredmásodperc")] | ||
[InlineData(86400000, 3, "1 nap")] | ||
[InlineData(86400000, 2, "1 nap")] | ||
[InlineData(86400000, 1, "1 nap")] | ||
[InlineData(86401000, 1, "1 nap")] | ||
[InlineData(86401000, 2, "1 nap, 1 másodperc")] | ||
[InlineData(86401200, 2, "1 nap, 1 másodperc")] | ||
[InlineData(86401200, 3, "1 nap, 1 másodperc, 200 ezredmásodperc")] | ||
[InlineData(1296000000, 1, "2 hét")] | ||
[InlineData(1296000000, 2, "2 hét, 1 nap")] | ||
[InlineData(1299600000, 2, "2 hét, 1 nap")] | ||
[InlineData(1299600000, 3, "2 hét, 1 nap, 1 óra")] | ||
[InlineData(1299630020, 3, "2 hét, 1 nap, 1 óra")] | ||
[InlineData(1299630020, 4, "2 hét, 1 nap, 1 óra, 30 másodperc")] | ||
[InlineData(1299630020, 5, "2 hét, 1 nap, 1 óra, 30 másodperc, 20 ezredmásodperc")] | ||
public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected) | ||
{ | ||
var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion); | ||
Assert.Equal(expected, actual); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
var noTime = TimeSpan.Zero; | ||
var actual = noTime.Humanize(); | ||
Assert.Equal("nincs idő", actual); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to be quite a few commits behind upstream. Please rebase your branch.