|
Java example source code file (ImmutableSetTest.java)
The ImmutableSetTest.java Java example source code
/*
* Copyright (C) 2007 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.testing.ListTestSuiteBuilder;
import com.google.common.collect.testing.SetTestSuiteBuilder;
import com.google.common.collect.testing.features.CollectionFeature;
import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.google.SetGenerators.DegeneratedImmutableSetGenerator;
import com.google.common.collect.testing.google.SetGenerators.ImmutableSetAsListGenerator;
import com.google.common.collect.testing.google.SetGenerators.ImmutableSetCopyOfGenerator;
import com.google.common.collect.testing.google.SetGenerators.ImmutableSetWithBadHashesGenerator;
import com.google.common.testing.EqualsTester;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
/**
* Unit test for {@link ImmutableSet}.
*
* @author Kevin Bourrillion
* @author Jared Levy
* @author Nick Kralevich
*/
@GwtCompatible(emulated = true)
public class ImmutableSetTest extends AbstractImmutableSetTest {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(SetTestSuiteBuilder.using(new ImmutableSetCopyOfGenerator())
.named(ImmutableSetTest.class.getName())
.withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(
new ImmutableSetWithBadHashesGenerator())
.named(ImmutableSetTest.class.getName() + ", with bad hashes")
.withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(SetTestSuiteBuilder.using(
new DegeneratedImmutableSetGenerator())
.named(ImmutableSetTest.class.getName() + ", degenerate")
.withFeatures(CollectionSize.ONE, CollectionFeature.KNOWN_ORDER,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTest(ListTestSuiteBuilder.using(new ImmutableSetAsListGenerator())
.named("ImmutableSet.asList")
.withFeatures(CollectionSize.ANY,
CollectionFeature.REJECTS_DUPLICATES_AT_CREATION,
CollectionFeature.SERIALIZABLE,
CollectionFeature.ALLOWS_NULL_QUERIES)
.createTestSuite());
suite.addTestSuite(ImmutableSetTest.class);
return suite;
}
@Override protected Set<String> of() {
return ImmutableSet.of();
}
@Override protected Set<String> of(String e) {
return ImmutableSet.of(e);
}
@Override protected Set<String> of(String e1, String e2) {
return ImmutableSet.of(e1, e2);
}
@Override protected Set<String> of(String e1, String e2, String e3) {
return ImmutableSet.of(e1, e2, e3);
}
@Override protected Set<String> of(
String e1, String e2, String e3, String e4) {
return ImmutableSet.of(e1, e2, e3, e4);
}
@Override protected Set<String> of(
String e1, String e2, String e3, String e4, String e5) {
return ImmutableSet.of(e1, e2, e3, e4, e5);
}
@Override protected Set<String> of(String e1, String e2, String e3,
String e4, String e5, String e6, String... rest) {
return ImmutableSet.of(e1, e2, e3, e4, e5, e6, rest);
}
@Override protected Set<String> copyOf(String[] elements) {
return ImmutableSet.copyOf(elements);
}
@Override protected Set<String> copyOf(Collection
Other Java examples (source code examples)Here is a short list of links related to this Java ImmutableSetTest.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.