1 // Tags: JDK1.4 |
|
2 |
|
3 // Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com> |
|
4 |
|
5 // This file is part of Mauve. |
|
6 |
|
7 // Mauve is free software; you can redistribute it and/or modify |
|
8 // it under the terms of the GNU General Public License as published by |
|
9 // the Free Software Foundation; either version 2, or (at your option) |
|
10 // any later version. |
|
11 |
|
12 // Mauve is distributed in the hope that it will be useful, |
|
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 // GNU General Public License for more details. |
|
16 |
|
17 // You should have received a copy of the GNU General Public License |
|
18 // along with Mauve; see the file COPYING. If not, write to |
|
19 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
20 // Boston, MA 02111-1307, USA. */ |
|
21 |
|
22 package gnu.testlet.java.util.Collections; |
|
23 |
|
24 import gnu.testlet.TestHarness; |
|
25 import gnu.testlet.Testlet; |
|
26 |
|
27 import java.util.ArrayList; |
|
28 import java.util.Collections; |
|
29 import java.util.List; |
|
30 |
|
31 public class rotate implements Testlet |
|
32 { |
|
33 |
|
34 public void test(TestHarness harness) |
|
35 { |
|
36 List list1 = new ArrayList(); |
|
37 list1.add("t"); list1.add("a"); list1.add("n"); list1.add("k"); list1.add("s"); |
|
38 List list2 = new ArrayList(); |
|
39 list2.add("s"); list2.add("t"); list2.add("a"); list2.add("n"); list2.add("k"); |
|
40 Collections.rotate(list1, -4); |
|
41 harness.check(list1.equals(list2)); // check 1 |
|
42 |
|
43 // try an empty list |
|
44 list1 = new ArrayList(); |
|
45 Collections.rotate(list1, 2); |
|
46 harness.check(list1.isEmpty()); // check 2 |
|
47 |
|
48 // try a null list |
|
49 boolean pass = false; |
|
50 try |
|
51 { |
|
52 Collections.rotate(null, 2); |
|
53 } |
|
54 catch (NullPointerException e) |
|
55 { |
|
56 pass = true; |
|
57 } |
|
58 harness.check(pass); // check 3 |
|
59 |
|
60 // try an unmodifiable list |
|
61 list1 = Collections.unmodifiableList(list1); |
|
62 pass = false; |
|
63 try |
|
64 { |
|
65 Collections.rotate(null, 2); |
|
66 } |
|
67 catch (NullPointerException e) |
|
68 { |
|
69 pass = true; |
|
70 } |
|
71 harness.check(pass); // check 4 |
|
72 |
|
73 } |
|
74 } |
|