Source for file numbers.inc.php
Documentation is available at numbers.inc.php
* test case for number functions
* 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.
* @author m2mtech <tech@m2m.at>
* @copyright 2007 m2m server software gmbh
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
* @version $Id: numbers.inc.php 133 2007-08-24 13:59:14Z m2mtech $
* @link http://www.ea-geier.at/
require_once('code/numbers.inc.php');
* test case for number functions
$this->UnitTestCase('Test Number Functions');
* - numbers with comma and dot separator
* - different decimal precession
$this->assertEqual(makeDot($number), 12.35);
$this->assertEqual(makeDot($number), 12.35);
// check decimals - komma
$this->assertEqual(makeDot($number, 1), 12.3);
$this->assertEqual(makeDot($number, 1), 12.3);
// check for rounding error
$this->assertEqual(makeDot($number), 162.3);
* tests makeDotOnly function
* - numbers with comma and dot separator
* - different decimal precession
// check for rounding error
* - numbers with comma and dot separator
* - different decimal precession
$this->assertEqual(makeNum($number), '12,35');
$this->assertEqual(makeNum($number), '12,35');
$this->assertEqual(makeNum($number, ','), '12,35');
$this->assertEqual(makeNum($number, ','), '12,35');
$this->assertEqual(makeNum($number, '.'), 12.35);
$this->assertEqual(makeNum($number, '.'), 12.35);
// check decimals - komma
$this->assertEqual(makeNum($number, ',', 1), '12,3');
$this->assertEqual(makeNum($number, ',', 1), '12,3');
// check decimals - komma
$this->assertEqual(makeNum($number, '.', 1), 12.3);
$this->assertEqual(makeNum($number, '.', 1), 12.3);
// check for rounding error
$this->assertEqual(makeNum($number), '162,30');
// check for rounding error
$this->assertEqual(makeNum($number), '162,30');
// check for rounding error
$this->assertEqual(makeNum($number, '.'), 162.3);
$this->assertEqual(makeNum($number, '.'), '162.30');
// check for rounding error
$this->assertEqual(makeNum($number, '.'), 162.3);
$this->assertEqual(makeNum($number, '.'), '162.30');
* - numbers with comma and dot separator
$this->assertEqual(makeNumOnly($number, ','), '12,345');
$this->assertEqual(makeNumOnly($number, ','), '12,345');
// check without decimals - komma
// check without decimals - dot
// check without decimals - none
// check without decimals - komma
// check without decimals - dot
// check without decimals - none
// check only decimals - komma
$this->assertEqual(makeNumOnly($number, ','), '0,345');
// check only decimals - dot
$this->assertEqual(makeNumOnly($number, ','), '0,345');
// check only decimals - komma
// check only decimals - dot
// check for rounding error
// check for rounding error
// check for rounding error
$this->assertEqual(makeNumOnly($number, '.'), 162.295);
// check for rounding error
$this->assertEqual(makeNumOnly($number, '.'), 162.295);
|