Example #1
0
        public void WildcardMultiSegmentDoesNotYieldPrefix()
        {
            var glob  = new GlobParser().Parse("**");
            var start = new GlobMatchFactory(true).Start(glob);

            var prefix = start.GetPrefixFilter();

            Assert.That(prefix, Is.EqualTo(""));
        }
Example #2
0
        public void WildcardSegmentMatchesOnlyOnce()
        {
            var glob  = new GlobParser().Parse("dir*ory");
            var start = new GlobMatchFactory(true).Start(glob);

            var child = ApplyToHierarchy(start, "directory", "directory");

            Assert.That(child.IsMatch, Is.False);
            Assert.That(child.CanContinue, Is.False);
        }
Example #3
0
        public void WildcardMultiSegmentCanMatchNoSegments()
        {
            var glob  = new GlobParser().Parse("a/**/b");
            var start = new GlobMatchFactory(true).Start(glob);

            var child = ApplyToHierarchy(start, "a", "b");

            Assert.That(child.IsMatch, Is.True);
            Assert.That(child.CanContinue, Is.True);
            Assert.That(child.GetPathSegments().ToArray(), Is.EqualTo(new [] { "a", "b" }));
        }
Example #4
0
        public void WildcardMultiSegmentCanMatchMultipleDepths()
        {
            var glob  = new GlobParser().Parse("a/**/b/**/c");
            var start = new GlobMatchFactory(true).Start(glob);

            Assert.That(ApplyToHierarchy(start, "a", "b", "c").IsMatch, Is.True);
            Assert.That(ApplyToHierarchy(start, "a", "b", "c").GetPathSegments().ToArray(), Is.EqualTo(new [] { "a", "b", "c" }));

            Assert.That(ApplyToHierarchy(start, "a", "b", "c", "d").IsMatch, Is.False);

            Assert.That(ApplyToHierarchy(start, "a", "b", "c", "d", "c").IsMatch, Is.True);
            Assert.That(ApplyToHierarchy(start, "a", "b", "c", "d", "c").GetPathSegments().ToArray(), Is.EqualTo(new [] { "a", "b", "c", "d", "c" }));

            Assert.That(ApplyToHierarchy(start, "a", "c").IsMatch, Is.False);

            Assert.That(ApplyToHierarchy(start, "a", "d", "b", "c").IsMatch, Is.True);
            Assert.That(ApplyToHierarchy(start, "a", "d", "b", "c").GetPathSegments().ToArray(), Is.EqualTo(new [] { "a", "d", "b", "c" }));
        }