18 Questions
What is the primary purpose of a Control Flow Graph (CFG)?
To describe the control structures of a program
What is a Basic Block in a Control Flow Graph?
A sequence of statements with no branches
What does an edge in a Control Flow Graph represent?
A transfer of control
What is the purpose of annotating a Control Flow Graph with extra information?
To provide additional context for testing
What is the main difference between an if-else structure and an if structure without an else?
The presence of a default branch
What is the primary application of Graph Coverage?
To test software specifications
What is the chapter of the textbook that covers Graph Coverage?
Chapter 7
What is the name of the authors of the textbook 'Introduction to Software Testing'?
Paul Ammann and Jeff Offutt
In a CFG, what is the purpose of adding 'extra' nodes?
To handle loops
Which type of loop structure has an implicit initialization?
For loop
What is the condition for the while loop to terminate?
x >= y
What is the purpose of the return statement in a CFG?
To terminate the function
What is the purpose of the dummy node in a CFG?
To handle loops
In a CFG, what type of edges are not allowed?
Edges from node 2 to 3
What is the purpose of the incremental statement in a loop?
To increment the loop counter
What is the difference between a do-while loop and a while loop?
The do-while loop checks the condition after the loop body
What is the purpose of the print statement in a CFG?
To print the value of x
What is the purpose of the function call in the loop body?
To perform some calculation
Study Notes
Graph Coverage for Source Code
- A control flow graph (CFG) models all executions of a program by describing control structures.
- In a CFG, nodes represent statements or sequences of statements (basic blocks), and edges represent transfers of control.
- A basic block is a sequence of statements where if the first statement is executed, all statements will be (no branches).
- CFGs can be annotated with extra information.
Control Flow Graphs for if Statements
- In an if-else structure, CFG nodes are created for each branch.
- If there is no else clause, CFG nodes are still created to ensure proper control flow.
Control Flow Graphs for Loops
- Loops require additional nodes to be added to the CFG, which do not represent statements or basic blocks.
- In a while loop structure, a dummy node is added to ensure proper control flow.
- For loop structures, nodes are implicitly created to handle initialization and incrementation.
- Do-while loop structures also require additional nodes for proper control flow.
This quiz covers chapters 7.3-7.6 of the 2nd edition of 'Introduction to Software Testing' by Paul Ammann and Jeff Offutt, focusing on graph coverage. It's designed for the SWE 202 course.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free