You are going to write tests for the following program. Its requirements are to Take an integer array data of SIZE elements Take...
You are going to write tests for the following program.
Its requirements are to
Take an integer array data of SIZE elements
Take a positive, non-null, integer value n
If the value is null or negative, the program should not alter the array
If it is positive, each element in the array should be shifted right by n positions
If an element is pushed past the end of the array, we keep pushing it as if the end of the array connected to its start. Our array is a kind of “ring”.
Your objective is to write tests which will guarantee
The program conforms to the requirements; the program below might or might not, your tests need to be able to determine this
All possible execution paths have been tested
Your program does not feature any of the novice errors discussed in the textbook / videos / …
Program to Test
// all arrays in this program will have same size
#define SIZE 3
void rotate(int data[], int n){
int index = 0;
int tmp[SIZE];
// copying data into tmp array
for(index = 0 ; index < SIZE ; index++){
tmp[index] = data[index];
}
for(index = 0 ; index < SIZE ; index++){
next = (index + n) % SIZE;
data[next] = tmp[index];
}
}
12 years ago 5
- •What are the key financial policy targets for which the board is responsible for? List and explain each.
- You have a rack that can hold 30 CDs you can fit seven more CDs on the rack before the...
- inf342 project quality
- case study 6.3 northouse theory and leadership
- Asthma attack Nashnana
- corp
- For Mhlbraveheart only
- career path planning
- Read over the media messages released over the last two months. Choose one of the messages and create the next media message in the series. Be creative in your approach. Use Box 6-2 on page 63 of the textbook to guide you.
- phi