Skip to content
Snippets Groups Projects
Commit 4ffdb081 authored by Johannes Späth's avatar Johannes Späth
Browse files

Proper hashCode and equals method for CryptSLPredicate (#140)

parent f5581c6d
No related branches found
No related tags found
No related merge requests found
......@@ -28,33 +28,42 @@ public class CryptSLPredicate extends CryptSLLiteral implements java.io.Serializ
this.optConstraint = constraint;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((baseObject == null) ? 0 : baseObject.hashCode());
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
result = prime * result + ((predName == null) ? 0 : predName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
if (this == obj)
return true;
}
if (obj == null) {
if (obj == null)
return false;
}
if (!(obj instanceof CryptSLPredicate)) {
if (getClass() != obj.getClass())
return false;
}
CryptSLPredicate other = (CryptSLPredicate) obj;
if (baseObject == null) {
if (other.baseObject != null)
return false;
} else if (!baseObject.equals(other.baseObject))
return false;
if (parameters == null) {
if (other.parameters != null)
return false;
} else if (!parameters.equals(other.parameters))
return false;
if (predName == null) {
if (other.predName != null) {
if (other.predName != null)
return false;
}
} else if (!predName.equals(other.predName)) {
} else if (!predName.equals(other.predName))
return false;
}
return true;
}
......
......@@ -6,6 +6,7 @@ import org.junit.Test;
import crypto.HeadlessCryptoScanner;
import crypto.analysis.errors.IncompleteOperationError;
import crypto.analysis.errors.RequiredPredicateError;
import test.IDEALCrossingTestingFramework;
public class GenerateSecureRandomExample extends AbstractHeadlessTest {
......@@ -16,6 +17,7 @@ public class GenerateSecureRandomExample extends AbstractHeadlessTest {
MavenProject mavenProject = createAndCompile(mavenProjectPath);
HeadlessCryptoScanner scanner = createScanner(mavenProject, IDEALCrossingTestingFramework.RESOURCE_PATH);
setErrorsCount("<example.Demo: void generateSecureRandom()>", RequiredPredicateError.class, 1);
scanner.exec();
assertErrors();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment