Skip to content

Commit

Permalink
glib: use test DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
jacknagel committed Feb 2, 2013
1 parent 1533427 commit 49c6437
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions Formula/glib.rb
Expand Up @@ -71,27 +71,25 @@ def install
(share+'gtk-doc').rmtree
end

def test
mktemp do
(Pathname.pwd/'test.c').write <<-EOS.undent
#include <string.h>
#include <glib.h>
int main(void)
{
gchar *result_1, *result_2;
char *str = "string";
result_1 = g_convert(str, strlen(str), "ASCII", "UTF-8", NULL, NULL, NULL);
result_2 = g_convert(result_1, strlen(result_1), "UTF-8", "ASCII", NULL, NULL, NULL);
return (strcmp(str, result_2) == 0) ? 0 : 1;
}
EOS
flags = *`pkg-config --cflags --libs glib-2.0`.split
flags += ENV.cflags.split
system ENV.cc, "-o", "test", "test.c", *flags
system "./test"
end
test do
(testpath/'test.c').write <<-EOS.undent
#include <string.h>
#include <glib.h>
int main(void)
{
gchar *result_1, *result_2;
char *str = "string";
result_1 = g_convert(str, strlen(str), "ASCII", "UTF-8", NULL, NULL, NULL);
result_2 = g_convert(result_1, strlen(result_1), "UTF-8", "ASCII", NULL, NULL, NULL);
return (strcmp(str, result_2) == 0) ? 0 : 1;
}
EOS
flags = *`pkg-config --cflags --libs glib-2.0`.split
flags += ENV.cflags.split
system ENV.cc, "-o", "test", "test.c", *flags
system "./test"
end
end

0 comments on commit 49c6437

Please sign in to comment.