Helper is useful for universal error messages
when using zlib functionality.
I plan to use it in D28105 or following patch for
better uncompression errors diagnostic output.
Details
Diff Detail
Event Timeline
Can you add (unit)tests for this?
lib/Support/Compression.cpp | ||
---|---|---|
23–24 | isAvailable() returns always true, so, how can this be ever hit? |
lib/Support/Compression.cpp | ||
---|---|---|
23–24 | I can imagine some code like next: Status S = zlib::StatusUnsupported; if (zlib::isAvailable() { S = ...; //Do something } if (S != zlib::StatusOK) printError(zlib::toString(S) So it looks can be useful to cover this enum value too. |
lib/Support/Compression.cpp | ||
---|---|---|
23–24 | Ah, my example will not work currently, I see now. |
- Added unittest
- Made toString() to be single implementation for cases when ZLib is available/NA
unittests/Support/CompressionTest.cpp | ||
---|---|---|
70 | To be honest, I don't think this test takes makes a lot of sense since it's pretty much a duplicate of the function itself. As far as I can see, rather than catching bugs it's going to get people frustrated when they change one of the messages. |
unittests/Support/CompressionTest.cpp | ||
---|---|---|
70 | That is why I did not add it in inital diff. |
unittests/Support/CompressionTest.cpp | ||
---|---|---|
70 | What I actually meant is to create test scenarios triggering these errors, not copying the function itself. |
As an alternative, you can merge the patch and the patch where you plan to use this code together (which would make more sense, IMHO).
In fact, I'm still confused why you splitted this in the first place.
I wanted to use it in LLD. That would mean 2 patches anyways, LLD and this one.
Previously Rafael suggested to return Error for methods of this API instead of status.
I think that is good idea, result will be single patch affecting users of this (Decomressor class, something else probably) and changing API itself in a single patch, just like you suggesting.
isAvailable() returns always true, so, how can this be ever hit?