示例#1
0
        private bool Sink(string match, bool ignoreCase)
        {
            // Is there enough left for this match?
            if (_sources.IsPastEnd(_position + match.Length - 1))
            {
                return(false);
            }

            string compare = _sources.Substring(_position, match.Length);

            if
            (
                String.Equals
                (
                    match,
                    compare,
                    (ignoreCase /* ignore case */) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal
                )
            )
            {
                Skip(match.Length);
                return(true);
            }

            return(false);
        }
        public void Regress_Mutation_1DNotAppendedIfAlreadyThere()
        {
            RestartCountingStream stream = new RestartCountingStream(StreamHelpers.StringToStream("\xd"));
            StreamMappedString s = new StreamMappedString(stream, false);

            // There's only one \x1d so IsPastEnd(1) should be true.
            Assert.IsTrue(s.IsPastEnd(1));
        }
        public void Regress_Mutation_IsPastEndWorks()
        {
            RestartCountingStream stream = new RestartCountingStream(StreamHelpers.StringToStream("a"));
            StreamMappedString s = new StreamMappedString(stream, false);

            // There's only one character, so IsPastEnd(2) should be true.
            Assert.IsTrue(s.IsPastEnd(2)); // <-- 2 required because of extra \xd added.
        }