Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:31:31+00:00 2026-06-01T10:31:31+00:00

Is there easily embeddable C++ test lib with a friendly license? I would like

  • 0

Is there easily embeddable C++ test lib with a friendly license? I would like a single header file. No .cpp files, no five petabytes of includes. So CppUnit and Boost.Test are out.

Basically all I want is to drop single file to project tree, include it and be able to write

 testEqual(a,b)

and see if it fail. I’d use assert, but it doesn’t work in non-debug mode and can’t print values of a and b, and before rewriting assert I’d rather search existing library.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:31:32+00:00Added an answer on June 1, 2026 at 10:31 am

    I’m tempted to say “write your own”, which is what I have done. On the other hand, you might want to reuse what I wrote: test_util.hpp and test_util.cpp. It is straightforward to inline the one definition from the cpp file into the hpp file. MIT lisence. I have also pasted it into this answer, below.

    This lets you write a test file like this:

    #include "test_util.hpp"
    
    bool test_one() {
        bool ok = true;
    
        CHECK_EQUAL(1, 1);
    
        return ok;
    }
    
    int main() {
        bool ok = true;
    
        ok &= test_one();
    
        // Alternatively, if you want better error reporting:
        ok &= EXEC(test_one);
    
        // ...
    
        return ok ? 0 : 1;
    }
    

    Browse around in the tests directory for more inspiration.


    // By Magnus Hoff, from http://stackoverflow.com/a/9964394
    
    #ifndef TEST_UTIL_HPP
    #define TEST_UTIL_HPP
    
    #include <iostream>
    
    // The error messages are formatted like GCC's error messages, to allow an IDE
    // to pick them up as error messages.
    #define REPORT(msg) \
        std::cerr << __FILE__ << ':' << __LINE__ << ": error: " msg << std::endl;
    
    #define CHECK_EQUAL(a, b) \
        if ((a) != (b)) { \
            REPORT( \
                "Failed test: " #a " == " #b " " \
                "(" << (a) << " != " << (b) << ')' \
            ) \
            ok = false; \
        }
    
    static bool execute(bool(*f)(), const char* f_name) {
        bool result = f();
        if (!result) {
            std::cerr << "Test failed: " << f_name << std::endl;
        }
        return result;
    }
    
    #define EXEC(f) execute(f, #f)
    
    #endif // TEST_UTIL_HPP
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to easily find an iterator where an element would be
Is there a way to easily rename XML files in Eclipse while developing for
Is there any way to easily use a remote javascript file as a content
Is there a single (or multiple) Rails gem that will help to easily capture
There are operator classes in STL like less, equal_to, greater_equal etc. How to easily
Is there any open-source document-oriented key-value map/reduce storage that: is easily embeddable (Yes, it
There is some easily available information on finding the status of a battery, or
Is there any way to easily make a HTTP request with C++? Specifically, I
Is there any way of easily deciphering (i.e. at a glance) whether or not
There is simple JSON serialization module with name simplejson which easily serializes Python objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.