Compare commits

...

2 Commits

Author SHA1 Message Date
Rick Ossendrijver
8ba4f872be Add tests and more context in the StringRules file 2024-09-03 16:45:28 +02:00
Rick Ossendrijver
3d5678e20e Introduce comment for the String#copyValueOf rewrite 2024-09-03 16:45:27 +02:00
3 changed files with 15 additions and 0 deletions

View File

@@ -244,4 +244,11 @@ final class StringRules {
return Utf8.encodedLength(str);
}
}
// Rewrite `String#copyValueOf(char[])` to `new String(char[])`.
// Example:
// String.copyValueOf(new char[]);
// -->
// new String(new char[]);
}

View File

@@ -96,4 +96,8 @@ final class StringRulesTest implements RefasterRuleCollectionTestCase {
int testUtf8EncodedLength() {
return "foo".getBytes(UTF_8).length;
}
String testNewStringChar() {
return String.copyValueOf(new char[] {'f', 'o', 'o'});
}
}

View File

@@ -96,4 +96,8 @@ final class StringRulesTest implements RefasterRuleCollectionTestCase {
int testUtf8EncodedLength() {
return Utf8.encodedLength("foo");
}
String testNewStringChar() {
return new String(new char[] {'f', 'o', 'o'});
}
}