3 class DiffHistoryBlobTest
extends MediaWikiTestCase
{
5 if ( !extension_loaded( 'xdiff' ) ) {
6 $this->markTestSkipped( 'The xdiff extension is not available' );
9 if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash' ) ) {
10 $this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
16 * Test for DiffHistoryBlob::xdiffAdler32()
17 * @dataProvider provideXdiffAdler32
19 function testXdiffAdler32( $input ) {
20 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
21 $dhb = new DiffHistoryBlob
;
22 $myHash = $dhb->xdiffAdler32( $input );
23 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
24 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
27 function provideXdiffAdler32() {
29 array( '', 'Empty string' ),
30 array( "\0", 'Null' ),
31 array( "\0\0\0", "Several nulls" ),
32 array( "Hello", "An ASCII string" ),
33 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" )