3 class DiffHistoryBlobTest
extends MediaWikiTestCase
{
4 protected function setUp() {
5 if ( !extension_loaded( 'xdiff' ) ) {
6 $this->markTestSkipped( 'The xdiff extension is not available' );
9 if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
10 $this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
13 if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash' ) ) {
14 $this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
21 * Test for DiffHistoryBlob::xdiffAdler32()
22 * @dataProvider provideXdiffAdler32
24 function testXdiffAdler32( $input ) {
25 $xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
26 $dhb = new DiffHistoryBlob
;
27 $myHash = $dhb->xdiffAdler32( $input );
28 $this->assertSame( bin2hex( $xdiffHash ), bin2hex( $myHash ),
29 "Hash of " . addcslashes( $input, "\0..\37!@\@\177..\377" ) );
32 public static function provideXdiffAdler32() {
34 array( '', 'Empty string' ),
35 array( "\0", 'Null' ),
36 array( "\0\0\0", "Several nulls" ),
37 array( "Hello", "An ASCII string" ),
38 array( str_repeat( "x", 6000 ), "A string larger than xdiff's NMAX (5552)" )