use of org.neo4j.collection.primitive.PrimitiveCollection in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method addingTheSameValuesMustProduceEqualCollections.
@Theory
public void addingTheSameValuesMustProduceEqualCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
Value value = values.randomValue();
value.add(a);
value.add(b);
assertEquals(a, b);
}
}
use of org.neo4j.collection.primitive.PrimitiveCollection in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method capacityDifferencesMustNotInfluenceEquality.
@Theory
public void capacityDifferencesMustNotInfluenceEquality(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
List<Value> tmps = new ArrayList<>();
for (int i = 0; i < 5000; i++) {
Value value = values.randomValue();
value.add(b);
tmps.add(value);
}
Value specificValue = values.randomValue();
specificValue.add(a);
specificValue.add(b);
for (int i = 0; i < 5000; i++) {
Value value = values.randomValue();
value.add(b);
tmps.add(value);
}
Collections.shuffle(tmps);
for (Value value : tmps) {
value.remove(b);
}
assertEquals(a, b);
}
}
use of org.neo4j.collection.primitive.PrimitiveCollection in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method emptyCollectionsAreEqual.
@Theory
public void emptyCollectionsAreEqual(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
assertEquals(a, b);
}
}
use of org.neo4j.collection.primitive.PrimitiveCollection in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method differentButEquivalentMutationsShouldProduceEqualCollections.
@Theory
public void differentButEquivalentMutationsShouldProduceEqualCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
// Note that this test, cute as it is, also verifies that the hashCode implementation is order-invariant :)
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
Value x = values.randomValue();
Value y = values.randomValue();
Value z = values.randomValue();
x.add(a);
z.add(a);
z.add(b);
y.add(b);
x.add(b);
y.remove(b);
assertEquals(a, b);
}
}
use of org.neo4j.collection.primitive.PrimitiveCollection in project neo4j by neo4j.
the class PrimitiveCollectionEqualityTest method addingDifferentValuesMustProduceUnequalCollections.
@Theory
public void addingDifferentValuesMustProduceUnequalCollections(ValueProducer values, Factory<PrimitiveCollection> factoryA, Factory<PrimitiveCollection> factoryB) {
assumeTrue(values.isApplicable(factoryA));
assumeTrue(values.isApplicable(factoryB));
try (PrimitiveCollection a = factoryA.newInstance();
PrimitiveCollection b = factoryB.newInstance()) {
values.randomValue().add(a);
values.randomValue().add(b);
assertNotEquals(a, b);
}
}
Aggregations