Search in sources :

Example 96 with EqualsTester

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();
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 97 with EqualsTester

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) File(java.io.File) Test(org.junit.Test)

Example 98 with EqualsTester

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();
}
Also used : Empty(com.google.auto.value.annotations.Empty) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 99 with EqualsTester

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) StringValues(com.google.auto.value.annotations.StringValues) Test(org.junit.Test)

Example 100 with EqualsTester

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);
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)171 Test (org.junit.Test)77 GwtIncompatible (com.google.common.annotations.GwtIncompatible)10 ParameterizedType (java.lang.reflect.ParameterizedType)10 WildcardType (java.lang.reflect.WildcardType)8 Method (java.lang.reflect.Method)7 Entry (java.util.Map.Entry)7 GenericArrayType (java.lang.reflect.GenericArrayType)6 Type (java.lang.reflect.Type)6 ImmutableList (com.google.common.collect.ImmutableList)5 Path (com.google.devtools.build.lib.vfs.Path)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Set (java.util.Set)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Label (com.google.devtools.build.lib.cmdline.Label)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3