Beispiel #1
0
        private void CheckEncoding(RlePackets packets)
        {
            var stream = new MemoryStream(500);

            packets.WriteEncoding(stream);

            stream.Position = 0;
            packets.ReadAndCheckEncoding(stream);
        }
Beispiel #2
0
        public void RleWriterPairTest()
        {
            // Pairs encoded as repeats, within a string of repeats.
            var bracketedByRepeats = new RlePackets(new IRlePacket[]
            {
                new RepeatPacket(3, 'A'),
                new RepeatPacket(2, 'B'),
                new RepeatPacket(2, 'C'),
                new RepeatPacket(4, 'A')
            });

            CheckEncoding(bracketedByRepeats);

            // Pairs encoded as repeats, because they are followed but not
            // preceded by a literal.
            var followedByLiteral = new RlePackets(new IRlePacket[]
            {
                new RepeatPacket(5, 'Z'),
                new RepeatPacket(2, 'A'),
                new RepeatPacket(2, 'B'),
                new RepeatPacket(2, 'C'),
                new LiteralPacket("ZYZY")
            });

            CheckEncoding(followedByLiteral);
            var startsWithPairs = new RlePackets(new IRlePacket[]
            {
                new RepeatPacket(2, 'A'),
                new RepeatPacket(2, 'B'),
                new RepeatPacket(2, 'C'),
                new LiteralPacket("ZYZY")
            });

            CheckEncoding(startsWithPairs);

            // Pairs encoded as literal, because they are preceded by a literal.
            var precededByLiteral = new RlePackets(new IRlePacket[]
            {
                new LiteralPacket("ZYXAABBCC")
            });

            CheckEncoding(precededByLiteral);

            // Pairs encoded as literal, because they are bracketed by literals.
            var bracketedByLiterals = new RlePackets(new IRlePacket[]
            {
                new LiteralPacket("ZYXAABBZYX"),
                new RepeatPacket(5, 'Z')
            });

            CheckEncoding(bracketedByLiterals);
        }