[518] | 1 | package de.ugoe.cs.quest.usageprofiles;
|
---|
| 2 |
|
---|
| 3 | import java.util.ArrayList;
|
---|
| 4 | import java.util.List;
|
---|
| 5 | import org.junit.*;
|
---|
| 6 |
|
---|
| 7 | import de.ugoe.cs.quest.usageprofiles.IncompleteMemory;
|
---|
| 8 | import static org.junit.Assert.*;
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * The class <code>IncompleteMemoryTest</code> contains tests for the class <code>{@link IncompleteMemory}</code>.
|
---|
| 12 | *
|
---|
| 13 | * @author Steffen Herbold
|
---|
| 14 | * @version 1.0
|
---|
| 15 | */
|
---|
| 16 | public class IncompleteMemoryTest {
|
---|
| 17 |
|
---|
| 18 | @Test
|
---|
| 19 | public void testIncompleteMemory_1()
|
---|
| 20 | throws Exception {
|
---|
| 21 | int length = 1;
|
---|
| 22 |
|
---|
| 23 | IncompleteMemory<String> result = new IncompleteMemory<String>(length);
|
---|
| 24 |
|
---|
| 25 | assertNotNull(result);
|
---|
| 26 | assertEquals(0, result.getLast(1).size());
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | @Test(expected = java.security.InvalidParameterException.class)
|
---|
| 30 | public void testIncompleteMemory_2()
|
---|
| 31 | throws Exception {
|
---|
| 32 | int length = 0;
|
---|
| 33 |
|
---|
| 34 | new IncompleteMemory<String>(length);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | @Test
|
---|
| 38 | public void testGetLast_1()
|
---|
| 39 | throws Exception {
|
---|
| 40 | int length = 2;
|
---|
| 41 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 42 | fixture.add("1");
|
---|
| 43 | fixture.add("2");
|
---|
| 44 | fixture.add("3");
|
---|
| 45 | int num = -1;
|
---|
| 46 |
|
---|
| 47 | List<String> result = fixture.getLast(num);
|
---|
| 48 |
|
---|
| 49 | assertNotNull(result);
|
---|
| 50 | assertEquals(0, result.size());
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | @Test
|
---|
| 54 | public void testGetLast_2()
|
---|
| 55 | throws Exception {
|
---|
| 56 | int length = 2;
|
---|
| 57 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 58 | fixture.add("1");
|
---|
| 59 | fixture.add("2");
|
---|
| 60 | fixture.add("3");
|
---|
| 61 | int num = 1;
|
---|
| 62 |
|
---|
| 63 | List<String> expected = new ArrayList<String>();
|
---|
| 64 | expected.add("3");
|
---|
| 65 |
|
---|
| 66 | List<String> result = fixture.getLast(num);
|
---|
| 67 |
|
---|
| 68 | assertNotNull(result);
|
---|
| 69 | assertEquals(expected, result);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | @Test
|
---|
| 73 | public void testGetLast_3()
|
---|
| 74 | throws Exception {
|
---|
| 75 | int length = 2;
|
---|
| 76 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 77 | fixture.add("1");
|
---|
| 78 | fixture.add("2");
|
---|
| 79 | fixture.add("3");
|
---|
| 80 | int num = 2;
|
---|
| 81 |
|
---|
| 82 | List<String> expected = new ArrayList<String>();
|
---|
| 83 | expected.add("2");
|
---|
| 84 | expected.add("3");
|
---|
| 85 |
|
---|
| 86 | List<String> result = fixture.getLast(num);
|
---|
| 87 |
|
---|
| 88 | assertNotNull(result);
|
---|
| 89 | assertEquals(expected, result);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | @Test
|
---|
| 93 | public void testGetLast_4()
|
---|
| 94 | throws Exception {
|
---|
| 95 | int length = 2;
|
---|
| 96 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 97 | fixture.add("1");
|
---|
| 98 | fixture.add("2");
|
---|
| 99 | fixture.add("3");
|
---|
| 100 | int num = 3;
|
---|
| 101 |
|
---|
| 102 | List<String> expected = new ArrayList<String>();
|
---|
| 103 | expected.add("2");
|
---|
| 104 | expected.add("3");
|
---|
| 105 |
|
---|
| 106 | List<String> result = fixture.getLast(num);
|
---|
| 107 |
|
---|
| 108 | assertNotNull(result);
|
---|
| 109 | assertEquals(expected, result);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | @Test
|
---|
| 113 | public void testGetLength_1()
|
---|
| 114 | throws Exception {
|
---|
| 115 | int length = 2;
|
---|
| 116 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 117 |
|
---|
| 118 | int result = fixture.getLength();
|
---|
| 119 |
|
---|
| 120 | assertEquals(0, result);
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | @Test
|
---|
| 124 | public void testGetLength_2()
|
---|
| 125 | throws Exception {
|
---|
| 126 | int length = 2;
|
---|
| 127 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 128 | fixture.add("1");
|
---|
| 129 |
|
---|
| 130 | int result = fixture.getLength();
|
---|
| 131 |
|
---|
| 132 | assertEquals(1, result);
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | @Test
|
---|
| 136 | public void testGetLength_3()
|
---|
| 137 | throws Exception {
|
---|
| 138 | int length = 2;
|
---|
| 139 | IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
|
---|
| 140 | fixture.add("1");
|
---|
| 141 | fixture.add("2");
|
---|
| 142 | fixture.add("3");
|
---|
| 143 |
|
---|
| 144 | int result = fixture.getLength();
|
---|
| 145 |
|
---|
| 146 | assertEquals(2, result);
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | public static void main(String[] args) {
|
---|
| 150 | new org.junit.runner.JUnitCore().run(IncompleteMemoryTest.class);
|
---|
| 151 | }
|
---|
| 152 | } |
---|