Sqlite: Add endsWith to UtfString

Change-Id: I82ea54a1e23625690192a967b5f33451cdc199af
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-08-19 16:17:33 +02:00
parent 26cfe2446f
commit 8e2bb1048d
3 changed files with 13 additions and 0 deletions

View File

@@ -153,6 +153,11 @@ bool Utf8String::startsWith(char character) const
return byteArray.startsWith(character); return byteArray.startsWith(character);
} }
bool Utf8String::endsWith(const Utf8String &text) const
{
return byteArray.endsWith(text.byteArray);
}
bool Utf8String::isEmpty() const bool Utf8String::isEmpty() const
{ {
return byteArray.isEmpty(); return byteArray.isEmpty();

View File

@@ -82,6 +82,7 @@ public:
bool startsWith(const Utf8String &text) const; bool startsWith(const Utf8String &text) const;
bool startsWith(const char *text) const; bool startsWith(const char *text) const;
bool startsWith(char character) const; bool startsWith(char character) const;
bool endsWith(const Utf8String &text) const;
bool isEmpty() const; bool isEmpty() const;
bool hasContent() const; bool hasContent() const;

View File

@@ -176,6 +176,13 @@ TEST(Utf8, StartsWith)
ASSERT_FALSE(text.startsWith('@')); ASSERT_FALSE(text.startsWith('@'));
} }
TEST(Utf8, EndsWith)
{
Utf8String text(Utf8StringLiteral("/my/path"));
ASSERT_TRUE(text.endsWith(Utf8StringLiteral("path")));
}
TEST(Utf8, Clear) TEST(Utf8, Clear)
{ {
Utf8String text(Utf8StringLiteral("$column")); Utf8String text(Utf8StringLiteral("$column"));