rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java
Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program 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, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
18 package org.apidesign.bck2brwsr.compact.tck;
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.Collection;
23 import java.util.Comparator;
24 import java.util.HashMap;
25 import java.util.HashSet;
26 import java.util.List;
28 import java.util.Map.Entry;
29 import java.util.Vector;
30 import org.apidesign.bck2brwsr.vmtest.Compare;
31 import org.apidesign.bck2brwsr.vmtest.VMTest;
32 import org.testng.annotations.Factory;
36 * @author Jaroslav Tulach <jtulach@netbeans.org>
38 public class CollectionsTest {
39 @Compare public String sortStringsInArray() {
40 List<String> list = new ArrayList<>();
52 String[] arr = list.toArray(new String[list.size()]);
55 return Arrays.asList(arr).toString();
58 @Compare public String sortStringsInHashSet() {
59 Collection<String> list = new HashSet<>();
71 String[] arr = list.toArray(new String[0]);
74 return Arrays.asList(arr).toString();
77 @SuppressWarnings("unchecked")
78 @Compare public String sortStringsInHashMapWithComparator() {
79 class C implements Comparator<Map.Entry<String,Integer>> {
80 public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
81 return o1.getKey().compareTo(o2.getKey());
85 Map<String,Integer> map = new HashMap<>();
97 List<Entry<String,Integer>> arr = new Vector<>();
98 arr.addAll(map.entrySet());
99 return arr.toString();
103 public static Object[] create() {
104 return VMTest.create(CollectionsTest.class);