added test checks about the length of strings#313
added test checks about the length of strings#313stefano-zanotti-88 wants to merge 1 commit intocharlesnicholson:mainfrom
Conversation
|
Thanks, this is a very good insight and I agree that it should be added to the test harness and a non-stupid solution should be applied (clearly npf is screwing up by returning 3). How would you like to proceed on this PR, given the conversation about testing in #132 ? (Additionally, I agree that your extremely thorough listing of all the UB issues should be extracted into an explicit UB test module and pulled out of the conformance stuff; how do you see this working with that?) Maybe we should convert this PR to an issue instead to track it there? |
|
There are tests for UB in #298. However, they are specifically to check that the "safety" option catches them correctly. About the problematic behavior of NPF: About %p, we should not test against sys-printf at all. And we should either:
Feel free to organize things as you see most fit, ie open an issue about this, or else. |
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.