Search in sources :

Example 36 with EqualsTester

use of com.google.common.testing.EqualsTester in project closure-templates by google.

the class SoyMsgRawTextPartTest method testEquals.

@Test
public void testEquals() {
    assertThat(SoyMsgRawTextPart.of(LATIN_STRING)).isEqualTo(SoyMsgRawTextPart.of(LATIN_STRING));
    assertThat(SoyMsgRawTextPart.of(CHINESE_STRING)).isEqualTo(SoyMsgRawTextPart.of(CHINESE_STRING));
    assertThat(SoyMsgRawTextPart.of(LATIN_STRING).equals(SoyMsgRawTextPart.of(LATIN_STRING_2))).isFalse();
    assertThat(SoyMsgRawTextPart.of(CHINESE_STRING).equals(SoyMsgRawTextPart.of(CHINESE_STRING_2))).isFalse();
    assertThat(SoyMsgRawTextPart.of(LATIN_STRING).equals(SoyMsgRawTextPart.of(CHINESE_STRING))).isFalse();
    assertThat(SoyMsgRawTextPart.of(CHINESE_STRING).equals(SoyMsgRawTextPart.of(LATIN_STRING))).isFalse();
    assertThat(SoyMsgRawTextPart.of(CHINESE_STRING).equals(SoyMsgRawTextPart.of(""))).isFalse();
    assertThat(SoyMsgRawTextPart.of("").equals(SoyMsgRawTextPart.of(LATIN_STRING))).isFalse();
    new EqualsTester().addEqualityGroup(SoyMsgRawTextPart.of(LATIN_STRING)).addEqualityGroup(new Object()).testEquals();
    new EqualsTester().addEqualityGroup(SoyMsgRawTextPart.of(CHINESE_STRING)).addEqualityGroup(CHINESE_STRING).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 37 with EqualsTester

use of com.google.common.testing.EqualsTester in project vespa by vespa-engine.

the class HostInfoTest method testEquals.

@Test
public void testEquals() {
    HostInfo a = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("foo", "bar", null, null, "config-id", "host-name")));
    HostInfo b = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("foo", "bar", null, null, "config-id", "host-name")));
    HostInfo c = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("foo", "baz", null, null, "config-id", "host-name")));
    HostInfo d = new HostInfo("foo.yahoo.com", Arrays.asList(new ServiceInfo("bar", "baz", null, null, "config-id", "host-name")));
    HostInfo e = new HostInfo("bar.yahoo.com", null);
    new EqualsTester().addEqualityGroup(a, b).addEqualityGroup(c).addEqualityGroup(d).addEqualityGroup(e).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 38 with EqualsTester

use of com.google.common.testing.EqualsTester in project vespa by vespa-engine.

the class PayloadTest method testEquals.

@Test
public void testEquals() {
    final String foo1 = "foo 1";
    final String foo2 = "foo 2";
    Payload a = Payload.from(foo1);
    Payload b = Payload.from(foo1);
    Payload c = Payload.from(foo2);
    Slime slime = new Slime();
    slime.setString(foo1);
    Payload d = Payload.from(new ConfigPayload(slime));
    slime.setString(foo1);
    Payload e = Payload.from(new ConfigPayload(slime));
    slime.setString("foo 2");
    Payload f = Payload.from(new ConfigPayload(slime));
    Payload g = null;
    Payload h = null;
    Payload i = null;
    Payload j = null;
    try {
        g = Payload.from(new Utf8Array(foo1.getBytes("UTF-8")), CompressionInfo.uncompressed());
        h = Payload.from(new Utf8Array(foo1.getBytes("UTF-8")), CompressionInfo.uncompressed());
        LZ4PayloadCompressor compressor = new LZ4PayloadCompressor();
        CompressionInfo info = CompressionInfo.create(CompressionType.LZ4, foo2.length());
        Utf8Array compressed = new Utf8Array(compressor.compress(foo2.getBytes()));
        i = Payload.from(compressed, info);
        j = Payload.from(compressed, info);
    } catch (UnsupportedEncodingException e1) {
        fail();
    }
    new EqualsTester().addEqualityGroup(a, b, g, h).addEqualityGroup(c).addEqualityGroup(d, e).addEqualityGroup(f).addEqualityGroup(i, j).testEquals();
}
Also used : ConfigPayload(com.yahoo.vespa.config.ConfigPayload) EqualsTester(com.google.common.testing.EqualsTester) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) LZ4PayloadCompressor(com.yahoo.vespa.config.LZ4PayloadCompressor) Slime(com.yahoo.slime.Slime) Utf8Array(com.yahoo.text.Utf8Array) Test(org.junit.Test)

Example 39 with EqualsTester

use of com.google.common.testing.EqualsTester in project closure-compiler by google.

the class SymbolTableTest method testPrototypeSymbolEqualityForTwoPathsToSamePrototype.

public void testPrototypeSymbolEqualityForTwoPathsToSamePrototype() {
    String input = lines("/**\n", "* An employer.\n", "*\n", "* @param {String} name name of employer.\n", "* @param {String} address address of employer.\n", "* @constructor\n", "*/\n", "function Employer(name, address) {\n", "this.name = name;\n", "this.address = address;\n", "}\n", "\n", "/**\n", "* @return {String} information about an employer.\n", "*/\n", "Employer.prototype.getInfo = function() {\n", "return this.name + '.' + this.address;\n", "};");
    SymbolTable table = createSymbolTable(input);
    Symbol employer = getGlobalVar(table, "Employer");
    assertNotNull(employer);
    SymbolScope propertyScope = employer.getPropertyScope();
    assertNotNull(propertyScope);
    Symbol prototypeOfEmployer = propertyScope.getQualifiedSlot("prototype");
    assertNotNull(prototypeOfEmployer);
    Symbol employerPrototype = getGlobalVar(table, "Employer.prototype");
    assertNotNull(employerPrototype);
    new EqualsTester().addEqualityGroup(employerPrototype, prototypeOfEmployer).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Symbol(com.google.javascript.jscomp.SymbolTable.Symbol) SymbolScope(com.google.javascript.jscomp.SymbolTable.SymbolScope)

Example 40 with EqualsTester

use of com.google.common.testing.EqualsTester in project closure-templates by google.

the class SoyListDataTest method testIsEqualto.

@Test
public void testIsEqualto() {
    SoyListData sld0 = new SoyListData();
    SoyListData sld1 = new SoyListData("boo");
    new EqualsTester().addEqualityGroup(sld0).addEqualityGroup(sld1).testEquals();
    assertThat(sld0.equals(new SoyListData())).isFalse();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)225 Test (org.junit.Test)118 GwtIncompatible (com.google.common.annotations.GwtIncompatible)10 ParameterizedType (java.lang.reflect.ParameterizedType)10 Test (org.junit.jupiter.api.Test)9 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 HashMap (java.util.HashMap)6 ImmutableList (com.google.common.collect.ImmutableList)5 Path (com.google.devtools.build.lib.vfs.Path)5 List (java.util.List)5 DisplayName (org.junit.jupiter.api.DisplayName)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Label (com.google.devtools.build.lib.cmdline.Label)3