2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 03:44:52 +00:00

Math.pm: added unittest for round function

git-svn-id: https://svn.fhem.de/fhem/trunk@27092 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
sidey79 2023-01-20 21:07:45 +00:00
parent 7834a0e577
commit d33382c95d

View File

@ -0,0 +1,33 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test2::V0;
use Test2::Tools::Compare qw{is};
use FHEM::Core::Utils::Math;
subtest 'Round to three decimals after dot' => sub {
is (FHEM::Core::Utils::Math::round(100/3,3),33.333,'round returned three decimals after dot');
};
subtest 'Round negative, to one decimals after dot' => sub {
is (FHEM::Core::Utils::Math::round(-100/3,1),-33.3,'round returned one decimals after dot');
};
subtest 'Round negative, to no decimals after dot' => sub {
is (FHEM::Core::Utils::Math::round(100/3,0),33,'round returned zero decimals after dot');
};
subtest 'No decimals specified' => sub {
is (FHEM::Core::Utils::Math::round(100/3),U(),'round returned undef');
};
subtest 'No value specified' => sub {
is (FHEM::Core::Utils::Math::round(),U(),'round returned undef');
};
done_testing();
exit(0);
1;