From 169a797659dc0777eb4547f44e2f0d1e59f4ac8b Mon Sep 17 00:00:00 2001 From: JCount Date: Tue, 25 Jul 2017 17:40:34 -0400 Subject: [PATCH] opus: add test --- Formula/opus.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Formula/opus.rb b/Formula/opus.rb index 1c9dd32e79..c7cfd7c6f5 100644 --- a/Formula/opus.rb +++ b/Formula/opus.rb @@ -29,4 +29,35 @@ class Opus < Formula system "./configure", *args system "make", "install" end + + test do + (testpath/"test.cpp").write <<-EOS.undent + #include + + 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