https://github.com/jorgepiloto/scitest
A simple header file for testing your own scientific C libraries
https://github.com/jorgepiloto/scitest
Last synced: 3 months ago
JSON representation
A simple header file for testing your own scientific C libraries
- Host: GitHub
- URL: https://github.com/jorgepiloto/scitest
- Owner: jorgepiloto
- Created: 2020-05-16T17:29:00.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T07:29:46.000Z (about 5 years ago)
- Last Synced: 2025-01-25T21:11:26.853Z (5 months ago)
- Language: C
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
SCITEST: a simple header file for unit testing in C
===================================================Although there are lots of testing frameworks available for C programming I
found most of them "too complex" for such a simple task. Therefore I ended up
developing my own testing framework oriented to scientific development.How to use
----------
Simply copy the **scitest.h** header inside yout `tests/` directory. Let us see
how to create a simple file test under the name `test_example.c`:```c
#include "scitest.h"/**
* Tests the addition of two integer numbers
*/
void test_add_two_numbers( void ) {
/* Define actual and expected values for the test */
int actual = 2 + 2;
int expected = 4;
/* Assert if both integer values are equal */
ASSERT_INT_EQUAL(actual, expected);
}/**
* Main function in which tests are collected
*/
int main ( void ) {/* Test session begins */
START_TEST_SESSION();/* A collection of tests */
RUN_TEST("test_add_two_numbers", test_add_two_numbers);/* Collect results and finish test session */
FINISH_TEST_SESSION();return 0;
}
```This output is very similar to the one shown by the Pytest framework from Python
language:```bash
============================ TEST SESSION STARTS =========================test_add_two_numbers... [PASSED]
==========================
PASSED: 1 FAILED: 0
```Future improvements
-------------------I still need to add more MACROS related to floats, double, pointers, structures
and others. Hope to do it as soon as I required them.