Split from git://repo.or.cz/quvi.git
[libquvi-scripts.git] / tests / t / mem.t
blobad779c680bb425cbeddd508bac77aadfbdb1bc1b
2 use warnings;
3 use strict;
5 use Test::More;
7 eval "use JSON::XS";
8 plan skip_all => "JSON::XS required for testing" if $@;
10 use Test::Quvi;
12 my $q = Test::Quvi->new;
14 plan skip_all => "TEST_SKIP rule"
15   if $q->test_skip("mem");
17 my $c = $q->get_config;
19 plan skip_all =>
20   'valgrind required for testing, specify with --valgrind-path'
21   unless $c->{valgrind_path};
23 plan tests => 9;
25 # invalid option, make an exception to redirect to /dev/null),
26 # gengetopt produced code checks and exits if this error occurs.
27 my ($r) = $q->run_with_valgrind('--invalid', '2>/dev/null');
28 is($r, 0x1, "exit status == 0x1");
30 # --version
31 ($r) = $q->run_with_valgrind('--version');
32 is($r, 0x0, "exit status == 0x0");    # 0x0 = QUVI_OK
34 # --help
35 ($r) = $q->run_with_valgrind('--help');
36 is($r, 0x0, "exit status == 0x0");    # 0x0 = QUVI_OK
38 # --support
39 ($r) = $q->run_with_valgrind('--support');
40 is($r, 0x0, "exit status == 0x0");    # 0x0 = QUVI_OK
42 # --support arg
43 ($r) =
44   $q->run_with_valgrind('http://vimeo.com/1485507', '--support -qr');
45 is($r, 0x0, "exit status == 0x0");
47 # fetch, parse, exit
48 ($r) = $q->run_with_valgrind('http://vimeo.com/1485507', '-qr');
49 is($r, 0x0, "exit status == 0x0");
51 # fetch, parse, exec and exit
52 ($r) = $q->run_with_valgrind('http://vimeo.com/1485507',
53                              '-qr --exec "echo %t ; echo %u"');
54 is($r, 0x0, "exit status == 0x0");
56 # (fetch, parse) x 2, exit
57 ($r) =
58   $q->run_with_valgrind(
59                         'http://vimeo.com/1485507',
60                         'http://megavideo.com/?v=HJVPVMTV',
61                         '-qr'
62                        );
63 is($r, 0x0, "exit status == 0x0");
65 # (fetch, parse) x 2, exit
66 # NOTE: first fails intentionally
67 ($r) =
68   $q->run_with_valgrind(
69                         'http://ww.vimeo.com/1485507',
70                         'http://megavideo.com/?v=HJVPVMTV',
71                         '-qr'
72                        );
73 is($r, 0x0, "exit status == 0x0");
75 # vim: set ts=2 sw=2 tw=72 expandtab: