public virtual void TestCharSequenceInterface()
        {
            const string s = "0123456789";
            CharTermAttribute t = new CharTermAttribute();
            t.Append(s);

            Assert.AreEqual(s.Length, t.Length);
            Assert.AreEqual("12", t.SubSequence(1, 3).ToString());
            Assert.AreEqual(s, t.SubSequence(0, s.Length).ToString());

            Assert.IsTrue(Regex.IsMatch(t.ToString(), "01\\d+"));
            Assert.IsTrue(Regex.IsMatch(t.SubSequence(3, 5).ToString(), "34"));

            Assert.AreEqual(s.Substring(3, 4), t.SubSequence(3, 7).ToString());

            for (int i = 0; i < s.Length; i++)
            {
                Assert.IsTrue(t[i] == s[i]);
            }

            // LUCENENET specific to test indexer
            for (int i = 0; i < s.Length; i++)
            {
                Assert.IsTrue(t[i] == s[i]);
            }
        }
        public virtual void TestExceptions()
        {
            CharTermAttribute t = new CharTermAttribute();
            t.Append("test");
            Assert.AreEqual("test", t.ToString());

            try
            {
                var _ = t[-1];
                Assert.Fail("Should throw IndexOutOfBoundsException");
            }
            catch (System.IndexOutOfRangeException)
            {
            }

            try
            {
                var _ = t[4];
                Assert.Fail("Should throw IndexOutOfBoundsException");
            }
            catch (System.IndexOutOfRangeException)
            {
            }

            try
            {
                t.SubSequence(0, 5);
                Assert.Fail("Should throw IndexOutOfBoundsException");
            }
            catch (System.IndexOutOfRangeException)
            {
            }

            try
            {
                t.SubSequence(5, 0);
                Assert.Fail("Should throw IndexOutOfBoundsException");
            }
            catch (System.IndexOutOfRangeException)
            {
            }
        }