This document contains a mid-semester examination for a software testing methodologies course. It consists of 4 questions. Question 1 provides code to check if a URL string contains any illegal characters and tests the validity of the URL. Question 2 describes a health insurance specification and asks to identify causes and effects to generate a cause-effect graph and test cases. Question 3 provides code to calculate a car insurance premium based on various factors and asks to derive test cases for white box testing methods. Question 4 analyzes a binary search procedure and asks to provide associations to satisfy all-definitions and all-uses criteria for a variable.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
140 views4 pages
STM Emc Iiisem Midsem
This document contains a mid-semester examination for a software testing methodologies course. It consists of 4 questions. Question 1 provides code to check if a URL string contains any illegal characters and tests the validity of the URL. Question 2 describes a health insurance specification and asks to identify causes and effects to generate a cause-effect graph and test cases. Question 3 provides code to calculate a car insurance premium based on various factors and asks to derive test cases for white box testing methods. Question 4 analyzes a binary search procedure and asks to provide associations to satisfy all-definitions and all-uses criteria for a variable.
1. The following function, written in a Pascal-like pseudo-code, takes as input a string assumed to be a URL and checks to see if it contains any characters that are illegal. Illegal URL characters are control characters (0-31, 127 decimal), space (32 decimal), and delimiter characters (">", "<", "#", "%", and the double quote character). The function returns true if the URL is valid (does not contain an illegal character), and false if the URL is invalid (contains an illegal character).
For the switch statement, the conditional is evaluated, then code associated with the conditional runs, then execution goes to the statement immediately after the end of the switch. Strings are represented as a (length, character buffer) pair. That is, you do not need to explicitly null terminate your strings.
is_illegal(input String url, output Boolean valid) Integer i; Char c; valid =TRUE; i = 1; while (i <= length(url) AND valid == TRUE) begin c = url[i]; if (c >= 0 AND c <= 32) then valid = false; else switch (c) case ">": valid = false; case "<": valid = false; case "#": valid = false; case "%": valid = false; case "\"": check for quote character valid = false; end switch; end if; end while; end;
2 For the following program, provide the following: a. DD Path graph [2] b. The set of unique paths through the program [3] c. For each feasible path, exact values of program variables that would cause the path to be executed. [3] d. Cyclomatic complexity [2]
2. Consider the specification given below. Identify the Causes and Effects in this specification and then produce a cause effect graph showing their relationship. Using this truth table construct a set of test cases for this specification.
Specification: the basic cost of a health insurance premium is 100, however, this premium can increase or decrease depending on two factors: their age and whether they are a smoker. Customers who are above the age of 65 have their insurance premium increased by 50. Customers who smoke have their premium increased by 60. Customers who are above the age of 65 and also smoke have their premium increased by 120 [5]
3. The basic cost of an insurance premium for drivers is 500, however, this premium can increase or decrease depending on four factors: their age, their gender, their marital status and number of penalty points. The input gender is given by the character M for male and F for female. Drivers that are below the age of 25, male and single face an additional premium increase of 1500. If a driver outside of this bracket is married or female their premium reduces by 200, and if there are aged between 46 and 65 inclusive, their premium goes down by 100. Regardless of their status a driver will be charged an extra 20 for each penalty point they have up to a maximum of 5. An entry of 0 is made for drivers with no penalty points
(1) int CarIns (int age, char gender, boolean married, int points) { (2) Premium=500; (3) If ((age<25) && (gender==M) && (!married)) { (4) Premium += 1500; (5) } else { (6) If (married || gender==F) { (7) Premium -= 200 (8) } (9) If ((age>45) && (age<65)) { (10) Premium -= 100; (11) } (12) } (13) if (points>5) { (14) points=5; (15) } (16) Premium = Premium + points*20; (17) return Premium; (18) } 3 Derive test cases and test data for the following White Box Software testing methods: i. Statement Testing [2] ii. Condition Coverage Testing [3] iii. Multiple Condition Coverage Testing [4]
4. For the following binary search procedure.
1. int BSearch (List, Elem, LEN) 2. int LEN, List [LEN], Elem; 3. { 4. int high, low, mid; 5. 6. low = 1; 7. high = LEN-1; 8. mid = (low + high) / 2; 9. while (Elem != List[mid]) 10. { 11. mid = (low + high) / 2; 12. if (high < low) 13. return (FALSE); 14. else if (Elem == List[mid]) 15. return (TRUE); 16. else if (Elem > List[mid]) 17. low = mid + 1; 18. else 19. high = mid - 1; 20. } 21. return (TRUE); 22. }
a. Give the required associations to satisfy All-Defs for the variable mid (both definitions of mid). [2] b. Give the required associations to satisfy All-Uses for the variable mid (both definitions of mid). [4]
NOTE:
1. The Question Paper has 3 printed Pages and 4 Questions. 2. The Questions which requires justification for answers will be awarded marks only if justification is provided. Else no marks will be awarded. 3. Just Answer to the Question. Do not write additional things which are not required. It will not fetch you any marks. 4. Copying is a serious offence. You will be severely penalized if there are evidences leading to the confirmation of my suspicion 4