public void TestInlineMarkerMatch()
        {
            StringTri stringTri = new StringTri();
            int nextIndex;
            bool isInline = true;

            MarkerSpec aimsAbc = MarkerSpec.CreateMarkerSpec("abc", "dummyMarker", "dummyData",
                isInline, null, null, null);
            MarkerSpec aimsAb = MarkerSpec.CreateMarkerSpec("ab", "dummyMarker", "dummyData",
                isInline, null, null, null);

            stringTri.Add(aimsAbc);
            stringTri.Add(aimsAb);

            // See if we can find an inline marker.
            Assert.AreEqual(aimsAbc, stringTri.Match("To abc this is the day",
                3, out nextIndex));
            Assert.AreEqual(6, nextIndex);

            // If we make ab inline we can find it.
            Assert.AreEqual(aimsAb, stringTri.Match("To ab this is the day",
                3, out nextIndex));
            Assert.AreEqual(5, nextIndex);

            // abc and ab now both match, but we want to find the longer one.
            Assert.AreEqual(aimsAbc, stringTri.Match("To abc this is the day",
                3, out nextIndex));
            Assert.AreEqual(6, nextIndex);

            // Minimal case, verifies we can match inline marker at start and end of line.
            Assert.AreEqual(aimsAb, stringTri.Match("ab", 0, out nextIndex));
            Assert.AreEqual(2, nextIndex);

            // Make sure we can match without a following space.
            Assert.AreEqual(aimsAb, stringTri.Match("To abXYZ", 3, out nextIndex));
            Assert.AreEqual(5, nextIndex);
        }
        public void TestFieldMarkerMatch()
        {
            StringTri stringTri = new StringTri();
            int nextIndex;
            bool isInline = false;

            MarkerSpec fmsAbc = MarkerSpec.CreateMarkerSpec("abc", "dummy1", "dummy2",
                isInline, null, null, null);
            MarkerSpec fmsAbd = MarkerSpec.CreateMarkerSpec("abd", "dummy1", "dummy2",
                isInline, null, null, null);
            MarkerSpec fmsAb = MarkerSpec.CreateMarkerSpec("ab", "dummy1", "dummy2",
                isInline, null, null, null);

            stringTri.Add(fmsAbc);
            stringTri.Add(fmsAbd);
            stringTri.Add(fmsAb);

            // Should find at start.
            Assert.AreEqual(fmsAbc, stringTri.Match("abc this is the day",	0, out nextIndex));
            Assert.AreEqual(4, nextIndex);

            // Should only absorb one space.
            Assert.AreEqual(fmsAbc, stringTri.Match("abc  this is the day", 0, out nextIndex));
            Assert.AreEqual(4, nextIndex);

            // Should match on closing newline, but no space to absorb.
            Assert.AreEqual(fmsAbc, stringTri.Match("abc", 0, out nextIndex));
            Assert.AreEqual(3, nextIndex);

            // Should fail with no white space following.
            Assert.IsNull(stringTri.Match("abcXYZ", 0, out nextIndex));
            Assert.AreEqual(1, nextIndex);

            // Should be able to find abd also
            Assert.AreEqual(fmsAbd, stringTri.Match("abd this is the day", 0, out nextIndex));
            Assert.AreEqual(4, nextIndex);

            // Should be able to find ab also
            Assert.AreEqual(fmsAb, stringTri.Match("ab this is the day", 0, out nextIndex));
            Assert.AreEqual(3, nextIndex);

            // Should not find except at start of line.
            Assert.IsNull(stringTri.Match("To abc this is the day", 3, out nextIndex));
            Assert.AreEqual(4, nextIndex);
        }