use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class PackageLookupFunctionTest method testPackageLookupValueHashCodeAndEqualsContract.
@Test
public void testPackageLookupValueHashCodeAndEqualsContract() throws Exception {
Path root1 = rootDirectory.getRelative("root1");
Path root2 = rootDirectory.getRelative("root2");
// Our (seeming) duplication of parameters here is intentional. Some of the subclasses of
// PackageLookupValue are supposed to have reference equality semantics, and some are supposed
// to have logical equality semantics.
new EqualsTester().addEqualityGroup(PackageLookupValue.success(root1, BuildFileName.BUILD), PackageLookupValue.success(root1, BuildFileName.BUILD)).addEqualityGroup(PackageLookupValue.success(root2, BuildFileName.BUILD), PackageLookupValue.success(root2, BuildFileName.BUILD)).addEqualityGroup(PackageLookupValue.NO_BUILD_FILE_VALUE, PackageLookupValue.NO_BUILD_FILE_VALUE).addEqualityGroup(PackageLookupValue.DELETED_PACKAGE_VALUE, PackageLookupValue.DELETED_PACKAGE_VALUE).addEqualityGroup(PackageLookupValue.invalidPackageName("nope1"), PackageLookupValue.invalidPackageName("nope1")).addEqualityGroup(PackageLookupValue.invalidPackageName("nope2"), PackageLookupValue.invalidPackageName("nope2")).testEquals();
}
use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class AspectValueTest method keyEquality.
@Test
public void keyEquality() throws Exception {
update();
BuildConfiguration c1 = getTargetConfiguration();
BuildConfiguration c2 = getHostConfiguration();
Label l1 = Label.parseAbsolute("//a:l1");
Label l1b = Label.parseAbsolute("//a:l1");
Label l2 = Label.parseAbsolute("//a:l2");
AspectParameters i1 = new AspectParameters.Builder().addAttribute("foo", "bar").build();
AspectParameters i1b = new AspectParameters.Builder().addAttribute("foo", "bar").build();
AspectParameters i2 = new AspectParameters.Builder().addAttribute("foo", "baz").build();
AttributeAspect a1 = TestAspects.ATTRIBUTE_ASPECT;
AttributeAspect a1b = TestAspects.ATTRIBUTE_ASPECT;
ExtraAttributeAspect a2 = TestAspects.EXTRA_ATTRIBUTE_ASPECT;
// label: //a:l1 or //a:l2
// aspectConfiguration: target or host
// baseConfiguration: target or host
// aspect: Attribute or ExtraAttribute
// parameters: bar or baz
new EqualsTester().addEqualityGroup(createKey(l1, c1, a1, i1, c1), createKey(l1, c1, a1, i1b, c1), createKey(l1, c1, a1b, i1, c1), createKey(l1, c1, a1b, i1b, c1), createKey(l1b, c1, a1, i1, c1), createKey(l1b, c1, a1, i1b, c1), createKey(l1b, c1, a1b, i1, c1), createKey(l1b, c1, a1b, i1b, c1)).addEqualityGroup(createKey(l1, c1, a1, i2, c1), createKey(l1, c1, a1b, i2, c1), createKey(l1b, c1, a1, i2, c1), createKey(l1b, c1, a1b, i2, c1)).addEqualityGroup(createKey(l1, c1, a2, i1, c1), createKey(l1, c1, a2, i1b, c1), createKey(l1b, c1, a2, i1, c1), createKey(l1b, c1, a2, i1b, c1)).addEqualityGroup(createKey(l1, c1, a2, i2, c1), createKey(l1b, c1, a2, i2, c1)).addEqualityGroup(createKey(l1, c2, a1, i1, c1), createKey(l1, c2, a1, i1b, c1), createKey(l1, c2, a1b, i1, c1), createKey(l1, c2, a1b, i1b, c1), createKey(l1b, c2, a1, i1, c1), createKey(l1b, c2, a1, i1b, c1), createKey(l1b, c2, a1b, i1, c1), createKey(l1b, c2, a1b, i1b, c1)).addEqualityGroup(createKey(l1, c2, a1, i2, c1), createKey(l1, c2, a1b, i2, c1), createKey(l1b, c2, a1, i2, c1), createKey(l1b, c2, a1b, i2, c1)).addEqualityGroup(createKey(l1, c2, a2, i1, c1), createKey(l1, c2, a2, i1b, c1), createKey(l1b, c2, a2, i1, c1), createKey(l1b, c2, a2, i1b, c1)).addEqualityGroup(createKey(l1, c2, a2, i2, c1), createKey(l1b, c2, a2, i2, c1)).addEqualityGroup(createKey(l1, c1, a1, i1, c2), createKey(l1, c1, a1, i1b, c2), createKey(l1, c1, a1b, i1, c2), createKey(l1, c1, a1b, i1b, c2), createKey(l1b, c1, a1, i1, c2), createKey(l1b, c1, a1, i1b, c2), createKey(l1b, c1, a1b, i1, c2), createKey(l1b, c1, a1b, i1b, c2)).addEqualityGroup(createKey(l1, c1, a1, i2, c2), createKey(l1, c1, a1b, i2, c2), createKey(l1b, c1, a1, i2, c2), createKey(l1b, c1, a1b, i2, c2)).addEqualityGroup(createKey(l1, c1, a2, i1, c2), createKey(l1, c1, a2, i1b, c2), createKey(l1b, c1, a2, i1, c2), createKey(l1b, c1, a2, i1b, c2)).addEqualityGroup(createKey(l1, c1, a2, i2, c2), createKey(l1b, c1, a2, i2, c2)).addEqualityGroup(createKey(l1, c2, a1, i1, c2), createKey(l1, c2, a1, i1b, c2), createKey(l1, c2, a1b, i1, c2), createKey(l1, c2, a1b, i1b, c2), createKey(l1b, c2, a1, i1, c2), createKey(l1b, c2, a1, i1b, c2), createKey(l1b, c2, a1b, i1, c2), createKey(l1b, c2, a1b, i1b, c2)).addEqualityGroup(createKey(l1, c2, a1, i2, c2), createKey(l1, c2, a1b, i2, c2), createKey(l1b, c2, a1, i2, c2), createKey(l1b, c2, a1b, i2, c2)).addEqualityGroup(createKey(l1, c2, a2, i1, c2), createKey(l1, c2, a2, i1b, c2), createKey(l1b, c2, a2, i1, c2), createKey(l1b, c2, a2, i1b, c2)).addEqualityGroup(createKey(l1, c2, a2, i2, c2), createKey(l1b, c2, a2, i2, c2)).addEqualityGroup(createKey(l2, c1, a1, i1, c1), createKey(l2, c1, a1, i1b, c1), createKey(l2, c1, a1b, i1, c1), createKey(l2, c1, a1b, i1b, c1)).addEqualityGroup(createKey(l2, c1, a1, i2, c1), createKey(l2, c1, a1b, i2, c1)).addEqualityGroup(createKey(l2, c1, a2, i1, c1), createKey(l2, c1, a2, i1b, c1)).addEqualityGroup(createKey(l2, c1, a2, i2, c1)).addEqualityGroup(createKey(l2, c2, a1, i1, c1), createKey(l2, c2, a1, i1b, c1), createKey(l2, c2, a1b, i1, c1), createKey(l2, c2, a1b, i1b, c1)).addEqualityGroup(createKey(l2, c2, a1, i2, c1), createKey(l2, c2, a1b, i2, c1)).addEqualityGroup(createKey(l2, c2, a2, i1, c1), createKey(l2, c2, a2, i1b, c1)).addEqualityGroup(createKey(l2, c2, a2, i2, c1)).addEqualityGroup(createKey(l2, c1, a1, i1, c2), createKey(l2, c1, a1, i1b, c2), createKey(l2, c1, a1b, i1, c2), createKey(l2, c1, a1b, i1b, c2)).addEqualityGroup(createKey(l2, c1, a1, i2, c2), createKey(l2, c1, a1b, i2, c2)).addEqualityGroup(createKey(l2, c1, a2, i1, c2), createKey(l2, c1, a2, i1b, c2)).addEqualityGroup(createKey(l2, c1, a2, i2, c2)).addEqualityGroup(createKey(l2, c2, a1, i1, c2), createKey(l2, c2, a1, i1b, c2), createKey(l2, c2, a1b, i1, c2), createKey(l2, c2, a1b, i1b, c2)).addEqualityGroup(createKey(l2, c2, a1, i2, c2), createKey(l2, c2, a1b, i2, c2)).addEqualityGroup(createKey(l2, c2, a2, i1, c2), createKey(l2, c2, a2, i1b, c2)).addEqualityGroup(createKey(l2, c2, a2, i2, c2)).addEqualityGroup(createDerivedKey(l1, c1, a1, i1, c1, a2, i2, c2), createDerivedKey(l1, c1, a1, i1b, c1, a2, i2, c2)).addEqualityGroup(createDerivedKey(l1, c1, a2, i1, c1, a1, i2, c2), createDerivedKey(l1, c1, a2, i1b, c1, a1, i2, c2)).testEquals();
}
use of com.google.common.testing.EqualsTester in project bazel by bazelbuild.
the class LicensingTests method testTargetLicenseEquality.
@Test
public void testTargetLicenseEquality() throws Exception {
Label label1 = Label.parseAbsolute("//foo");
Label label2 = Label.parseAbsolute("//bar");
License restricted = License.parseLicense(ImmutableList.of("restricted"));
License unencumbered = License.parseLicense(ImmutableList.of("unencumbered"));
new EqualsTester().addEqualityGroup(new TargetLicense(label1, restricted), new TargetLicense(label1, restricted)).addEqualityGroup(new TargetLicense(label2, restricted), new TargetLicense(label2, restricted)).addEqualityGroup(new TargetLicense(label2, unencumbered), new TargetLicense(label2, unencumbered)).testEquals();
}
use of com.google.common.testing.EqualsTester in project caffeine by ben-manes.
the class CacheTesting method checkEmpty.
static void checkEmpty(Collection<?> collection) {
assertTrue(collection.isEmpty());
assertEquals(0, collection.size());
assertFalse(collection.iterator().hasNext());
assertEquals(0, collection.toArray().length);
assertEquals(0, collection.toArray(new Object[0]).length);
if (collection instanceof Set) {
new EqualsTester().addEqualityGroup(ImmutableSet.of(), collection).addEqualityGroup(ImmutableSet.of("")).testEquals();
} else if (collection instanceof List) {
new EqualsTester().addEqualityGroup(ImmutableList.of(), collection).addEqualityGroup(ImmutableList.of("")).testEquals();
}
}
use of com.google.common.testing.EqualsTester in project error-prone by google.
the class UUnaryTest method equality.
@Test
public void equality() {
ULiteral sevenLit = ULiteral.intLit(7);
ULiteral threeLit = ULiteral.intLit(3);
ULiteral falseLit = ULiteral.booleanLit(false);
new EqualsTester().addEqualityGroup(UUnary.create(Kind.UNARY_MINUS, sevenLit)).addEqualityGroup(UUnary.create(Kind.UNARY_MINUS, threeLit)).addEqualityGroup(UUnary.create(Kind.BITWISE_COMPLEMENT, sevenLit)).addEqualityGroup(UUnary.create(Kind.LOGICAL_COMPLEMENT, falseLit)).testEquals();
}
Aggregations