Skip to content

torpedro/microtest.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microtest.h (C++)

GitHub release Build Status

This is a small header-only C++ unit testing framework. It allows to define small unit tests with set of assertions available. It is contained within a single header file, so you can simply copy that header file to your project and don't have to link libraries or include multiple header files, if all you need is a quick testing framework.

How to Use

To create a test file you only need to include microtest/microtest.h. Then you can define your unit tests. To execute all tests one of your source files needs to contain the TEST_MAIN(); macro. See the following example:

#include "microtest/microtest.h"

TEST(ExampleSucceedingTest) {
  ASSERT(true);

  ASSERT_TRUE(true);

  ASSERT_FALSE(false);

  ASSERT_EQ(20, 20);

  ASSERT_NULL(NULL);

  int* x = new int;
  ASSERT_NOTNULL(x);
  delete x;

  ASSERT_STREQ("abc", "abc");
}

TEST(ExampleFailingTest) {
  ASSERT_EQ(20, 5);
}

TEST_MAIN();

Releases

No releases published

Packages

No packages published