bug - XDSL adslAtucCurrOutputPwr exception (Cisco CSCvj53634) (#15614)

* Cisco CSCvj53634

tests

change RRD minimas to accept negative dbm output power

unnecessary tests

* unsignedAsSigned function

* use new function Number::unsignedAsSigned

* negative power for Vdsl as well

* style

* style

* Add types

* simplify and exception if over max value

* Add tests

* Style fixes

* Tell phpstan to shut up

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
PipoCanaja
2023-12-15 17:06:52 +01:00
committed by GitHub
parent 45b3e0f624
commit 648a5ea7d3
3 changed files with 43 additions and 4 deletions

View File

@@ -126,4 +126,21 @@ class FunctionsTest extends TestCase
$this->assertSame(1, Number::cast(1.0));
$this->assertSame(2, Number::cast('2.000'));
}
public function testNumberAsUnsigned()
{
$this->assertSame(42, Number::unsignedAsSigned('42')); /** @phpstan-ignore-line */
$this->assertSame(2147483647, Number::unsignedAsSigned(2147483647));
$this->assertSame(-2147483648, Number::unsignedAsSigned(2147483648));
$this->assertSame(-2147483647, Number::unsignedAsSigned(2147483649));
$this->assertSame(-1, Number::unsignedAsSigned(4294967295));
}
public function testNumberAsUnsignedValueExceedsMaxUnsignedValue()
{
$this->expectException(\InvalidArgumentException::class);
// Exceeds the maximum representable value for a 32-bit unsigned integer
Number::unsignedAsSigned(4294967296, 32);
}
}