public function testCopy2() { $str = CharArray::fromString("Test"); $str->setSize(5); $res = System::arraycopy($str, 1, $str, 2, 3); $this->assertEquals("Teest", (string) $res); }
public function testOffsetSet() { $chars = new CharArray(16); $chars[0] = 'o'; $chars[1] = 'ß'; $this->assertEquals('oß', $chars->toString()->getOriginalValue()); $this->assertEquals('oß', (string) $chars); }
/** * Converts this string to a new character array. * * @return CharArray a newly allocated character array whose length is the length * of this string and whose contents are initialized to contain * the character sequence represented by this string. */ public function toCharArray() { return Option::fromValue($this->charArray)->getOrCall(function () { return $this->charArray = CharArray::fromString($this->value); }); }
/** * @return \PHPJ\Lang\String - a string consisting of exactly this sequence of characters */ public function toString() { return $this->length() ? new String($this->value->toString()) : new String(); }