[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / corlib / Test / System.Globalization / StringInfoTest.cs
1 //
2 // StringInfoTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //
7 // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
8 //
9
10 using NUnit.Framework;
11 using System;
12 using System.Globalization;
13 using System.IO;
14 using System.Runtime.Serialization;
15 using System.Runtime.Serialization.Formatters.Binary;
16
17 namespace MonoTests.System.Globalization
18 {
19
20         [TestFixture]
21         public class StringInfoTest
22         {
23                 [Test]
24                 public void GetNextTextElement ()
25                 {
26                         Assert.AreEqual ("A", StringInfo.GetNextTextElement ("ABC", 0), "#1");
27                         Assert.AreEqual ("C", StringInfo.GetNextTextElement ("ABC", 2), "#2");
28                         Assert.AreEqual ("A\u0330", StringInfo.GetNextTextElement ("A\u0330BC", 0), "#3");
29                         Assert.AreEqual ("B", StringInfo.GetNextTextElement ("A\u0330BC", 2), "#4");
30
31                         // hmm ...
32                         Assert.AreEqual (String.Empty, StringInfo.GetNextTextElement ("A\u0330BC", 4), "#4");
33                 }
34
35                 [Test]
36                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
37                 public void GetNextTextElementOutOfRange1 ()
38                 {
39                         StringInfo.GetNextTextElement ("ABC", -1);
40                 }
41
42                 [Test]
43                 public void LengthInTextElements ()
44                 {
45                         Assert.AreEqual (3, new StringInfo ("ABC").LengthInTextElements, "#1");
46                         Assert.AreEqual (5, new StringInfo (" ABC ").LengthInTextElements, "#2");
47                         Assert.AreEqual (3, new StringInfo ("A\u0330BC\u0330").LengthInTextElements, "#3");
48                         Assert.AreEqual (3, new StringInfo ("A\u0330\u0331BC\u0330").LengthInTextElements, "#4");
49                 }
50
51                 [Test]
52                 public void SubstringByTextElements ()
53                 {
54                         StringInfo si = new StringInfo ("A\u0330BC\u0330");
55                         Assert.AreEqual ("A\u0330BC\u0330", si.SubstringByTextElements (0), "#1");
56                         Assert.AreEqual ("BC\u0330", si.SubstringByTextElements (1), "#2");
57                         Assert.AreEqual ("C\u0330", si.SubstringByTextElements (2), "#3");
58                 }
59
60                 [Test]
61                 public void DefaultConstructor ()
62                 {
63                         var info = new StringInfo ();
64                         Assert.AreEqual (string.Empty, info.String);
65                 }
66
67                 [Test]
68                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
69                 public void SubstringByTextElementsOutOfRange1 ()
70                 {
71                         new StringInfo ("A\u0330BC\u0330").SubstringByTextElements (-1);
72                 }
73
74                 [Test]
75                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
76                 public void SubstringByTextElementsOutOfRange2 ()
77                 {
78                         new StringInfo ("A\u0330BC\u0330").SubstringByTextElements (4);
79                 }
80
81                 [Test]
82                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
83                 public void SubstringByTextElementsOutOfRange3 ()
84                 {
85                         new StringInfo (String.Empty).SubstringByTextElements (0);
86                 }
87         }
88
89 }