@@ -36,6 +36,21 @@ public function testFromString(): void
3636 self ::assertInstanceOf (NegativeBigDecimal::class, $ actual );
3737 }
3838
39+ public function testNegativeValueReturnsNegativeFloat (): void
40+ {
41+ /** @Given a negative float value */
42+ $ value = -10.155 ;
43+
44+ /** @When creating a NegativeBigDecimal from the float */
45+ $ negativeBigDecimal = NegativeBigDecimal::fromFloat (value: $ value );
46+
47+ /** @Then the toFloat method should return the correct negative value */
48+ self ::assertSame ($ value , $ negativeBigDecimal ->toFloat ());
49+
50+ /** @Then the toString method should return the correct string representation */
51+ self ::assertSame (sprintf ('-%s ' , abs ($ value )), $ negativeBigDecimal ->toString ());
52+ }
53+
3954 #[DataProvider('dataProviderForTestNonNegativeValue ' )]
4055 public function testNonNegativeValue (mixed $ value ): void
4156 {
@@ -50,20 +65,6 @@ public function testNonNegativeValue(mixed $value): void
5065 NegativeBigDecimal::fromFloat (value: $ value );
5166 }
5267
53- public function testNonNegativeValueWithNegate (): void
54- {
55- /** @Given a NegativeBigDecimal value */
56- $ template = 'Value <%s> is not valid. Must be a negative number less than zero. ' ;
57-
58- /** @Then a NonNegativeValue exception should be thrown when the value is negated */
59- $ this ->expectException (NonNegativeValue::class);
60- $ this ->expectExceptionMessage (sprintf ($ template , 10.155 ));
61-
62- /** @When negating a negative number, it should trigger an exception */
63- $ negative = NegativeBigDecimal::fromFloat (value: -10.155 );
64- $ negative ->negate ();
65- }
66-
6768 public static function dataProviderForTestNonNegativeValue (): array
6869 {
6970 return [
0 commit comments