Merge "Remove String16::remove." am: e9c7c5c80c am: 50d6fc417e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1704013 Change-Id: If8fa89c9dd4a726d3599a486eb78649da24acd7c
This commit is contained in:
commit
203cdf89fc
4 changed files with 0 additions and 57 deletions
|
|
@ -411,36 +411,4 @@ status_t String16::replaceAll(char16_t replaceThis, char16_t withThis)
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t String16::remove(size_t len, size_t begin)
|
|
||||||
{
|
|
||||||
const size_t N = size();
|
|
||||||
if (begin >= N) {
|
|
||||||
release();
|
|
||||||
mString = getEmptyString();
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
if (len > N || len > N - begin) len = N - begin;
|
|
||||||
if (begin == 0 && len == N) {
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (begin > 0) {
|
|
||||||
SharedBuffer* buf = static_cast<SharedBuffer*>(editResize((N + 1) * sizeof(char16_t)));
|
|
||||||
if (!buf) {
|
|
||||||
return NO_MEMORY;
|
|
||||||
}
|
|
||||||
char16_t* str = (char16_t*)buf->data();
|
|
||||||
memmove(str, str+begin, (N-begin+1)*sizeof(char16_t));
|
|
||||||
mString = str;
|
|
||||||
}
|
|
||||||
SharedBuffer* buf = static_cast<SharedBuffer*>(editResize((len + 1) * sizeof(char16_t)));
|
|
||||||
if (buf) {
|
|
||||||
char16_t* str = (char16_t*)buf->data();
|
|
||||||
str[len] = 0;
|
|
||||||
mString = str;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
return NO_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
|
|
||||||
|
|
@ -72,12 +72,6 @@ std::vector<std::function<void(FuzzedDataProvider&, android::String16, android::
|
||||||
char16_t replaceChar = dataProvider.ConsumeIntegral<char16_t>();
|
char16_t replaceChar = dataProvider.ConsumeIntegral<char16_t>();
|
||||||
str1.replaceAll(findChar, replaceChar);
|
str1.replaceAll(findChar, replaceChar);
|
||||||
}),
|
}),
|
||||||
([](FuzzedDataProvider& dataProvider, android::String16 str1,
|
|
||||||
android::String16) -> void {
|
|
||||||
size_t len = dataProvider.ConsumeIntegral<size_t>();
|
|
||||||
size_t begin = dataProvider.ConsumeIntegral<size_t>();
|
|
||||||
str1.remove(len, begin);
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void callFunc(uint8_t index, FuzzedDataProvider& dataProvider, android::String16 str1,
|
void callFunc(uint8_t index, FuzzedDataProvider& dataProvider, android::String16 str1,
|
||||||
|
|
@ -111,7 +105,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
callFunc(op, dataProvider, str_one_utf16, str_two_utf16);
|
callFunc(op, dataProvider, str_one_utf16, str_two_utf16);
|
||||||
}
|
}
|
||||||
|
|
||||||
str_one_utf16.remove(0, str_one_utf16.size());
|
|
||||||
str_two_utf16.remove(0, str_two_utf16.size());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,13 +90,6 @@ TEST(String16Test, Insert) {
|
||||||
EXPECT_STR16EQ(u"VerifyInsert me", tmp);
|
EXPECT_STR16EQ(u"VerifyInsert me", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(String16Test, Remove) {
|
|
||||||
String16 tmp("Verify me");
|
|
||||||
tmp.remove(2, 6);
|
|
||||||
EXPECT_EQ(2U, tmp.size());
|
|
||||||
EXPECT_STR16EQ(u" m", tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(String16Test, ReplaceAll) {
|
TEST(String16Test, ReplaceAll) {
|
||||||
String16 tmp("Verify verify Verify");
|
String16 tmp("Verify verify Verify");
|
||||||
tmp.replaceAll(u'r', u'!');
|
tmp.replaceAll(u'r', u'!');
|
||||||
|
|
@ -161,14 +154,6 @@ TEST(String16Test, StaticStringInsert) {
|
||||||
EXPECT_FALSE(tmp.isStaticString());
|
EXPECT_FALSE(tmp.isStaticString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(String16Test, StaticStringRemove) {
|
|
||||||
StaticString16 tmp(u"Verify me");
|
|
||||||
tmp.remove(2, 6);
|
|
||||||
EXPECT_EQ(2U, tmp.size());
|
|
||||||
EXPECT_STR16EQ(u" m", tmp);
|
|
||||||
EXPECT_FALSE(tmp.isStaticString());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(String16Test, StaticStringReplaceAll) {
|
TEST(String16Test, StaticStringReplaceAll) {
|
||||||
StaticString16 tmp(u"Verify verify Verify");
|
StaticString16 tmp(u"Verify verify Verify");
|
||||||
tmp.replaceAll(u'r', u'!');
|
tmp.replaceAll(u'r', u'!');
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,6 @@ public:
|
||||||
status_t replaceAll(char16_t replaceThis,
|
status_t replaceAll(char16_t replaceThis,
|
||||||
char16_t withThis);
|
char16_t withThis);
|
||||||
|
|
||||||
status_t remove(size_t len, size_t begin=0);
|
|
||||||
|
|
||||||
inline int compare(const String16& other) const;
|
inline int compare(const String16& other) const;
|
||||||
|
|
||||||
inline bool operator<(const String16& other) const;
|
inline bool operator<(const String16& other) const;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue