added test checks about the length of strings #313
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.
Adds checks about the length of the produced string, and the size reported as the return value.
Also checks it against the return value of the sys printf.
This is just an idea. I haven't actually compiled the NPF tests (usual problems).
It should also be extended to other test files.
Adding these checks caught some issues. I've run those checks on (a replica of) conformance.cc only, not on the test cases in paland.cc nor the other test suites.
Issues:
require_conform(output, "%c", i);: prints "", returns 1require_conform("", "%+c", 0);: prints "", returns 1require_conform(buf, "%p", p);: due to implementation-defined behavior; might be fixed in your latest commits (about optional "0x" in %p), but we should checkrequire_conform("0.00390625", "%.8Lf", (long double)0.00390625);: my own sys printf prints "0.00000000". Maybe something to look out for when comparing npf to sys.require_conform("-0.00390625", "%.8Lf", (long double)-0.00390625);: my own sys printf prints "0.00000000". Maybe something to look out for when comparing npf to sysNote that printing '\0' is UB.
I've seen this behavior:
A test like
printf("a%cx", '\0')should be added to our tests -- I'm thinking of a new file gathering all UB/IB, maybe the nan test cases could be moved there as well.