|
| 1 | +using System; |
| 2 | +using System.Text; |
| 3 | +using Xunit; |
| 4 | +using Unidecode.NET; |
| 5 | + |
| 6 | +namespace Unidecode.NET.Tests |
| 7 | +{ |
| 8 | + // these are the same tests you find in UnidecoderTest, but here we are testing directly the internal function SlowUnidecode |
| 9 | + // which is the Unidecode implementation that normally gets called only for very long strings |
| 10 | + // (because it is slower, but it has no limits on the size of the input string) |
| 11 | + public class SlowUnidecoderTest |
| 12 | + { |
| 13 | + [Fact] |
| 14 | + public void DocTest() |
| 15 | + { |
| 16 | + Assert.Equal("Bei Jing ", "\u5317\u4EB0".SlowUnidecode()); |
| 17 | + } |
| 18 | + |
| 19 | + [Fact] |
| 20 | + public void CustomTest() |
| 21 | + { |
| 22 | + Assert.Equal("Rabota s kirillitsei", "Работа с кириллицей".SlowUnidecode()); |
| 23 | + Assert.Equal("aouoAOUO", "äöűőÄÖŨŐ".SlowUnidecode()); |
| 24 | + } |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + [Fact] |
| 29 | + public void PythonTest() |
| 30 | + { |
| 31 | + |
| 32 | + Assert.Equal("Hello, World!", "Hello, World!".SlowUnidecode()); |
| 33 | + Assert.Equal("'\"\r\n", "'\"\r\n".SlowUnidecode()); |
| 34 | + Assert.Equal("CZSczs", "ČŽŠčžš".SlowUnidecode()); |
| 35 | + Assert.Equal("a", "ア".SlowUnidecode()); |
| 36 | + Assert.Equal("a", "α".SlowUnidecode()); |
| 37 | + Assert.Equal("a", "а".SlowUnidecode()); |
| 38 | + Assert.Equal("chateau", "ch\u00e2teau".SlowUnidecode()); |
| 39 | + Assert.Equal("vinedos", "vi\u00f1edos".SlowUnidecode()); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + public void RussianAlphabetTest() |
| 44 | + { |
| 45 | + const string russianAlphabetLowercase = "а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я"; |
| 46 | + const string russianAlphabetUppercase = "А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я"; |
| 47 | + |
| 48 | + const string expectedLowercase = "a b v g d e io zh z i i k l m n o p r s t u f kh ts ch sh shch ' y ' e iu ia"; |
| 49 | + const string expectedUppercase = "A B V G D E Io Zh Z I I K L M N O P R S T U F Kh Ts Ch Sh Shch ' Y ' E Iu Ia"; |
| 50 | + |
| 51 | + Assert.Equal(expectedLowercase, russianAlphabetLowercase.SlowUnidecode()); |
| 52 | + Assert.Equal(expectedUppercase, russianAlphabetUppercase.SlowUnidecode()); |
| 53 | + } |
| 54 | + |
| 55 | + |
| 56 | + [Fact] |
| 57 | + public void UnidecodeOnNullShouldReturnEmptyString() |
| 58 | + { |
| 59 | + Assert.Equal("", ((string)null).SlowUnidecode()); |
| 60 | + } |
| 61 | + |
| 62 | + } |
| 63 | +} |
0 commit comments