Example #1
0
        public void testFindSingleFile()
        {
            string          path = "a-File-path";
            DirCache        dc   = DirCache.read(db);
            DirCacheBuilder b    = dc.builder();

            Assert.IsNotNull(b);

            DirCacheEntry entOrig = new DirCacheEntry(path);

            entOrig.setFileMode(FileMode.RegularFile);
            Assert.AreNotSame(path, entOrig.getPathString());
            Assert.AreEqual(path, entOrig.getPathString());
            b.add(entOrig);
            b.finish();

            Assert.AreEqual(1, dc.getEntryCount());
            Assert.AreSame(entOrig, dc.getEntry(0));
            Assert.AreEqual(0, dc.findEntry(path));

            Assert.AreEqual(-1, dc.findEntry("@@-before"));
            Assert.AreEqual(0, real(dc.findEntry("@@-before")));

            Assert.AreEqual(-2, dc.findEntry("a-zoo"));
            Assert.AreEqual(1, real(dc.findEntry("a-zoo")));

            Assert.AreSame(entOrig, dc.getEntry(path));
        }
Example #2
0
        public void testFindOnEmpty()
        {
            DirCache dc = DirCache.newInCore();

            byte[] path = Constants.encode("a");
            Assert.AreEqual(-1, dc.findEntry(path, path.Length));
        }
Example #3
0
        public void testAdd_ReverseGitSortOrder()
        {
            DirCache dc = DirCache.read(db);

            string[]        paths = { "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].setFileMode(FileMode.RegularFile);
            }

            DirCacheBuilder b = dc.builder();

            for (int i = ents.Length - 1; i >= 0; i--)
            {
                b.add(ents[i]);
            }
            b.finish();

            Assert.AreEqual(paths.Length, dc.getEntryCount());
            for (int i = 0; i < paths.Length; i++)
            {
                Assert.AreSame(ents[i], dc.getEntry(i));
                Assert.AreEqual(paths[i], dc.getEntry(i).getPathString());
                Assert.AreEqual(i, dc.findEntry(paths[i]));
                Assert.AreSame(ents[i], dc.getEntry(paths[i]));
            }
        }