mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
C++: Add size() method to SharedString (#6417)
The length is an important property of a string and should be available as a getter. The new size() method is consistent with std::string. ChangeLog: [C++] Added `SharedString::size()`
This commit is contained in:
parent
9c04c62cc6
commit
40811193aa
2 changed files with 9 additions and 0 deletions
|
@ -13,6 +13,7 @@ SCENARIO("SharedString API")
|
|||
slint::SharedString str;
|
||||
|
||||
REQUIRE(str.empty());
|
||||
REQUIRE(str.size() == 0);
|
||||
REQUIRE(str == "");
|
||||
REQUIRE(std::string_view(str.data()) == ""); // this test null termination of data()
|
||||
|
||||
|
@ -45,6 +46,12 @@ SCENARIO("SharedString API")
|
|||
str = "Hello";
|
||||
REQUIRE(str.begin() + std::string_view(str).size() == str.end());
|
||||
}
|
||||
|
||||
SECTION("size")
|
||||
{
|
||||
str = "Hello";
|
||||
REQUIRE(str.size() == 5);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Basic SharedVector API", "[vector]")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue