Testing the low-level interface

Exercise 2.a: Add a test that checks that ZSTD_compress() and ZSTD_decompress() work as expected. To do so, generate a buffer containing random data (for example 1024 bytes of random data, see the rand crate), compress it, decompress it, and check that the decompressed data match the original data.

This test should be created in a new file located in the tests directory (that you must create) of the zstd-sys crate.

You will need to use the zstd API documentation. You will also have to use the following auxiliary functions:

  • ZSTD_isError() to check the values returned by ZSTD_compress() and ZSTD_decompress();
  • ZSTD_compressBound() to get the maximum size of compressed data;
  • ZSTD_getFrameContentSize() (to get the size of the decompressed data).