public void MyCircularQueueTestCase1() { var queue = new MyCircularQueue(3); queue.IsEmpty().Should().BeTrue(); queue.EnQueue(1).Should().BeTrue(); queue.ToString().Should().Be("1"); queue.Rear().Should().Be(1); queue.Front().Should().Be(1); queue.EnQueue(2).Should().BeTrue(); queue.ToString().Should().Be("1, 2"); queue.Front().Should().Be(1); queue.EnQueue(3).Should().BeTrue(); queue.ToString().Should().Be("1, 2, 3"); queue.EnQueue(4).Should().BeFalse(); queue.Front().Should().Be(1); queue.Rear().Should().Be(3); queue.IsFull().Should().BeTrue(); queue.DeQueue().Should().BeTrue(); queue.ToString().Should().Be("2, 3"); queue.Front().Should().Be(2); queue.EnQueue(4).Should().BeTrue(); queue.ToString().Should().Be("2, 3, 4"); queue.Rear().Should().Be(4); queue.Front().Should().Be(2); queue.DeQueue().Should().BeTrue(); queue.DeQueue().Should().BeTrue(); queue.DeQueue().Should().BeTrue(); queue.DeQueue().Should().BeFalse(); queue.IsEmpty().Should().BeTrue(); queue.IsFull().Should().BeFalse(); queue.EnQueue(1).Should().BeTrue(); queue.IsEmpty().Should().BeFalse(); }
public void Check_MyCircularQueue_BaseCase() { MyCircularQueue circularQueue = new MyCircularQueue(3); Assert.IsTrue(circularQueue.EnQueue(1)); // return true Assert.IsTrue(circularQueue.EnQueue(2)); // return true Assert.IsTrue(circularQueue.EnQueue(3)); // return true Assert.IsFalse(circularQueue.EnQueue(4)); // return false, the queue is full Assert.IsTrue(circularQueue.Rear() == 3); // return 3 Assert.IsTrue(circularQueue.IsFull()); // return true Assert.IsTrue(circularQueue.DeQueue()); // return true Assert.IsTrue(circularQueue.EnQueue(4)); // return true Assert.IsTrue(circularQueue.Rear() == 4); // return 4 }
static void Main(string[] args) { MyCircularQueue obj = new MyCircularQueue(3); bool param_1 = obj.EnQueue(7); bool param_7 = obj.DeQueue(); int front1 = obj.Front(); bool param_8 = obj.DeQueue(); int front2 = obj.Front(); int rear = obj.Rear(); bool param_2 = obj.EnQueue(0); bool isfull = obj.IsFull(); bool param_9 = obj.DeQueue(); int rear2 = obj.Rear(); bool param_10 = obj.EnQueue(3); }
public void dequeueTest() { MyCircularQueue c = new MyCircularQueue(5); Assert.False(c.DeQueue()); Assert.Equal(-1, c.Rear()); Assert.True(c.EnQueue(1)); Assert.Equal(1, c.Rear()); Assert.True(c.EnQueue(2)); Assert.Equal(2, c.Rear()); Assert.True(c.DeQueue()); Assert.True(c.DeQueue()); Assert.False(c.DeQueue()); Assert.Equal(-1, c.Front()); Assert.Equal(-1, c.Front()); }
public void REARFRONTTest() { MyCircularQueue c = new MyCircularQueue(5); Assert.True(c.EnQueue(36)); Assert.True(c.EnQueue(42)); Assert.True(c.EnQueue(56)); Assert.Equal(36, c.Front()); Assert.Equal(56, c.Rear()); Assert.True(c.DeQueue()); Assert.Equal(42, c.Front()); Assert.True(c.DeQueue()); Assert.Equal(56, c.Front()); Assert.Equal(56, c.Rear()); Assert.True(c.DeQueue()); Assert.Equal(-1, c.Front()); Assert.Equal(-1, c.Rear()); }
public void ST_MyCircularQueue_Test() { var _q = new MyCircularQueue(5); _q.EnQueue(1); _q.EnQueue(2); _q.EnQueue(3); _q.EnQueue(4); _q.EnQueue(5); Assert.False(_q.EnQueue(6)); Assert.Equal(1, _q.Front()); Assert.Equal(5, _q.Rear()); Assert.True(_q.IsFull()); Assert.True(_q.DeQueue()); Assert.True(_q.DeQueue()); Assert.True(_q.EnQueue(6)); Assert.True(_q.EnQueue(7)); Assert.True(_q.IsFull()); Assert.False(_q.EnQueue(8)); _q.DeQueue(); _q.DeQueue(); _q.DeQueue(); _q.DeQueue(); Assert.True(_q.Front() == 7 && _q.Rear() == 7); _q.DeQueue(); Assert.True(_q.IsEmpty()); MyCircularQueue circularQueue = new MyCircularQueue(2); circularQueue.EnQueue(8); circularQueue.EnQueue(8); var a = circularQueue.Front(); circularQueue.EnQueue(4); circularQueue.DeQueue(); circularQueue.EnQueue(1); circularQueue.EnQueue(1); circularQueue.DeQueue(); Assert.True(circularQueue.Front() == 1 && circularQueue.Rear() == 1); }
public void Test2() { //["MyCircularQueue","enQueue","Rear","Rear","deQueue","enQueue","Rear","deQueue","Front","deQueue","deQueue","deQueue"] // [[6],[6],[],[],[],[5],[],[],[],[],[],[]] MyCircularQueue obj = new MyCircularQueue(6); bool param_1 = obj.EnQueue(6); int r_1 = obj.Rear(); int r_2 = obj.Rear(); bool d_1 = obj.DeQueue(); bool param_2 = obj.EnQueue(5); int r_3 = obj.Rear(); bool d_2 = obj.DeQueue(); int f_1 = obj.Front(); bool d_3 = obj.DeQueue(); bool d_4 = obj.DeQueue(); bool d_5 = obj.DeQueue(); }
public void enquedequeUnitTest() { MyCircularQueue c = new MyCircularQueue(2); Assert.True(c.EnQueue(4)); Assert.Equal(4, c.Rear()); Assert.True(c.EnQueue(9)); Assert.True(c.DeQueue()); Assert.Equal(9, c.Front()); Assert.True(c.DeQueue()); Assert.True(c.IsEmpty()); Assert.False(c.DeQueue()); Assert.True(c.EnQueue(6)); Assert.True(c.EnQueue(4)); }
public void Test1() { MyCircularQueue obj = new MyCircularQueue(3); bool param_1 = obj.EnQueue(1); bool param_2 = obj.EnQueue(2); bool param_3 = obj.EnQueue(3); bool param_4 = obj.EnQueue(4); bool d_1 = obj.DeQueue(); bool param_5 = obj.EnQueue(4); bool d_2 = obj.DeQueue(); bool d_3 = obj.DeQueue(); bool d_4 = obj.DeQueue(); bool d_5 = obj.DeQueue(); int f_1 = obj.Front(); int r_1 = obj.Rear(); bool e_1 = obj.IsEmpty(); bool full_1 = obj.IsFull(); }
public void enqueueTest() { MyCircularQueue c = new MyCircularQueue(6); Assert.True(c.EnQueue(1)); Assert.Equal(1, c.Rear()); Assert.True(c.EnQueue(2)); Assert.Equal(2, c.Rear()); Assert.True(c.EnQueue(3)); Assert.Equal(3, c.Rear()); Assert.True(c.EnQueue(4)); Assert.Equal(4, c.Rear()); Assert.True(c.EnQueue(5)); Assert.Equal(5, c.Rear()); Assert.True(c.EnQueue(6)); Assert.True(c.DeQueue()); Assert.Equal(2, c.Front()); Assert.True(c.EnQueue(6)); Assert.Equal(6, c.Rear()); }
public void RearTest() { Assert.AreEqual(5, circularQueue.Rear()); }