Skip to content

Med-Yassine-B/Th_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CPP_TESTING_FRAMEWORK

An easy to use testing framework for cpp

usage

Simply copy the ./th_test.hpp to your test/ directory and include the header following the ./test_example.cpp

Simple example

//file_to_test.cpp

int squared(int x){
    return x*x;
}
//test.cpp

#include "th_test.hpp"
#include "file_to_test.cpp"

void test_squared(){
    TH_TEST::assert(squared(2)==4)//passing test
    TH_TEST::assert(squared(2)==6)//failing test
    TH_TEST::assert(squared(2)==4)//failing test

}
TEST(test_squared)
//note: this will register as a single test but throw multiple errors!

int main(){
    //tests are gonna run here and show the failing ones
    TH_TEST::RUN_TESTS();

    return 0;
}

How the testing framework works

the testing works by registering tests and their data (file,line,function name) in a vector, execute the tests and track if they passed.then show the resaults

Why use this framework?

  • This framework helps creating test cases easily for cpp programs
  • Easy to add to the project (a single header copy/paste)
  • Easy to use and non time consuming

About

An easy to use testing framework for cpp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages