Size() публичный Метод

public Size ( ) : int
Результат int
Пример #1
0
 /// <summary>Formats a list of edits in unified diff format</summary>
 /// <param name="edits">some differences which have been calculated between A and B</param>
 /// <param name="a">the text A which was compared</param>
 /// <param name="b">the text B which was compared</param>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public virtual void Format(EditList edits, RawText a, RawText b)
 {
     for (int curIdx = 0; curIdx < edits.Count;)
     {
         Edit curEdit = edits[curIdx];
         int  endIdx  = FindCombinedEnd(edits, curIdx);
         Edit endEdit = edits[endIdx];
         int  aCur    = Math.Max(0, curEdit.GetBeginA() - context);
         int  bCur    = Math.Max(0, curEdit.GetBeginB() - context);
         int  aEnd    = Math.Min(a.Size(), endEdit.GetEndA() + context);
         int  bEnd    = Math.Min(b.Size(), endEdit.GetEndB() + context);
         WriteHunkHeader(aCur, aEnd, bCur, bEnd);
         while (aCur < aEnd || bCur < bEnd)
         {
             if (aCur < curEdit.GetBeginA() || endIdx + 1 < curIdx)
             {
                 WriteContextLine(a, aCur);
                 if (IsEndOfLineMissing(a, aCur))
                 {
                     @out.Write(noNewLine);
                 }
                 aCur++;
                 bCur++;
             }
             else
             {
                 if (aCur < curEdit.GetEndA())
                 {
                     WriteRemovedLine(a, aCur);
                     if (IsEndOfLineMissing(a, aCur))
                     {
                         @out.Write(noNewLine);
                     }
                     aCur++;
                 }
                 else
                 {
                     if (bCur < curEdit.GetEndB())
                     {
                         WriteAddedLine(b, bCur);
                         if (IsEndOfLineMissing(b, bCur))
                         {
                             @out.Write(noNewLine);
                         }
                         bCur++;
                     }
                 }
             }
             if (End(curEdit, aCur, bCur) && ++curIdx < edits.Count)
             {
                 curEdit = edits[curIdx];
             }
         }
     }
 }
Пример #2
0
		public virtual void TestEquals()
		{
			RawText a = new RawText(Constants.EncodeASCII("foo-a\nfoo-b\n"));
			RawText b = new RawText(Constants.EncodeASCII("foo-b\nfoo-c\n"));
			RawTextComparator cmp = RawTextComparator.DEFAULT;
			NUnit.Framework.Assert.AreEqual(2, a.Size());
			NUnit.Framework.Assert.AreEqual(2, b.Size());
			// foo-a != foo-b
			NUnit.Framework.Assert.IsFalse(cmp.Equals(a, 0, b, 0));
			NUnit.Framework.Assert.IsFalse(cmp.Equals(b, 0, a, 0));
			// foo-b == foo-b
			NUnit.Framework.Assert.IsTrue(cmp.Equals(a, 1, b, 0));
			NUnit.Framework.Assert.IsTrue(cmp.Equals(b, 0, a, 1));
		}
