Skip to content

Commit

Permalink
BASIL-1: Fixed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggyfish committed Sep 12, 2023
1 parent f1d1cb0 commit d77d42a
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/test/scala/BitVectorAnalysisTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ class BitVectorAnalysisTests extends AnyFunSuite {
assert(result == BigInt(2))
}

test("Natural to BitVector - should return 0 when natural number does not fit within specified bit size") {
val result = nat2bv(8, BigInt(256))
assert(result == BitVecLiteral(BigInt(0), 8))
}

test("Natural to BitVector - should return number when natural number does fit within specified bit size") {
val result = nat2bv(8, BigInt(255))
assert(result == BitVecLiteral(BigInt(255), 8))
Expand All @@ -26,11 +21,6 @@ class BitVectorAnalysisTests extends AnyFunSuite {
assert(result == BitVecLiteral(18, 8))
}

test("BitVector Add - should subtract two BitVectors when the second value is negative") {
val result = smt_bvadd(BitVecLiteral(255, 8), BitVecLiteral(-1, 8))
assert(result == BitVecLiteral(254, 8))
}

test("BitVector Add - should throw exception when the result is negative") {
intercept[IllegalArgumentException] {
val result = smt_bvadd(BitVecLiteral(0, 8), BitVecLiteral(-1, 8))
Expand All @@ -42,6 +32,11 @@ class BitVectorAnalysisTests extends AnyFunSuite {
assert(result == BitVecLiteral(0, 8))
}

test("BitVector Add - should calculate the sum of two numbers that have a high bit count") {
val result = smt_bvadd(BitVecLiteral(BigInt("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE", 16), 128), BitVecLiteral(4, 128))
assert(result == BitVecLiteral(2, 128))
}

// smt_bvmul

test("BitVector Multiply - should return the product of two BitVectors") {
Expand All @@ -56,8 +51,8 @@ class BitVectorAnalysisTests extends AnyFunSuite {
}

test("BitVector Multiply - should return wrap BitVectors when sum is greater size number of bits") {
val result = smt_bvmul(BitVecLiteral(255, 8), BitVecLiteral(1, 8))
assert(result == BitVecLiteral(255, 8))
val result = smt_bvmul(BitVecLiteral(255, 8), BitVecLiteral(2, 8))
assert(result == BitVecLiteral(254, 8))
}
// smt_bvneg

Expand All @@ -71,11 +66,6 @@ class BitVectorAnalysisTests extends AnyFunSuite {
assert(result == BitVecLiteral(0, 8))
}

test("BitVector Negate - should return x when negating negative numbers") {
val result = smt_bvneg(BitVecLiteral(-3, 8))
assert(result == BitVecLiteral(3, 8))
}

// smt_bvsub

test("BitVector Subtract - should subtract two numbers ") {
Expand Down Expand Up @@ -161,11 +151,6 @@ class BitVectorAnalysisTests extends AnyFunSuite {
assert(result == BitVecLiteral(BigInt("011", 2), 3))
}

test("BitVector Extract - should extract bits from a given number when range is outside of bit given bit range") {
val result = smt_extract(7, 5, BitVecLiteral(BigInt("111011", 2), 6))
assert(result == BitVecLiteral(BigInt("001", 2), 3))
}

// boogie_extract

test("Boogie Extract - should extract bits from a given number") {
Expand Down

0 comments on commit d77d42a

Please sign in to comment.