Testing Two-Stack Queue Implementation in JCSprout
This test suite validates the implementation of a queue data structure using two stacks in Java. It demonstrates the core queue operations through a series of append and delete operations while verifying the FIFO behavior.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
crossoverjie/jcsprout
src/test/java/com/crossoverjie/algorithm/TwoStackQueueTest.java
package com.crossoverjie.algorithm;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TwoStackQueueTest {
private final static Logger LOGGER = LoggerFactory.getLogger(TwoStackQueueTest.class);
@Test
public void queue(){
TwoStackQueue<String> twoStackQueue = new TwoStackQueue<String>() ;
twoStackQueue.appendTail("1") ;
twoStackQueue.appendTail("2") ;
twoStackQueue.appendTail("3") ;
twoStackQueue.appendTail("4") ;
twoStackQueue.appendTail("5") ;
int size = twoStackQueue.getSize();
for (int i = 0; i< size ; i++){
LOGGER.info(twoStackQueue.deleteHead());
}
LOGGER.info("========第二次添加=========");
twoStackQueue.appendTail("6") ;
size = twoStackQueue.getSize();
for (int i = 0; i< size ; i++){
LOGGER.info(twoStackQueue.deleteHead());
}
}
}