diff options
| author | Baptiste Fontaine | 2015-03-29 14:31:56 +0200 |
|---|---|---|
| committer | Xu Cheng | 2015-03-30 11:28:01 +0800 |
| commit | 88ea471de243cd00cfbe193ee85b9408d55ab147 (patch) | |
| tree | 612b425e94816d8cb0f9c29eea391c6b3d4db89e /Library | |
| parent | 6e05920f2add7d286325bbcee6205d9237172a49 (diff) | |
| download | homebrew-88ea471de243cd00cfbe193ee85b9408d55ab147.tar.bz2 | |
ucl: test added
Closes #38176.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Formula/ucl.rb | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/Library/Formula/ucl.rb b/Library/Formula/ucl.rb index 75b74e0fc..1e389f965 100644 --- a/Library/Formula/ucl.rb +++ b/Library/Formula/ucl.rb @@ -1,13 +1,48 @@ -require 'formula' - class Ucl < Formula - homepage 'http://www.oberhumer.com/opensource/ucl/' - url 'http://www.oberhumer.com/opensource/ucl/download/ucl-1.03.tar.gz' - sha1 '5847003d136fbbca1334dd5de10554c76c755f7c' + homepage "http://www.oberhumer.com/opensource/ucl/" + url "http://www.oberhumer.com/opensource/ucl/download/ucl-1.03.tar.gz" + sha256 "b865299ffd45d73412293369c9754b07637680e5c826915f097577cd27350348" def install - system "./configure", "--disable-debug", "--disable-dependency-tracking", + system "./configure", "--disable-debug", + "--disable-dependency-tracking", "--prefix=#{prefix}" - system "make install" + system "make", "install" + end + + test do + (testpath/"test.c").write <<-EOS.undent + // simplified version of + // https://github.com/korczis/ucl/blob/master/examples/simple.c + #include <stdio.h> + #include <ucl/ucl.h> + #include <ucl/uclconf.h> + #define IN_LEN (128*1024L) + #define OUT_LEN (IN_LEN + IN_LEN / 8 + 256) + int main(int argc, char *argv[]) { + int r; + ucl_byte *in, *out; + ucl_uint in_len, out_len, new_len; + + if (ucl_init() != UCL_E_OK) { return 4; } + in = (ucl_byte *) ucl_malloc(IN_LEN); + out = (ucl_byte *) ucl_malloc(OUT_LEN); + if (in == NULL || out == NULL) { return 3; } + + in_len = IN_LEN; + ucl_memset(in,0,in_len); + + r = ucl_nrv2b_99_compress(in,in_len,out,&out_len,NULL,5,NULL,NULL); + if (r != UCL_E_OK) { return 2; } + if (out_len >= in_len) { return 0; } + r = ucl_nrv2b_decompress_8(out,out_len,in,&new_len,NULL); + if (r != UCL_E_OK && new_len == in_len) { return 1; } + ucl_free(out); + ucl_free(in); + return 0; + } + EOS + system ENV.cc, "test.c", "-L#{lib}", "-lucl", "-o", "test" + system "./test" end end |
