This repository contains unit tests for the homework assignments of the course CS2100 at UTEC.
Feel free to create a pull request if you
- have tests that you consider useful. Thus, others students can also benefit from that. The more tests we have, the more bugs we can find in our implementations.
- would like to improve anything in this repository.
If you don’t know how to use Catch2, then consider watching this 5-minute video that shows a basic introduction on this framework.
First of all, you need clone this repository.
Having done that, you only need to execute make
, but in order for make
to know the location of the files and the name of the homework you want to test, you need to set environment variables as shown below.
HOMEWORK_LOCATION=../homeworks/bst HOMEWORK_NAME=bst make run
g++ -I ../homeworks/bst tests-main.o ./tests-bst.cpp ./a.out =============================================================================== All tests passed (8 assertions in 2 test cases)
You can also pass custom flags to Catch2 (see the two examples shown below.)
HOMEWORK_LOCATION=../homeworks/bst HOMEWORK_NAME=bst CATCH2_FLAGS="-t" make run
g++ -I ../homeworks/bst tests-main.o ./tests-bst.cpp ./a.out -t All available tags: 2 [BSTree] 1 [maxValue] 1 [minValue] 3 tags make: *** [makefile:38: run] Error 3
HOMEWORK_LOCATION=../homeworks/bst HOMEWORK_NAME=bst CATCH2_FLAGS="-l" make run
g++ -I ../homeworks/bst tests-main.o ./tests-bst.cpp ./a.out -l All available test cases: Getting the minimum value in a BST [BSTree][minValue] Getting the maximum value in a BST [BSTree][maxValue] 2 test cases make: *** [makefile:38: run] Error 2
You can find all the flags that Catch2 supports in the official documenation of Catch2.