Search in sources :

Example 91 with EqualsTester

use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.

the class StorageSpecShould method provide_equals_based_on_values.

@Test
public void provide_equals_based_on_values() {
    final BoundedContextName bcName = newName(getClass().getName());
    new EqualsTester().addEqualityGroup(StorageSpec.of(bcName, TypeUrl.of(StringValue.class), String.class), StorageSpec.of(bcName, TypeUrl.of(StringValue.class), String.class)).addEqualityGroup(StorageSpec.of(bcName, TypeUrl.of(Timestamp.class), Integer.class), StorageSpec.of(bcName, TypeUrl.of(Timestamp.class), Integer.class)).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Timestamp(com.google.protobuf.Timestamp) BoundedContextName(io.spine.core.BoundedContextName) Test(org.junit.Test)

Example 92 with EqualsTester

use of com.google.common.testing.EqualsTester in project guava by hceylan.

the class OrderingTest method testFrom.

public void testFrom() {
    Ordering<String> caseInsensitiveOrdering = Ordering.from(String.CASE_INSENSITIVE_ORDER);
    assertEquals(0, caseInsensitiveOrdering.compare("A", "a"));
    assertTrue(caseInsensitiveOrdering.compare("a", "B") < 0);
    assertTrue(caseInsensitiveOrdering.compare("B", "a") > 0);
    // test of deprecated method
    @SuppressWarnings("deprecation") Ordering<String> orderingFromOrdering = Ordering.from(Ordering.<String>natural());
    new EqualsTester().addEqualityGroup(caseInsensitiveOrdering, Ordering.from(String.CASE_INSENSITIVE_ORDER)).addEqualityGroup(orderingFromOrdering, Ordering.natural()).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester)

Example 93 with EqualsTester

use of com.google.common.testing.EqualsTester in project guava by hceylan.

the class BloomFilterTest method testEquals.

public void testEquals() {
    BloomFilter<CharSequence> bf1 = BloomFilter.create(Funnels.stringFunnel(), 100);
    bf1.put("1");
    bf1.put("2");
    BloomFilter<CharSequence> bf2 = BloomFilter.create(Funnels.stringFunnel(), 100);
    bf2.put("1");
    bf2.put("2");
    new EqualsTester().addEqualityGroup(bf1, bf2).testEquals();
    bf2.put("3");
    new EqualsTester().addEqualityGroup(bf1).addEqualityGroup(bf2).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester)

Example 94 with EqualsTester

use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.

the class StatementTest method equalsAndHashCode.

@Test
public void equalsAndHashCode() {
    EqualsTester tester = new EqualsTester();
    tester.addEqualityGroup(Statement.of("SELECT 1"), Statement.of("SELECT 1"), Statement.newBuilder("SELECT ").append("1").build());
    tester.addEqualityGroup(Statement.of("SELECT 2"));
    // Note that some of the following are incomplete bindings: they would fail if executed.
    tester.addEqualityGroup(Statement.newBuilder("SELECT @x, @y").bind("x").to(1).build(), Statement.newBuilder("SELECT @x, @y").bind("x").to(1).build());
    tester.addEqualityGroup(Statement.newBuilder("SELECT @x, @y").bind("x").to("1").build());
    tester.addEqualityGroup(Statement.newBuilder("SELECT @x, @y").bind("x").to(2).build());
    tester.addEqualityGroup(Statement.newBuilder("SELECT @x, @y").bind("y").to(2).build());
    tester.addEqualityGroup(Statement.newBuilder("SELECT @x, @y").bind("x").to(1).bind("y").to(2).build());
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 95 with EqualsTester

use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.

the class StructTest method equalsAndHashCode.

@Test
public void equalsAndHashCode() {
    EqualsTester tester = new EqualsTester();
    tester.addEqualityGroup(Struct.newBuilder().build(), Struct.newBuilder().build());
    tester.addEqualityGroup(Struct.newBuilder().set("x").to(1).build(), Struct.newBuilder().add("x", Value.int64(1)).build());
    tester.addEqualityGroup(Struct.newBuilder().set("x").to((Long) null).build());
    tester.addEqualityGroup(Struct.newBuilder().set("x").to((String) null).build());
    tester.addEqualityGroup(Struct.newBuilder().set("x").to(1).set("y").to(2).build());
    tester.addEqualityGroup(Struct.newBuilder().set("x").to(1).set("y").to("2").build());
    tester.addEqualityGroup(Struct.newBuilder().set("y").to(2).set("x").to(1).build());
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)177 Test (org.junit.Test)83 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 List (java.util.List)5 Set (java.util.Set)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 HashMap (java.util.HashMap)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