source: trunk/autoquest-core-usageprofiles-test/src/test/java/de/ugoe/cs/autoquest/usageprofiles/IncompleteMemoryTest.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 4.0 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.usageprofiles;
16
17import java.util.ArrayList;
18import java.util.List;
19import org.junit.*;
20
21import de.ugoe.cs.autoquest.usageprofiles.IncompleteMemory;
22import static org.junit.Assert.*;
23
24/**
25 * The class <code>IncompleteMemoryTest</code> contains tests for the class <code>{@link IncompleteMemory}</code>.
26 *
27 * @author Steffen Herbold
28 * @version 1.0
29 */
30public class IncompleteMemoryTest {
31
32        @Test
33        public void testIncompleteMemory_1()
34                throws Exception {
35                int length = 1;
36
37                IncompleteMemory<String> result = new IncompleteMemory<String>(length);
38
39                assertNotNull(result);
40                assertEquals(0, result.getLast(1).size());
41        }
42
43        @Test(expected = java.lang.IllegalArgumentException.class)
44        public void testIncompleteMemory_2()
45                throws Exception {
46                int length = 0;
47
48                new IncompleteMemory<String>(length);
49        }
50
51        @Test
52        public void testGetLast_1()
53                throws Exception {
54                int length = 2;
55                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
56                fixture.add("1");
57                fixture.add("2");
58                fixture.add("3");
59                int num = -1;
60
61                List<String> result = fixture.getLast(num);
62
63                assertNotNull(result);
64                assertEquals(0, result.size());
65        }
66
67        @Test
68        public void testGetLast_2()
69                throws Exception {
70                int length = 2;
71                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
72                fixture.add("1");
73                fixture.add("2");
74                fixture.add("3");
75                int num = 1;
76               
77                List<String> expected = new ArrayList<String>();
78                expected.add("3");
79
80                List<String> result = fixture.getLast(num);
81
82                assertNotNull(result);
83                assertEquals(expected, result);
84        }
85
86        @Test
87        public void testGetLast_3()
88                throws Exception {
89                int length = 2;
90                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
91                fixture.add("1");
92                fixture.add("2");
93                fixture.add("3");
94                int num = 2;
95               
96                List<String> expected = new ArrayList<String>();
97                expected.add("2");
98                expected.add("3");
99
100                List<String> result = fixture.getLast(num);
101
102                assertNotNull(result);
103                assertEquals(expected, result);
104        }
105       
106        @Test
107        public void testGetLast_4()
108                throws Exception {
109                int length = 2;
110                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
111                fixture.add("1");
112                fixture.add("2");
113                fixture.add("3");
114                int num = 3;
115               
116                List<String> expected = new ArrayList<String>();
117                expected.add("2");
118                expected.add("3");
119
120                List<String> result = fixture.getLast(num);
121
122                assertNotNull(result);
123                assertEquals(expected, result);
124        }
125
126        @Test
127        public void testGetLength_1()
128                throws Exception {
129                int length = 2;
130                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
131               
132                int result = fixture.getLength();
133
134                assertEquals(0, result);
135        }
136       
137        @Test
138        public void testGetLength_2()
139                throws Exception {
140                int length = 2;
141                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
142                fixture.add("1");
143               
144                int result = fixture.getLength();
145
146                assertEquals(1, result);
147        }
148       
149        @Test
150        public void testGetLength_3()
151                throws Exception {
152                int length = 2;
153                IncompleteMemory<String> fixture = new IncompleteMemory<String>(length);
154                fixture.add("1");
155                fixture.add("2");
156                fixture.add("3");
157               
158                int result = fixture.getLength();
159
160                assertEquals(2, result);
161        }
162
163        public static void main(String[] args) {
164                new org.junit.runner.JUnitCore().run(IncompleteMemoryTest.class);
165        }
166}
Note: See TracBrowser for help on using the repository browser.