コード例 #1
0
ファイル: CharSet.cs プロジェクト: brian-reichle/Buffalo
        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);
                    }
                }
            }
        }
コード例 #2
0
        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));
        }