Wrap quvi_supported
[www-quvi.git] / t / WWW-Quvi-Defaults.t
blobb6a8a4ed40de728f64205bf990c33e5881759012
2 use warnings;
3 use strict;
5 use Test::More tests => 39;
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);
33 is ($opts->{category},   WWW::Quvi::ProtoHttp);
35 $opts->{user_agent} = "Mozilla/5.0";
36 is ($opts->{user_agent}, "Mozilla/5.0");
38 $opts->{http_proxy} = "http://foo:1234";
39 is ($opts->{http_proxy}, "http://foo:1234");
41 $opts->{format} = "hd";
42 is ($opts->{format}, "hd");
44 $opts->{verify} = 0;
45 is ($opts->{verify}, "");
47 $opts->{verbose_libcurl} = 1;
48 is ($opts->{verbose_libcurl}, 1);
50 $opts->{shortened} = 0;
51 is ($opts->{shortened}, "");
53 $opts->{category} = WWW::Quvi::ProtoMms;
54 is ($opts->{category}, WWW::Quvi::ProtoMms);
56 # Link.
58 my $l = new WWW::Quvi::Link;
59 isa_ok ($l, 'WWW::Quvi::Link');
61 is ($l->{content_type}, "");
62 is ($l->{file_suffix},  "");
63 is ($l->{length_bytes}, -1);
64 is ($l->{url},          "");
66 # Video.
68 my $v = new WWW::Quvi::Video;
69 isa_ok ($v, 'WWW::Quvi::Video');
71 is ($v->{title},     "");
72 is ($v->{host},      "");
73 is ($v->{url},       "");
74 is ($v->{id},        "");
75 is ($v->{ok},        "");
77 # Query.
79 my $q = new WWW::Quvi::Query;
80 isa_ok ($q, 'WWW::Quvi::Query');
82 is ($q->{last_error}, "");
83 is ($q->{quvi_code},   0);
84 is ($q->{resp_code},  -1);
86 # Websites.
88 my ($rc, $domain, $formats) = $q->next_website;
89 is ($rc, WWW::Quvi::OK);
90 like ($domain, qr{^\w+.\w+$});
91 like ($formats, qr{^\w+(?:|)});
93 # Supported.
95 $rc = $q->supported ("http://dai.ly");
96 is ($rc, WWW::Quvi::OK);
98 # QUVIcode aliases.
100 my @QUVIcode = {
101    WWW::Quvi::OK,
102    WWW::Quvi::Mem,
103    WWW::Quvi::BadHandle,
104    WWW::Quvi::InvArg,
105    WWW::Quvi::CurlInit,
106    WWW::Quvi::Last,
107    WWW::Quvi::AbortedByCallback,
108    WWW::Quvi::LuaInit,
109    WWW::Quvi::NoLuaWebsite,
110    WWW::Quvi::PcreError,
111    WWW::Quvi::NoSupport,
112    WWW::Quvi::CurlError,
113    WWW::Quvi::IconvError,
114    WWW::Quvi::LuaError,
117 # QUVIcategory aliases.
119 my @QUVIcategory = {
120    WWW::Quvi::ProtoHttp,
121    WWW::Quvi::ProtoMms,
122    WWW::Quvi::ProtoRtsp,
123    WWW::Quvi::ProtoRtmp,
124    WWW::Quvi::ProtoAll,
125 0xffff # Pad to prevent "Odd number of elements in anonymous hash" warning