ReadByte() 공개 메소드

Read a byte from the buffer.
public ReadByte ( ) : int
리턴 int
예제 #1
0
        public void Basic()
        {
            const int Size = 64;

            buffer_ = new ReadWriteRingBuffer(Size);

            Assert.IsFalse(buffer_.IsFull);
            Assert.IsTrue(buffer_.IsEmpty);

            buffer_.WriteByte(1);

            Assert.IsFalse(buffer_.IsFull);
            Assert.IsFalse(buffer_.IsEmpty);
            Assert.AreEqual(1, buffer_.Count);

            Assert.AreEqual(1, buffer_.ReadByte());

            Assert.IsFalse(buffer_.IsFull);
            Assert.IsTrue(buffer_.IsEmpty);

            for (int i = 0; i < buffer_.Length; ++i)
            {
                buffer_.WriteByte(unchecked ((byte)(i & 0xff)));
            }

            Assert.IsTrue(buffer_.IsFull);
            Assert.IsFalse(buffer_.IsEmpty);

            buffer_.Close();

            Assert.IsTrue(buffer_.IsClosed);

            bool caught = false;

            try
            {
                buffer_.WriteByte(1);
            }
            catch
            {
                caught = true;
            }

            Assert.IsTrue(caught);

            int count    = Size;
            int expected = 0;

            while (count != 0)
            {
                Assert.AreEqual(count, buffer_.Count);
                Assert.AreEqual(expected, buffer_.ReadByte());
                count--;
                expected = (expected + 1) & 0xff;
            }

            Assert.IsTrue(buffer_.IsEmpty);
            Assert.AreEqual(-1, buffer_.ReadByte());
        }
예제 #2
0
		public void Basic()
		{
			const int Size = 64;

			buffer_ = new ReadWriteRingBuffer(Size);

			Assert.IsFalse(buffer_.IsFull);
			Assert.IsTrue(buffer_.IsEmpty);

			buffer_.WriteByte(1);

			Assert.IsFalse(buffer_.IsFull);
			Assert.IsFalse(buffer_.IsEmpty);
			Assert.AreEqual(1, buffer_.Count);

			Assert.AreEqual(1, buffer_.ReadByte());

			Assert.IsFalse(buffer_.IsFull);
			Assert.IsTrue(buffer_.IsEmpty);

			for (int i = 0; i < buffer_.Length; ++i)
			{
				buffer_.WriteByte(unchecked((byte)(i & 0xff)));
			}

			Assert.IsTrue(buffer_.IsFull);
			Assert.IsFalse(buffer_.IsEmpty);

			buffer_.Close();

			Assert.IsTrue(buffer_.IsClosed);

			bool caught = false;
			try
			{
				buffer_.WriteByte(1);
			}
			catch
			{
				caught = true;
			}

			Assert.IsTrue(caught);

			int count = Size;
			int expected = 0;

			while (count != 0)
			{
				Assert.AreEqual(count, buffer_.Count);
				Assert.AreEqual(expected, buffer_.ReadByte());
				count--;
				expected = (expected + 1) & 0xff;
			}

			Assert.IsTrue(buffer_.IsEmpty);
			Assert.AreEqual(-1, buffer_.ReadByte());
		}