2014-02-15 17:21:23 -05:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2014-02-15 17:21:23 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test;
|
|
|
|
|
|
2016-05-20 09:38:20 -04:00
|
|
|
class LargeFileHelperTest extends TestCase {
|
2014-02-15 17:21:23 -05:00
|
|
|
protected $helper;
|
|
|
|
|
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function setUp(): void {
|
2014-02-15 17:21:23 -05:00
|
|
|
parent::setUp();
|
|
|
|
|
$this->helper = new \OC\LargeFileHelper;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testFormatUnsignedIntegerFloat(): void {
|
2014-02-15 17:21:23 -05:00
|
|
|
$this->assertSame(
|
|
|
|
|
'9007199254740992',
|
2024-08-23 09:10:27 -04:00
|
|
|
$this->helper->formatUnsignedInteger((float)9007199254740992)
|
2014-02-15 17:21:23 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testFormatUnsignedIntegerInt(): void {
|
2014-02-15 17:21:23 -05:00
|
|
|
$this->assertSame(
|
|
|
|
|
PHP_INT_SIZE === 4 ? '4294967295' : '18446744073709551615',
|
|
|
|
|
$this->helper->formatUnsignedInteger(-1)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testFormatUnsignedIntegerString(): void {
|
2014-02-15 17:21:23 -05:00
|
|
|
$this->assertSame(
|
|
|
|
|
'9007199254740993',
|
|
|
|
|
$this->helper->formatUnsignedInteger('9007199254740993')
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testFormatUnsignedIntegerStringException(): void {
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->expectException(\UnexpectedValueException::class);
|
|
|
|
|
|
2014-02-15 17:21:23 -05:00
|
|
|
$this->helper->formatUnsignedInteger('900ABCD254740993');
|
|
|
|
|
}
|
|
|
|
|
}
|