예제 #1
0
        public virtual void TestAdd_ReverseGitSortOrder()
        {
            DirCache dc = db.ReadDirCache();

            string[]        paths = new string[] { "a.", "a.b", "a/b", "a0b" };
            DirCacheEntry[] ents  = new DirCacheEntry[paths.Length];
            for (int i = 0; i < paths.Length; i++)
            {
                ents[i]          = new DirCacheEntry(paths[i]);
                ents[i].FileMode = FileMode.REGULAR_FILE;
            }
            DirCacheBuilder b = dc.Builder();

            for (int i_1 = ents.Length - 1; i_1 >= 0; i_1--)
            {
                b.Add(ents[i_1]);
            }
            b.Finish();
            NUnit.Framework.Assert.AreEqual(paths.Length, dc.GetEntryCount());
            for (int i_2 = 0; i_2 < paths.Length; i_2++)
            {
                NUnit.Framework.Assert.AreSame(ents[i_2], dc.GetEntry(i_2));
                NUnit.Framework.Assert.AreEqual(paths[i_2], dc.GetEntry(i_2).PathString);
                NUnit.Framework.Assert.AreEqual(i_2, dc.FindEntry(paths[i_2]));
                NUnit.Framework.Assert.AreSame(ents[i_2], dc.GetEntry(paths[i_2]));
            }
        }
예제 #2
0
        public virtual void TestFindOnEmpty()
        {
            DirCache dc = DirCache.NewInCore();

            byte[] path = Constants.Encode("a");
            NUnit.Framework.Assert.AreEqual(-1, dc.FindEntry(path, path.Length));
        }
예제 #3
0
        public virtual void TestFindSingleFile()
        {
            string          path = "a-file-path";
            DirCache        dc   = db.ReadDirCache();
            DirCacheBuilder b    = dc.Builder();

            NUnit.Framework.Assert.IsNotNull(b);
            DirCacheEntry entOrig = new DirCacheEntry(path);

            entOrig.FileMode = FileMode.REGULAR_FILE;
            NUnit.Framework.Assert.AreNotSame(path, entOrig.PathString);
            NUnit.Framework.Assert.AreEqual(path, entOrig.PathString);
            b.Add(entOrig);
            b.Finish();
            NUnit.Framework.Assert.AreEqual(1, dc.GetEntryCount());
            NUnit.Framework.Assert.AreSame(entOrig, dc.GetEntry(0));
            NUnit.Framework.Assert.AreEqual(0, dc.FindEntry(path));
            NUnit.Framework.Assert.AreEqual(-1, dc.FindEntry("@@-before"));
            NUnit.Framework.Assert.AreEqual(0, Real(dc.FindEntry("@@-before")));
            NUnit.Framework.Assert.AreEqual(-2, dc.FindEntry("a-zoo"));
            NUnit.Framework.Assert.AreEqual(1, Real(dc.FindEntry("a-zoo")));
            NUnit.Framework.Assert.AreSame(entOrig, dc.GetEntry(path));
        }