forked from bchavez/Bogus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Transliteration (bchavez#233)
Fixes bchavez#225. Transliteration using Trie data-structure. ❤️
- Loading branch information
Showing
16 changed files
with
1,681 additions
and
22 deletions.
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
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
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,38 @@ | ||
using Bogus.DataSets; | ||
using Bogus.Extensions; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests.GitHubIssues | ||
{ | ||
public class Issue225 : SeededTest | ||
{ | ||
[Fact] | ||
public void can_generate_sane_email_addresses_in_different_locales() | ||
{ | ||
var p = new Bogus.Person("ru"); | ||
p.FullName.Should().Be("Анастасия Евсеева"); | ||
p.Email.Should().Be("Anastasiya69@gmail.com"); | ||
} | ||
|
||
[Fact] | ||
public void can_generate_sane_email_address_from_ru() | ||
{ | ||
var i = new Internet(); | ||
i.Email("Анна", "Фомина").Should().Be("Anna81@yahoo.com"); | ||
} | ||
|
||
[Fact] | ||
public void can_generate_email_without_transliteration() | ||
{ | ||
var i = new Internet(); | ||
i.Email("Анна", "Фомина").Should().Be("Anna81@yahoo.com"); | ||
} | ||
|
||
[Fact] | ||
public void simple_translation() | ||
{ | ||
"Анна Фомина".Transliterate().Should().Be("Anna Fomina"); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests | ||
{ | ||
public class TransliterateTests | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
Transliterater.Translate("À").Should().Be("A"); | ||
Transliterater.Translate("ден").Should().Be("MKD"); | ||
Transliterater.Translate("စျ").Should().Be("za"); | ||
} | ||
|
||
[Fact] | ||
public void index_test() | ||
{ | ||
Transliterater.Translate("ေါင်ူ").Should().Be("aungu"); | ||
} | ||
|
||
[Fact] | ||
public void simple_test() | ||
{ | ||
Transliterater.Translate("ာ").Should().Be("a"); | ||
} | ||
|
||
[Fact] | ||
public void basic_ru_test() | ||
{ | ||
Transliterater.Translate("Анна Фомина").Should().Be("Anna Fomina"); | ||
} | ||
|
||
[Fact] | ||
public void index2_test() | ||
{ | ||
Transliterater.Translate("ေါင်ff").Should().Be("aungff"); | ||
} | ||
|
||
[Fact] | ||
public void transliterate_with_unknown_langauge_doesnt_throw() | ||
{ | ||
Action a = () => Transliterater.Translate("fefefe", "gggg"); | ||
a.ShouldNotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void can_translate_symbol() | ||
{ | ||
Transliterater.Translate("♥").Should().Be("love"); | ||
} | ||
|
||
[Fact] | ||
public void can_translate_symbol_with_locale() | ||
{ | ||
Transliterater.Translate("♥", "es").Should().Be("amor"); | ||
} | ||
|
||
[Fact] | ||
public void can_translate_with_langchar_map() | ||
{ | ||
Transliterater.Translate("Ä").Should().Be("Ae"); | ||
Transliterater.Translate("Ä", lang: "fi").Should().Be("A"); | ||
Transliterater.Translate("Ä", lang: "hu").Should().Be("A"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.