* TextInfoTest.cs: Added ListSeparator test.
[mono.git] / mcs / class / corlib / Test / System.Globalization / TextInfoTest.cs
1 // TextInfoTest.cs - NUnit Test Cases for the
2 // System.Globalization.TextInfo class
3 //
4 // Miguel de Icaza <miguel@ximian.com>
5 //
6 // (C) 2004 Novell, Inc.  http://www.novell.com
7 //
8
9 using NUnit.Framework;
10 using System;
11 using System.Globalization;
12
13 namespace MonoTests.System.Globalization
14 {
15
16 [TestFixture]
17 public class TextInfoTest : Assertion
18 {
19         public TextInfoTest () {}
20
21         [Test]
22         public void TitleCase ()
23         {
24                 TextInfo ti = new CultureInfo ("en-US", false).TextInfo;
25
26                 AssertEquals (" The Dog", ti.ToTitleCase (" the dog"));
27                 AssertEquals (" The Dude", ti.ToTitleCase (" The Dude"));
28                 AssertEquals ("La Guerra Yla Paz", ti.ToTitleCase ("la Guerra yLa pAz"));
29                 AssertEquals ("\tTab\tAnd\tPeace", ti.ToTitleCase ("\ttab\taNd\tpeaCE"));
30         }
31
32         [Test]
33         public void ListSeparator ()
34         {
35                 TextInfo ti;
36
37                 ti = new CultureInfo ("en-US", false).TextInfo;
38                 AssertEquals ("#1", ",", ti.ListSeparator);
39
40                 ti = CultureInfo.InvariantCulture.TextInfo;
41                 AssertEquals ("#2", ",", ti.ListSeparator);
42
43                 ti = new CultureInfo ("nl-BE", false).TextInfo;
44                 AssertEquals ("#3", ";", ti.ListSeparator);
45         }
46
47         [Test]
48         public void TitleCase2 ()
49         {
50                 foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
51                         Check (ci, "AB", "AB");
52                         Check (ci, "ab", "Ab");
53                         Check (ci, "aB", "Ab");
54                         Check (ci, "1Ab", "1Ab");
55                         Check (ci, "abc AB ab aB Ab ABc 1AB 1Ab 1ab 1aB",
56                                 "Abc AB Ab Ab Ab Abc 1AB 1Ab 1Ab 1Ab");
57                         Check (ci, "LJ", "LJ");
58                         Check (ci, "lj", "Lj");
59                         Check (ci, "lJ", "Lj");
60                         Check (ci, "lj abc ljabc", "Lj Abc Ljabc");
61                         Check (ci, "ab", "Ab");
62
63                         // Some greek titlecase characters
64                         Check (ci, "\u01c4", "\u01c5");
65                         Check (ci, "\u01c5", "\u01c5");
66                         Check (ci, "\u01c6", "\u01c5");
67                         Check (ci, "\u01ca", "\u01cb");
68                         Check (ci, "\u01cb", "\u01cb");
69                         Check (ci, "\u01cc", "\u01cb");
70                         // Roman numbers are not converted unlike ToUpper().
71                         Check (ci, "\u2170", "\u2170");
72                         Check (ci, "\u24e9", "\u24e9");
73                 }
74         }
75
76         private void Check (CultureInfo ci, string src, string expected)
77         {
78                 AssertEquals (src + " at culture " + ci.LCID,
79                         expected,
80                         ci.TextInfo.ToTitleCase (src));
81         }
82 }
83
84 }