remove unnecessary Carp
[sdlgit/SDL_perl.git] / t / rectpm.t
CommitLineData
8fde61e3 1#!/usr/bin/perl -w
2#
3# Copyright (C) 2003 Tels
4# Copyright (C) 2004 David J. Goehrig
5#
7b6a53a1 6# Copyright (C) 2005 David J. Goehrig <dgoehrig\@cpan.org>
7#
8# ------------------------------------------------------------------------------
9#
10# This library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 2.1 of the License, or (at your option) any later version.
14#
15# This library is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# Lesser General Public License for more details.
19#
20# You should have received a copy of the GNU Lesser General Public
21# License along with this library; if not, write to the Free Software
22# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23#
24# ------------------------------------------------------------------------------
25#
26# Please feel free to send questions, suggestions or improvements to:
27#
28# David J. Goehrig
29# dgoehrig\@cpan.org
30#
31#
8fde61e3 32# basic testing of SDL::Rect
33
34BEGIN {
35 unshift @INC, 'blib/lib','blib/arch';
36}
37
38use strict;
39
40use Test::More;
41
d690c5f9 42plan ( tests => 35 );
8fde61e3 43
44use_ok( 'SDL::Rect' );
45
46can_ok ('SDL::Rect', qw/
47 new
48 x
49 y
50 width
d690c5f9 51 height
52 w
53 h
54 top
55 left
56 /);
8fde61e3 57
2daadb0f 58my $rect = SDL::Rect->new(0,0,0,0);
8fde61e3 59
60# creating with defaults
e4ab5b2e 61isa_ok ($rect,'SDL::Rect');
8fde61e3 62is ($rect->x(), 0, 'x is 0');
63is ($rect->y(), 0, 'y is 0');
d690c5f9 64is ($rect->top(), 0, 'top is 0');
65is ($rect->left(), 0, 'left is 0');
66is ($rect->width(), 0, 'width is 0');
67is ($rect->height(), 0, 'height is 0');
68is ($rect->w(), 0, 'w is 0');
69is ($rect->h(), 0, 'h is 0');
8fde61e3 70
d690c5f9 71# set and get at the same time (and testing method aliases)
72is ($rect->left(15), 15, 'left is now 15');
73is ($rect->x, 15, 'x and left point to the same place');
8fde61e3 74is ($rect->x(12), 12, 'x is now 12');
d690c5f9 75is ($rect->left, 12, 'left is an alias to x');
76
77is ($rect->top(132), 132, 'top is now 132');
78is ($rect->y, 132, 'y and top point to the same place');
79is ($rect->y(123), 123, 'y is now 123');
80is ($rect->top, 123, 'top is an alias to y');
81
82is ($rect->w(54), 54, 'w is now 54');
83is ($rect->width, 54, 'w and width point to the same place');
8fde61e3 84is ($rect->width(45), 45, 'w is now 45');
d690c5f9 85is ($rect->w, 45, 'w is an alias to width');
86
87is ($rect->h(76), 76, 'h is now 76');
88is ($rect->height, 76, 'h and height point to the same place');
8fde61e3 89is ($rect->height(67), 67, 'h is now 67');
d690c5f9 90is ($rect->h, 67, 'h is an alias to height');
8fde61e3 91
92# get alone
93is ($rect->x(), 12, 'x is 12');
d690c5f9 94is ($rect->left(), 12, 'left is 12');
95is ($rect->y(), 123, 'y is 123');
96is ($rect->top(), 123, 'top is 123');
97is ($rect->width(), 45, 'width is 45');
98is ($rect->w(), 45, 'w is 45');
99is ($rect->height(), 67, 'height is 67');
100is ($rect->h(), 67, 'h is 67');
8fde61e3 101