size() public method

public size ( ) : int
return int
Exemplo n.º 1
0
 private static void WriteLine(Stream @out, char prefix, RawText text, int cur)
 {
     @out.WriteByte(Convert.ToByte(prefix));
     text.writeLine(@out, cur);
     @out.WriteByte(Convert.ToByte('\n'));
     if (cur + 1 == text.size() && text.isMissingNewlineAtEnd())
     {
         @out.Write(NoNewLine, 0, NoNewLine.Length);
     }
 }
Exemplo n.º 2
0
        public void testEquals()
        {
            var a = new RawText(Constants.encodeASCII("foo-a\nfoo-b\n"));
            var b = new RawText(Constants.encodeASCII("foo-b\nfoo-c\n"));

            Assert.AreEqual(2, a.size());
            Assert.AreEqual(2, b.size());

            // foo-a != foo-b
            Assert.IsFalse(a.equals(0, b, 0));
            Assert.IsFalse(b.equals(0, a, 0));

            // foo-b == foo-b
            Assert.IsTrue(a.equals(1, b, 0));
            Assert.IsTrue(b.equals(0, a, 1));
        }
Exemplo n.º 3
0
        private void FormatEdits(Stream @out, RawText a, RawText b, EditList edits)
        {
            for (int curIdx = 0; curIdx < edits.Count; /* */)
            {
                Edit curEdit = edits.get(curIdx);
                int  endIdx  = FindCombinedEnd(edits, curIdx);
                Edit endEdit = edits.get(endIdx);

                int aCur = Math.Max(0, curEdit.BeginA - _context);
                int bCur = Math.Max(0, curEdit.BeginB - _context);
                int aEnd = Math.Min(a.size(), endEdit.EndA + _context);
                int bEnd = Math.Min(b.size(), endEdit.EndB + _context);

                WriteHunkHeader(@out, aCur, aEnd, bCur, bEnd);

                while (aCur < aEnd || bCur < bEnd)
                {
                    if (aCur < curEdit.BeginA || endIdx + 1 < curIdx)
                    {
                        WriteLine(@out, ' ', a, aCur);
                        aCur++;
                        bCur++;
                    }
                    else if (aCur < curEdit.EndA)
                    {
                        WriteLine(@out, '-', a, aCur++);
                    }
                    else if (bCur < curEdit.EndB)
                    {
                        WriteLine(@out, '+', b, bCur++);
                    }

                    if (End(curEdit, aCur, bCur) && ++curIdx < edits.Count)
                    {
                        curEdit = edits.get(curIdx);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void FormatEdits(Stream @out, RawText a, RawText b, EditList edits)
        {
            for (int curIdx = 0; curIdx < edits.Count; /* */)
            {
                Edit curEdit = edits.get(curIdx);
                int endIdx = FindCombinedEnd(edits, curIdx);
                Edit endEdit = edits.get(endIdx);

                int aCur = Math.Max(0, curEdit.BeginA - _context);
                int bCur = Math.Max(0, curEdit.BeginB - _context);
                int aEnd = Math.Min(a.size(), endEdit.EndA + _context);
                int bEnd = Math.Min(b.size(), endEdit.EndB + _context);

                WriteHunkHeader(@out, aCur, aEnd, bCur, bEnd);

                while (aCur < aEnd || bCur < bEnd)
                {
                    if (aCur < curEdit.BeginA || endIdx + 1 < curIdx)
                    {
                        WriteLine(@out, ' ', a, aCur);
                        aCur++;
                        bCur++;
                    }
                    else if (aCur < curEdit.EndA)
                    {
                        WriteLine(@out, '-', a, aCur++);

                    }
                    else if (bCur < curEdit.EndB)
                    {
                        WriteLine(@out, '+', b, bCur++);
                    }

                    if (End(curEdit, aCur, bCur) && ++curIdx < edits.Count)
                    {
                        curEdit = edits.get(curIdx);
                    }
                }
            }
        }
Exemplo n.º 5
0
 private static void WriteLine(Stream @out, char prefix, RawText text, int cur)
 {
     @out.WriteByte(Convert.ToByte(prefix));
     text.writeLine(@out, cur);
     @out.WriteByte(Convert.ToByte('\n'));
     if (cur + 1 == text.size() && text.isMissingNewlineAtEnd())
     {
         @out.Write(NoNewLine, 0, NoNewLine.Length);
     }
 }
Exemplo n.º 6
0
 public void testEmpty()
 {
     var r = new RawText(new byte[0]);
     Assert.AreEqual(0, r.size());
 }