* Switch the archiving from the ‹zip› to ‹tar.gz› and ‹tar.bz2› * Adjust the static files to have consistent paths Signed-off-by: Matej Focko <me@mfocko.xyz>
5.3 KiB
id | title | description |
---|---|---|
seminar-10 | 10th seminar | Finding bugs in a hangman. |
Introduction
For this bonus you are given almost finished project - The Hangman Game. Your task is to try the game, in case you find any bugs point them out and cover as much of the game as possible with tests.
For this bonus you can get at maximum 2 K₡.
Item | Bonus |
---|---|
Fixing bugs from failing tests | 0.25 |
word_guessed |
0.50 |
Hidden bug | 0.50 |
Extending tests, undetectable bugs or evil bug | 0.37 |
Refactor | 0.38 |
Project
Project consists of 2 source files - hangman.c
and main.c
.
main.c
is quite short and concise, there is nothing for you to do.
hangman.c
contains implementation of the game. In case you feel lost, consult
the documentation in hangman.h
that represents an interface that can be used
for implementing the game.
Apart from those sources this project is a bit more complicated. Game loop is realised via single encapsulated function that complicates the testing. Because of that, there are 2 kinds of tests:
-
Unit tests - that are present in
test_hangman.c
and can be run via:$ make check-unit
They cover majorly functions that can be tested easily via testing framework.
-
Functional tests - same as in
seminar-08
and are focused on testing the program as whole. Basic smoke test is already included inusage
test case.They can be run via:
$ make check-functional
When testing
hangman
function (the game loop), it is suggested to create functional tests.When submitting the files for review, please leave out functional tests that were given as a part of the assignment, so that it is easier to navigate, I will drag the common files myself. :)
Whole test suite can be run via:
$ make check
Summary of the gameplay
- Secret word gets chosen from the file that's path is given as an argument.
- You get 8 guesses.
- Invalid characters don't count.
- Already guessed characters don't count, even if not included in the secret.
- You can guess the whole word at once
- If you get it right, you won, game ends.
- If you don't get it right, you get to see the secret, game ends.
- In case of end of input, game finishes via force.
- In case of invalid input, no guesses are subtracted, game carries on.
- Letters and words are not case sensitive.
Suggested workflow
As we have talked about on the seminar, I suggest you to follow Test-Driven Development in this case.
In our current scenario we are already in the stage of refactoring and fixing the bugs. Therefore try to follow this succession of steps:
- Try to reproduce the bug.
- Create a test that proves the presence of the bug.
- Fix the bug.
In case you are submitting the bonus via GitLab, it is helpful to commit tests
before commiting the fixes, so that it is apparent that the bug is manifested.
Example of git log
(notice that the first line represents latest commit):
feat: Implement fizz_buzzer
test: Add tests for fizz_buzzer
fix: Fix NULL-check in print_name
test: Add test for NULL in print_name
Tasks
As to your tasks, there are multiple things wrong in this project.
-
There are 2 "bugs" that cannot be detected via tests, i.e. they are not bugs that affect functionality of the game.
-
There is one evil bug in
get_word
. It is not required to be fixed ;) Assign it the lowest priority. -
There are some tests failing. Please try to figure it out, so you have green tests for the rest :)
-
We have gotten a bug report for
word_guessed
, all we got isdoesn't work when there are too many
a
sPlease try to replicate the bug and create a tests, so we don't get any regression later on.
-
One hidden bug :) Closely non-specified, we cannot reproduce it and we were drunk while playing the game, so we don't remember a thing. :/
-
Try to cover as much code via the tests as possible. We are not going to look at the metrics, but DRY is violated a lot, so as a last task try to remove as much of the duplicit code as possible.
Tests should help you a lot in case there are some regressions.
In case you wonder why there are always 3 same words in the file with words, it
is because of the get_word
bug. It is not a bug that can be easily fixed, so
it is a not requirement at all and you can still get all points for the bonus ;)
Dictionary
Submitting
In case you have any questions, feel free to reach out to me.
Ideally submit the assignment through the merge request. Step-by-step tutorial
is present here. For setting assignee my xlogin is xfocko
.
In case you do not want to experiment on GitLab, send me the source code via
email, but please prefix subject with: [PB071/14][seminar-10]
Deadline for the submission of the bonus is May 17 24:00.