Commit ab0b1b40 authored by Nigel Kukard's avatar Nigel Kukard

Revamped unit tests

parent 0d4b3fc6
# Test harness for booleanize
# Copyright (C) 2014-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Test::More;
use strict;
use warnings;
use AWITPT::Util;
is(booleanize(0),0,"Booleanize of 0 should return 0");
is(booleanize("0"),0,"Booleanize of '0' should return 0");
is(booleanize("00"),0,"Booleanize of '00' should return 0");
is(booleanize("-1"),0,"Booleanize of '-1' should return 0");
is(booleanize("-0"),0,"Booleanize of '-0' should return 0");
is(booleanize("a"),0,"Booleanize of 'a' should return 0");
is(booleanize("0a"),0,"Booleanize of 'a' should return 0");
is(booleanize("a0"),0,"Booleanize of 'a' should return 0");
is(booleanize("TruE"),1,"Booleanize of 'TruE' should return 1");
is(booleanize("oN"),1,"Booleanize of 'oN' should return 1");
is(booleanize("SeT"),1,"Booleanize of 'SeT' should return 1");
is(booleanize("EnAblED"),1,"Booleanize of 'EnAblED' should return 1");
is(booleanize(1),1,"Booleanize of 1 should return 1");
is(booleanize("1"),1,"Booleanize of '1' should return 1");
done_testing();
# Test harness for isNumber
# Copyright (C) 2014, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Test::More;
use strict;
use warnings;
use AWITPT::Util;
use AWITPT::Object;
my $hash = { 'makeHash' => 1 };
my $scalar = 1;
my $object = AWITPT::Object->new();
is(isHash($hash),1,"Make sure a HASH returns 1");
is(isHash($scalar),0,"Make sure a scalar returns 0");
is(isHash(0),0,"Make sure 0 returns 0");
is(isHash("0"),0,"Make sure '0' returns 0");
is(isHash("a"),0,"Make sure 'a' returns 0");
is(isHash($object),0,"Make sure OBJECT returns 0");
done_testing();
# Test harness for indentExpand
# Copyright (C) 2014-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Test::More;
use strict;
use warnings;
use AWITPT::Util;
is(indentExpand(' ', 4),' ',"Check that indentExpand 4 spaces returns 4 spaces");
is(indentExpand(' ', 4),' ',"Check that indentExpand 4 x 4 spaces returns 16 spaces");
is(indentExpand(' ', 2),' ',"Check that indentExpand 2 spaces returns 2 spaces");
is(indentExpand(' ', 2),' ',"Check that indentExpand 2 x 2 spaces returns 4 spaces");
is(indentExpand(' ', 1),' ',"Check that indentExpand 1 spaces returns 1 space");
is(indentExpand(' ', 1),' ',"Check that indentExpand 1 x 5 spaces returns 1 space");
is(indentExpand(' ', 3),' ',"Check that indentExpand 3 returns 3 spaces");
is(indentExpand(' ', 3),' ',"Check that indentExpand 3 x 3 spaces returns 9 spaces");
done_testing();
# Test harness for isNumber
# Copyright (C) 2014, AllWorldIT
# Copyright (C) 2014-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -17,31 +17,50 @@
use Test::More;
use strict;
use warnings;
use AWITPT::Util;
use AWITPT::Object;
my $hash = { 'makeHash' => 1 };
my $object = AWITPT::Object->new();
is(isNumber(0),undef,"Check 0 returns undef");
is(isNumber("0"),undef,"Check '0' returns undef");
is(isNumber(0),undef);
is(isNumber(0,ISNUMBER_ALLOW_ZERO),0);
is(isNumber("000",ISNUMBER_ALLOW_ZERO),0);
is(isNumber("-0",ISNUMBER_ALLOW_ZERO),0);
is(isNumber(0,ISNUMBER_ALLOW_ZERO),0,"Check 0 returns 0 when using ISNUMBER_ALLOW_ZERO");
is(isNumber("000",ISNUMBER_ALLOW_ZERO),0,"Check 000 returns 0 when using ISNUMBER_ALLOW_ZEOR");
is(isNumber("-0",ISNUMBER_ALLOW_ZERO),0,"Check -0 returns 0 when using ISNUMBER_ALLOW_ZERO");
is(isNumber(-1),undef);
is(isNumber(-1,ISNUMBER_ALLOW_NEGATIVE),-1);
is(isNumber("-1",ISNUMBER_ALLOW_NEGATIVE),-1);
is(isNumber("-01",ISNUMBER_ALLOW_NEGATIVE),-1);
is(isNumber(-1),undef,"Check -1 returns undef");
is(isNumber("-1"),undef,"Check '-1' returns undef");
is(isNumber(-1,ISNUMBER_ALLOW_NEGATIVE),-1,"Check -1 returns -1 when using ISNUMBER_ALLOW_NEGATIVE");
is(isNumber("-1",ISNUMBER_ALLOW_NEGATIVE),-1,"Check '-1' returns -1 when using ISNUMBER_ALLOW_NEGATIVE");
is(isNumber("-01",ISNUMBER_ALLOW_NEGATIVE),-1,"Check '-01' returns -1 when using ISNUMBER_ALLOW_NEGATIVE");
is(isNumber(1),1);
is(isNumber(1),1,"Check 1 returns 1");
is(isNumber("1"),1,"Check '1' returns 1");
is(isNumber("0001"),1);
is(isNumber("0001"),1,"Check '0001' returns 1");
is(isNumber("a"),undef,"Check 'a' returns undef");
is(isNumber("0a"),undef,"Check '0a' returns undef");
is(isNumber("a0"),undef,"Check 'a0' returns undef");
is(isNumber("-a0"),undef,"Check '-a0' returns undef");
is(isNumber("-0a"),undef,"Check '-0a' returns undef");
is(isNumber($hash),undef,"Check HASH returns undef");
is(isNumber($object),undef,"Check OBJECT returns undef");
is(isNumber("a"),undef);
is(isNumber("0a"),undef);
is(isNumber("a0"),undef);
is(isNumber("-a0"),undef);
is(isNumber("-0a"),undef);
done_testing();
# Test harness for isVariable
# Copyright (C) 2014-2016, AllWorldIT
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Test::More;
use strict;
use warnings;
use AWITPT::Util;
my $hashtable = { 'makeHash' => 1 };
my $scalar = 1;
is(isVariable($hashtable),0,"Check that a hash returns 0");
is(isVariable($scalar),1,"Check that a variable returns 1");
is(isVariable(1),1,"Check that 1 returns 1");
is(isVariable(undef),undef,"Check that a undef returns undef");
done_testing();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment