Add QUVIOPT_NOSHORTENED support
[www-quvi.git] / t / WWW-Quvi-Defaults.t
blob1cc54cd52bc78cc5215d97a6a32e8612612c2d47
2 use warnings;
3 use strict;
5 use Test::More tests => 36;
6 BEGIN { use_ok('WWW::Quvi') };
8 # Version.
10 like (&WWW::Quvi::version, qr{^\d+.\d+$});
12 like (&WWW::Quvi::version(WWW::Quvi::ModuleVersion), qr{^\d+.\d+$});
14 like (
15     &WWW::Quvi::version(WWW::Quvi::libquviVersion), qr{^\d+.\d+.\d+$});
17 like (
18     &WWW::Quvi::version(WWW::Quvi::libquviVersionLong),
19     qr{^\d+.\d+.\d+.* built on \d+.\d+.\d+ .* (.*)$}
22 # Options.
24 my $opts = new WWW::Quvi::Options;
25 isa_ok ($opts, 'WWW::Quvi::Options');
27 is ($opts->{user_agent}, "");
28 is ($opts->{http_proxy}, "");
29 is ($opts->{format},     "default");
30 is ($opts->{verify},     1);
31 is ($opts->{verbose_libcurl}, "");
32 is ($opts->{shortened},  1);
34 $opts->{user_agent} = "Mozilla/5.0";
35 is ($opts->{user_agent}, "Mozilla/5.0");
37 $opts->{http_proxy} = "http://foo:1234";
38 is ($opts->{http_proxy}, "http://foo:1234");
40 $opts->{format} = "hd";
41 is ($opts->{format}, "hd");
43 $opts->{verify} = 0;
44 is ($opts->{verify}, "");
46 $opts->{verbose_libcurl} = 1;
47 is ($opts->{verbose_libcurl}, 1);
49 $opts->{shortened} = 0;
50 is ($opts->{shortened}, "");
52 # Link.
54 my $l = new WWW::Quvi::Link;
55 isa_ok ($l, 'WWW::Quvi::Link');
57 is ($l->{content_type}, "");
58 is ($l->{file_suffix},  "");
59 is ($l->{length_bytes}, -1);
60 is ($l->{url},          "");
62 # Video.
64 my $v = new WWW::Quvi::Video;
65 isa_ok ($v, 'WWW::Quvi::Video');
67 is ($v->{title},     "");
68 is ($v->{host},      "");
69 is ($v->{url},       "");
70 is ($v->{id},        "");
71 is ($v->{ok},        "");
73 # Query.
75 my $q = new WWW::Quvi::Query;
76 isa_ok ($q, 'WWW::Quvi::Query');
78 is ($q->{last_error}, "");
79 is ($q->{quvi_code},   0);
80 is ($q->{resp_code},  -1);
82 # Websites.
84 my ($rc, $domain, $formats) = $q->next_website;
85 is ($rc, 0);
86 like ($domain, qr{^\w+.\w+$});
87 like ($formats, qr{^\w+(?:|)});
89 # QUVIcode aliases.
91 my @QUVIcode = {
92    WWW::Quvi::OK,
93    WWW::Quvi::Mem,
94    WWW::Quvi::BadHandle,
95    WWW::Quvi::InvArg,
96    WWW::Quvi::CurlInit,
97    WWW::Quvi::Last,
98    WWW::Quvi::AbortedByCallback,
99    WWW::Quvi::LuaInit,
100    WWW::Quvi::NoLuaWebsite,
101    WWW::Quvi::PcreError,
102    WWW::Quvi::NoSupport,
103    WWW::Quvi::CurlError,
104    WWW::Quvi::IconvError,
105    WWW::Quvi::LuaError,