[ox/std] Make String::beginsWtih and endsWith functions that take StringViews

This commit is contained in:
2023-01-03 03:30:33 -06:00
parent 03378ebe43
commit 5508dc5dc0
8 changed files with 50 additions and 47 deletions

View File

@@ -75,17 +75,17 @@ static std::map<ox::String, ox::Error(*)()> tests = {
oxAssert(s == "asdf", "String assign broken");
s += "aoeu";
oxAssert(s == "asdfaoeu", "String append broken");
ox::String ending = "asdf";
oxAssert(ending.beginsWith("as"), "String::beginsWith is broken");
oxAssert(ending.beginsWith("asd"), "String::beginsWith is broken");
oxAssert(ending.beginsWith("asdf"), "String::beginsWith is broken");
oxAssert(!ending.beginsWith("aa"), "String::beginsWith is broken");
oxAssert(!ending.beginsWith("aaaaaaa"), "String::beginsWith is broken");
oxAssert(!ending.beginsWith("li"), "String::beginsWith is broken");
oxAssert(!ending.beginsWith("afoif"), "String::beginsWith is broken");
oxAssert(ending.endsWith("df"), "String::endsWith is broken");
oxAssert(!ending.endsWith("awefawe"), "String::endsWith is broken");
oxAssert(!ending.endsWith("eu"), "String::endsWith is broken");
const ox::StringView str = "asdf";
oxAssert(beginsWith(str, "as"), "String beginsWith is broken");
oxAssert(beginsWith(str, "asd"), "String beginsWith is broken");
oxAssert(beginsWith(str, "asdf"), "String beginsWith is broken");
oxAssert(!beginsWith(str, "aa"), "String beginsWith is broken");
oxAssert(!beginsWith(str, "aaaaaaa"), "String beginsWith is broken");
oxAssert(!beginsWith(str, "li"), "String beginsWith is broken");
oxAssert(!beginsWith(str, "afoif"), "String beginsWith is broken");
oxAssert(endsWith(str, "df"), "String endsWith is broken");
oxAssert(!endsWith(str, "awefawe"), "String endsWith is broken");
oxAssert(!endsWith(str, "eu"), "String endsWith is broken");
return OxError(0);
}
},