Fix various Linter issues and mispelling
This commit is contained in:
2
tests/unit/.gitignore
vendored
2
tests/unit/.gitignore
vendored
@@ -19,4 +19,4 @@ build/
|
||||
|
||||
# Coverage file
|
||||
coverage.info
|
||||
coverage
|
||||
coverage
|
||||
|
||||
@@ -62,4 +62,4 @@ add_library(demo SHARED ./demo_tu.c)
|
||||
|
||||
target_link_libraries(test_demo PUBLIC cmocka gcov demo)
|
||||
|
||||
add_test(test_demo test_demo)
|
||||
add_test(test_demo test_demo)
|
||||
|
||||
@@ -39,4 +39,4 @@ clean:
|
||||
@if [ -d coverage ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage && $(RM) -r coverage ; fi;
|
||||
@if [ -f coverage.info ]; then $(ECHO) -e "${RED}[ RM ]${RESET}" coverage.info && $(RM) -r coverage.info ; fi;
|
||||
|
||||
.PHONY: all coverage clean
|
||||
.PHONY: all coverage clean
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Unit tests
|
||||
|
||||
It is important to unit test your functions.
|
||||
This also allows you to document how your functions work.
|
||||
It is important to unit test your functions.
|
||||
This also allows you to document how your functions work.
|
||||
We use the library [**cmocka**](https://cmocka.org/#features)
|
||||
|
||||
## Requirement
|
||||
@@ -9,11 +9,12 @@ We use the library [**cmocka**](https://cmocka.org/#features)
|
||||
- [CMake >= 3.10](https://cmake.org/download/)
|
||||
- [lcov >= 1.14](http://ltp.sourceforge.net/coverage/lcov.php)
|
||||
|
||||
Don't worry, you don't necessarily need to install the `cmocka library` because the **cmakelist automatically fetches** the library
|
||||
Don't worry, you don't necessarily need to install the `cmocka library`
|
||||
because the **cmakelist automatically fetches** the library
|
||||
|
||||
## Add new test
|
||||
|
||||
Create new file into `tests` folder and follow [this initiation](https://cmocka.org/talks/cmocka_unit_testing_and_mocking.pdf)
|
||||
Create new file into `tests` folder and follow [this initiation](https://cmocka.org/talks/cmocka_unit_testing_and_mocking.pdf)
|
||||
|
||||
Now go to the `CMakeLists.txt` file and add your test with the specific file you want to test.
|
||||
|
||||
@@ -27,12 +28,15 @@ The `default rules` of makefile will compile the tests and run them.
|
||||
make
|
||||
```
|
||||
|
||||
The `coverage rule` will launch the default rules and generate the coverage and you will be **automatically redirected** to the generated .html
|
||||
The `coverage rule` will launch the default rules and generate the coverage
|
||||
and you will be **automatically redirected** to the generated .html
|
||||
|
||||
```sh
|
||||
make coverage
|
||||
```
|
||||
|
||||
The `clean rule` will delete the folders and files generated
|
||||
|
||||
```sh
|
||||
make clean
|
||||
```
|
||||
```
|
||||
|
||||
@@ -9,4 +9,4 @@ int local_strchr_demo(char *string, char ch) {
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ int main(void) {
|
||||
cmocka_unit_test(null_test_success),
|
||||
};
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user