mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-02 09:14:48 +02:00
Added some more tests.
Also changed the behavior of some code to meet the expectation.
This commit is contained in:
parent
322778af68
commit
a97d016740
8 changed files with 523 additions and 12 deletions
|
@ -74,9 +74,11 @@ class SIFormatterTest extends WebTestCase
|
|||
|
||||
public function testgetPrefixByMagnitude()
|
||||
{
|
||||
$this->assertSame([1, ''], $this->service->getPrefixByMagnitude(2));
|
||||
|
||||
$this->assertSame([1000, 'k'], $this->service->getPrefixByMagnitude(3));
|
||||
$this->assertSame([1000, 'k'], $this->service->getPrefixByMagnitude(2));
|
||||
$this->assertSame([1000, 'k'], $this->service->getPrefixByMagnitude(4));
|
||||
$this->assertSame([1000, 'k'], $this->service->getPrefixByMagnitude(5));
|
||||
|
||||
$this->assertSame([0.001, 'm'], $this->service->getPrefixByMagnitude(-3));
|
||||
$this->assertSame([0.001, 'm'], $this->service->getPrefixByMagnitude(-2));
|
||||
|
@ -86,6 +88,8 @@ class SIFormatterTest extends WebTestCase
|
|||
public function testFormat()
|
||||
{
|
||||
$this->assertSame("2.32 km", $this->service->format(2321, 'm'));
|
||||
$this->assertEquals("230.45 km", $this->service->format(230450.3, 'm'));
|
||||
$this->assertSame("-98.20 mg", $this->service->format(-0.0982, 'g'));
|
||||
$this->assertSame('-0.23 g', $this->service->format(-0.23, 'g'));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue