1
# Copyright (C) 2008-2012 eBox Technologies S.L.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License, version 2, as
5
# published by the Free Software Foundation.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
use Test::More tests => 28;
27
use EBox::Types::Test;
29
use EBox::Types::Text;
43
# negative value as min bound
48
# value between defined bounds
54
# equal than min value
59
# equal than max value
67
# default min value must be zero, so no negatives allowed
71
# mix and max mismatch
92
foreach my $case_r (@validCases) {
93
my @params = @{ $case_r };
94
EBox::Types::Test::createOk(
98
"Checking instance creation with valid parameters and value"
103
foreach my $case_r (@deviantCases) {
104
my @params = @{ $case_r };
105
EBox::Types::Test::createFail(
108
"Checking instance creation raises error when called with invalid parameters and value"
116
my $four = new EBox::Types::Int(
121
my $otherFour = new EBox::Types::Int(
122
fieldName => 'otherFour',
125
my $two = new EBox::Types::Int(
129
my $seven = new EBox::Types::Int(
130
fieldName => 'seven',
136
my $fourWithMin = new EBox::Types::Int(
137
fieldName => 'fourWithMin',
141
my $fourWithMax = new EBox::Types::Int(
142
fieldName => 'fourWithMax',
147
my $text = new EBox::Types::Text(
152
ok $four->isEqualTo($otherFour), 'checking isEqualTo for equality';
153
ok((not $four->isEqualTo($two)), 'checking isEqualTo for inequality');
155
is $four->cmp($otherFour), 0,
156
'checking cmp method for equality';
157
is $four->cmp($two), 1,
158
'checking cmp method with a lesser other';
159
is $four->cmp($seven), -1,
160
'checking cmp method with a greater other';
162
cmp_ok($four->cmp($fourWithMin), '==', 0,
163
'checking cmp for equalify though the bounds');
165
cmp_ok($four->cmp($fourWithMax), '==', 0,
166
'checking cmp for equalify though the bounds');
168
is $four->cmp($text), undef,
169
'whether different types are incomparable';
174
EBox::TestStubs::activateTestStubs();
177
EBox::Types::Test::defaultValueOk('EBox::Types::Int', 4);
180
EBox::Types::Test::storeAndRestoreGConfTest('EBox::Types::Int', 4, 1, 4 ,5);