static void AppendRanges(StringBuilder builder, CharRange[] ranges) { if (ranges.Length > 0) { var r = ranges[0]; CharEscapeHelper.AppendEscapedChar(builder, r.From); if (r.To != r.From) { builder.Append('-'); CharEscapeHelper.AppendEscapedChar(builder, r.To); } for (var i = 1; i < ranges.Length; i++) { r = ranges[i]; builder.Append(','); CharEscapeHelper.AppendEscapedChar(builder, r.From); if (r.To != r.From) { builder.Append('-'); CharEscapeHelper.AppendEscapedChar(builder, r.To); } } } }
public void Append() { var builder = new StringBuilder(); for (var i = 0; i < InChars.Length; i++) { CharEscapeHelper.AppendEscapedChar(builder, InChars[i]); } Assert.That(builder.ToString(), Is.EqualTo(OutChars)); }