blob: 3e14d3998b1cc35e4d3d38ad5d13adacba716ae9 [file] [log] [blame]
Jesse Wilson090f9b42009-12-10 17:44:48 -08001/*
2 * Copyright (C) 2008 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.common.collect;
18
19import com.google.common.collect.testing.SetTestSuiteBuilder;
20import com.google.common.collect.testing.TestStringSetGenerator;
21import com.google.common.collect.testing.features.CollectionFeature;
22import com.google.common.collect.testing.features.CollectionSize;
23import com.google.common.collect.testing.features.SetFeature;
24
25import junit.framework.Test;
26import junit.framework.TestCase;
27import junit.framework.TestSuite;
28
29import java.util.Set;
30
31/**
32 * Collection tests for bimaps.
33 *
34 * @author Jared Levy
35 */
36public class BiMapCollectionTest extends TestCase {
37
38 public static Test suite() {
39 TestSuite suite = new TestSuite();
40 suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
41 @Override protected Set<String> create(String[] elements) {
42 BiMap<String, Integer> bimap = HashBiMap.create();
43 for (int i = 0; i < elements.length; i++) {
44 bimap.put(elements[i], i);
45 }
46 return bimap.keySet();
47 }
48 })
49 .named("HashBiMap.keySet")
50 .withFeatures(CollectionSize.ANY,
51 CollectionFeature.ALLOWS_NULL_VALUES,
52 CollectionFeature.REMOVE_OPERATIONS)
53 .createTestSuite());
54
55 suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() {
56 @Override protected Set<String> create(String[] elements) {
57 BiMap<Integer, String> bimap = HashBiMap.create();
58 for (int i = 0; i < elements.length; i++) {
59 bimap.put(i, elements[i]);
60 }
61 return bimap.values();
62 }
63 })
64 .named("HashBiMap.values")
65 .withFeatures(CollectionSize.ANY,
66 CollectionFeature.ALLOWS_NULL_VALUES,
67 CollectionFeature.REMOVE_OPERATIONS,
68 SetFeature.REJECTS_DUPLICATES_AT_CREATION)
69 .createTestSuite());
70
71 return suite;
72 }
73}