tests: Provide style definition to the C / C++ tests.#465
Merged
emilio merged 2 commits intomozilla:masterfrom Jan 26, 2020
Merged
tests: Provide style definition to the C / C++ tests.#465emilio merged 2 commits intomozilla:masterfrom
emilio merged 2 commits intomozilla:masterfrom
Conversation
This will be useful to add static assertion to some tests like mozilla#463 wants to do. For example, in the case of the test for mozilla#463, the test would need something like: trailer = """ #include <assert.h> #if defined(CBINDGEN_STYLE_TAG) && !defined(__cplusplus) static_assert(sizeof(struct P) == 4, "unexpected size for P"); #else static_assert(sizeof(P) == 4, "unexpected size for P"); #endif """ As more of these tests are added it may be worth just adding a helper header like this to avoid some duplication: #include <assert.h> #if defined(CBINDGEN_STYLE_TAG) && !defined(__cplusplus) #define CBINDGEN_STRUCT(name) struct name #else #define CBINDGEN_STRUCT(name) name #endif And so on, so the previous configuration would become just: trailer = """ #include "testing-helpers.h" // Or whatever static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P"); """ That may or may not be overkill to do as part of mozilla#463.
This allows to assert easily as described in the previous commit.
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.
This will be useful to add static assertion to some tests like #463 wants to do.
For example, in the case of the test for #463, the test would need something
like:
As more of these tests are added it may be worth just adding a helper header
like this to avoid some duplication:
And so on, so the previous configuration would become just:
That may or may not be overkill to do as part of #463.