Exercises for Week Two.

Consider the following module, described by pseudo-code.

Procedure ConvertRtoN (roman:string; VAR number:integer)

Procedure to convert a string containing a roman numeral into the equivalent integer value.
Input: a string variable containing the string of characters making up the roman numeral.
Output: An integer variable containing the same value.
Local: numchar is integer variable containing length of string
i is control variable for loop

Pseudo-code

Set number to zero.
Set numchar to the length of the string using Length(roman).
Begin loop for i from 1 to numchar
	Copy ith character from the string into letter
	IF letter = “M” then add 1000 to number
	IF letter = “D” then add 500 to number
	IF letter = “C” then add 100 to number
	IF letter = “L” then add 50 to number
	IF letter = “X” then add 10 to number
	IF letter = “V” then add 5 to number
	IF letter = “I” then add 1 to number
End loop
Return to calling module and end procedure.

Black Box Testing.
What are the equivalence classes for this procedure?
How many test cases are needed?

Follow through the logic and say what values you expect for each of the following text strings.
I II III IIII V VI VII VIII VIIII X FIVE SIX SEVEN IV XIV XIIII
What additional values do you need to test this procdure fully?

Is boundary value analysis suitable for this procedure?
Is it suitable for other single procedures?
Is it suitable for large programs involving several procedures?

Glass-Box testing.

Are there different paths through the procedure which need extra testing?
Do the equivalence classes defined above give tests for each route through the program?
What other error conditions are possible? How does the procedure deal with these?


Hand in your solutions to the above questions by twelve noon on Tuesday.

If time, you might also consider how to extend the module so that it checks for other conditions in the later Roman numerals. e.g. the use of IV for four and similar cases where the order of the letters is significant, or a check to ensure that the number of ocurrances of any letter does not exceed its maximum permitted value.

What cohesion does this module exhibit?