Skip to content

Commit ba23a24

Browse files
committed
fixing test cases
1 parent a20f85c commit ba23a24

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

src/main/scala/br/unb/cic/soot/graph/Graph.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class Graph[NodeT]() {
1616
val map = new mutable.HashMap[NodeT,mutable.MutableList[NodeT]]()
1717

1818
def addEdge(source: NodeT, target: NodeT): Unit = {
19+
if(source == target) {
20+
return
21+
}
22+
1923
if(map.contains(source)) {
2024
val adjacentList = map.get(source).get
2125
adjacentList += target

src/main/scala/br/unb/cic/soot/svfa/SVFA.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ abstract class SVFA {
6969

7070
for(n <- svg.nodes()) {
7171
nodeColor = n.nodeType match {
72-
case SourceNode => "[blue]"
73-
case SinkNode => "[red]"
72+
case SourceNode => "[fillcolor=blue, style=filled]"
73+
case SinkNode => "[fillcolor=red, style=filled]"
7474
case _ => ""
7575
}
7676

src/test/scala/br/unb/cic/soot/BlackBoard.scala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package br.unb.cic.soot
22

33
import br.unb.cic.soot.graph._
4-
import org.scalatest.FunSuite
4+
import org.scalatest.{BeforeAndAfter, FunSuite}
55
import scalax.collection.Graph
66
import scalax.collection.GraphEdge.DiEdge
77
import soot.jimple.{AssignStmt, InvokeExpr, InvokeStmt}
@@ -33,14 +33,22 @@ class BlackBoard extends JSVFATest {
3333
}
3434
}
3535

36-
class BlackBoardTestSuite extends FunSuite {
36+
class BlackBoardTestSuite extends FunSuite with BeforeAndAfter {
3737

38-
test("we should correctly compute the number of nodes and edges") {
39-
val svfa = new BlackBoard()
38+
val svfa = new BlackBoard()
39+
40+
before {
4041
svfa.buildSparseValueFlowGraph()
41-
println(svfa.reportConflicts())
42+
}
43+
44+
test("we should correctly compute the number of nodes and edges") {
4245
assert(svfa.svg.nodes.size == 7)
43-
assert(svfa.svg.numberOfEdges() == 7)
46+
assert(svfa.svg.numberOfEdges() == 6)
47+
}
48+
49+
test("we should find exactly one conflict in this analysis") {
50+
println(svfa.svgToDotModel())
51+
assert(svfa.reportConflicts().size == 0)
4452
}
4553

4654
}

src/test/scala/br/unb/cic/soot/CC16Test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CC16TestSuite extends FunSuite with BeforeAndAfter {
3939

4040
test("we should correctly compute the number of nodes and edges") {
4141
assert(svfa.svg.nodes.size == 10)
42-
assert(svfa.svg.numberOfEdges() == 10)
42+
assert(svfa.svg.numberOfEdges() == 9)
4343
}
4444

4545
test("we should find exactly one conflict in this analysis") {

src/test/scala/br/unb/cic/soot/IfElseTest.scala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package br.unb.cic.soot
22

33
import br.unb.cic.soot.graph._
4-
import org.scalatest.FunSuite
4+
import org.scalatest.{BeforeAndAfter, FunSuite}
55
import soot.jimple.{AssignStmt, InvokeExpr, InvokeStmt}
66

77
class IfElseTest extends JSVFATest {
@@ -33,13 +33,21 @@ class IfElseTest extends JSVFATest {
3333
}
3434

3535

36-
class IfElseTestSuite extends FunSuite {
37-
test("we should correctly compute the number of nodes and edges") {
38-
val svfa = new IfElseTest()
36+
class IfElseTestSuite extends FunSuite with BeforeAndAfter {
37+
var svfa: IfElseTest = _
38+
39+
before {
40+
svfa = new IfElseTest()
3941
svfa.buildSparseValueFlowGraph()
42+
}
43+
44+
test("we should correctly compute the number of nodes and edges") {
4045
assert(svfa.svg.nodes.size == 12)
41-
assert(svfa.svg.numberOfEdges() == 13)
46+
assert(svfa.svg.numberOfEdges() == 11)
47+
}
4248

43-
assert(!svfa.reportConflicts().isEmpty)
49+
test("we should find exactly one conflict in this analysis") {
50+
println(svfa.svgToDotModel())
51+
assert(svfa.reportConflicts().size == 1)
4452
}
4553
}

0 commit comments

Comments
 (0)