Skip to the task
Layout
Back to classic view
READTask 1 of 17 · step 1: How the test works

How the test works

Two parts: questions without a compiler and two programs in the test/2 folder with autotests. They give no points.

The test after topic 12 checks topics 7–12: modules, pointers and bits, strings, structs, files and dynamic memory. This lesson is practice in the same shape.

Two parts

  • Questions. Short code: what it prints, why it doesn't compile, where the bug is. You answer on your own, without a compiler. There are twelve here, each with an answer and an explanation.
  • Programs. Two small tasks in the test/2/ folder: words.c and shopping.c. Autotests check them, like the homework.

How long the real test takes and what you may use will be announced by your lecturer. Practice has no time limit, but try to write both tasks within an hour and a half.

How to check the programs

The task descriptions and the exact output text are in steps 4 and 5 and in the test/2/tests/ files. Run the tests like this:

ctest --preset debug -L test2

In CLion: the All CTest configuration and ▶. Both files already have the #includes and main; while they are empty, the tests fail.

These tasks give no points: GitHub Actions builds them and runs them with ASan and UBSan, but "Points" doesn't count them. They are for checking yourself.

What is checked, same as in the homework

  • the program builds without warnings (-Wall -Wextra -Werror -pedantic -Wvla);
  • the output matches the expected text letter by letter;
  • each part is a function with a contract and an assert, and main only calls them;
  • shopping.c: realloc, free and fclose are there, fscanf isn't, and GitHub CI finds no leak;
  • no TODO is left.

If you get stuck, go back to the topic the question comes from: every answer says which topic it belongs to.