예제 #1
0
        public void Pop()
        {
            InterpreterStream stream = new InterpreterStream();

            try {
                stream.Pop();
                Assert.Fail();
            } catch (InvalidOperationException) {
            }
            stream.Push(new byte[] { 0x10, 0x20 });
            Assert.AreEqual(2, stream.Length);
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(1, stream.Depth);
            stream.Push(new byte[] { 0x30, 0x40, 0x50 });
            Assert.AreEqual(3, stream.Length);
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(2, stream.Depth);
            stream.Pop();
            Assert.AreEqual(2, stream.Length);
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(1, stream.Depth);
            stream.Pop();
            Assert.AreEqual(0, stream.Length);
            Assert.AreEqual(0, stream.Position);
            Assert.AreEqual(0, stream.Depth);
            try {
                stream.Pop();
                Assert.Fail();
            } catch (InvalidOperationException) {
            }
        }
예제 #2
0
        public void Length()
        {
            InterpreterStream stream = new InterpreterStream();

            Assert.AreEqual(0, stream.Length);
            stream.Push(new byte[] { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 });
            Assert.AreEqual(6, stream.Length);
            stream.Push(new byte[] { 0x10, 0x20, 0x30, 0x40 });
            Assert.AreEqual(4, stream.Length);
            stream.Pop();
            Assert.AreEqual(6, stream.Length);
            stream.Push(new byte[] { 0x10, 0x20 });
            Assert.AreEqual(2, stream.Length);
            stream.Pop();
            Assert.AreEqual(6, stream.Length);
            stream.Pop();
            Assert.AreEqual(0, stream.Length);
        }
예제 #3
0
        public void Next()
        {
            InterpreterStream stream = new InterpreterStream();

            Assert.AreEqual(0, stream.Next());
            stream.Push(new byte[] { 0x10, 0x20 });
            Assert.AreEqual(0x10, stream.Next());
            Assert.AreEqual(0x20, stream.Next());
            Assert.IsFalse(stream.HasNext());
            Assert.AreEqual(0, stream.Next());
            stream.Pop();
            Assert.IsFalse(stream.HasNext());
            Assert.AreEqual(0, stream.Next());
        }