Esempio n. 1
0
        public void WriteUtf8CompositeWrapped()
        {
            string utf8 = "Some UTF-8 like äÄ∏ŒŒ";
            var    buf  = Unpooled.Buffer(16);

            buf.WriteBytes(TextEncodings.UTF8NoBOM.GetBytes(utf8));
            var buf2 = new WrappedCompositeByteBuffer(Unpooled.CompositeBuffer().AddComponent(
                                                          Unpooled.Buffer(8)).AddComponent(Unpooled.Buffer(24)));

            // write some byte so we start writing with an offset.
            buf2.WriteByte(1);
            ByteBufferUtil.WriteUtf8(buf2, utf8);

            // Skip the previously written byte.
            Assert.Equal(buf, buf2.SkipBytes(1));

            buf.Release();
            buf2.Release();
        }
Esempio n. 2
0
        public void WriteUsAsciiCompositeWrapped()
        {
            string usAscii = "NettyRocks";
            var    buf     = Unpooled.Buffer(16);

            buf.WriteBytes(Encoding.ASCII.GetBytes(usAscii));
            var buf2 = new WrappedCompositeByteBuffer(Unpooled.CompositeBuffer().AddComponent(
                                                          Unpooled.Buffer(8)).AddComponent(Unpooled.Buffer(24)));

            // write some byte so we start AddComponent with an offset.
            buf2.WriteByte(1);
            ByteBufferUtil.WriteAscii(buf2, usAscii);

            // Skip the previously written byte.
            Assert.Equal(buf, buf2.SkipBytes(1));

            buf.Release();
            buf2.Release();
        }