Commit | Line | Data |
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 | |
34 | BEGIN { |
35 | unshift @INC, 'blib/lib','blib/arch'; |
36 | } |
37 | |
38 | use strict; |
39 | |
40 | use Test::More; |
41 | |
d690c5f9 |
42 | plan ( tests => 35 ); |
8fde61e3 |
43 | |
44 | use_ok( 'SDL::Rect' ); |
45 | |
46 | can_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 | |
58 | my $rect = SDL::Rect->new(); |
59 | |
60 | # creating with defaults |
61 | is (ref($rect),'SDL::Rect','new went ok'); |
62 | is ($rect->x(), 0, 'x is 0'); |
63 | is ($rect->y(), 0, 'y is 0'); |
d690c5f9 |
64 | is ($rect->top(), 0, 'top is 0'); |
65 | is ($rect->left(), 0, 'left is 0'); |
66 | is ($rect->width(), 0, 'width is 0'); |
67 | is ($rect->height(), 0, 'height is 0'); |
68 | is ($rect->w(), 0, 'w is 0'); |
69 | is ($rect->h(), 0, 'h is 0'); |
8fde61e3 |
70 | |
d690c5f9 |
71 | # set and get at the same time (and testing method aliases) |
72 | is ($rect->left(15), 15, 'left is now 15'); |
73 | is ($rect->x, 15, 'x and left point to the same place'); |
8fde61e3 |
74 | is ($rect->x(12), 12, 'x is now 12'); |
d690c5f9 |
75 | is ($rect->left, 12, 'left is an alias to x'); |
76 | |
77 | is ($rect->top(132), 132, 'top is now 132'); |
78 | is ($rect->y, 132, 'y and top point to the same place'); |
79 | is ($rect->y(123), 123, 'y is now 123'); |
80 | is ($rect->top, 123, 'top is an alias to y'); |
81 | |
82 | is ($rect->w(54), 54, 'w is now 54'); |
83 | is ($rect->width, 54, 'w and width point to the same place'); |
8fde61e3 |
84 | is ($rect->width(45), 45, 'w is now 45'); |
d690c5f9 |
85 | is ($rect->w, 45, 'w is an alias to width'); |
86 | |
87 | is ($rect->h(76), 76, 'h is now 76'); |
88 | is ($rect->height, 76, 'h and height point to the same place'); |
8fde61e3 |
89 | is ($rect->height(67), 67, 'h is now 67'); |
d690c5f9 |
90 | is ($rect->h, 67, 'h is an alias to height'); |
8fde61e3 |
91 | |
92 | # get alone |
93 | is ($rect->x(), 12, 'x is 12'); |
d690c5f9 |
94 | is ($rect->left(), 12, 'left is 12'); |
95 | is ($rect->y(), 123, 'y is 123'); |
96 | is ($rect->top(), 123, 'top is 123'); |
97 | is ($rect->width(), 45, 'width is 45'); |
98 | is ($rect->w(), 45, 'w is 45'); |
99 | is ($rect->height(), 67, 'height is 67'); |
100 | is ($rect->h(), 67, 'h is 67'); |
8fde61e3 |
101 | |