1 /*
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
137 m.put(t, t);
138 }
139 return m;
140 }
141
142 void add(String description, Collection<?> expected, Supplier<Spliterator<?>> s) {
143 description = joiner(description).toString();
144 data.add(new Object[]{description, expected, s});
145 }
146
147 void add(String description, Supplier<Spliterator<?>> s) {
148 add(description, exp, s);
149 }
150
151 void addCollection(Function<Collection<T>, ? extends Collection<T>> c) {
152 add("new " + c.apply(Collections.<T>emptyList()).getClass().getName() + ".spliterator()",
153 () -> c.apply(exp).spliterator());
154 }
155
156 void addList(Function<Collection<T>, ? extends List<T>> l) {
157 // @@@ If collection is instance of List then add sub-list tests
158 addCollection(l);
159 }
160
161 void addMap(Function<Map<T, T>, ? extends Map<T, T>> m) {
162 String description = "new " + m.apply(Collections.<T, T>emptyMap()).getClass().getName();
163 addMap(m, description);
164 }
165
166 void addMap(Function<Map<T, T>, ? extends Map<T, T>> m, String description) {
167 add(description + ".keySet().spliterator()", () -> m.apply(mExp).keySet().spliterator());
168 add(description + ".values().spliterator()", () -> m.apply(mExp).values().spliterator());
169 add(description + ".entrySet().spliterator()", mExp.entrySet(), () -> m.apply(mExp).entrySet().spliterator());
170 }
171
172 StringBuilder joiner(String description) {
173 return new StringBuilder(description).
174 append(" {").
175 append("size=").append(exp.size()).
176 append("}");
177 }
178 }
|
1 /*
2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
137 m.put(t, t);
138 }
139 return m;
140 }
141
142 void add(String description, Collection<?> expected, Supplier<Spliterator<?>> s) {
143 description = joiner(description).toString();
144 data.add(new Object[]{description, expected, s});
145 }
146
147 void add(String description, Supplier<Spliterator<?>> s) {
148 add(description, exp, s);
149 }
150
151 void addCollection(Function<Collection<T>, ? extends Collection<T>> c) {
152 add("new " + c.apply(Collections.<T>emptyList()).getClass().getName() + ".spliterator()",
153 () -> c.apply(exp).spliterator());
154 }
155
156 void addList(Function<Collection<T>, ? extends List<T>> l) {
157 addCollection(l);
158 addCollection(l.andThen(list -> list.subList(0, list.size())));
159 }
160
161 void addMap(Function<Map<T, T>, ? extends Map<T, T>> m) {
162 String description = "new " + m.apply(Collections.<T, T>emptyMap()).getClass().getName();
163 addMap(m, description);
164 }
165
166 void addMap(Function<Map<T, T>, ? extends Map<T, T>> m, String description) {
167 add(description + ".keySet().spliterator()", () -> m.apply(mExp).keySet().spliterator());
168 add(description + ".values().spliterator()", () -> m.apply(mExp).values().spliterator());
169 add(description + ".entrySet().spliterator()", mExp.entrySet(), () -> m.apply(mExp).entrySet().spliterator());
170 }
171
172 StringBuilder joiner(String description) {
173 return new StringBuilder(description).
174 append(" {").
175 append("size=").append(exp.size()).
176 append("}");
177 }
178 }
|