Skip to content

Commit

Permalink
fix 11.75 conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwhansen committed Jan 20, 2024
1 parent 370fbd2 commit 86cd1a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Distance.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function convertToEnglish($value, $cmValue = null)
$feet = floor($length / 12);
$inch = $length - 12 * $feet;

if ($inch > 11.75) {
if ($inch > 11.78) {
$feet++;
$inch = 0;
}
Expand Down
11 changes: 8 additions & 3 deletions tests/DistanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,29 @@

it('can convert 18 from english to metric', function () {
$result = Distance::fromFeet(18)->to(Format::METRIC);
expect($result)->toEqual(5.49);
expect($result)->toEqual(5.486);
});

it('can convert "18" from english to metric', function () {
$result = Distance::fromFeet("18")->to(Format::METRIC);
expect($result)->toEqual(5.49);
expect($result)->toEqual(5.486);
});

it('can convert "18-2" from english to metric', function () {
$result = Distance::fromFeet("18-2")->to(Format::METRIC);
expect($result)->toEqual(5.54);
expect($result)->toEqual(5.537);
});

it('can convert "18-2.5" from english to metric', function () {
$result = Distance::fromFeet("18-2.5")->to(Format::METRIC);
expect($result)->toEqual(5.55);
});

it('can convert "18-11.75" from english to metric', function () {
$result = Distance::fromFeet("18-11.75")->to(Format::METRIC);
expect($result)->toEqual(5.785);
});

it('can convert "18-2.5" from english to metric using toMetric helper', function () {
$result = Distance::fromFeet("18-2.5")->toMetric();
expect($result)->toEqual(5.55);
Expand Down

0 comments on commit 86cd1a5

Please sign in to comment.