예제 #1
0
 public static void AreEqual(FilterableBuffer b1, FilterableBuffer b2)
 {
     if (!b1.CurrentWordSymbols.SequenceEqual(b2.CurrentWordSymbols))
     {
         Assert.IsTrue(false);
     }
     AreEqual(b1.Buffer, b2.Buffer);
 }
예제 #2
0
        public void TestBufferFilter_Punctuation1()
        {
            var primer = new FilterableBuffer();

            primer.Buffer = new char[] { 'a' };
            char[] original = new char[] { '(', 'a', ')', };
            AssertBufferFilter(0, true, original, primer);
        }
예제 #3
0
        public void TestFilterBufferTwoSpaces()
        {
            var primer = new FilterableBuffer();

            primer.Buffer = new char[] { 'a', ' ', ' ', 'b', };
            char[] original = new char[] { 'a', ' ', ' ', 'b', };
            AssertBufferFilter(1, false, original, primer);
        }
예제 #4
0
        public void TestBufferFilter2()
        {
            var primer = new FilterableBuffer();

            primer.CurrentWordSymbols = new Queue <char>(new[] { 'h', 'j' });
            primer.Buffer             = new char[] { 'a', 'b', 'c', ' ', '\n', };
            char[] original = new char[] { 'a', 'b', 'c', ' ', 'e', 'd', '\n',
                                           'f', 'g', ' ', 'h', 'j', };
            AssertBufferFilter(3, false, original, primer);
        }
예제 #5
0
        public void TestBufferFilter1()
        {
            var primer = new FilterableBuffer();

            primer.Buffer = new char[] { 'a', 'b', 'c', ' ', '\n',
                                         'h', 'j', 'k', };
            char[] original = new char[] { 'a', 'b', 'c', ' ', 'd', 'e', '\n',
                                           'f', 'g', ' ', 'h', 'j', 'k', };
            AssertBufferFilter(3, false, original, primer);
        }
예제 #6
0
        public void TestBufferFilter_Punctuation3()
        {
            var primer = new FilterableBuffer();

            primer.Buffer             = new char[] { 'a', ' ', 'b', };
            primer.CurrentWordSymbols = new Queue <char> {
            };
            char[] original = new char[] { 'a', ',', ' ', 'b', };
            AssertBufferFilter(0, true, original, primer);
        }
예제 #7
0
        public static void AssertBufferFilter(int wordLength, bool removing, char[] original, FilterableBuffer primer)
        {
            var filter = new TextFilter(wordLength, removing, original.Length);

            filter.FilterBuffer(original);
            CustomAssert.AreEqual(filter, primer);
        }