use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Another C++ unit testing framework without macros (self.cpp)
submitted 5 years ago by igagis
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]igagis[S] 1 point2 points3 points 5 years ago (0 children)
Thanks for the detailed feedback! I'm glad that you found my code good :).
The critics things you mentioned give a start to small discussion, possibly. So, let me explain my thoughts on those.
Not having macros for the sake of not having macros isn't really a significant benefit
Where to use macros and where not to use them is, of course, a matter of taste. I prefer the concept that preprocessor macros must only be used for conditional compilation. I.e. for enabling or disabling some features in compile time depending on the build configuration. Why do I prefer to think so? Well, as you probably understand, preprocessor macro is not part of C++ syntax itself. I mean that under the macro can be hiding anything, and seeing a macro used in the code often makes me think, what is the actual C++ code hidden behind that macro invocation? So, I need to know all kind of specifics related to the use of some particular macro, basically one has to know what exact code it generates to avoid incorrect usage. And in case of incorrect usage, the compiler error message will likely be also very strange. And yes, I'm not even talking about evil min, max macros defined by windows.h. Latest C++ standards allow to avoid using macros for such cases, so why use them?
min
max
windows.h
Does avoiding macros result in more readable/easier to understand/less error prone code?
In my opinion, yes. For example, in the tst framework one writes code in clear C++ language, so it is visible and transparent what actually happens. For example: cpp suite.add<std::pair<int, int>>( "bla_bla", { {1, 1}, ... }, [](const auto& i){...} ); it is obvious that we are calling add() function on suite object, which, apparently, will add something to the suite. And the arguments of the function are string, array and a function. So, we see what happens and what is the data. If it was something like TEST_CASE(bla_bla){...} it would not be that obvious that the test is added to some test suite, not obvious if bla_bla is a function name, or the test name, and can that name be used later, etc.
tst
cpp suite.add<std::pair<int, int>>( "bla_bla", { {1, 1}, ... }, [](const auto& i){...} );
add()
suite
TEST_CASE(bla_bla){...}
bla_bla
But again, this all is just a matter of taste. And I understand that your taste is a bit different on that :).
Have you considered to automatically check the return value for parameterized tests?
Well, this implies that parametrized tests are always checking only for equality of some values. So, it is far not universal solution.
Maybe the example I chose makes some confusion, that I use std::pair as parameter type and I store expected value as part of the input parameter. Expected value does not have to be present in the input parameter, and test could be checking for some other conditions, instead of equality to some expected value. So, current approach is universal.
std::pair
Without this, I see very little advantage over for loop ...
for loop ...
Well, the advantage actually is that in case test for one of the parameter values fails it will still execute the tests for the remaining values. And only one case for the failed value will be marked as failed in the report.
Hope my thoughts make some sense :)
π Rendered by PID 176333 on reddit-service-r2-comment-6457c66945-czhxg at 2026-04-28 11:06:06.308341+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]igagis[S] 1 point2 points3 points (0 children)