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

  • Home
  • SEARCH
  • 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 9033037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:07:31+00:00 2026-06-16T08:07:31+00:00

I am working on a c++ unit tester(mostly as practice) and had some questions

  • 0

I am working on a c++ unit tester(mostly as practice) and had some questions about my implementation.
I wanted to have the ability to overload my custom assertions so I decided to implement them as functions that I wrapped in a namespace.

My current implementation is as follows:

Tester.h
#include <string>

#define INFO __FILE__, __LINE__

namespace Tester
{
    void Assert(char const* input, char const* file_path, int line_number, std::string error_message);
    ...more overloaded Asserts and some Log functions...
}

And when I call the function:

#include "Tester.h"
...code...
    Tester::Assert(false, INFO, "Some message");
...code...

This works but I´m not sure that the ‘INFO’ macro is good practice.
I welcome all suggestions and pointers about this implementation, and feel free to tell me if it makes no sense and I should be doing something completely different 😉

  • 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-16T08:07:32+00:00Added an answer on June 16, 2026 at 8:07 am

    INFO as a macro seems perfectly fine. An alternative, which I prefer is to have a macro

    #define TEST_ASSERT(condition, message) Tester::Asssert(condition, __FILE__, __LINE__, message)
    

    or something of that sort.

    If you have different number of arguments, something like this may work:

    #define TEST_ASSERT(condition, ...) Tester::Asssert(condition, __FILE__, __LINE__, __VA_ARGS__)
    

    Assuming your compiler is new enough, that is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m working on a unit tester for c++, mostly for practice, but I´m stuck.
currently I am working on a spring based application. I do have some unit
I have a large simulation written in C++. The main working unit for the
I'm working on unit tests for my Rails app and have run into the
I was working on a Unit of Work implementation that works both in Entity
I have a unit test class Tester ; I want it to access private
I am working with Silverlight Unit Testing i need to test a function which
I am working with a unit-testing suite that hijacks function calls and tests expected
now i'm working on a project for creating audio unit instrument that provide the
I am working with Erlang and EUnit to do unit tests, and I would

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.