Fix compilation error when using #define TEST_NO_MAIN#75
Open
manugoyal wants to merge 1 commit intomity:masterfrom
Open
Fix compilation error when using #define TEST_NO_MAIN#75manugoyal wants to merge 1 commit intomity:masterfrom
#define TEST_NO_MAIN#75manugoyal wants to merge 1 commit intomity:masterfrom
Conversation
I noticed the following compilation error when utilizing the
`TEST_NO_MAIN` macro to split test definitions over multiple files:
```
../third_party/acutest/include/acutest.h:1991:5: error: extraneous closing brace ('}')
} /* extern "C" */
^
1 error generated.
```
To reproduce, create the following files in one directory.
`tests.h`
```
#pragma once
void test_failure();
```
`tests.cc`
```
#include "tests.h"
#define TEST_NO_MAIN
#include "acutest.h"
void test_failure() {
TEST_CHECK(1 == 2);
}
```
`test_runner.cc`
```
#include "acutest.h"
#include "tests.h"
TEST_LIST = {
{ "test_failure", test_failure },
{ NULL, NULL },
};
```
Before this change, I see the error:
```
$ c++ -I ../third_party/acutest/include tests.cc test_runner.cc
In file included from tests.cc:4:
../third_party/acutest/include/acutest.h:1991:5: error: extraneous closing brace ('}')
} /* extern "C" */
^
1 error generated.
```
Afterwards, I get the desired output:
```
$ c++ -I ../third_party/acutest/include tests.cc test_runner.cc
$ ./a.out
Test test_failure... [ FAILED ]
tests.cc:7: 1 == 2... failed
FAILED: 1 of 1 unit tests has failed.
```
Contributor
|
Seems like my bug in #70 |
amgross
approved these changes
Sep 12, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed the following compilation error when utilizing the
TEST_NO_MAINmacro to split test definitions over multiple files:To reproduce, create the following files in one directory.
tests.htests.cctest_runner.ccBefore this change, I see the error:
Afterwards, I get the desired output: