]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/zstd/tests/invalidDictionaries.c
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r308421, and update
[FreeBSD/FreeBSD.git] / contrib / zstd / tests / invalidDictionaries.c
1 #include <stddef.h>
2 #include "zstd.h"
3
4 static const char invalidRepCode[] = {
5   0x37, 0xa4, 0x30, 0xec, 0x2a, 0x00, 0x00, 0x00, 0x39, 0x10, 0xc0, 0xc2,
6   0xa6, 0x00, 0x0c, 0x30, 0xc0, 0x00, 0x03, 0x0c, 0x30, 0x20, 0x72, 0xf8,
7   0xb4, 0x6d, 0x4b, 0x9f, 0xfc, 0x97, 0x29, 0x49, 0xb2, 0xdf, 0x4b, 0x29,
8   0x7d, 0x4a, 0xfc, 0x83, 0x18, 0x22, 0x75, 0x23, 0x24, 0x44, 0x4d, 0x02,
9   0xb7, 0x97, 0x96, 0xf6, 0xcb, 0xd1, 0xcf, 0xe8, 0x22, 0xea, 0x27, 0x36,
10   0xb7, 0x2c, 0x40, 0x46, 0x01, 0x08, 0x23, 0x01, 0x00, 0x00, 0x06, 0x1e,
11   0x3c, 0x83, 0x81, 0xd6, 0x18, 0xd4, 0x12, 0x3a, 0x04, 0x00, 0x80, 0x03,
12   0x08, 0x0e, 0x12, 0x1c, 0x12, 0x11, 0x0d, 0x0e, 0x0a, 0x0b, 0x0a, 0x09,
13   0x10, 0x0c, 0x09, 0x05, 0x04, 0x03, 0x06, 0x06, 0x06, 0x02, 0x00, 0x03,
14   0x00, 0x00, 0x02, 0x02, 0x00, 0x04, 0x06, 0x03, 0x06, 0x08, 0x24, 0x6b,
15   0x0d, 0x01, 0x10, 0x04, 0x81, 0x07, 0x00, 0x00, 0x04, 0xb9, 0x58, 0x18,
16   0x06, 0x59, 0x92, 0x43, 0xce, 0x28, 0xa5, 0x08, 0x88, 0xc0, 0x80, 0x88,
17   0x8c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
18   0x08, 0x00, 0x00, 0x00
19 };
20
21 typedef struct dictionary_s {
22   const char *data;
23   size_t size;
24 } dictionary;
25
26 static const dictionary dictionaries[] = {
27   {invalidRepCode, sizeof(invalidRepCode)},
28   {NULL, 0},
29 };
30
31 int main(int argc, const char** argv) {
32   const dictionary *dict;
33   for (dict = dictionaries; dict->data != NULL; ++dict) {
34     ZSTD_CDict *cdict;
35     ZSTD_DDict *ddict;
36     cdict = ZSTD_createCDict(dict->data, dict->size, 1);
37     if (cdict) {
38       ZSTD_freeCDict(cdict);
39       return 1;
40     }
41     ddict = ZSTD_createDDict(dict->data, dict->size);
42     if (ddict) {
43       ZSTD_freeDDict(ddict);
44       return 2;
45     }
46   }
47
48   (void)argc;
49   (void)argv;
50   return 0;
51 }