volume_mute

Partition Testing for catWhiteSpace

publish date2026/06/19 10:41:43.865487 UTC

volume_mute

A method called catWhiteSpace is part of a 'Paragraph' object. Within a paragraph, it replaces sequences of blank characters with a single blank character. For example, 'Hello   World' becomes 'Hello World'. Which of the following correctly identifies the input partitions for testing this method? Select all that apply.

Correct Answer

(1) A sequence with no blank characters (all other characters)
(2) A sequence with a single blank character between words
(3) A sequence with two or more consecutive blank characters
(4) An empty paragraph with no content
(5) A paragraph consisting only of blank characters
(6) A paragraph where blanks appear only at the beginning
(7) A paragraph where blanks appear only at the end

Explanation

Valid partitions for catWhiteSpace include: (1) no blanks - nothing to collapse; (2) single blanks between words - already compressed, should be unchanged; (3) multiple consecutive blanks - the primary transformation case; (4) empty paragraph - edge case; (5) all blanks - should become a single blank; (6) leading blanks only; (7) trailing blanks only. Each partition exercises a different behavioral path in the method.

Reference

Software Engineering, Ian Sommerville, 10th edition


Quizzes you can take where this question appears