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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations