Software Testing — Assignment 2 [15 marks total]

Answer all questions below — one tab per question. Q4 has an interactive playground. Your answers auto-save in this browser; export them as JSON at the bottom when done.

Q1  Extended Entry Decision Table [3 pts] · single choice

Test the UNSW Lecture-Theatre Booking system with Decision-Table testing. The system evaluates multi-valued conditions across several inputs to decide whether a booking is Booked, Wait-listed, or Rejected. Rules are checked one by one and the first matching rule applies.

Input specification

InputDomain valuesIn your submission
room_sizeSmall, Medium, Large1=Small, 2=Medium, 3=Large
time_slotMorning, Afternoon, Evening1=Morning, 2=Afternoon, 3=Evening
week1 to 12Numeric as is
equipmentStandard, AV, ComputerLab, Hybrid1=Standard, 2=AV, 3=ComputerLab, 4=Hybrid
staff_roleAcademic, Admin, Guest1=Academic, 2=Admin, 3=Guest

Output codes

CodeStatusTypical reason
0BookedRequest satisfies all constraints; first available room assigned
1Wait-listRequest valid but cannot be immediately fulfilled
2RejectedRequest violates system rules or contains invalid input

Program description

The program checks each rule one by one.

  1. A. Invalid Default. If any input contains an invalid value, the request is immediately rejected. Room size must be Small, Medium, or Large; time slot Morning, Afternoon, or Evening; week between 1 and 12; equipment Standard, AV, ComputerLab, or Hybrid; staff role Academic, Admin, or Guest.
  2. B. Exam-week nest. In exam weeks 11–12, only academic staff may book; everyone else is rejected. Even academics cannot request a Large theatre — those halls are blocked out for exams.
  3. C. Large-room. Any request for a Large lecture theatre must clear three hurdles, otherwise rejected: (1) Evening slot (large rooms close after 17:00); (2) Computer-Lab equipment (there are no large computer labs); (3) Guest requester (guests may not reserve large rooms).
  4. D. Equipment-specific. A Small room plus Hybrid kit is rejected.
  5. E. Guest + ComputerLab. A guest wanting a computer lab is never accepted outright during teaching weeks 1–10: early weeks 1–4 rejected, mid-semester 5–8 rejected, late weeks 9–10 rejected.
  6. F. Admin + Small. An admin requesting a Small room is wait-listed if either the slot is in the evening, or it is exam week.
  7. G. First-matching-theatre book. If none of the above rules block the request, the system books the first room that matches the requested size, contains the requested equipment, and (for evening bookings) allows evening use.
  8. H. Fallback. If no room can be booked after all checks, the request is put on a general wait-list with the reason “No matching theatre currently available”. (Rule H is outside the scope of this decision table.)

Assume that whenever a valid request is not blocked by Rules A–F, at least one matching theatre is always available.

Notation. ! = not; / = alternative; - = a range (e.g. room_size 1-3) or a don't-care. Week ranges are inclusive. The Default row applies when inputs are valid but match no prior rule. If a rule is already caught by an earlier rule, its outcome is N/A. Invalid rows use an out-of-domain value such as room_size 0 or week 13. Exactly one table below is correct — select it.

Reference function — binary_search (used in Q2–Q4)

Q2  Control-Flow Graph [2 pts] · single choice

Draw the control-flow graph for binary_search. Below are four candidate CFGs, written as complete DOT graphs and rendered. Exactly one is correct — select it.

Reference function — binary_search (used in Q2–Q4)

Q3  Loop-Boundary Test Cases [2 pts] · fill in the blanks

Develop a test suite achieving loop-boundary coverage (loop runs 0, 1, and 2 times). Fill each circled blank. Recall mid = int(round((top+bott)/2.0)).

Marking: each loop case = 1 mark; within a case, one wrong blank −0.5, two or more wrong −1.


  
Reference function — binary_search (used in Q2–Q4)

Q4  Coverage and Bug [6 pts] · playground

The Q3 suite reaches loop-boundary coverage, but coverage does not guarantee fault detection. This question asks you to demonstrate that gap on the binary_search function above.

(a) Introduce exactly one single-line bug into binary_search so that all three Q3 tests still pass (the bug is invisible to the Q3 suite). (b) Provide one extra test case — with target, key, the original output, and the variant output — that distinguishes the variant from the original (original passes it, variant fails).

Use the playground: edit the function to your variant, enter your distinguishing test, and press Run check. It reports whether your variant still passes the Q3 suite and whether your test separates the two.

(a) Describe your one-line change (form from → to):

Q4 Playground Loading Python runtime…
Fill these in yourself. Run check also prints the actual outputs so you can confirm.
(edit the function, fill the test, then Run check)

Q5  Halstead Programming Effort [2 pts] · single choice

Calculate the Halstead programming effort for the following code (parentheses are not counted as operators):


  
Student ID