assertEquals(\dokuwiki\Utf8\Clean::correctIdx($test[0],$test[1],$test[2]),$test[3]); } } function test_twobyte(){ // we test multiple cases here - format: in, offset, length, out $tests = array(); // two byte, should move to boundary, expect even number $tests[] = array('aaживπά우리をあöä',2,false,2); $tests[] = array('aaживπά우리をあöä',3,false,2); $tests[] = array('aaживπά우리をあöä',4,false,4); $tests[] = array('aaживπά우리をあöä',2,true,2); $tests[] = array('aaживπά우리をあöä',3,true,4); $tests[] = array('aaживπά우리をあöä',4,true,4); foreach($tests as $test){ $this->assertEquals(\dokuwiki\Utf8\Clean::correctIdx($test[0],$test[1],$test[2]),$test[3]); } } function test_threebyte(){ // we test multiple cases here - format: in, offset, length, out $tests = array(); // three byte, should move to boundary 10 or 13 $tests[] = array('aaживπά우리をあöä',10,false,10); $tests[] = array('aaживπά우리をあöä',11,false,10); $tests[] = array('aaживπά우리をあöä',12,false,10); $tests[] = array('aaживπά우리をあöä',13,false,13); $tests[] = array('aaживπά우리をあöä',10,true,10); $tests[] = array('aaживπά우리をあöä',11,true,13); $tests[] = array('aaживπά우리をあöä',12,true,13); $tests[] = array('aaживπά우리をあöä',13,true,13); foreach($tests as $test){ $this->assertEquals(\dokuwiki\Utf8\Clean::correctIdx($test[0],$test[1],$test[2]),$test[3]); } } function test_bounds(){ // we test multiple cases here - format: in, offset, length, out $tests = array(); // bounds checking $tests[] = array('aaживπά우리をあöä',-2,false,0); $tests[] = array('aaживπά우리をあöä',128,false,29); $tests[] = array('aaживπά우리をあöä',-2,true,0); $tests[] = array('aaживπά우리をあöä',128,true,29); foreach($tests as $test){ $this->assertEquals(\dokuwiki\Utf8\Clean::correctIdx($test[0],$test[1],$test[2]),$test[3]); } } } //Setup VIM: ex: et ts=4 :