Lines Matching defs:constrained
77 Collection<String> constrained = Constraints.constrainedCollection(
80 constrained.add("qux");
81 constrained.addAll(asList("cat", "dog"));
84 ASSERT.that(constrained).hasContentsInOrder("foo", "bar", TEST_ELEMENT, "qux", "cat", "dog");
89 Collection<String> constrained = Constraints.constrainedCollection(
92 constrained.add(TEST_ELEMENT);
96 constrained.addAll(asList("baz", TEST_ELEMENT));
99 ASSERT.that(constrained).hasContentsInOrder("foo", "bar");
105 Set<String> constrained = Constraints.constrainedSet(set, TEST_CONSTRAINT);
107 constrained.add("qux");
108 constrained.addAll(asList("cat", "dog"));
109 assertTrue(set.equals(constrained));
110 assertTrue(constrained.equals(set));
111 assertEquals(set.toString(), constrained.toString());
112 assertEquals(set.hashCode(), constrained.hashCode());
114 ASSERT.that(constrained).hasContentsInOrder("foo", "bar", TEST_ELEMENT, "qux", "cat", "dog");
119 Set<String> constrained = Constraints.constrainedSet(set, TEST_CONSTRAINT);
121 constrained.add(TEST_ELEMENT);
125 constrained.addAll(asList("baz", TEST_ELEMENT));
128 ASSERT.that(constrained).hasContentsInOrder("foo", "bar");
134 SortedSet<String> constrained = Constraints.constrainedSortedSet(
137 constrained.add("qux");
138 constrained.addAll(asList("cat", "dog"));
139 assertTrue(sortedSet.equals(constrained));
140 assertTrue(constrained.equals(sortedSet));
141 assertEquals(sortedSet.toString(), constrained.toString());
142 assertEquals(sortedSet.hashCode(), constrained.hashCode());
144 ASSERT.that(constrained).hasContentsInOrder("bar", "cat", "dog", "foo", "qux", TEST_ELEMENT);
145 assertNull(constrained.comparator());
146 assertEquals("bar", constrained.first());
147 assertEquals(TEST_ELEMENT, constrained.last());
152 SortedSet<String> constrained = Constraints.constrainedSortedSet(
155 constrained.add(TEST_ELEMENT);
159 constrained.subSet("bar", "foo").add(TEST_ELEMENT);
163 constrained.headSet("bar").add(TEST_ELEMENT);
167 constrained.tailSet("foo").add(TEST_ELEMENT);
171 constrained.addAll(asList("baz", TEST_ELEMENT));
174 ASSERT.that(constrained).hasContentsInOrder("bar", "foo");
180 List<String> constrained = Constraints.constrainedList(
183 constrained.add("qux");
184 constrained.addAll(asList("cat", "dog"));
185 constrained.add(1, "cow");
186 constrained.addAll(4, asList("box", "fan"));
187 constrained.set(2, "baz");
188 assertTrue(list.equals(constrained));
189 assertTrue(constrained.equals(list));
190 assertEquals(list.toString(), constrained.toString());
191 assertEquals(list.hashCode(), constrained.hashCode());
194 ASSERT.that(constrained).hasContentsInOrder(
196 ListIterator<String> iterator = constrained.listIterator();
199 constrained.listIterator(2).add("sky");
202 ASSERT.that(constrained).hasContentsInOrder(
204 assertTrue(constrained instanceof RandomAccess);
209 List<String> constrained = Constraints.constrainedList(
212 constrained.add("qux");
213 assertFalse(constrained instanceof RandomAccess);
218 List<String> constrained = Constraints.constrainedList(
221 constrained.add(TEST_ELEMENT);
225 constrained.listIterator().add(TEST_ELEMENT);
229 constrained.listIterator(1).add(TEST_ELEMENT);
233 constrained.listIterator().set(TEST_ELEMENT);
237 constrained.listIterator(1).set(TEST_ELEMENT);
241 constrained.subList(0, 1).add(TEST_ELEMENT);
245 constrained.add(1, TEST_ELEMENT);
249 constrained.set(1, TEST_ELEMENT);
253 constrained.addAll(asList("baz", TEST_ELEMENT));
257 constrained.addAll(1, asList("baz", TEST_ELEMENT));
260 ASSERT.that(constrained).hasContentsInOrder("foo", "bar");
266 Multiset<String> constrained = Constraints.constrainedMultiset(
269 constrained.add("qux");
270 constrained.addAll(asList("cat", "dog"));
271 constrained.add("cow", 2);
272 assertTrue(multiset.equals(constrained));
273 assertTrue(constrained.equals(multiset));
274 assertEquals(multiset.toString(), constrained.toString());
275 assertEquals(multiset.hashCode(), constrained.hashCode());
278 ASSERT.that(constrained).hasContentsAnyOrder(
280 assertEquals(1, constrained.count("foo"));
281 assertEquals(1, constrained.remove("foo", 3));
282 assertEquals(2, constrained.setCount("cow", 0));
284 ASSERT.that(constrained).hasContentsAnyOrder("bar", TEST_ELEMENT, "qux", "cat", "dog");
289 Multiset<String> constrained = Constraints.constrainedMultiset(
292 constrained.add(TEST_ELEMENT);
296 constrained.add(TEST_ELEMENT, 2);
300 constrained.addAll(asList("baz", TEST_ELEMENT));
303 ASSERT.that(constrained).hasContentsAnyOrder("foo", "bar");
309 List<String> constrained = Constraints.constrainedList(
312 constrained.addAll(onceIterable);
313 ASSERT.that(constrained).hasContentsInOrder("foo", "bar", "baz");
319 * iterator(). This verifies that the constrained collection uses a defensive
346 // TODO: Test serialization of constrained collections.