BitUtilsTest.php 784 B

12345678910111213141516171819202122232425
  1. <?php
  2. declare(strict_types = 1);
  3. namespace BaconQrCodeTest\Common;
  4. use BaconQrCode\Common\BitUtils;
  5. use PHPUnit\Framework\TestCase;
  6. class BitUtilsTest extends TestCase
  7. {
  8. public function testUnsignedRightShift() : void
  9. {
  10. $this->assertSame(1, BitUtils::unsignedRightShift(1, 0));
  11. $this->assertSame(1, BitUtils::unsignedRightShift(10, 3));
  12. $this->assertSame(536870910, BitUtils::unsignedRightShift(-10, 3));
  13. }
  14. public function testNumberOfTrailingZeros() : void
  15. {
  16. $this->assertSame(32, BitUtils::numberOfTrailingZeros(0));
  17. $this->assertSame(1, BitUtils::numberOfTrailingZeros(10));
  18. $this->assertSame(0, BitUtils::numberOfTrailingZeros(15));
  19. $this->assertSame(2, BitUtils::numberOfTrailingZeros(20));
  20. }
  21. }