Skip to content

Commit 2158c99

Browse files
daniel-rafflerkfriedberger
authored andcommitted
Added bitvector rotation to formula visitor tests
1 parent 6ab3339 commit 2158c99

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* This file is part of JavaSMT,
3+
* an API wrapper for a collection of SMT solvers:
4+
* https://github.com/sosy-lab/java-smt
5+
*
6+
* SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org>
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*/
10+
11+
package org.sosy_lab.java_smt.test;
12+
13+
import static com.google.common.truth.Truth.assertThat;
14+
15+
import org.junit.Test;
16+
import org.sosy_lab.java_smt.api.BitvectorFormula;
17+
18+
public class RotationVisitorTest extends SolverBasedTest0.ParameterizedSolverBasedTest0 {
19+
@Test
20+
public void rotateLeftTest() {
21+
requireBitvectors();
22+
BitvectorFormula x = bvmgr.makeBitvector(8, 7);
23+
assertThat(mgr.extractVariables(bvmgr.rotateLeft(x, 1))).isEmpty();
24+
}
25+
26+
@Test
27+
public void rotateRightTest() {
28+
requireBitvectors();
29+
BitvectorFormula x = bvmgr.makeBitvector(8, 7);
30+
assertThat(mgr.extractVariables(bvmgr.rotateRight(x, 1))).isEmpty();
31+
}
32+
33+
@Test
34+
public void rotateLeftIntegerTest() {
35+
requireBitvectors();
36+
BitvectorFormula x = bvmgr.makeBitvector(8, 7);
37+
BitvectorFormula y = bvmgr.makeBitvector(8, 1);
38+
assertThat(mgr.extractVariables(bvmgr.rotateLeft(x, y))).isEmpty();
39+
}
40+
41+
@Test
42+
public void rotateRightIntegerTest() {
43+
requireBitvectors();
44+
BitvectorFormula x = bvmgr.makeBitvector(8, 7);
45+
BitvectorFormula y = bvmgr.makeBitvector(8, 1);
46+
assertThat(mgr.extractVariables(bvmgr.rotateRight(x, y))).isEmpty();
47+
}
48+
}

src/org/sosy_lab/java_smt/test/SolverVisitorTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ public void bitvectorIdVisit() throws SolverException, InterruptedException {
230230
bvmgr.negate(x),
231231
bvmgr.extract(x, 7, 5),
232232
bvmgr.extract(x, 7, 5),
233-
bvmgr.concat(x, y))) {
233+
bvmgr.concat(x, y),
234+
bvmgr.rotateLeft(x, 1),
235+
bvmgr.rotateRight(x, 1),
236+
bvmgr.rotateLeft(x, y),
237+
bvmgr.rotateRight(x, y))) {
234238
mgr.visit(f, new FunctionDeclarationVisitorNoUF());
235239
if (Solvers.PRINCESS != solver) {
236240
// Princess models BV theory with intervals, such as "mod_cast(lower, upper , value)".

0 commit comments

Comments
 (0)