Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#include "lzf.h" 2#include <stdio.h> 3#include <string.h> 4 5int main(void) { 6 const char *test = "liblzf test for nixpkgs, nixpkgs for test liblzf"; 7 const size_t ilen = strlen(test) + 1; 8 9 printf("Test string length: %zu\n", ilen); 10 11 char compressed[100]; 12 char decompressed[100]; 13 14 unsigned int clen = 15 lzf_compress(test, ilen, compressed, sizeof(compressed)); 16 if (!clen) 17 return 1; 18 19 printf("Compressed length: %d\n", clen); 20 21 unsigned int dlen = 22 lzf_decompress(compressed, clen, decompressed, sizeof(decompressed)); 23 if (!dlen) 24 return 2; 25 26 if (strcmp(test, decompressed) != 0) { 27 printf("Strings don't match!\n"); 28 return 3; 29 } 30 31 printf("Strings match, tests passed!\n"); 32 return 0; 33}