From c853206e8a8d9f1f02180fcdd1a948e352cbd1b2 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 26 Nov 2021 16:21:40 +0100 Subject: add method to shorten a string to given byte size to Utils Signed-off-by: Arthur Schiwon --- tests/lib/UtilTest.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index bb328c5998d..ca7a4ad1442 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -310,4 +310,11 @@ class UtilTest extends \Test\TestCase { 'myApp/vendor/myFancyCSSFile2', ], \OC_Util::$styles); } + + public function testShortenMultibyteString() { + $this->assertEquals('Short nuff', \OCP\Util::shortenMultibyteString('Short nuff', 255)); + $this->assertEquals('ABC', \OCP\Util::shortenMultibyteString('ABCDEF', 3)); + // each of the characters is 12 bytes + $this->assertEquals('🙈', \OCP\Util::shortenMultibyteString('🙈🙊🙉', 16, 2)); + } } -- cgit v1.2.3