| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
class DiffHistoryBlobTest extends MediaWikiUnitTestCase { |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
public function testXdiffAdler32( $input ) { |
| 12 |
$xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 ); |
| 13 |
$dhb = new DiffHistoryBlob; |
| 14 |
$myHash = $dhb->xdiffAdler32( $input ); |
| 15 |
$this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ), |
| 16 |
"Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) ); |
| 17 |
} |
| 18 |
|
| 19 |
public static function provideXdiffAdler32() { |
| 20 |
return [ |
| 21 |
[ '', 'Empty string' ], |
| 22 |
[ "\0", 'Null' ], |
| 23 |
[ "\0\0\0", "Several nulls" ], |
| 24 |
[ "Hello", "An ASCII string" ], |
| 25 |
[ str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" ] |
| 26 |
]; |
| 27 |
} |
| 28 |
} |