-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ff0a61f
Adding basic Hungarian localization
gyurisc 8c5a9d7
Adding Hungarian date tests
gyurisc b246872
Finishing Hungarian date and timespan tests
gyurisc 09f9955
fixing issues as requested in the pull request
gyurisc db3bfa7
Merge pull request #193 from MehdiK/fixing-date-humanize
MehdiK 9b4ced8
removing further tests
gyurisc ab02f19
Adding basic Hungarian localization
gyurisc 34c0cc9
Adding Hungarian date tests
gyurisc 912833d
Finishing Hungarian date and timespan tests
gyurisc 9335c06
fixing issues as requested in the pull request
gyurisc 3e9e978
removing further tests
gyurisc da8b00a
fixing release notes
gyurisc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.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,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")] | ||
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); | ||
} | ||
|
||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/Humanizer.Tests/Localisation/hu/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,100 @@ | ||
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(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(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); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
No need for checking multiple values. Just check it for 1 and 2. This applies to all the tests you've written.