Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INFO does not compile when used like a function call #469

Closed
TestingPlant opened this issue Feb 12, 2021 · 1 comment
Closed

INFO does not compile when used like a function call #469

TestingPlant opened this issue Feb 12, 2021 · 1 comment

Comments

@TestingPlant
Copy link

Description

When INFO is used in code such as

if (condition)
	INFO("Information");

it will not compile. However, if you add braces on like

if (condition) {
	INFO("Information");
}

it compiles.

INFO() should act like any other function call, where you can omit the braces when used in if statements and such.

Steps to reproduce

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "./doctest/doctest/doctest.h"

TEST_CASE("") {
	if (true)
		INFO("Information");
}

Extra information

  • doctest version: v2.4.5
  • Operating System: Arch Linux
  • Compiler+version: g++ 10.2.0
onqtam added a commit that referenced this issue Feb 18, 2021
…wever this requires that the capturing lambda is also copied by value inside of ContextScope, but that shouldn't be a problem) - fixed #469
onqtam added a commit that referenced this issue Feb 18, 2021
…wever this requires that the capturing lambda is also copied by value inside of ContextScope, but that shouldn't be a problem) - fixed #469
@onqtam
Copy link
Member

onqtam commented Feb 18, 2021

Just pushed a fix for this in dev - thanks for reporting! I managed to change the entire macro to consist of a single statement so now it can be used properly like what you have suggested.

However, I should note that this usage is actually not useful at all - whatever is logged in an INFO() call will only be available for asserts which fail in it's block scope - and that block scope in this case is only the then part of the if statement - and thus you'd have no way of actually using whatever is logged in this way because this way the only statement in the then part of the if statement is the INFO() call itself.

@onqtam onqtam closed this as completed Mar 21, 2021
onqtam added a commit that referenced this issue Mar 22, 2021
…wever this requires that the capturing lambda is also copied by value inside of ContextScope, but that shouldn't be a problem) - fixed #469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants