mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-08-11 23:59:33 +02:00
Created Test Cases (markdown)
44
Test-Cases.md
Normal file
44
Test-Cases.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
The boxes sources have a low-tech test suite in the [test](https://github.com/ascii-boxes/boxes/tree/master/test) subdirectory.<br>
|
||||||
|
The Travis CI server will execute it in order to make sure that a change did not break the program.
|
||||||
|
|
||||||
|
Currently, the test suite could use more test cases, so any help with growing the number of tests is highly appreciated.
|
||||||
|
|
||||||
|
###Invocation
|
||||||
|
|
||||||
|
Start the entire suite by running `make && make test` from the top level directory.
|
||||||
|
|
||||||
|
Run an individual test by calling `./testrunner.sh testcase.txt` from the *test* directory.
|
||||||
|
|
||||||
|
###Test Case Format
|
||||||
|
|
||||||
|
Each test case is a single file within the *test* subdirectory. It must follow this naming convention:
|
||||||
|
|
||||||
|
nnn_description.txt
|
||||||
|
|
||||||
|
where `nnn` is a three-digit number which uniquely identifies the test case. `description` is any short text that describes what the test case does. It must not contain spaces; use underscores instead. The file extension is always `.txt`.
|
||||||
|
|
||||||
|
A test case that tests a successful invocation of boxes looks like this:
|
||||||
|
|
||||||
|
:ARGS
|
||||||
|
-s 10x4
|
||||||
|
:INPUT
|
||||||
|
foo
|
||||||
|
:EXPECTED
|
||||||
|
/********/
|
||||||
|
/* foo */
|
||||||
|
/* */
|
||||||
|
/********/
|
||||||
|
:EOF
|
||||||
|
|
||||||
|
Sections may be empty, e.g. if there are no arguments or there is no input.
|
||||||
|
|
||||||
|
A test case that makes sure boxes fails under certain conditions looks like this:
|
||||||
|
|
||||||
|
:ARGS
|
||||||
|
-f nonexistent
|
||||||
|
:INPUT
|
||||||
|
:EXPECTED-ERROR 1
|
||||||
|
boxes: Couldn't open config file 'nonexistent' for input.
|
||||||
|
:EOF
|
||||||
|
|
||||||
|
Note that you write `:EXPECTED-ERROR` instead of just `:EXPECTED`, and the expected return code is given after a space (in this example, it is `1`).
|
Reference in New Issue
Block a user