diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-01-17 13:20:17 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-01-17 13:20:17 +0000 |
commit | e29a32e9ce43d17cf65116f515fe48ccc1140dcb (patch) | |
tree | 966bb57c4c76184e813aa4fa508a4d2d41a3ec83 /llvm/unittests/Support/CompressionTest.cpp | |
parent | e1ff0cf2eb7bcd1658731866915e89da4a78ed3d (diff) | |
download | bcm5719-llvm-e29a32e9ce43d17cf65116f515fe48ccc1140dcb.tar.gz bcm5719-llvm-e29a32e9ce43d17cf65116f515fe48ccc1140dcb.zip |
[Support/Compression] - Change zlib API to return Error instead of custom status.
Previously API returned custom enum values.
Patch changes it to return Error with string description.
That should help users to report errors in universal way.
Differential revision: https://reviews.llvm.org/D28684
llvm-svn: 292214
Diffstat (limited to 'llvm/unittests/Support/CompressionTest.cpp')
-rw-r--r-- | llvm/unittests/Support/CompressionTest.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/unittests/Support/CompressionTest.cpp b/llvm/unittests/Support/CompressionTest.cpp index 36b84d85f22..18a6175460d 100644 --- a/llvm/unittests/Support/CompressionTest.cpp +++ b/llvm/unittests/Support/CompressionTest.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Compression.h" +#include "llvm/Support/Error.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Config/config.h" @@ -26,15 +27,21 @@ namespace { void TestZlibCompression(StringRef Input, zlib::CompressionLevel Level) { SmallString<32> Compressed; SmallString<32> Uncompressed; - EXPECT_EQ(zlib::StatusOK, zlib::compress(Input, Compressed, Level)); + + Error E = zlib::compress(Input, Compressed, Level); + EXPECT_FALSE(E); + consumeError(std::move(E)); + // Check that uncompressed buffer is the same as original. - EXPECT_EQ(zlib::StatusOK, - zlib::uncompress(Compressed, Uncompressed, Input.size())); + E = zlib::uncompress(Compressed, Uncompressed, Input.size()); + EXPECT_FALSE(E); + consumeError(std::move(E)); + EXPECT_EQ(Input, Uncompressed); if (Input.size() > 0) { // Uncompression fails if expected length is too short. - EXPECT_EQ(zlib::StatusBufferTooShort, - zlib::uncompress(Compressed, Uncompressed, Input.size() - 1)); + E = zlib::uncompress(Compressed, Uncompressed, Input.size() - 1); + EXPECT_EQ("zlib error: Z_BUF_ERROR", llvm::toString(std::move(E))); } } |