use of com.google.common.testing.EqualsTester in project guava by hceylan.
the class TypesTest method testNewArrayType.
public void testNewArrayType() {
Type jvmType1 = new TypeCapture<List<String>[]>() {
}.capture();
GenericArrayType ourType1 = (GenericArrayType) Types.newArrayType(Types.newParameterizedType(List.class, String.class));
Type jvmType2 = new TypeCapture<List[]>() {
}.capture();
Type ourType2 = Types.newArrayType(List.class);
new EqualsTester().addEqualityGroup(jvmType1, ourType1).addEqualityGroup(jvmType2, ourType2).testEquals();
assertEquals(new TypeCapture<List<String>>() {
}.capture(), ourType1.getGenericComponentType());
assertEquals(jvmType1.toString(), ourType1.toString());
assertEquals(jvmType2.toString(), ourType2.toString());
}
use of com.google.common.testing.EqualsTester in project guava by hceylan.
the class TypesTest method testNewParameterizedType.
public void testNewParameterizedType() {
ParameterizedType jvmType = (ParameterizedType) new TypeCapture<HashMap<String, int[][]>>() {
}.capture();
ParameterizedType ourType = Types.newParameterizedType(HashMap.class, String.class, int[][].class);
new EqualsTester().addEqualityGroup(jvmType, ourType).testEquals();
assertEquals(jvmType.toString(), ourType.toString());
assertEquals(jvmType.hashCode(), ourType.hashCode());
assertEquals(HashMap.class, ourType.getRawType());
ASSERT.that(ourType.getActualTypeArguments()).hasContentsInOrder(jvmType.getActualTypeArguments());
assertEquals(Arrays.asList(String.class, Types.newArrayType(Types.newArrayType(int.class))), Arrays.asList(ourType.getActualTypeArguments()));
assertEquals(null, ourType.getOwnerType());
}
use of com.google.common.testing.EqualsTester in project guava by hceylan.
the class UnsignedLongTest method testEqualsAndValueOf.
@GwtIncompatible("too slow")
public void testEqualsAndValueOf() {
EqualsTester equalsTester = new EqualsTester();
for (long a : TEST_LONGS) {
BigInteger big = (a >= 0) ? BigInteger.valueOf(a) : BigInteger.valueOf(a).add(BigInteger.ZERO.setBit(64));
equalsTester.addEqualityGroup(UnsignedLong.asUnsigned(a), UnsignedLong.valueOf(big), UnsignedLong.valueOf(big.toString()), UnsignedLong.valueOf(big.toString(16), 16));
}
equalsTester.testEquals();
}
use of com.google.common.testing.EqualsTester in project guava by google.
the class ImmutableListMultimapTest method testMultimapEquals.
public void testMultimapEquals() {
Multimap<String, Integer> multimap = createMultimap();
Multimap<String, Integer> arrayListMultimap = ArrayListMultimap.create();
arrayListMultimap.putAll("foo", Arrays.asList(1, 3));
arrayListMultimap.put("bar", 2);
new EqualsTester().addEqualityGroup(multimap, createMultimap(), arrayListMultimap, ImmutableListMultimap.<String, Integer>builder().put("bar", 2).put("foo", 1).put("foo", 3).build()).addEqualityGroup(ImmutableListMultimap.<String, Integer>builder().put("bar", 2).put("foo", 3).put("foo", 1).build()).addEqualityGroup(ImmutableListMultimap.<String, Integer>builder().put("foo", 2).put("foo", 3).put("foo", 1).build()).addEqualityGroup(ImmutableListMultimap.<String, Integer>builder().put("bar", 2).put("foo", 3).build()).testEquals();
}
use of com.google.common.testing.EqualsTester in project guava by google.
the class SetsTest method testPowerSetEqualsAndHashCode_verifyAgainstHashSet.
public void testPowerSetEqualsAndHashCode_verifyAgainstHashSet() {
ImmutableList<Integer> allElements = ImmutableList.of(4233352, 3284593, 3794208, 3849533, 4013967, 2902658, 1886275, 2131109, 985872, 1843868);
for (int i = 0; i < allElements.size(); i++) {
Set<Integer> elements = newHashSet(allElements.subList(0, i));
Set<Set<Integer>> powerSet1 = powerSet(elements);
Set<Set<Integer>> powerSet2 = powerSet(elements);
new EqualsTester().addEqualityGroup(powerSet1, powerSet2, toHashSets(powerSet1)).addEqualityGroup(ImmutableSet.of()).addEqualityGroup(ImmutableSet.of(9999999)).addEqualityGroup("notASet").testEquals();
assertEquals(toHashSets(powerSet1).hashCode(), powerSet1.hashCode());
}
}
Aggregations