1 /* test_compress.cc - Test compress() and uncompress() using hello world string */
2 
3 #include "zbuild.h"
4 #ifdef ZLIB_COMPAT
5 #  include "zlib.h"
6 #else
7 #  include "zlib-ng.h"
8 #endif
9 
10 #include <stdio.h>
11 #include <stdint.h>
12 #include <stdlib.h>
13 #include <string.h>
14 
15 #include "test_shared.h"
16 
17 #include <gtest/gtest.h>
18 
TEST(compress,basic)19 TEST(compress, basic) {
20     uint8_t compr[128], uncompr[128];
21     z_size_t compr_len = sizeof(compr), uncompr_len = sizeof(uncompr);
22     int err;
23 
24     err = PREFIX(compress)(compr, &compr_len, (const unsigned char *)hello, hello_len);
25     EXPECT_EQ(err, Z_OK);
26 
27     strcpy((char*)uncompr, "garbage");
28 
29     err = PREFIX(uncompress)(uncompr, &uncompr_len, compr, compr_len);
30     EXPECT_EQ(err, Z_OK);
31 
32     EXPECT_STREQ((char *)uncompr, (char *)hello);
33 }
34