Skip to content

Commit

Permalink
Package-sanity tests for solver package.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.sosy-lab.org/software/cpachecker/trunk@17855 4712c6d2-40bb-43ae-aa4b-fec3f1bdfe4c
  • Loading branch information
PhilippWendler committed Sep 18, 2015
1 parent 0129fc1 commit 30dffc3
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/org/sosy_lab/solver/FormulaManagerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static enum Solvers {
public FormulaManagerFactory(Configuration config, LogManager pLogger,
ShutdownNotifier pShutdownNotifier) throws InvalidConfigurationException {
config.inject(this);
logger = pLogger;
logger = checkNotNull(pLogger);
shutdownNotifier = checkNotNull(pShutdownNotifier);

if (!logAllQueries) {
Expand Down
37 changes: 37 additions & 0 deletions src/org/sosy_lab/solver/PackageSanityTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2015 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
package org.sosy_lab.solver;

import org.sosy_lab.common.ShutdownNotifier;
import org.sosy_lab.common.configuration.Configuration;

import com.google.common.testing.AbstractPackageSanityTests;

public class PackageSanityTest extends AbstractPackageSanityTests {

{
setDefault(Configuration.class, Configuration.defaultConfiguration());
setDefault(ShutdownNotifier.class, ShutdownNotifier.create());
}
}
5 changes: 3 additions & 2 deletions src/org/sosy_lab/solver/SolverException.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package org.sosy_lab.solver;

import javax.annotation.Nullable;

/**
* Exception that should be used if the SMT solver did something wrong.
Expand All @@ -31,11 +32,11 @@ public class SolverException extends Exception {

private static final long serialVersionUID = -1557936144555925180L;

public SolverException(String msg) {
public SolverException(@Nullable String msg) {
super(msg);
}

public SolverException(String msg, Throwable t) {
public SolverException(@Nullable String msg, @Nullable Throwable t) {
super(msg, t);
}
}
33 changes: 33 additions & 0 deletions src/org/sosy_lab/solver/api/PackageSanityTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2015 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
package org.sosy_lab.solver.api;

import com.google.common.testing.AbstractPackageSanityTests;

public class PackageSanityTest extends AbstractPackageSanityTests {

{
setDistinctValues(FormulaType.class, FormulaType.BooleanType, FormulaType.IntegerType);
}
}
14 changes: 8 additions & 6 deletions src/org/sosy_lab/solver/basicimpl/AbstractFormula.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
package org.sosy_lab.solver.basicimpl;


import static com.google.common.base.Preconditions.checkNotNull;

import javax.annotation.Nullable;

import org.sosy_lab.solver.api.ArrayFormula;
import org.sosy_lab.solver.api.BitvectorFormula;
import org.sosy_lab.solver.api.BooleanFormula;
Expand All @@ -42,13 +46,11 @@ abstract class AbstractFormula<TFormulaInfo> implements Formula {
private final TFormulaInfo formulaInfo;

protected AbstractFormula(TFormulaInfo formulaInfo) {
assert formulaInfo != null;

this.formulaInfo = formulaInfo;
this.formulaInfo = checkNotNull(formulaInfo);
}

@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (!(o instanceof AbstractFormula)) { return false; }
return formulaInfo.equals(((AbstractFormula<?>) o).formulaInfo);
}
Expand Down Expand Up @@ -80,8 +82,8 @@ class ArrayFormulaImpl<TI extends Formula, TE extends Formula, TFormulaInfo>

public ArrayFormulaImpl(TFormulaInfo info, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) {
super(info);
this.indexType = pIndexType;
this.elementType = pElementType;
this.indexType = checkNotNull(pIndexType);
this.elementType = checkNotNull(pElementType);
}

public FormulaType<TI> getIndexType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import java.util.List;

import javax.annotation.Nullable;

import org.sosy_lab.solver.api.Formula;
import org.sosy_lab.solver.api.FormulaType;
import org.sosy_lab.solver.api.UninterpretedFunctionDeclaration;
Expand All @@ -53,7 +55,7 @@ public int hashCode() {
}

@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2015 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
package org.sosy_lab.solver.basicimpl;

import org.junit.Test;

public class AbstractUninterpretedFunctionDeclarationTest {

@Test
public void testEquals() {
// equals method of AbstractUninterpretedFunctionDeclaration
// is not testable with PackageSanityTest because of type fields
}
}
35 changes: 35 additions & 0 deletions src/org/sosy_lab/solver/basicimpl/PackageSanityTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2015 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
package org.sosy_lab.solver.basicimpl;

import org.sosy_lab.solver.api.FormulaType;

import com.google.common.testing.AbstractPackageSanityTests;

public class PackageSanityTest extends AbstractPackageSanityTests {

{
setDistinctValues(FormulaType.class, FormulaType.BooleanType, FormulaType.IntegerType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
*/
package org.sosy_lab.solver.logging;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.List;
import java.util.Set;
import java.util.logging.Level;

import org.sosy_lab.common.log.LogManager;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.Model;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.api.BooleanFormula;
import org.sosy_lab.solver.api.InterpolatingProverEnvironmentWithAssumptions;

Expand All @@ -41,8 +43,8 @@ public class LoggingInterpolatingProverEnvironment<T> implements InterpolatingPr
int level = 0;

public LoggingInterpolatingProverEnvironment(LogManager logger, InterpolatingProverEnvironmentWithAssumptions<T> ipe) {
this.wrapped = ipe;
this.logger = logger;
this.wrapped = checkNotNull(ipe);
this.logger = checkNotNull(logger);
}

@Override
Expand Down
8 changes: 5 additions & 3 deletions src/org/sosy_lab/solver/logging/LoggingOptEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
*/
package org.sosy_lab.solver.logging;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.logging.Level;

import org.sosy_lab.common.log.LogManager;
import org.sosy_lab.common.rationals.Rational;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.Model;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.api.BooleanFormula;
import org.sosy_lab.solver.api.Formula;
import org.sosy_lab.solver.api.OptEnvironment;
Expand All @@ -44,8 +46,8 @@ public class LoggingOptEnvironment implements OptEnvironment {
LogManager logger;

public LoggingOptEnvironment(LogManager logger, OptEnvironment oe) {
this.wrapped = oe;
this.logger = logger;
this.wrapped = checkNotNull(oe);
this.logger = checkNotNull(logger);
}

@Override
Expand Down
8 changes: 5 additions & 3 deletions src/org/sosy_lab/solver/logging/LoggingProverEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
*/
package org.sosy_lab.solver.logging;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.List;
import java.util.logging.Level;

import org.sosy_lab.common.log.LogManager;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.Model;
import org.sosy_lab.solver.SolverException;
import org.sosy_lab.solver.api.BooleanFormula;
import org.sosy_lab.solver.api.Formula;
import org.sosy_lab.solver.api.ProverEnvironment;
Expand All @@ -43,8 +45,8 @@ public class LoggingProverEnvironment implements ProverEnvironment {
int level = 0;

public LoggingProverEnvironment(LogManager logger, ProverEnvironment pe) {
this.wrapped = pe;
this.logger = logger;
this.wrapped = checkNotNull(pe);
this.logger = checkNotNull(logger);
}

@Override
Expand Down
30 changes: 30 additions & 0 deletions src/org/sosy_lab/solver/logging/PackageSanityTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2015 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
package org.sosy_lab.solver.logging;

import com.google.common.testing.AbstractPackageSanityTests;

public class PackageSanityTest extends AbstractPackageSanityTests {

}

0 comments on commit 30dffc3

Please sign in to comment.