1 /* Copyright (C) 2001 ACUNIA |
|
2 |
|
3 This file is part of Mauve. |
|
4 |
|
5 Mauve is free software; you can redistribute it and/or modify |
|
6 it under the terms of the GNU General Public License as published by |
|
7 the Free Software Foundation; either version 2, or (at your option) |
|
8 any later version. |
|
9 |
|
10 Mauve is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 GNU General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU General Public License |
|
16 along with Mauve; see the file COPYING. If not, write to |
|
17 the Free Software Foundation, 59 Temple Place - Suite 330, |
|
18 Boston, MA 02111-1307, USA. |
|
19 */ |
|
20 |
|
21 // Tags: JDK1.2 |
|
22 |
|
23 package gnu.testlet.java.util.AbstractSet; |
|
24 |
|
25 import gnu.testlet.Testlet; |
|
26 import gnu.testlet.TestHarness; |
|
27 |
|
28 import java.util.*; |
|
29 |
|
30 /** |
|
31 * Written by ACUNIA. <br> |
|
32 * <br> |
|
33 * this file contains test for java.util.AbstractSet <br> |
|
34 * |
|
35 */ |
|
36 public class AcuniaAbstractSetTest extends AbstractSet implements Testlet |
|
37 { |
|
38 protected TestHarness th; |
|
39 |
|
40 public void test (TestHarness harness) |
|
41 { |
|
42 th = harness; |
|
43 test_equals(); |
|
44 test_hashCode(); |
|
45 } |
|
46 |
|
47 |
|
48 /** |
|
49 * implemented. <br> |
|
50 * |
|
51 */ |
|
52 public void test_equals(){ |
|
53 th.checkPoint("equals(java.lang.Object)boolean"); |
|
54 AcuniaAbstractSetTest xas1 = new AcuniaAbstractSetTest(); |
|
55 AcuniaAbstractSetTest xas2 = new AcuniaAbstractSetTest(); |
|
56 th.check( xas1.equals(xas2) , "checking equality -- 1"); |
|
57 th.check(!xas1.equals(null) , "checking equality -- 2"); |
|
58 th.check(!xas1.equals(new Object()) , "checking equality -- 3"); |
|
59 th.check( xas1.equals(xas1) , "checking equality -- 4"); |
|
60 xas1.v.add(null); |
|
61 xas1.v.add("a"); |
|
62 xas2.v.add("b"); |
|
63 xas2.v.add(null); |
|
64 xas2.v.add("a"); |
|
65 xas1.v.add("b"); |
|
66 th.check( xas1.equals(xas2) , "checking equality -- 5"); |
|
67 th.check( xas1.equals(xas1) , "checking equality -- 6"); |
|
68 |
|
69 |
|
70 } |
|
71 /** |
|
72 * implemented. <br> |
|
73 * |
|
74 */ |
|
75 public void test_hashCode(){ |
|
76 th.checkPoint("hashCode()int"); |
|
77 AcuniaAbstractSetTest xas = new AcuniaAbstractSetTest(); |
|
78 th.check(xas.hashCode() == 0 ,"checking hc-algorithm -- 1"); |
|
79 xas.v.add(null); |
|
80 th.check(xas.hashCode() == 0 ,"checking hc-algorithm -- 2"); |
|
81 xas.v.add("a"); |
|
82 int hash = "a".hashCode(); |
|
83 th.check(xas.hashCode() == hash ,"checking hc-algorithm -- 3"); |
|
84 hash += "b".hashCode(); |
|
85 xas.v.add("b"); |
|
86 th.check(xas.hashCode() == hash ,"checking hc-algorithm -- 4"); |
|
87 hash += "c".hashCode(); |
|
88 xas.v.add("c"); |
|
89 th.check(xas.hashCode() == hash ,"checking hc-algorithm -- 5"); |
|
90 hash += "d".hashCode(); |
|
91 xas.v.add("d"); |
|
92 th.check(xas.hashCode() == hash ,"checking hc-algorithm -- 6"); |
|
93 } |
|
94 |
|
95 // The following methods aand field are needed to use this class as |
|
96 // Set implementation. |
|
97 |
|
98 public Vector v = new Vector(); |
|
99 |
|
100 public AcuniaAbstractSetTest(){ |
|
101 super(); |
|
102 } |
|
103 |
|
104 public int size() { |
|
105 return v.size(); |
|
106 } |
|
107 |
|
108 public Iterator iterator() { |
|
109 return v.iterator(); |
|
110 } |
|
111 |
|
112 } |
|