return rhs.size() <= size() && compare(0, npos, rhs) == 0;
}
+ //----------------------------------------------------------------------------
+ bool String::ends_with(const String& rhs) const
+ {
+ return rhs.size() <= size() && compare(size() - rhs.size(), npos, rhs) == 0;
+ }
+
//----------------------------------------------------------------------------
size_t String::find(const char c, size_t pos) const
{
int compare(size_t pos, size_t len, const String& rhs) const;
bool starts_with(const String& rhs) const;
+ bool ends_with(const String& rhs) const;
size_t find(const char c, size_t pos = 0) const;
size_t find_first_of(const String& chr, size_t pos = 0) const;
VERIFY( !string.starts_with(String(c, "Test1")) );
VERIFY( !string.starts_with(String(c, "bb")) );
VERIFY( !string.starts_with(String(c, "bbasdasdafasd")) );
+ VERIFY( string.ends_with(String(c, "t")) );
+ VERIFY( string.ends_with(String(c, "st")) );
+ VERIFY( string.ends_with(String(c, "est")) );
+ VERIFY( string.ends_with(String(c, "Test")) );
+ VERIFY( !string.ends_with(String(c, "1Test")) );
+ VERIFY( !string.ends_with(String(c, "abc")) );
+ VERIFY( !string.ends_with(String(c, "estasdasd")) );
VERIFY( string.find('e') == 1 );
VERIFY( string.find('9') == String::npos );
VERIFY( string.find_first_of(String(c, "st")) == 2 );