Skip to content

Simple unit test framework made with C++ macro.

Notifications You must be signed in to change notification settings

Curt-Park/JWTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to use

 #include <iostream>
 #include "JWTestMain.h"
 
 //Test Suite Starts Here
 START_TEST_SUITE(SUITE_NAME)
     //Test Case1 Starts Here
     START_TEST_CASE("Test Case1")
         EXPECT_TRUE(1==1); // Ends with semicolon!
         EXPECT_FALSE(2==1);
         TEST_INFO("So Simple Test!");
     END_TEST_CASE()
     
     //Test Case2 Starts Here
     START_TEST_CASE("Test Case2")
         EXPECT_EQUAL(3, 3); 
         EXPECT_STR_EQUAL("haha", "haha");
     END_TEST_CASE()
 
     //Test Case3 Starts Here
     START_TEST_CASE("Test Case3")
         char c;
         std::cout<<"Don't input any number"<<std::endl;
         std::cin>>c;
         if(c>='0' && c<='9')
         {   
             TEST_FAIL("Just Fail!!!");
         }   
     END_TEST_CASE()
 END_TEST_SUITE()
 
 int main(void)
 {
     RUN_TEST_SUITE(SUITE_NAME);
     return 0;
 }

Result

ScreenShot

Functionalities

  1. EXPECT_EQUAL(A,B): check A equals to B
  2. EXPECT_STR_EQUAL(A,B): check str_A equals to str_B
  3. EXPECT_TRUE(A): check A returns true
  4. EXPECT_FALSE(B): check B returns false
  5. TEST_INFO(A): add a comment in a test case
  6. TEST_FAIL(A): trigger test failure

About

Simple unit test framework made with C++ macro.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages