Skip to content

Commit

Permalink
Add test for vipgoci_round_array_items()
Browse files Browse the repository at this point in the history
  • Loading branch information
gudmdharalds committed Aug 12, 2021

Unverified

No user is associated with the committer email.
1 parent e9a704c commit 78f1ba2
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/MiscRoundArrayItemsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Vipgoci\tests;

require_once( __DIR__ . '/IncludesForTests.php' );

use PHPUnit\Framework\TestCase;

// phpcs:disable PSR1.Files.SideEffects

final class MiscRoundArrayItemsTest extends TestCase {
/**
* @covers ::vipgoci_round_array_items
*/
public function testRoundArrayItems() {
$org_array = array(
'test1' => 10.333330,
'test2' => 0.034444444,
'test3' => 3.359999999,
'test4' => 5.0000003,
'test5' => 7.377777777,
'test6' => 5.00000001,
);

$res_array = vipgoci_round_array_items(
$org_array,
2,
PHP_ROUND_HALF_UP
);

$expected_array = array(
'test1' => 10.33,
'test2' => 0.03,
'test3' => 3.36,
'test4' => 5.00,
'test5' => 7.38,
'test6' => 5.0,
);

$this->assertSame(
$expected_array,
$res_array
);
}
}

0 comments on commit 78f1ba2

Please sign in to comment.