opus: add test

This commit is contained in:
JCount 2017-07-25 17:40:34 -04:00
parent 08e3576c8d
commit 169a797659

View file

@ -29,4 +29,35 @@ class Opus < Formula
system "./configure", *args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include <opus.h>
int main(int argc, char **argv)
{
int err = 0;
opus_int32 rate = 48000;
int channels = 2;
int app = OPUS_APPLICATION_AUDIO;
OpusEncoder *enc;
int ret;
enc = opus_encoder_create(rate, channels, app, &err);
if (!(err < 0))
{
err = opus_encoder_ctl(enc, OPUS_SET_BITRATE(OPUS_AUTO));
if (!(err < 0))
{
opus_encoder_destroy(enc);
return 0;
}
}
return err;
}
EOS
system ENV.cxx, "-I#{include}/opus", "-L#{lib}", "-lopus",
testpath/"test.cpp", "-o", "test"
system "./test"
end
end