1
0

LargeFileHelperTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test;
  8. class LargeFileHelperTest extends TestCase {
  9. protected $helper;
  10. protected function setUp(): void {
  11. parent::setUp();
  12. $this->helper = new \OC\LargeFileHelper;
  13. }
  14. public function testFormatUnsignedIntegerFloat() {
  15. $this->assertSame(
  16. '9007199254740992',
  17. $this->helper->formatUnsignedInteger((float) 9007199254740992)
  18. );
  19. }
  20. public function testFormatUnsignedIntegerInt() {
  21. $this->assertSame(
  22. PHP_INT_SIZE === 4 ? '4294967295' : '18446744073709551615',
  23. $this->helper->formatUnsignedInteger(-1)
  24. );
  25. }
  26. public function testFormatUnsignedIntegerString() {
  27. $this->assertSame(
  28. '9007199254740993',
  29. $this->helper->formatUnsignedInteger('9007199254740993')
  30. );
  31. }
  32. public function testFormatUnsignedIntegerStringException() {
  33. $this->expectException(\UnexpectedValueException::class);
  34. $this->helper->formatUnsignedInteger('900ABCD254740993');
  35. }
  36. }