INPUT Domain Stories¶
INPUT-STORY-001¶
AS A user I WANT the program to parse one or more minefields from standard input SO THAT each field can be processed correctly
Architecture Reference: Chapter 3 Context and Scope - External Interfaces, Chapter 5 Building Block View - Input Parser
INPUT-STORY-001-S1: Parse a single well-formed field¶
GIVEN
stdin contains a header line
R Cfollowed by R lines of.and*charactersthe input is terminated by
0 0
WHEN
the Input Parser reads stdin
THEN
exactly one
Fieldstruct is returnedthe struct contains the correct row count, column count, and grid rows
INPUT-STORY-001-S2: Parse multiple fields in sequence¶
GIVEN
stdin contains two or more fields, each preceded by its own
R Cheaderthe sequence is terminated by
0 0
WHEN
the Input Parser reads stdin
THEN
one
Fieldstruct is returned per field in the inputeach struct contains the correct dimensions and grid for its respective field
INPUT-STORY-001-S3: Return empty result for terminator-only input¶
GIVEN
stdin contains only the line
0 0
WHEN
the Input Parser reads stdin
THEN
an empty collection of fields is returned
no output is produced by the application
FE Sub-Stories¶
INPUT-FE-001.1¶
AS A user I WANT the program to accept input piped from a file or typed interactively SO THAT I can supply minefields in the standard way for a console application
Architecture Reference: Chapter 3 Context and Scope - External Interfaces, Chapter 7 Deployment View - Build and Run
INPUT-FE-001.1-S1: Accept piped file input¶
GIVEN
a text file containing valid minefield input exists on the developer machine
WHEN
the binary is launched with the file redirected to stdin (
./minesweeper < input.txt)
THEN
the program reads all fields from the file
annotated output is written to stdout
BE Sub-Stories¶
INPUT-BE-001.1¶
AS A developer
I WANT parseFields(istream&) to read and group header and grid lines into Field structs
SO THAT downstream components receive a well-defined data structure
Architecture Reference: Chapter 5 Building Block View - Input Parser, Chapter 8 Cross-Cutting Concepts - Testability
INPUT-BE-001.1-S1: Produce a correctly populated Field struct¶
GIVEN
an
istreamcontaining a header4 4followed by four grid rows
WHEN
parseFieldsis called with that stream
THEN
the returned vector contains one
FieldField.rowsequals4,Field.colsequals4Field.gridcontains exactly four strings matching the input rows
INPUT-BE-001.2¶
AS A developer
I WANT the parser to stop reading when it encounters 0 0
SO THAT the pipeline terminates correctly per the kata specification
Architecture Reference: Chapter 5 Building Block View - Input Parser, Chapter 6 Runtime View - Edge Case: Empty Input
INPUT-BE-001.2-S1: Stop on terminator line¶
GIVEN
an
istreamcontaining one valid field followed by0 0
WHEN
parseFieldsis called
THEN
only the fields before
0 0are returnedthe terminator line does not appear as a field or grid row
INFRA Sub-Stories¶
INPUT-INFRA-001.1¶
AS A developer
I WANT the Docker image to build successfully with g++ and Google Test available
SO THAT the project can be compiled and tested in a reproducible local container environment
Architecture Reference: Chapter 7 Deployment View - Build and Run, Chapter 2 Constraints - T-1
INPUT-INFRA-001.1-S1: Docker image builds with g++ and Google Test available¶
GIVEN
a
Dockerfileis present at the repository rootthe
Dockerfileinstallsg++andlibgtest-devand builds the Google Test libraries
WHEN
docker build -t kata-tests .is executed on the local machine
THEN
the image builds without errors
g++and the Google Test libraries are available inside the container
INPUT-INFRA-001.2¶
AS A developer
I WANT all parser tests to pass when running ./runTests inside the Docker container
SO THAT regressions in input parsing are detected in a clean, isolated local environment
Architecture Reference: Chapter 8 Cross-Cutting Concepts - Testability, Chapter 7 Deployment View - Build and Run
INPUT-INFRA-001.2-S1: Parser tests pass inside Docker¶
GIVEN
the
kata-testsDocker image has been built viadocker build -t kata-tests .the Dockerfile compiles
runTestsfromtests/*.cppand the source files usingg++ -std=c++17 -lgtest_main -lgtest -pthread
WHEN
docker run --rm kata-testsis executed
THEN
./runTestsruns inside the containerall parser-related tests pass
the container exits with code
0
INPUT-STORY-002¶
AS A user
I WANT input processing to stop when 0 0 is encountered
SO THAT the program terminates according to the kata rules
Architecture Reference: Chapter 5 Building Block View - Input Parser, Chapter 1 Introduction and Goals - F-4
INPUT-STORY-002-S1: Halt after reading the terminator¶
GIVEN
stdin contains one or more valid fields followed by the line
0 0
WHEN
the Input Parser reads stdin
THEN
parsing stops at
0 0only the fields read before the terminator are returned
INPUT-STORY-002-S2: Produce no output when terminator is the only input¶
GIVEN
stdin contains only
0 0
WHEN
the full pipeline runs
THEN
the parser returns an empty collection
nothing is written to stdout
BE Sub-Stories¶
INPUT-BE-002.1¶
AS A developer
I WANT the parser loop to exit as soon as it reads a header of 0 0
SO THAT no further lines are consumed after the terminator
Architecture Reference: Chapter 5 Building Block View - Input Parser, Chapter 6 Runtime View - Edge Case: Empty Input
INPUT-BE-002.1-S1: Exit loop on zero-dimension header¶
GIVEN
an
istreamwhose next header line is0 0
WHEN
parseFieldsreads that header
THEN
the parsing loop exits immediately
no grid rows are read for that header
the returned vector contains only previously parsed fields
INFRA Sub-Stories¶
INPUT-INFRA-002.1¶
AS A developer
I WANT the terminator-handling test to run inside the Docker container
SO THAT the stop-on-0 0 behaviour is automatically verified in a clean local environment
Architecture Reference: Chapter 8 Cross-Cutting Concepts - Testability, Chapter 7 Deployment View - Build and Run
INPUT-INFRA-002.1-S1: Terminator test executes inside Docker¶
GIVEN
the
kata-testsDocker image has been built viadocker build -t kata-tests .a Google Test case for
parseFieldswith"0 0\n"input exists intests/
WHEN
docker run --rm kata-testsis executed
THEN
./runTestsruns inside the containerthe terminator test is discovered and passes
the container exits with code
0
INPUT-STORY-003¶
AS A user I WANT multiple fields to be read sequentially from one input stream SO THAT all provided minefields are processed in one run
Architecture Reference: Chapter 5 Building Block View - Input Parser, Chapter 6 Runtime View - Main Processing Scenario
INPUT-STORY-003-S1: All fields are parsed from a single stream¶
GIVEN
stdin contains three fields, each with its own
R Cheader and grid rowsthe stream ends with
0 0
WHEN
the Input Parser reads stdin
THEN
three
Fieldstructs are returnedthey appear in the same order as in the input
INPUT-STORY-003-S2: Each output block corresponds to the correct input field¶
GIVEN
stdin contains two fields with different dimensions and mine layouts
WHEN
the full pipeline runs
THEN
the first output block reflects the first input field
the second output block reflects the second input field
BE Sub-Stories¶
INPUT-BE-003.1¶
AS A developer
I WANT parseFields to accumulate all fields into a vector before returning
SO THAT main() can iterate over them in order
Architecture Reference: Chapter 5 Building Block View - Input Parser, Chapter 9 Architecture Decisions - ADR-001
INPUT-BE-003.1-S1: Return all fields in input order¶
GIVEN
an
istreamcontaining two fields followed by0 0
WHEN
parseFieldsis called
THEN
the returned vector has exactly two elements
element 0 matches the first field, element 1 matches the second field
INFRA Sub-Stories¶
INPUT-INFRA-003.1¶
AS A developer I WANT the multi-field parsing test to run inside the Docker container SO THAT sequential parsing is automatically verified in a clean local environment
Architecture Reference: Chapter 8 Cross-Cutting Concepts - Testability, Chapter 7 Deployment View - Build and Run
INPUT-INFRA-003.1-S1: Multi-field test executes inside Docker¶
GIVEN
the
kata-testsDocker image has been built viadocker build -t kata-tests .a Google Test case supplying two fields via a
stringstreamexists intests/
WHEN
docker run --rm kata-testsis executed
THEN
./runTestsruns inside the containerthe multi-field test is discovered and passes
the container exits with code
0
Traceability Verification¶
Scenario ID |
Architecture Reference |
Parent Story |
Testable Assertion |
|---|---|---|---|
INPUT-STORY-001-S1 |
Chapter 5 Building Block View - Input Parser |
INPUT-STORY-001 |
single field parsed into correct Field struct |
INPUT-STORY-001-S2 |
Chapter 5 Building Block View - Input Parser |
INPUT-STORY-001 |
multiple fields each produce a correct Field struct |
INPUT-STORY-001-S3 |
Chapter 6 Runtime View - Edge Case: Empty Input |
INPUT-STORY-001 |
terminator-only input returns empty collection |
INPUT-FE-001.1-S1 |
Chapter 7 Deployment View - Build and Run |
INPUT-FE-001.1 |
binary accepts piped file and writes output to stdout |
INPUT-BE-001.1-S1 |
Chapter 5 Building Block View - Input Parser |
INPUT-BE-001.1 |
Field struct has correct rows, cols, and grid |
INPUT-BE-001.2-S1 |
Chapter 6 Runtime View - Edge Case: Empty Input |
INPUT-BE-001.2 |
parser stops at |
INPUT-INFRA-001.1-S1 |
Chapter 7 Deployment View - Build and Run |
INPUT-INFRA-001.1 |
|
INPUT-INFRA-001.2-S1 |
Chapter 8 Cross-Cutting Concepts - Testability |
INPUT-INFRA-001.2 |
|
INPUT-STORY-002-S1 |
Chapter 5 Building Block View - Input Parser |
INPUT-STORY-002 |
parser halts and returns only fields read before |
INPUT-STORY-002-S2 |
Chapter 6 Runtime View - Edge Case: Empty Input |
INPUT-STORY-002 |
|
INPUT-BE-002.1-S1 |
Chapter 5 Building Block View - Input Parser |
INPUT-BE-002.1 |
loop exits immediately when header row equals |
INPUT-INFRA-002.1-S1 |
Chapter 8 Cross-Cutting Concepts - Testability |
INPUT-INFRA-002.1 |
|
INPUT-STORY-003-S1 |
Chapter 5 Building Block View - Input Parser |
INPUT-STORY-003 |
all fields in a multi-field stream are returned in order |
INPUT-STORY-003-S2 |
Chapter 6 Runtime View - Main Processing Scenario |
INPUT-STORY-003 |
each output field corresponds to the correct input field |
INPUT-BE-003.1-S1 |
Chapter 5 Building Block View - Input Parser |
INPUT-BE-003.1 |
vector contains one Field per input field in correct order |
INPUT-INFRA-003.1-S1 |
Chapter 8 Cross-Cutting Concepts - Testability |
INPUT-INFRA-003.1 |
|