blob: 13c6750ccb74539c9780dd0903e2d7e587129a31 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*******************************************************************************
* Copyright (c) 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.utility.tests.internal;
import junit.framework.TestCase;
import org.eclipse.jpt.utility.internal.Bag;
import org.eclipse.jpt.utility.internal.HashBag;
@SuppressWarnings("nls")
public class BagTests extends TestCase {
public BagTests(String name) {
super(name);
}
public void testEmptyBag_iterator() throws Exception {
assertFalse(Bag.Empty.instance().iterator().hasNext());
}
public void testEmptyBag_size() throws Exception {
assertEquals(0, Bag.Empty.instance().size());
}
public void testEmptyBag_uniqueIterator() throws Exception {
assertFalse(Bag.Empty.instance().uniqueIterator().hasNext());
}
public void testEmptyBag_uniqueCount() throws Exception {
assertEquals(0, Bag.Empty.instance().uniqueCount());
}
public void testEmptyBag_count() throws Exception {
assertEquals(0, Bag.Empty.instance().count("foo"));
}
public void testEmptyBag_entries() throws Exception {
assertFalse(Bag.Empty.instance().entries().hasNext());
}
public void testEmptyBag_remove() throws Exception {
assertFalse(Bag.Empty.instance().remove("foo", 3));
}
public void testEmptyBag_add() throws Exception {
boolean exCaught = false;
try {
Bag.Empty.instance().add("foo", 3);
fail();
} catch (UnsupportedOperationException ex) {
exCaught = true;
}
assertTrue(exCaught);
}
public void testEmptyBag_equals() throws Exception {
assertTrue(Bag.Empty.instance().equals(Bag.Empty.instance()));
assertFalse(Bag.Empty.instance().equals("foo"));
Bag<Object> bag = new HashBag<Object>();
assertTrue(Bag.Empty.instance().equals(bag));
bag.add("foo");
assertFalse(Bag.Empty.instance().equals(bag));
}
public void testEmptyBag_hashCode() throws Exception {
assertEquals(0, Bag.Empty.instance().hashCode());
}
public void testEmptyBag_serialization() throws Exception {
Bag<?> xxx = TestTools.serialize(Bag.Empty.instance());
assertSame(Bag.Empty.instance(), xxx);
}
}
|