use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class FileFunctionTest method testModTimeVsDigest.
@Test
public void testModTimeVsDigest() throws Exception {
Path p = file("somefile", "fizzley");
fastDigest = true;
FileValue aMd5 = valueForPath(p);
fastDigest = false;
FileValue aModTime = valueForPath(p);
assertThat(aModTime).isNotEqualTo(aMd5);
new EqualsTester().addEqualityGroup(aMd5).addEqualityGroup(aModTime).testEquals();
}
use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class PathFragmentTest method testEqualsAndHashCode.
@Test
public void testEqualsAndHashCode() {
InMemoryFileSystem filesystem = new InMemoryFileSystem();
new EqualsTester().addEqualityGroup(new PathFragment("../relative/path"), new PathFragment("..").getRelative("relative").getRelative("path"), new PathFragment('\0', false, new String[] { "..", "relative", "path" }), new PathFragment(new File("../relative/path"))).addEqualityGroup(new PathFragment("something/else")).addEqualityGroup(new PathFragment("/something/else")).addEqualityGroup(new PathFragment("/"), new PathFragment("//////")).addEqualityGroup(new PathFragment(""), PathFragment.EMPTY_FRAGMENT).addEqualityGroup(// A Path object.
filesystem.getRootDirectory()).testEquals();
}
use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoAnnotationTest method testEmpty.
@Test
public void testEmpty() {
Empty expectedEmpty = AnnotatedClass.class.getAnnotation(Empty.class);
Empty actualEmpty = newEmpty();
new EqualsTester().addEqualityGroup(expectedEmpty, actualEmpty).testEquals();
}
use of com.google.common.testing.EqualsTester in project auto by google.
the class AutoAnnotationTest method testSimple.
@Test
public void testSimple() {
StringValues expectedStringValues = AnnotatedClass.class.getAnnotation(StringValues.class);
StringValues actualStringValues = newStringValues(new String[] { "oops" });
StringValues otherStringValues = newStringValues(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 testNullablePrimitiveArrays.
@Test
public void testNullablePrimitiveArrays() {
assumeTrue(javacHandlesTypeAnnotationsCorrectly);
PrimitiveArrays object0 = PrimitiveArrays.create(new boolean[0], null);
boolean[] booleans = { false, true, true, false };
PrimitiveArrays object1 = PrimitiveArrays.create(booleans.clone(), null);
PrimitiveArrays object2 = PrimitiveArrays.create(booleans.clone(), null);
new EqualsTester().addEqualityGroup(object1, object2).addEqualityGroup(object0).testEquals();
String expectedString = "PrimitiveArrays{booleans=" + Arrays.toString(booleans) + ", " + "ints=null}";
assertThat(object1.toString()).isEqualTo(expectedString);
assertThat(object1.booleans()).isSameAs(object1.booleans());
assertThat(object1.booleans()).isEqualTo(booleans);
object1.booleans()[0] ^= true;
assertThat(object1.booleans()).isNotEqualTo(booleans);
}
Aggregations