SkillAgentSearch skills...

Microtest.h

C++ single-header-only unit testing framework

Install / Use

/learn @torpedro/Microtest.h
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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();
View on GitHub
GitHub Stars6
CategoryDevelopment
Updated2y ago
Forks6

Languages

C++

Security Score

75/100

Audited on May 29, 2023

No findings