diff options
| author | Misty De Meo | 2015-04-24 22:57:01 -0700 | 
|---|---|---|
| committer | Misty De Meo | 2015-04-24 22:57:01 -0700 | 
| commit | 5e00614786f91e17ece884cf7767dc45c8eeb7e7 (patch) | |
| tree | b7a32cf3d31e6a09f7972e28088c8ebe0d756f62 | |
| parent | 7166d8f651e24535712774e1038ed807a10fa684 (diff) | |
| download | homebrew-5e00614786f91e17ece884cf7767dc45c8eeb7e7.tar.bz2 | |
mdxmini: add test
| -rw-r--r-- | Library/Formula/mdxmini.rb | 28 | 
1 files changed, 28 insertions, 0 deletions
| diff --git a/Library/Formula/mdxmini.rb b/Library/Formula/mdxmini.rb index 243972117..bac6e38ab 100644 --- a/Library/Formula/mdxmini.rb +++ b/Library/Formula/mdxmini.rb @@ -10,6 +10,11 @@ class Mdxmini < Formula    depends_on 'sdl' unless build.include? "lib-only" +  resource "test_song" do +    url "ftp://ftp.modland.com/pub/modules/MDX/Popful Mail/pop-00.mdx" +    sha256 "86f21fbbaf93eb60e79fa07c759b906a782afe4e1db5c7e77a1640e6bf63fd14" +  end +    def install      cd "jni/mdxmini" do        # Specify Homebrew's cc @@ -28,4 +33,27 @@ class Mdxmini < Formula        (include+'libmdxmini').install Dir['src/*.h']      end    end + +  test do +    resource("test_song").stage testpath +    (testpath/"mdxtest.c").write <<-EOS.undent +    #include <stdio.h> +    #include "libmdxmini/mdxmini.h" + +    int main(int argc, char** argv) +    { +        t_mdxmini mdx; +        char title[100]; +        mdx_open(&mdx, argv[1], argv[2]); +        mdx_get_title(&mdx, title); +        printf("%s\\n", title); +    } +    EOS +    system ENV.cc, "mdxtest.c", "-lmdxmini", "-o", "mdxtest" + +    result = `#{testpath}/mdxtest #{testpath}/pop-00.mdx #{testpath}`.chomp +    # Song title is in Shift-JIS +    expected = "\x82\xDB\x82\xC1\x82\xD5\x82\xE9\x83\x81\x83C\x83\x8B         \x83o\x83b\x83N\x83A\x83b\x83v\x8D\xEC\x90\xAC          (C)Falcom 1992 cv.\x82o\x82h. ass.\x82s\x82`\x82o\x81{" +    assert_equal expected, result +  end  end | 
