From cd6e6383aba8e93f983e298e6044164e0fc19cab Mon Sep 17 00:00:00 2001 From: Shaun McCance Date: Mon, 26 Apr 2010 11:24:17 -0500 Subject: [libyelp] Adding GIO decompressors for bz2, lzma, and magic --- tests/Makefile.am | 12 +++++++++++ tests/test-bz2.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-lzma.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/test-magic.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 192 insertions(+) create mode 100644 tests/test-bz2.c create mode 100644 tests/test-lzma.c create mode 100644 tests/test-magic.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 02f1d98a..c4b9c543 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,19 +12,31 @@ YELP_COMMON_LDADD = \ $(top_builddir)/libyelp/libyelp.la check_PROGRAMS = \ + test-bz2 \ test-io-channel \ test-location-entry \ + test-lzma \ + test-magic \ test-settings \ test-transform \ test-uri \ test-view +test_bz2_CFLAGS = $(YELP_COMMON_CFLAGS) +test_bz2_LDADD = $(YELP_COMMON_LDADD) + test_io_channel_CFLAGS = $(YELP_COMMON_CFLAGS) test_io_channel_LDADD = $(YELP_COMMON_LDADD) test_location_entry_CFLAGS = $(YELP_COMMON_CFLAGS) test_location_entry_LDADD = $(YELP_COMMON_LDADD) +test_lzma_CFLAGS = $(YELP_COMMON_CFLAGS) +test_lzma_LDADD = $(YELP_COMMON_LDADD) + +test_magic_CFLAGS = $(YELP_COMMON_CFLAGS) +test_magic_LDADD = $(YELP_COMMON_LDADD) + test_settings_CFLAGS = $(YELP_COMMON_CFLAGS) test_settings_LDADD = $(YELP_COMMON_LDADD) diff --git a/tests/test-bz2.c b/tests/test-bz2.c new file mode 100644 index 00000000..a2da96cb --- /dev/null +++ b/tests/test-bz2.c @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2009 Shaun McCance +#include +#include + +#include + +#include "yelp-bz2-decompressor.h" + +int +main (int argc, char **argv) +{ + GConverter *converter; + GFile *file; + GFileInputStream *file_stream; + GInputStream *stream; + gchar buf[1024]; + gssize bytes; + + if (argc < 2) { + g_printerr ("Usage: test-bz2 FILE\n"); + return 1; + } + + g_type_init (); + + file = g_file_new_for_path (argv[1]); + file_stream = g_file_read (file, NULL, NULL); + converter = yelp_bz2_decompressor_new (); + stream = g_converter_input_stream_new (file_stream, converter); + + while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) { + gchar *out = g_strndup (buf, bytes); + puts (out); + g_free (out); + } + + return 0; +} diff --git a/tests/test-lzma.c b/tests/test-lzma.c new file mode 100644 index 00000000..76af37d8 --- /dev/null +++ b/tests/test-lzma.c @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2009 Shaun McCance +#include +#include + +#include + +#include "yelp-lzma-decompressor.h" + +int +main (int argc, char **argv) +{ + GConverter *converter; + GFile *file; + GFileInputStream *file_stream; + GInputStream *stream; + gchar buf[1024]; + gssize bytes; + + if (argc < 2) { + g_printerr ("Usage: test-lzma FILE\n"); + return 1; + } + + g_type_init (); + + file = g_file_new_for_path (argv[1]); + file_stream = g_file_read (file, NULL, NULL); + converter = yelp_lzma_decompressor_new (); + stream = g_converter_input_stream_new (file_stream, converter); + + while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) { + gchar *out = g_strndup (buf, bytes); + puts (out); + g_free (out); + } + + return 0; +} diff --git a/tests/test-magic.c b/tests/test-magic.c new file mode 100644 index 00000000..9a937991 --- /dev/null +++ b/tests/test-magic.c @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2009 Shaun McCance +#include +#include + +#include + +#include "yelp-magic-decompressor.h" + +int +main (int argc, char **argv) +{ + GConverter *converter; + GFile *file; + GFileInputStream *file_stream; + GInputStream *stream; + gchar buf[1024]; + gssize bytes; + + if (argc < 2) { + g_printerr ("Usage: test-magic FILE\n"); + return 1; + } + + g_type_init (); + + file = g_file_new_for_path (argv[1]); + file_stream = g_file_read (file, NULL, NULL); + converter = yelp_magic_decompressor_new (); + stream = g_converter_input_stream_new (file_stream, converter); + + while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) { + gchar *out = g_strndup (buf, bytes); + puts (out); + g_free (out); + } + + return 0; +} -- cgit v1.2.1