This problem has two dimensions that influence the function's behavior: the index j and the guessed word itself. To thoroughly apply Boundary Value Testing, we isolate each of these variables and test how the logic transitions as we move across their respective boundaries. First, we hold the index constant and vary the guessed letter to reveal how matches, near-matches, and mismatches affect the outcome. Next, we hold the guessed word constant and vary the index to examine how the same characters behave across different positions in the word.
This two-dimensional BVT approach demonstrates how we can apply boundary testing not only across numeric thresholds, but across distinct control flow transitions, validating correctness from multiple interacting angles.
Equivalence Classes for checkLetters
Class |
Condition |
Description |
Expected Behavior |
EC1 |
guess[j] == secret[j] |
exact match |
green, increment rightSpot |
EC2 |
guess[j] != secret[j] && guess[j] in secret |
in word but wrong position |
yellow, rightSpot unchanged |
EC3 |
guess[j] not in secret |
completely incorrect |
gray, rightSpot unchanged |
These values represent boundaries between green → yellow → gray transitions, based on exact character alignment and word inclusion. We keep the index constant (j = 0) and vary only the guessed letter to examine how the output behavior changes across key logical transitions: an exact match, a letter in the word but in the wrong position, and a letter not in the word at all.
This isolation allows us to precisely identify the boundaries that shift the program from one behavior (green coloring and incrementing rightSpot) to another (yellow or gray coloring with no increment). Boundary Value Testing is not limited to numeric comparisons; it can be extended to categorical logic, such as character string comparisons and boolean condition transitions, wherever a meaningful behavioral boundary exists.
Test Cases Created in Step 1 - Dimension 1: Character Variation
For these tests, we hold the index constant (j = 0) and vary only the guessed letter to examine how the output behavior changes across the key logical transitions.
Test ID |
Secret Word |
Guessed Word |
Index (j) |
Expected Behavior |
Boundary Being Tested |
BVT1 |
"CRANE" |
"CRASS" |
0 |
Green, rightSpot++ |
'C' exact match (EC1) |
BVT2 |
"CRANE" |
"EATER" |
0 |
Yellow, rightSpot unchanged |
'E' in word but wrong position (EC2) |
BVT3 |
"CRANE" |
"PRANK" |
0 |
Gray, rightSpot unchanged |
'P' not in word (EC3) |
Test Cases Created in Step 1 - Dimension 2: Position Variation
We then shift focus to the second dimension, position. By keeping the guess word constant and varying the index j, we test how the function applies the same comparison logic across multiple positions in the word. Using a partially overlapping word like "CRASS" against the secret word "CRANE" allows us to track how the same letter behaves differently depending on its position.
Test ID |
Secret Word |
Guessed Word |
Index (j) |
Expected Behavior |
Boundary Being Tested |
BVT4 |
"CRANE" |
"CRASS" |
0 |
Green, rightSpot++ |
'C' at correct position (EC1) |
BVT5 |
"CRANE" |
"SCARS" |
1 |
Gray, rightSpot unchanged |
'C' at wrong position, but not in word at that position (EC3) |
BVT6 |
"CRANE" |
"TEACH" |
2 |
Green, rightSpot++ |
'A' exact match at position 2 matching 'A' in "CRANE" (EC1) |
To make this truly reflect Boundary Value Testing, we observe how the same guessed letter produces different behavior at different positions. For example, the character 'C' appears in both guess words, "CRASS" and "SCARS", but at different indices. In "CRASS", it aligns with the same position in the secret word (index 0), triggering a correct match (green). In "SCARS", the same 'C' appears at index 1, which does not match the corresponding character in the secret word, resulting in gray. This demonstrates that the function's output is not solely determined by the presence of the letter but also by its position.