package de.ugoe.cs.quest.usageprofiles; import java.util.ArrayList; import java.util.List; import org.junit.*; import de.ugoe.cs.quest.usageprofiles.IncompleteMemory; import static org.junit.Assert.*; /** * The class IncompleteMemoryTest contains tests for the class {@link IncompleteMemory}. * * @author Steffen Herbold * @version 1.0 */ public class IncompleteMemoryTest { @Test public void testIncompleteMemory_1() throws Exception { int length = 1; IncompleteMemory result = new IncompleteMemory(length); assertNotNull(result); assertEquals(0, result.getLast(1).size()); } @Test(expected = java.security.InvalidParameterException.class) public void testIncompleteMemory_2() throws Exception { int length = 0; new IncompleteMemory(length); } @Test public void testGetLast_1() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); fixture.add("1"); fixture.add("2"); fixture.add("3"); int num = -1; List result = fixture.getLast(num); assertNotNull(result); assertEquals(0, result.size()); } @Test public void testGetLast_2() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); fixture.add("1"); fixture.add("2"); fixture.add("3"); int num = 1; List expected = new ArrayList(); expected.add("3"); List result = fixture.getLast(num); assertNotNull(result); assertEquals(expected, result); } @Test public void testGetLast_3() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); fixture.add("1"); fixture.add("2"); fixture.add("3"); int num = 2; List expected = new ArrayList(); expected.add("2"); expected.add("3"); List result = fixture.getLast(num); assertNotNull(result); assertEquals(expected, result); } @Test public void testGetLast_4() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); fixture.add("1"); fixture.add("2"); fixture.add("3"); int num = 3; List expected = new ArrayList(); expected.add("2"); expected.add("3"); List result = fixture.getLast(num); assertNotNull(result); assertEquals(expected, result); } @Test public void testGetLength_1() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); int result = fixture.getLength(); assertEquals(0, result); } @Test public void testGetLength_2() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); fixture.add("1"); int result = fixture.getLength(); assertEquals(1, result); } @Test public void testGetLength_3() throws Exception { int length = 2; IncompleteMemory fixture = new IncompleteMemory(length); fixture.add("1"); fixture.add("2"); fixture.add("3"); int result = fixture.getLength(); assertEquals(2, result); } public static void main(String[] args) { new org.junit.runner.JUnitCore().run(IncompleteMemoryTest.class); } }