summaryrefslogtreecommitdiff
path: root/libutils/String16_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge "libutil: no special copy from StaticString16" am: 7d067aee62 am: ↵Treehugger Robot2021-06-301-8/+18
|\ | | | | | | | | | | | | | | ece939ecc9 Original change: https://android-review.googlesource.com/c/platform/system/core/+/1751786 Change-Id: Ic13c3a84471160c534b0e84ac5d0987f457eef75
| * libutil: no special copy from StaticString16Jooyung Han2021-06-301-8/+18
| | | | | | | | | | | | | | | | | | String16's ctors already handle static strings, so we don't need a specialized constructor which accepts StaticString16. Bug: n/a Test: libutils_test Change-Id: I93a1ba70d743ff9c73f113d53ffba73cef6adade
* | Merge "String16 is moveable (noexcept)" am: 3551e457ca am: 32ceaa1299Treehugger Robot2021-06-301-2/+19
|\| | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/system/core/+/1749261 Change-Id: Ia658a7b6ad2c21c83ef109230a4c5f0a7d02068a
| * String16 is moveable (noexcept)Jooyung Han2021-06-291-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String16 is still in use by AIDL compiler. Because String16 is not noexcept-move-constructible, the C++ compiler will complain when it is used with non-copyable types (such as ParcelFileDescriptor). For example, when vector<Foo> is resized, copy-ctor of Foo is called, which is not available. parcelable Foo { String s; ParcelFileDescriptor[] pfds; } By providing noexcept move-ctor for String16, vector<Foo> can be resized with no problem. Btw, copy from StaticString16 is specialized for efficiency and move from StaticString16 don't need to be different from copy. Bug: 192136980 Test: libutils_test Change-Id: I13744a2ceebf5781c3ef7f3a04237a6750b0db0a
| * Remove String16::remove.Elliott Hughes2021-05-121-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function, ironically, is being removed. Even more amusing, it was never "remove" anyway --- it literally did the opposite, and removed everything *except* the range you passed to it, and should probably have been called "keep"! I'm looking at reimplementing much of libutils, but first I'm improving test coverage, and literally every test I wrote for this failed. And then when I fixed the "obvious bugs" in the implementation, I found there actually were a couple of existing unit tests --- that mostly served to demonstrate just how counter-intuitive this function was. Bug: http://b/156999009 Test: treehugger Change-Id: I41fd85f7c0988070f4039f607d2e57523d862ed9
| * Remove String16::makeLower().Elliott Hughes2021-04-071-15/+0
| | | | | | | | | | | | | | | | | | | | If you need to do a case transformation for a Unicode string, you need to use icu4c. This only worked for ASCII, which is just silly. Luckily it doesn't seem to be used anywhere. Test: treehugger Change-Id: I4a864823ec35a0b57b50909587cc3efac3f531a7 Merged-In: I4a864823ec35a0b57b50909587cc3efac3f531a7
* | Check for overflow in String16::append and String16::insert.Elliott Hughes2021-06-101-2/+34
| | | | | | | | | | | | | | Bug: http://b/178802681 Bug: http://b/178821065 Test: new tests Change-Id: I2352ea4c65e3f29e44e2ad6cad20ad610ceace1f
* | Remove String16::remove tests.Elliott Hughes2021-05-121-29/+0
| | | | | | | | | | | | | | | | | | | | These tests are only in internal right now, preventing me from removing this function entirely. So let's get them out of the way... Test: treehugger Ignore-AOSP-First: workaround for presubmit merge conflict Bug: http://b/35267372 Change-Id: Ib5de178ffad833c87e8e93bfd33e85a0ff504ac0
* | Remove String16::makeLower().Elliott Hughes2021-04-081-15/+0
| | | | | | | | | | | | | | | | | | | | | | If you need to do a case transformation for a Unicode string, you need to use icu4c. This only worked for ASCII, which is just silly. Luckily it doesn't seem to be used anywhere. Test: treehugger Change-Id: I4a864823ec35a0b57b50909587cc3efac3f531a7 Merged-In: I4a864823ec35a0b57b50909587cc3efac3f531a7 (cherry picked from commit c74d97c85442ea4d2bde2505750ab4bfe98ed325)
* | Merge "libutils: add unit tests for invalid utf-8 and utf-16 strings" am: ↵Devin Moore2020-11-121-0/+12
|\| | | | | | | | | | | | | | | eb85221dcf am: c21e63ea26 am: ddc33e4f85 am: cc2f1917ac Original change: https://android-review.googlesource.com/c/platform/system/core/+/1470423 Change-Id: Ie9f981fb869868a3acc2ca60e1a1a727b0905ad5
| * libutils: add unit tests for invalid utf-8 and utf-16 stringsDevin Moore2020-11-101-0/+12
| | | | | | | | | | | | | | Characters get dropped during the conversionis between 8 and 16. Test: atest libutils_test Change-Id: Ie76dd38e97968137555ba2ab7ce188c9122ed06e
* | String16::remove - avoid overflowSteven Moreland2020-05-281-0/+14
|/ | | | | | Bug: 156999009 Test: libutils_test (cases added) Change-Id: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
* Reland "libutils: Introduce StaticString16""Vic Yang2019-09-051-0/+218
| | | | | | | | | This reverts commit 1270e4fbf17402fb01dbfa7928a654d41d8553ee. Bug: 138856262 Test: Run unit tests. Change-Id: I37be01d7d4f98a83078870cb0917275336fa2bbd Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
* Revert "Reland "libutils: Introduce StaticString16"""Kevin Han2019-08-301-218/+0
| | | | | | | | | This reverts commit c55ac92bd6b6f14778758893730415f5328da530. Reason for revert: Breaks down-stream branches. See b/140315617 Change-Id: I4937fdf4bdcc7a44d5f10700ecf2d5e96aef7d27 Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
* Reland "libutils: Introduce StaticString16""Vic Yang2019-08-301-0/+218
| | | | | | | | | This time with old branches excluded. Bug: 138856262 Test: Run unit tests. Change-Id: Id0bb1d54b71e38244d64f1b684db1fda81de854c Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
* Revert "libutils: Introduce StaticString16"Vic Yang2019-08-291-218/+0
| | | | | | | | This reverts commit d4cb4894348818b90457d94580ed4d611c5d11b0. Reason for revert: Breaking aosp_bonito-userdebug Change-Id: Iea72f39d40f476002ce0ad6b5ce3b4e1ca570de7
* libutils: Introduce StaticString16Vic Yang2019-08-091-0/+218
This is a backward compatible implementation of compile time constructed String16 support. As much as we'd like a regular constexpr constructor for String16, we want to make sure the regular non-static String16 does not regress. We also need to make sure prebuilts built with previous version of String16 still works with new libutils. This means we cannot change the size of String16 objects and we cannot make anything virtual. To add a flag to indicate whether a String16 is static without increasing the size of non-static String16 objects, we repurpose a reserved field in SharedBuffer as "for client use". With this, we can tag every String16 and perform memory operation differently based on how the underlying buffers are allocated. By using StaticString16, we are able to eliminate the runtime construction of a String16 and move it out of .bss section. Bug: 138856262 Test: Run newly added unit tests. Change-Id: I72bb8dc27a59b9ef34e0d934bc1e00b0f675855a