Пример #3
0
        public virtual void TestEquals()
        {
            RawText           a   = new RawText(Constants.EncodeASCII("foo-a\nfoo-b\n"));
            RawText           b   = new RawText(Constants.EncodeASCII("foo-b\nfoo-c\n"));
            RawTextComparator cmp = RawTextComparator.DEFAULT;

            NUnit.Framework.Assert.AreEqual(2, a.Size());
            NUnit.Framework.Assert.AreEqual(2, b.Size());
            // foo-a != foo-b
            NUnit.Framework.Assert.IsFalse(cmp.Equals(a, 0, b, 0));
            NUnit.Framework.Assert.IsFalse(cmp.Equals(b, 0, a, 0));
            // foo-b == foo-b
            NUnit.Framework.Assert.IsTrue(cmp.Equals(a, 1, b, 0));
            NUnit.Framework.Assert.IsTrue(cmp.Equals(b, 0, a, 1));
        }
		public virtual void TestEqualsWithoutWhitespace()
		{
			RawText a = new RawText(Constants.EncodeASCII("foo-a\nfoo-b\nfoo\n"));
			RawText b = new RawText(Constants.EncodeASCII("foo-b\nfoo-c\nf\n"));
			NUnit.Framework.Assert.AreEqual(3, a.Size());
			NUnit.Framework.Assert.AreEqual(3, b.Size());
			// foo-a != foo-b
			NUnit.Framework.Assert.IsFalse(cmp.Equals(a, 0, b, 0));
			NUnit.Framework.Assert.IsFalse(cmp.Equals(b, 0, a, 0));
			// foo-b == foo-b
			NUnit.Framework.Assert.IsTrue(cmp.Equals(a, 1, b, 0));
			NUnit.Framework.Assert.IsTrue(cmp.Equals(b, 0, a, 1));
			// foo != f
			NUnit.Framework.Assert.IsFalse(cmp.Equals(a, 2, b, 2));
			NUnit.Framework.Assert.IsFalse(cmp.Equals(b, 2, a, 2));
		}
        public virtual void TestEqualsWithoutWhitespace()
        {
            RawText a = new RawText(Constants.EncodeASCII("foo-a\nfoo-b\nfoo\n"));
            RawText b = new RawText(Constants.EncodeASCII("foo-b\nfoo-c\nf\n"));

            NUnit.Framework.Assert.AreEqual(3, a.Size());
            NUnit.Framework.Assert.AreEqual(3, b.Size());
            // foo-a != foo-b
            NUnit.Framework.Assert.IsFalse(cmp.Equals(a, 0, b, 0));
            NUnit.Framework.Assert.IsFalse(cmp.Equals(b, 0, a, 0));
            // foo-b == foo-b
            NUnit.Framework.Assert.IsTrue(cmp.Equals(a, 1, b, 0));
            NUnit.Framework.Assert.IsTrue(cmp.Equals(b, 0, a, 1));
            // foo != f
            NUnit.Framework.Assert.IsFalse(cmp.Equals(a, 2, b, 2));
            NUnit.Framework.Assert.IsFalse(cmp.Equals(b, 2, a, 2));
        }
Пример #6
0
		/// <exception cref="System.Exception"></exception>
		private ApplyResult Init(string name, bool preExists, bool postExists)
		{
			Git git = new Git(db);
			if (preExists)
			{
				a = new RawText(ReadFile(name + "_PreImage"));
				Write(new FilePath(db.Directory.GetParent(), name), a.GetString(0, a.Size(), false
					));
				git.Add().AddFilepattern(name).Call();
				git.Commit().SetMessage("PreImage").Call();
			}
			if (postExists)
			{
				b = new RawText(ReadFile(name + "_PostImage"));
			}
			return git.Apply().SetPatch(typeof(DiffFormatterReflowTest).GetResourceAsStream(name
				 + ".patch")).Call();
		}
Пример #7
0
		static string[] GetLineStrings (RawText text)
		{
			int lineCount = text.Size ();
			string[] lines = new string[lineCount];

			for (int i = 0; i < lineCount; i++) {
				lines [i] = text.GetString (i);
			}

			return lines;
		}
Пример #8
0
		static int[] GetDiffCodes (ref int codeCounter, Dictionary<string, int> codeDictionary, RawText text)
		{
			int lineCount = text.Size ();
			int[] result = new int[lineCount];
			string[] lines = GetLineStrings (text);
			for (int i = 0; i < lineCount; i++) {
				string lineText = lines [i];
				int curCode;
				if (!codeDictionary.TryGetValue (lineText, out curCode)) {
					codeDictionary [lineText] = curCode = ++codeCounter;
				}
				result [i] = curCode;
			}
			return result;
		}
Пример #9
0
 private bool IsEndOfLineMissing(RawText text, int line)
 {
     return(line + 1 == text.Size() && text.IsMissingNewlineAtEnd());
 }
Пример #10
0
        public virtual void TestEmpty()
        {
            RawText r = new RawText(new byte[0]);

            NUnit.Framework.Assert.AreEqual(0, r.Size());
        }
Пример #11
0
 public virtual void TestEmpty()
 {
     RawText r = new RawText(new byte[0]);
     NUnit.Framework.Assert.AreEqual(0, r.Size());
 }
Пример #12
0
		internal BlameResult(BlameGenerator bg, string path, RawText text)
		{
			generator = bg;
			resultPath = path;
			resultContents = text;
			int cnt = text.Size();
			sourceCommits = new RevCommit[cnt];
			sourceAuthors = new PersonIdent[cnt];
			sourceCommitters = new PersonIdent[cnt];
			sourceLines = new int[cnt];
			sourcePaths = new string[cnt];
		}