File: size.t

package info (click to toggle)
libgeo-google-mapobject-perl 0.06-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 523; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 4,249 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!perl 
use strict;
use warnings;
use Test::More tests => 33;
use Test::JSON;
use Geo::Google::MapObject;

{
   my $map = Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>"512x640");
   ok($map, "map created");
   ok($map->static_map_url eq "http://maps.google.com/maps/api/staticmap?center=Berlin&zoom=10&mobile=false&key=api1&sensor=false&size=512x640", "static_map_url");
   ok($map->javascript_url eq "http://maps.google.com/maps?file=api&v=2&key=api1&sensor=false", "javascript_url");
   is_json($map->json, '{"zoom":"10","sensor":"false","markers":[],"mobile":"false","center":"Berlin","size":{"width":"512","height":"640"}}', "json");
   ok($map->width == 512, "width");
   ok($map->height == 640, "height");
}

{
   my $map = Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>"600x100");
   ok($map, "map created");
   ok($map->static_map_url eq "http://maps.google.com/maps/api/staticmap?center=Berlin&zoom=10&mobile=false&key=api1&sensor=false&size=600x100", "static_map_url");
   ok($map->javascript_url eq "http://maps.google.com/maps?file=api&v=2&key=api1&sensor=false", "javascript_url");
   is_json($map->json, '{"zoom":"10","sensor":"false","markers":[],"mobile":"false","center":"Berlin","size":{"width":"600","height":"100"}}', "json");
   ok($map->width == 600, "width");
   ok($map->height == 100, "height");
}

{
   my $map = Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width=>100,height=>200});
   ok($map, "map created");
   ok($map->static_map_url eq "http://maps.google.com/maps/api/staticmap?center=Berlin&zoom=10&mobile=false&key=api1&sensor=false&size=100x200", "static_map_url");
   ok($map->javascript_url eq "http://maps.google.com/maps?file=api&v=2&key=api1&sensor=false", "javascript_url");
   is_json($map->json, '{"zoom":"10","sensor":"false","markers":[],"mobile":"false","center":"Berlin","size":{"width":"100","height":"200"}}', "json");
   ok($map->width == 100, "width");
   ok($map->height == 200, "height");
}

eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width1=>100,height=>200})};
like($@, qr/^no width/, "no width");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width=>100,height1=>200})};
like($@, qr/^no height/, "no height");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>"100X200")};
like($@, qr/^cannot recognize size/, "X instead of x");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>"100x2000")};
like($@, qr/^cannot recognize size/, "massive height");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>"-100x200")};
like($@, qr/^cannot recognize size/, "negative width");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width=>-10,height=>1})};
like($@, qr/^width should positive and be no more than 640 /, "negative width");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width=>641,height=>1})};
like($@, qr/^width should positive and be no more than 640 /, "boundary condition");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width=>10,height=>-1})};
like($@, qr/^height should positive and be no more than 640 /, "negative height");
eval{ Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>{width=>10,height=>641})};
like($@, qr/^height should positive and be no more than 640 /, "boundary condition");

{
   my $map = Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10);
   ok($map, "map created");
   ok($map->static_map_url eq "http://maps.google.com/maps/api/staticmap?center=Berlin&zoom=10&mobile=false&key=api1&sensor=false", "static_map_url");
   ok($map->javascript_url eq "http://maps.google.com/maps?file=api&v=2&key=api1&sensor=false", "javascript_url");
   is_json($map->json, '{"zoom":"10","sensor":"false","markers":[],"mobile":"false","center":"Berlin"}', "json");
   ok(!defined($map->width), "width");
   ok(!defined($map->height), "height");
}