use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoAnnotationTest method testSimpleVarArgs.
@Test
public void testSimpleVarArgs() {
StringValues expectedStringValues = AnnotatedClass.class.getAnnotation(StringValues.class);
StringValues actualStringValues = newStringValuesVarArgs("oops");
StringValues otherStringValues = newStringValuesVarArgs(new String[] {});
new EqualsTester().addEqualityGroup(expectedStringValues, actualStringValues).addEqualityGroup(otherStringValues).testEquals();
}
use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoValueJava8Test method testPrimitiveArrays.
@Test
public void testPrimitiveArrays() {
PrimitiveArrays object0 = PrimitiveArrays.create(new boolean[0], new int[0]);
boolean[] booleans = { false, true, true, false };
int[] ints = { 6, 28, 496, 8128, 33550336 };
PrimitiveArrays object1 = PrimitiveArrays.create(booleans.clone(), ints.clone());
PrimitiveArrays object2 = PrimitiveArrays.create(booleans.clone(), ints.clone());
new EqualsTester().addEqualityGroup(object1, object2).addEqualityGroup(object0).testEquals();
// EqualsTester also exercises hashCode(). We clone the arrays above to ensure that using the
// default Object.hashCode() will fail.
String expectedString = "PrimitiveArrays{booleans=" + Arrays.toString(booleans) + ", " + "ints=" + Arrays.toString(ints) + "}";
assertThat(object1.toString()).isEqualTo(expectedString);
assertThat(object1.ints()).isSameAs(object1.ints());
}
use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoValueTest method testFloatingEquality.
@Test
public void testFloatingEquality() {
FloatProperty floatZero = FloatProperty.create(0.0f);
FloatProperty floatMinusZero = FloatProperty.create(-0.0f);
FloatProperty floatNaN = FloatProperty.create(Float.NaN);
DoubleProperty doubleZero = DoubleProperty.create(0.0);
DoubleProperty doubleMinusZero = DoubleProperty.create(-0.0);
DoubleProperty doubleNaN = DoubleProperty.create(Double.NaN);
new EqualsTester().addEqualityGroup(floatZero).addEqualityGroup(floatMinusZero).addEqualityGroup(floatNaN).addEqualityGroup(doubleZero).addEqualityGroup(doubleMinusZero).addEqualityGroup(doubleNaN).testEquals();
}
use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoValueTest method testTwoPropertiesWithBuilderClass.
@Test
public void testTwoPropertiesWithBuilderClass() {
TwoPropertiesWithBuilderClass a1 = TwoPropertiesWithBuilderClass.builder().string("23").integer(17).build();
TwoPropertiesWithBuilderClass a2 = TwoPropertiesWithBuilderClass.builder("23").integer(17).build();
TwoPropertiesWithBuilderClass a3 = TwoPropertiesWithBuilderClass.builder().integer(17).string("23").build();
TwoPropertiesWithBuilderClass b = TwoPropertiesWithBuilderClass.builder().string("17").integer(17).build();
new EqualsTester().addEqualityGroup(a1, a2, a3).addEqualityGroup(b).testEquals();
try {
TwoPropertiesWithBuilderClass.builder().string(null);
fail("Did not get expected exception");
} catch (NullPointerException expected) {
}
}
use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoValueTest method testPrimitiveArrays.
@Test
public void testPrimitiveArrays() {
PrimitiveArrays object0 = PrimitiveArrays.create(new boolean[0], new int[0]);
boolean[] booleans = { false, true, true, false };
int[] ints = { 6, 28, 496, 8128, 33550336 };
PrimitiveArrays object1 = PrimitiveArrays.create(booleans.clone(), ints.clone());
PrimitiveArrays object2 = PrimitiveArrays.create(booleans.clone(), ints.clone());
new EqualsTester().addEqualityGroup(object1, object2).addEqualityGroup(object0).testEquals();
// EqualsTester also exercises hashCode(). We clone the arrays above to ensure that using the
// default Object.hashCode() will fail.
String expectedString = "PrimitiveArrays{booleans=" + Arrays.toString(booleans) + ", " + "ints=" + Arrays.toString(ints) + "}";
assertEquals(expectedString, object1.toString());
assertThat(object1.ints()).isSameAs(object1.ints());
}
Aggregations