Fixes for languages

This commit is contained in:
David Bomba 2022-02-26 14:53:51 +11:00
parent 980fcb789f
commit 0ab1153e4d
2 changed files with 506 additions and 312 deletions

File diff suppressed because it is too large Load Diff

View File

@ -62,23 +62,6 @@ class NumberTest extends TestCase
$this->assertEquals(7.99, $converted_amount);
}
// public function testParsingFloats()
// {
// Currency::all()->each(function ($currency) {
// $amount = 123456789.12;
// $formatted_amount = Number::formatValue($amount, $currency);
// $float_amount = Number::parseFloat($formatted_amount);
// if ($currency->precision == 0) {
// $this->assertEquals(123456789, $float_amount);
// } else {
// $this->assertEquals($amount, $float_amount);
// }
// });
// }
public function testRoundingDecimalsTwo()
{
$currency = Currency::find(1);
@ -141,4 +124,25 @@ class NumberTest extends TestCase
$this->assertEquals(0.00000005, $x);
}
public function testRoundingPositive()
{
$currency = Currency::find(1);
$x = Number::formatValueNoTrailingZeroes(1.5, $currency);
$this->assertEquals(1.5, $x);
$x = Number::formatValueNoTrailingZeroes(1.50, $currency);
$this->assertEquals(1.5, $x);
$x = Number::formatValueNoTrailingZeroes(1.500, $currency);
$this->assertEquals(1.5, $x);
$x = Number::formatValueNoTrailingZeroes(1.50005, $currency);
$this->assertEquals(1.50005, $x);
$x = Number::formatValueNoTrailingZeroes(1.50000005, $currency);
$this->assertEquals(1.50000005, $x);
}
}