Software Testing & QA Homework Set 4: Testing Function Slope & Orthogonal Arrays, Assignments of Computer Science

Instructions for completing homework set 4 in the cpsc 6178 software testing and quality assurance course. It includes test cases for a function that calculates the slope of a line connecting two points in a plane, as well as instructions for using orthogonal arrays to select pairwise subsets for testing software under various options. The title and description should attract students in the field of computer science and software engineering who are interested in software testing and quality assurance.

Typology: Assignments

Pre 2010

Uploaded on 08/04/2009

koofers-user-mrz
koofers-user-mrz 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC 6178 Software Testing and Quality Assurance
Homework Set 4 Due Friday, November 18, 2005
KEY WITH ANSWERS AND COMMENTS.
1. We are asked to test a function that takes two pairs of points in a plane, (X1, Y1) and
(X2, Y2) and produces the slope of the line connecting the two points. The result refers
to the use of an equation of the form Y = MX + B to describe the line.
Devise a number of tests and specify them in the form (X1, Y1, X2, Y2, M) – that is,
the two points and the expected result – that will test the correct functioning of the
software. Allow for both positive and negative slopes. Hint: Only four test cases
are required, one of which cannot easily be specified by the 5–tuple.
ANSWERS: We begin with the expected answers and then continue the discussion.
For this discussion, consider four distinct real numbers (A, B, C, D), with no two equal.
The basic four scenarios (and an extra one) for testing are the following.
1. Let X1 = A, X2 = B, Y1 = C, Y2 = D and verify that M = (D – C) / (B – A),
2. Let X1 = B, X2 = A, Y1 = C, Y2 = D and verify that M = (D – C) / (A – B).
One might verify that this is the negative of the first slope.
3. Let X1 = A, X2 = B, Y1 = C, Y2 = C and verify that M = 0.
4. Let X1 = A, X2 = A, Y1 = C, Y2 = D and verify that an exception is raised properly.
5. Let X1 = A, X2 = A, Y1 = C, Y2 = C and investigate the return value.
For those who want to push the arithmetic precision issue, here is a test that might be run.
// Assume that x1 and y1 have been given numeric values at this point.
// Assume that all numeric variables are declared identically: either float or double.
// The sole exception to this rule is the integer counter n, declared as type int.
//
try { y2 = y1 + 1.0 ;
delta = 1.0 ;
x2 = x1 + 1.0 ; // Really x2 = x1 + (1.0 / delta )
n = 1 ;
while ( x2 > x1 ) // This allows for the precision of the type
{ slope (x1, x2, y1, y2, m ) ;
println ( format_string, n, delta, m ) ;
delta = delta * 8.0 ; // Later division by 10 introduces imprecision.
n = n + 1 ;
x2 = x1 + (1.0 / delta) ; // Shrink the X interval
} ;
println ( format_string, “Normal termination ”)
return ;
} ;
catch { // catch any numeric overflow here
println ( format_string, “Numeric overflow for delta = ” , delta ) ;
} ;
pf3

Partial preview of the text

Download Software Testing & QA Homework Set 4: Testing Function Slope & Orthogonal Arrays and more Assignments Computer Science in PDF only on Docsity!

CPSC 6178 Software Testing and Quality Assurance

Homework Set 4 Due Friday, November 18, 2005

KEY WITH ANSWERS AND COMMENTS.

  1. We are asked to test a function that takes two pairs of points in a plane, (X1, Y1) and (X2, Y2) and produces the slope of the line connecting the two points. The result refers to the use of an equation of the form Y = MX + B to describe the line. Devise a number of tests and specify them in the form (X1, Y1, X2, Y2, M) – that is, the two points and the expected result – that will test the correct functioning of the software. Allow for both positive and negative slopes. Hint: Only four test cases are required, one of which cannot easily be specified by the 5–tuple. ANSWERS: We begin with the expected answers and then continue the discussion. For this discussion, consider four distinct real numbers (A, B, C, D), with no two equal. The basic four scenarios (and an extra one) for testing are the following.
    1. Let X1 = A, X2 = B, Y1 = C, Y2 = D and verify that M = (D – C) / (B – A),
    2. Let X1 = B, X2 = A, Y1 = C, Y2 = D and verify that M = (D – C) / (A – B). One might verify that this is the negative of the first slope.
    3. Let X1 = A, X2 = B, Y1 = C, Y2 = C and verify that M = 0.
    4. Let X1 = A, X2 = A, Y1 = C, Y2 = D and verify that an exception is raised properly.
    5. Let X1 = A, X2 = A, Y1 = C, Y2 = C and investigate the return value. For those who want to push the arithmetic precision issue, here is a test that might be run. // Assume that x1 and y1 have been given numeric values at this point. // Assume that all numeric variables are declared identically: either float or double. // The sole exception to this rule is the integer counter n, declared as type int. // try { y2 = y1 + 1.0 ; delta = 1.0 ; x2 = x1 + 1.0 ; // Really x2 = x1 + (1.0 / delta ) n = 1 ; while ( x2 > x1 ) // This allows for the precision of the type { slope (x1, x2, y1, y2, m ) ; println ( format_string, n, delta, m ) ; delta = delta * 8.0 ; // Later division by 10 introduces imprecision. n = n + 1 ; x2 = x1 + (1.0 / delta) ; // Shrink the X interval } ; println ( format_string, “Normal termination ”) return ; } ; catch { // catch any numeric overflow here println ( format_string, “Numeric overflow for delta = ” , delta ) ; } ;
  1. You are asked to devise a number of test cases for software that will be used under a number of options. a) Three browser options: Internet Explorer, Netscape, and Firefox, b) Client Operating System: Windows XP, MacOS, and Linux c) Server Operating System: Windows NT, Windows XP, and Linux d) Plug In: None, RealPlayer, and Windows Media Player e) Server: IIS, Apache, and WebLogic Use the textbook’s method of orthogonal arrays to select pairwise subsets for testing this software. Be sure to give the name of the orthogonal array using the notation on page 67 of the textbook. ANSWER: First, we count the numbers of options. a) Browser 3 b) Client OS 3 c) Server OS 3 d) Plug In 3 e) Server 3 We now follow the instructions on pages 71 – 85 of the textbook.
    1. Identify the variables: DONE
    2. Determine the choices: DONE
    3. Locate an appropriate orthogonal array. We have five columns, each of which has a maximum value of 3. We need LR(3^5 ). The best candidate is L 18 (3^5 ), table 6–3 on page 69. 1 1 1 1 1 1 2 1 2 3 3 1 3 1 3 2 3 2 4 1 2 2 1 3 5 1 3 1 2 3 6 1 1 3 2 2 7 2 2 2 2 2 8 2 3 1 1 2 9 2 1 3 1 3 10 2 3 3 2 1 11 2 1 2 3 1 12 2 2 1 3 3 13 3 3 3 3 3 14 3 1 2 2 3 15 3 2 1 2 1 16 3 1 1 3 2 17 3 2 3 1 2 18 3 2 3 1 2 The test matrix generated should be based on this 18–by–5 matrix.