Skip to the task
Layout
Back to classic view

You are looking ahead. Your place is still task 1: Algorithm.

RUNTask 21 of 21 · step 8: Homework: the receiptRun the homework tests
Run the homework tests in practice/01/

In CLion pick All CTest and ▶, or run only topic 1's tests in the terminal. Fix things until both pass.

Checklist

  • Every task is one commit with a clear message.
Details & hint
$ ctest --preset debug -L hw01
    Start 2: hw01_receipt
1/2 Test #2: hw01_receipt .....................***Failed    0.08 sec

=== hw01_receipt: FAILED ===
The output differs on line 5.
  expected: |Item\tQty\tPrice|
  got:      |Item  Qty  Price|
  (\t = tab, ~ = a space at the end of the line)

You should see: While the receipt is wrong, the test shows the first line that differs, with tabs made visible (\t). Here spaces were typed instead of tabs. When all is well: 100% tests passed.

Stuck? The test compares the output with hw/01/tests/expected.txt: fix the program, not that file.

practice 01 main.c Code Diff
UNCHANGED This step does not change this file.
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
printf("\n");
printf("Algorithm: the average of grades\n");
printf("1. Add up all the grades.\n");
printf("2. Count how many grades there are.\n");
printf("3. Divide the sum by the count.\n");
printf("4. Print the answer.\n");
printf("\n");
printf("Grade\tMeaning\n");
printf("10\t\"excellent\"\n");
printf("5\t\"satisfactory\"\n");
printf("File: C:\\course\\practice\\01\\main.c\n");
printf("Done: 100%%\n");
return 0;
}
opened for this task
$ ctest --preset debug -L hw01
    Start 2: hw01_receipt
1/2 Test #2: hw01_receipt .....................***Failed    0.08 sec

=== hw01_receipt: FAILED ===
The output differs on line 5.
  expected: |Item\tQty\tPrice|
  got:      |Item  Qty  Price|
  (\t = tab, ~ = a space at the end of the line)