GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — First (far from done) implementation for printf style formatting for … by alariois · Pull Request #500 · ThrowTheSwitch/Unity Conversation
Contributor
I'd like to add printf style formating to all TEST_*_MESSAGE macros as long as UNITY_INCLUDE_PRINT_FORMATTED is defined. I managed to get a first proof of concept working but as I dont know (yet) the inner working of CMock and Ceedling I'd like some feedback on whether I'm breaking some dependencies. All other suggestions are also welcome of course! Supported at the moment: For formating and printing I'm using UnityPrintFVA The biggest possibly breaking change with CMock and Ceedling is that I had to change the ordering of some function parameters. (UnityFail, UnityIgnore, UnityMessage, UnityAssertEqualNumber) I used a quite hackish (but short) way to define some functions to support variable argument lists and fallbacks without it. #ifdef UNITY_INCLUDE_PRINT_FORMATTED #define VA_LIST_IF_ENABLED , va_list va #define VA_ARGS_IF_ENABLED , ... #else #define VA_LIST_IF_ENABLED #define VA_ARGS_IF_ENABLED #endif With this trick its possible to write This expands to if UNITY_INCLUDE_PRINT_FORMATTED is not defined and otherwise to Also worth noting is that the _MESSAGE macros are defined like #define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, ...) rather than #define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, format, ...) This is to support c99, that needs at least one parameter in VA_ARGS list. TEST_ASSERT_EQUAL_INT_MESSAGE(1, 2, "I cannot believe this failed"); Without any extra parameters TEST_PRINTF is now alias to TEST_MESSAGE TEST_MESSAGE("Hello, World!"); TEST_MESSAGE("Hello %s! pi = %f", "World", 3.141592); The ugliest thing about implementing this feature is that all the _MESSAGE macros have to be duplicated. Yikes! Its not possible to use the VA_ARGS_IF_ENABLED trick with macros sadly. Again ... all suggestions are welcome! :)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. …rtEqualString, UnityAssertEqualStringLen, UnityAssertEqualStringArray, UnityAssertEqualIntArray …ityIsOneArrayNull … ordering in tests
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | ||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |