public void TestEmptyString() { String str1 = ""; CharIterator ct = new CharIterator(str1); Assert.IsFalse(ct.MoveNext()); }
private static string Unescape(string s) { StringBuilder sb = new StringBuilder(); CharIterator i = new CharIterator(s); while (i.MoveNext()) { char c = i.Current; if (c == '%') { i.MoveNext(); char c1 = i.Current; i.MoveNext(); char c2 = i.Current; sb.Append(( char )((StringUtil.FromHex(c1) << 4) | StringUtil.FromHex(c2))); } else if (c == '+') { sb.Append(' '); } else { sb.Append(c); } } return(sb.ToString()); }
private static void Escape(StringBuilder sb, string s) { if (s == null) { sb.Append("null"); return; } CharIterator i = new CharIterator(s); while (i.MoveNext()) { char c = i.Current; if (IsEscaped(c)) { sb.Append('%'); sb.Append(StringUtil.ToHex((c >> 4) & 15)); sb.Append(StringUtil.ToHex(c & 15)); } else if (c == ' ') { sb.Append('+'); } else { sb.Append(c); } } }
public void TestString1() { String str1 = "tcp"; CharIterator ct = new CharIterator(str1); Assert.IsTrue(ct.MoveNext()); Assert.AreEqual('t', ct.Current); Assert.IsTrue(ct.MoveNext()); Assert.AreEqual('c', ct.Current); Assert.IsTrue(ct.MoveNext()); Assert.AreEqual('p', ct.Current); Assert.IsFalse(ct.MoveNext()); }
public void TestNullString() { String str1 = null; CharIterator ct = new CharIterator(str1); }