Skip to content

Instantly share code, notes, and snippets.

@dtinth
Created February 4, 2013 06:51
Show Gist options
  • Save dtinth/4705333 to your computer and use it in GitHub Desktop.
Save dtinth/4705333 to your computer and use it in GitHub Desktop.
Call Log Test
import static org.junit.Assert.*;
import org.junit.Test;
public class CallLogTest {
private CallLog log = new CallLog();
@Test
public void testSimple() {
log.record("1");
check("1");
}
@Test
public void testMultiple() {
log.record("1");
log.record("2");
check("2", "1");
}
@Test
public void testLimit() {
log.record("1");
log.record("2");
log.record("3");
log.record("4");
log.record("5");
log.record("6");
check("6", "5", "4", "3", "2");
}
@Test
public void testDuplicate() {
log.record("2");
log.record("2");
check("2");
}
@Test
public void testMultiDuplicate() {
log.record("1");
log.record("2");
log.record("3");
log.record("1");
log.record("1");
log.record("4");
log.record("2");
check("2", "4", "1", "3");
}
@Test
public void testLimit2() {
log.record("1");
log.record("2");
log.record("3");
log.record("4");
log.record("5");
log.record("6");
log.record("5");
check("5", "6", "4", "3", "2");
}
@Test
public void testExample() {
log.record("191");
log.record("1112");
log.record("1150");
log.record("191");
log.record("181");
log.record("1175");
log.record("1678");
log.record("181");
check("181", "1678", "1175", "191", "1150");
}
public void check(String... expecteds) {
assertArrayEquals(expecteds, log.getNumbers());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment