Пример #1
0
 public void GetCodePointArgumentException()
 {
     Assert.Throws <ArgumentNullException>(() => UnicodeUtility.GetCodePoint(null !, 0));
     Assert.Throws <ArgumentOutOfRangeException>(() => UnicodeUtility.GetCodePoint(new StringBuilder("a"), -1));
     Assert.Throws <ArgumentOutOfRangeException>(() => UnicodeUtility.GetCodePoint(new StringBuilder("a"), 1));
     Assert.Throws <ArgumentOutOfRangeException>(() => UnicodeUtility.GetCodePoint(new StringBuilder("\uD800"), 0));
 }
Пример #2
0
        public void GetCodePoint(string s, int index, int expected)
        {
            StringBuilder sb = new StringBuilder(s);

            Assert.AreEqual(expected, UnicodeUtility.GetCodePoint(sb, index));
            Assert.AreEqual(char.ConvertToUtf32(s, index), UnicodeUtility.GetCodePoint(sb, index));
        }