Removed util::startsWith(a, b)

pull/2/head
Tatsuhiro Tsujikawa 2011-11-04 23:43:32 +09:00
parent f84d2253b2
commit 601ec0f44a
19 changed files with 109 additions and 79 deletions

View File

@ -253,7 +253,8 @@ AuthConfigFactory::findBasicCred
std::lower_bound(basicCreds_.begin(), basicCreds_.end(), bc); std::lower_bound(basicCreds_.begin(), basicCreds_.end(), bc);
for(; i != basicCreds_.end() && (*i).host_ == host && (*i).port_ == port; for(; i != basicCreds_.end() && (*i).host_ == host && (*i).port_ == port;
++i) { ++i) {
if(util::startsWith(bc.path_, (*i).path_)) { if(util::startsWith(bc.path_.begin(), bc.path_.end(),
(*i).path_.begin(), (*i).path_.end())) {
return i; return i;
} }
} }

View File

@ -173,7 +173,7 @@ bool ChunkedDecodingStreamFilter::readDataEnd
size_t pbufSize = buf_.size(); size_t pbufSize = buf_.size();
buf_.append(&inbuf[inbufOffset], &inbuf[inlen]); buf_.append(&inbuf[inbufOffset], &inbuf[inlen]);
if(buf_.size() >= 2) { if(buf_.size() >= 2) {
if(util::startsWith(buf_, A2STR::CRLF)) { if(buf_[0] == '\r' && buf_[1] == '\n') {
inbufOffset += 2-pbufSize; inbufOffset += 2-pbufSize;
buf_.clear(); buf_.clear();
state_ = readChunkSizeStateHandler_; state_ = readChunkSizeStateHandler_;

View File

@ -57,6 +57,7 @@
#include "a2functional.h" #include "a2functional.h"
#include "fmt.h" #include "fmt.h"
#include "SocketRecvBuffer.h" #include "SocketRecvBuffer.h"
#include "array_fun.h"
namespace aria2 { namespace aria2 {
@ -86,11 +87,14 @@ std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
std::string result; std::string result;
std::string line; std::string line;
while(getline(istr, line)) { while(getline(istr, line)) {
static const std::string AUTH_HEADER("Authorization: Basic"); const char A2_AUTH_HEADER[] = "Authorization: Basic";
static const std::string PROXY_AUTH_HEADER("Proxy-Authorization: Basic"); const char A2_PROXY_AUTH_HEADER[] = "Proxy-Authorization: Basic";
if(util::startsWith(line, AUTH_HEADER)) { if(util::startsWith(line.begin(), line.end(),
A2_AUTH_HEADER, vend(A2_AUTH_HEADER)-1)) {
result += "Authorization: Basic ********\n"; result += "Authorization: Basic ********\n";
} else if(util::startsWith(line, PROXY_AUTH_HEADER)) { } else if(util::startsWith(line.begin(), line.end(),
A2_PROXY_AUTH_HEADER,
vend(A2_PROXY_AUTH_HEADER)-1)) {
result += "Proxy-Authorization: Basic ********\n"; result += "Proxy-Authorization: Basic ********\n";
} else { } else {
strappend(result, line, "\n"); strappend(result, line, "\n");

View File

@ -254,7 +254,8 @@ std::string HttpRequest::createRequest()
std::vector<std::string>::const_iterator j = headers_.begin(); std::vector<std::string>::const_iterator j = headers_.begin();
std::vector<std::string>::const_iterator jend = headers_.end(); std::vector<std::string>::const_iterator jend = headers_.end();
for(; j != jend; ++j) { for(; j != jend; ++j) {
if(util::startsWith(*j, (*i).first)) { if(util::startsWith((*j).begin(), (*j).end(),
(*i).first.begin(), (*i).first.end())) {
break; break;
} }
} }
@ -440,11 +441,15 @@ bool HttpRequest::conditionalRequest() const
if(!ifModSinceHeader_.empty()) { if(!ifModSinceHeader_.empty()) {
return true; return true;
} }
const char A2_IF_MOD_SINCE[] = "if-modified-since";
const char A2_IF_NONE_MATCH[] = "if-none-match";
for(std::vector<std::string>::const_iterator i = headers_.begin(), for(std::vector<std::string>::const_iterator i = headers_.begin(),
eoi = headers_.end(); i != eoi; ++i) { eoi = headers_.end(); i != eoi; ++i) {
std::string hd = util::toLower(*i); std::string hd = util::toLower(*i);
if(util::startsWith(hd, "if-modified-since") || if(util::startsWith(hd.begin(), hd.end(),
util::startsWith(hd, "if-none-match")) { A2_IF_MOD_SINCE, vend(A2_IF_MOD_SINCE)-1) ||
util::startsWith(hd.begin(), hd.end(),
A2_IF_NONE_MATCH, vend(A2_IF_NONE_MATCH)-1)) {
return true; return true;
} }
} }

View File

@ -149,13 +149,13 @@ void Netrc::parse(const std::string& path)
if(!fp.getsn(buf, sizeof(buf))) { if(!fp.getsn(buf, sizeof(buf))) {
break; break;
} }
std::string line(buf); size_t len = strlen(buf);
if(util::startsWith(line, "#")) { if(len == 0 || buf[0] == '#') {
continue; continue;
} }
std::vector<Scip> tokens; std::vector<Scip> tokens;
const char A2_DELIMS[] = " \t"; const char A2_DELIMS[] = " \t";
util::splitIterM(line.begin(), line.end(), std::back_inserter(tokens), util::splitIterM(&buf[0], &buf[len], std::back_inserter(tokens),
A2_DELIMS, vend(A2_DELIMS)-1, true); A2_DELIMS, vend(A2_DELIMS)-1, true);
const char A2_MACHINE[] = "machine"; const char A2_MACHINE[] = "machine";
const char A2_DEFAULT[] = "default"; const char A2_DEFAULT[] = "default";

View File

@ -55,11 +55,10 @@ NsCookieParser::~NsCookieParser() {}
namespace { namespace {
bool parseNsCookie bool parseNsCookie
(Cookie& cookie, const std::string& nsCookieStr, time_t creationTime) (Cookie& cookie, const char* buf, size_t buflen, time_t creationTime)
{ {
std::vector<Scip> vs; std::vector<Scip> vs;
util::splitIter(nsCookieStr.begin(), nsCookieStr.end(), util::splitIter(&buf[0], &buf[buflen], std::back_inserter(vs), '\t', true);
std::back_inserter(vs), '\t', true);
if(vs.size() < 6) { if(vs.size() < 6) {
return false; return false;
} }
@ -113,12 +112,12 @@ std::vector<Cookie> NsCookieParser::parse
if(!fp.getsn(buf, sizeof(buf))) { if(!fp.getsn(buf, sizeof(buf))) {
break; break;
} }
std::string line(buf); size_t len = strlen(buf);
if(util::startsWith(line, A2STR::SHARP_C)) { if(len == 0 || buf[0] == '#') {
continue; continue;
} }
Cookie c; Cookie c;
if(parseNsCookie(c, line, creationTime)) { if(parseNsCookie(c, buf, len, creationTime)) {
cookies.push_back(c); cookies.push_back(c);
} }
} }

View File

@ -58,6 +58,7 @@
#include "LogFactory.h" #include "LogFactory.h"
#include "uri.h" #include "uri.h"
#include "SegList.h" #include "SegList.h"
#include "array_fun.h"
#ifdef ENABLE_MESSAGE_DIGEST #ifdef ENABLE_MESSAGE_DIGEST
# include "MessageDigest.h" # include "MessageDigest.h"
#endif // ENABLE_MESSAGE_DIGEST #endif // ENABLE_MESSAGE_DIGEST
@ -611,9 +612,15 @@ void HttpProxyOptionHandler::parseArg(Option& option, const std::string& optarg)
} else { } else {
Request req; Request req;
std::string uri; std::string uri;
if(util::startsWith(optarg, "http://") || const char A2_HTTP[] = "http://";
util::startsWith(optarg, "https://") || const char A2_HTTPS[] = "https://";
util::startsWith(optarg, "ftp://")) { const char A2_FTP[] = "ftp://";
if(util::startsWith(optarg.begin(), optarg.end(),
A2_HTTP, vend(A2_HTTP)-1) ||
util::startsWith(optarg.begin(), optarg.end(),
A2_HTTPS, vend(A2_HTTPS)-1) ||
util::startsWith(optarg.begin(), optarg.end(),
A2_FTP, vend(A2_FTP)-1)) {
uri = optarg; uri = optarg;
} else { } else {
uri = "http://"; uri = "http://";

View File

@ -181,7 +181,7 @@ void OptionParser::parse(Option& option, std::istream& is) const
{ {
std::string line; std::string line;
while(getline(is, line)) { while(getline(is, line)) {
if(util::startsWith(line, A2STR::SHARP_C)) { if(line.empty() || line[0] == '#') {
continue; continue;
} }
std::pair<Scip, Scip> nv; std::pair<Scip, Scip> nv;

View File

@ -106,11 +106,14 @@ void Request::setReferer(const std::string& uri)
bool Request::redirectUri(const std::string& uri) { bool Request::redirectUri(const std::string& uri) {
supportsPersistentConnection_ = true; supportsPersistentConnection_ = true;
++redirectCount_; ++redirectCount_;
if(uri.empty()) {
return false;
}
std::string redirectedUri; std::string redirectedUri;
if(uri.find("://") == std::string::npos) { if(uri.find("://") == std::string::npos) {
// rfc2616 requires absolute URI should be provided by Location header // rfc2616 requires absolute URI should be provided by Location header
// field, but some servers don't obey this rule. // field, but some servers don't obey this rule.
if(util::startsWith(uri, "/")) { if(uri[0] == '/') {
// abosulute path // abosulute path
redirectedUri = strconcat(protocol_, "://", host_, uri); redirectedUri = strconcat(protocol_, "://", host_, uri);
} else { } else {

View File

@ -65,7 +65,7 @@ void UriListParser::parseNext(std::vector<std::string>& uris, Option& op)
} }
const SharedHandle<OptionParser>& optparser = OptionParser::getInstance(); const SharedHandle<OptionParser>& optparser = OptionParser::getInstance();
while(1) { while(1) {
if(!util::startsWith(line_, A2STR::SHARP_C) && !util::strip(line_).empty()){ if(!line_.empty() && line_[0] != '#') {
util::split(line_.begin(), line_.end(), std::back_inserter(uris), util::split(line_.begin(), line_.end(), std::back_inserter(uris),
'\t', true); '\t', true);
// Read options // Read options
@ -76,12 +76,16 @@ void UriListParser::parseNext(std::vector<std::string>& uris, Option& op)
break; break;
} }
line_.assign(&buf[0], &buf[strlen(buf)]); line_.assign(&buf[0], &buf[strlen(buf)]);
if(util::startsWith(line_, " ") || util::startsWith(line_, "\t")) { if(line_.empty()) {
ss << line_ << "\n";
} else if(util::startsWith(line_, A2STR::SHARP_C)) {
continue; continue;
} else { } else {
break; if(line_[0] == ' ' || line_[0] == '\t') {
ss << line_ << "\n";
} else if(line_[0] == '#') {
continue;
} else {
break;
}
} }
} }
optparser->parse(op, ss); optparser->parse(op, ss);

View File

@ -59,6 +59,7 @@
#include "prefs.h" #include "prefs.h"
#include "FileEntry.h" #include "FileEntry.h"
#include "error_code.h" #include "error_code.h"
#include "array_fun.h"
namespace aria2 { namespace aria2 {
@ -874,10 +875,12 @@ SharedHandle<TorrentAttribute> parseMagnet(const std::string& magnet)
} }
SharedHandle<TorrentAttribute> attrs(new TorrentAttribute()); SharedHandle<TorrentAttribute> attrs(new TorrentAttribute());
std::string infoHash; std::string infoHash;
const char A2_URN_BTIH[] = "urn:btih:";
for(List::ValueType::const_iterator xtiter = xts->begin(), for(List::ValueType::const_iterator xtiter = xts->begin(),
eoi = xts->end(); xtiter != eoi && infoHash.empty(); ++xtiter) { eoi = xts->end(); xtiter != eoi && infoHash.empty(); ++xtiter) {
const String* xt = downcast<String>(*xtiter); const String* xt = downcast<String>(*xtiter);
if(util::startsWith(xt->s(), "urn:btih:")) { if(util::startsWith(xt->s().begin(), xt->s().end(),
A2_URN_BTIH, vend(A2_URN_BTIH)-1)) {
std::string xtarg = xt->s().substr(9); std::string xtarg = xt->s().substr(9);
size_t size = xtarg.size(); size_t size = xtarg.size();
if(size == 32) { if(size == 32) {

View File

@ -376,7 +376,8 @@ bool domainMatch(const std::string& requestHost, const std::string& domain)
bool pathMatch(const std::string& requestPath, const std::string& path) bool pathMatch(const std::string& requestPath, const std::string& path)
{ {
return requestPath == path || return requestPath == path ||
(util::startsWith(requestPath, path) && (util::startsWith(requestPath.begin(), requestPath.end(),
path.begin(), path.end()) &&
(path[path.size()-1] == '/' || requestPath[path.size()] == '/')); (path[path.size()-1] == '/' || requestPath[path.size()] == '/'));
} }

View File

@ -34,6 +34,7 @@
/* copyright --> */ /* copyright --> */
#include "magnet.h" #include "magnet.h"
#include "util.h" #include "util.h"
#include "array_fun.h"
namespace aria2 { namespace aria2 {
@ -42,7 +43,9 @@ namespace magnet {
SharedHandle<Dict> parse(const std::string& magnet) SharedHandle<Dict> parse(const std::string& magnet)
{ {
SharedHandle<Dict> dict; SharedHandle<Dict> dict;
if(!util::startsWith(magnet, "magnet:?")) { const char A2_MSGNET[] = "magnet:?";
if(!util::startsWith(magnet.begin(), magnet.end(),
A2_MSGNET, vend(A2_MSGNET)-1)) {
return dict; return dict;
} }
dict.reset(new Dict()); dict.reset(new Dict());

View File

@ -57,6 +57,7 @@
#include "bittorrent_helper.h" #include "bittorrent_helper.h"
#include "BufferedFile.h" #include "BufferedFile.h"
#include "console.h" #include "console.h"
#include "array_fun.h"
#ifndef HAVE_DAEMON #ifndef HAVE_DAEMON
#include "daemon.h" #include "daemon.h"
#endif // !HAVE_DAEMON #endif // !HAVE_DAEMON
@ -114,7 +115,9 @@ void option_processing(Option& op, std::vector<std::string>& uris,
keyword = TAG_BASIC; keyword = TAG_BASIC;
} else { } else {
keyword = op.get(PREF_HELP); keyword = op.get(PREF_HELP);
if(util::startsWith(keyword, "--")) { const char A2_HH[] = "--";
if(util::startsWith(keyword.begin(), keyword.end(),
A2_HH, vend(A2_HH)-1)) {
keyword = keyword.substr(2); keyword = keyword.substr(2);
} }
std::string::size_type eqpos = keyword.find("="); std::string::size_type eqpos = keyword.find("=");

View File

@ -306,7 +306,7 @@ std::string joinUri(const std::string& baseUri, const std::string& uri)
return uri; return uri;
} }
std::vector<std::string> parts; std::vector<std::string> parts;
if(!util::startsWith(uri, "/")) { if(uri.empty() || uri[0] != '/') {
util::split(bus.dir.begin(), bus.dir.end(), std::back_inserter(parts), util::split(bus.dir.begin(), bus.dir.end(), std::back_inserter(parts),
'/'); '/');
} }

View File

@ -230,20 +230,6 @@ int32_t difftvsec(struct timeval tv1, struct timeval tv2) {
return tv1.tv_sec-tv2.tv_sec; return tv1.tv_sec-tv2.tv_sec;
} }
bool startsWith(const std::string& target, const std::string& part) {
if(target.size() < part.size()) {
return false;
}
if(part.empty()) {
return true;
}
if(target.find(part) == 0) {
return true;
} else {
return false;
}
}
bool endsWith(const std::string& target, const std::string& part) { bool endsWith(const std::string& target, const std::string& part) {
if(target.size() < part.size()) { if(target.size() < part.size()) {
return false; return false;
@ -786,17 +772,20 @@ void parseParam(OutputIterator out, const std::string& header)
std::string getContentDispositionFilename(const std::string& header) std::string getContentDispositionFilename(const std::string& header)
{ {
const char A2_KEYNAME[] = "filename";
std::string filename; std::string filename;
std::vector<std::string> params; std::vector<std::string> params;
parseParam(std::back_inserter(params), header); parseParam(std::back_inserter(params), header);
for(std::vector<std::string>::const_iterator i = params.begin(), for(std::vector<std::string>::const_iterator i = params.begin(),
eoi = params.end(); i != eoi; ++i) { eoi = params.end(); i != eoi; ++i) {
const std::string& param = *i; const std::string& param = *i;
static const std::string keyName = "filename"; std::string lowparam = toLower(param);
if(!startsWith(toLower(param), keyName) || param.size() == keyName.size()) { if(!startsWith(lowparam.begin(), lowparam.end(),
A2_KEYNAME, vend(A2_KEYNAME)-1) ||
param.size() == sizeof(A2_KEYNAME)-1) {
continue; continue;
} }
std::string::const_iterator markeritr = param.begin()+keyName.size(); std::string::const_iterator markeritr = param.begin()+sizeof(A2_KEYNAME)-1;
if(*markeritr == '*') { if(*markeritr == '*') {
// See RFC2231 Section4 and draft-reschke-rfc2231-in-http. // See RFC2231 Section4 and draft-reschke-rfc2231-in-http.
// Please note that this function doesn't do charset conversion // Please note that this function doesn't do charset conversion
@ -1370,13 +1359,23 @@ void generateRandomKey(unsigned char* key)
// 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) // 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
bool inPrivateAddress(const std::string& ipv4addr) bool inPrivateAddress(const std::string& ipv4addr)
{ {
if(util::startsWith(ipv4addr, "10.") || const char A2_IP10[] = "10.";
util::startsWith(ipv4addr, "192.168.")) { const char A2_IP192[] = "192.168.";
if(util::startsWith(ipv4addr.begin(), ipv4addr.end(),
A2_IP10, vend(A2_IP10)-1) ||
util::startsWith(ipv4addr.begin(), ipv4addr.end(),
A2_IP192, vend(A2_IP192)-1)) {
return true; return true;
} }
if(util::startsWith(ipv4addr, "172.")) { std::string p172("172.");
if(util::startsWith(ipv4addr.begin(), ipv4addr.end(),
p172.begin(), p172.end())) {
for(int i = 16; i <= 31; ++i) { for(int i = 16; i <= 31; ++i) {
if(util::startsWith(ipv4addr, "172."+util::itos(i)+".")) { std::string t(p172);
t += util::itos(i);
t += '.';
if(util::startsWith(ipv4addr.begin(), ipv4addr.end(),
t.begin(), t.end())) {
return true; return true;
} }
} }
@ -1386,6 +1385,9 @@ bool inPrivateAddress(const std::string& ipv4addr)
bool detectDirTraversal(const std::string& s) bool detectDirTraversal(const std::string& s)
{ {
if(s.empty()) {
return false;
}
for(std::string::const_iterator i = s.begin(), eoi = s.end(); i != eoi; ++i) { for(std::string::const_iterator i = s.begin(), eoi = s.end(); i != eoi; ++i) {
unsigned char c = *i; unsigned char c = *i;
if(in(c, 0x00u, 0x1fu) || c == 0x7fu) { if(in(c, 0x00u, 0x1fu) || c == 0x7fu) {
@ -1393,24 +1395,24 @@ bool detectDirTraversal(const std::string& s)
} }
} }
static std::string A2_DS = "./"; const char A2_DS[] = "./";
static std::string A2_DDS = "../"; const char A2_DDS[] = "../";
static std::string A2_SD = "/."; const char A2_SD[] = "/.";
static std::string A2_SDD = "/.."; const char A2_SDD[] = "/..";
static std::string A2_SDDS = "/../"; const char A2_SDDS[] = "/../";
static std::string A2_SDS = "/./"; const char A2_SDS[] = "/./";
static std::string A2_DD = ".."; const char A2_DD[] = "..";
return s == A2STR::DOT_C || return s == A2STR::DOT_C ||
s == A2_DD || s == A2_DD ||
util::startsWith(s, A2STR::SLASH_C) || s[0] == '/' ||
util::startsWith(s, A2_DS) || util::startsWith(s.begin(), s.end(), A2_DS, vend(A2_DS)-1) ||
util::startsWith(s, A2_DDS) || util::startsWith(s.begin(), s.end(), A2_DDS, vend(A2_DDS)-1) ||
s.find(A2_SDDS) != std::string::npos || s.find(A2_SDDS) != std::string::npos ||
s.find(A2_SDS) != std::string::npos || s.find(A2_SDS) != std::string::npos ||
util::endsWith(s, A2STR::SLASH_C) || s[s.size()-1] == '/' ||
util::endsWith(s, A2_SD) || util::endsWith(s.begin(), s.end(), A2_SD, vend(A2_SD)-1) ||
util::endsWith(s, A2_SDD); util::endsWith(s.begin(), s.end(), A2_SDD, vend(A2_SDD)-1);
} }
std::string escapePath(const std::string& s) std::string escapePath(const std::string& s)
@ -1615,8 +1617,7 @@ bool noProxyDomainMatch
(const std::string& hostname, (const std::string& hostname,
const std::string& domain) const std::string& domain)
{ {
if(!util::isNumericHost(hostname) && if(!domain.empty() && domain[0] == '.' && !util::isNumericHost(hostname)) {
util::startsWith(domain, A2STR::DOT_C)) {
return util::endsWith(hostname, domain); return util::endsWith(hostname, domain);
} else { } else {
return hostname == domain; return hostname == domain;

View File

@ -86,7 +86,7 @@ void showUsage
std::cout << _("Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE |" std::cout << _("Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE |"
" METALINK_FILE]...") << "\n" " METALINK_FILE]...") << "\n"
<< "\n"; << "\n";
if(util::startsWith(keyword, "#")) { if(!keyword.empty() && keyword[0] == '#') {
std::vector<SharedHandle<OptionHandler> > handlers = std::vector<SharedHandle<OptionHandler> > handlers =
keyword == TAG_ALL ? oparser->findAll() : oparser->findByTag(keyword); keyword == TAG_ALL ? oparser->findAll() : oparser->findByTag(keyword);
if(keyword == TAG_ALL) { if(keyword == TAG_ALL) {

View File

@ -1,11 +1,13 @@
#include "Sqlite3CookieParserImpl.h" #include "Sqlite3CookieParserImpl.h"
#include <cstring>
#include <iostream> #include <iostream>
#include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/HelperMacros.h>
#include "RecoverableException.h" #include "RecoverableException.h"
#include "util.h" #include "util.h"
#include "array_fun.h"
namespace aria2 { namespace aria2 {
@ -85,8 +87,9 @@ void Sqlite3CookieParserTest::testMozParse_fileNotFound()
CPPUNIT_FAIL("exception must be thrown."); CPPUNIT_FAIL("exception must be thrown.");
} catch(RecoverableException& e) { } catch(RecoverableException& e) {
// SUCCESS // SUCCESS
CPPUNIT_ASSERT(util::startsWith(e.what(), const char A2_SQLITE_ERR[] = "SQLite3 database is not opened";
"SQLite3 database is not opened")); CPPUNIT_ASSERT(util::startsWith(e.what(), e.what()+strlen(e.what()),
A2_SQLITE_ERR, vend(A2_SQLITE_ERR)-1));
} }
} }

View File

@ -740,43 +740,36 @@ void UtilTest::testStartsWith() {
target = "abcdefg"; target = "abcdefg";
part = "abc"; part = "abc";
CPPUNIT_ASSERT(util::startsWith(target, part));
CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
target = "abcdefg"; target = "abcdefg";
part = "abx"; part = "abx";
CPPUNIT_ASSERT(!util::startsWith(target, part));
CPPUNIT_ASSERT(!util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(!util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
target = "abcdefg"; target = "abcdefg";
part = "bcd"; part = "bcd";
CPPUNIT_ASSERT(!util::startsWith(target, part));
CPPUNIT_ASSERT(!util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(!util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
target = ""; target = "";
part = "a"; part = "a";
CPPUNIT_ASSERT(!util::startsWith(target, part));
CPPUNIT_ASSERT(!util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(!util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
target = ""; target = "";
part = ""; part = "";
CPPUNIT_ASSERT(util::startsWith(target, part));
CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
target = "a"; target = "a";
part = ""; part = "";
CPPUNIT_ASSERT(util::startsWith(target, part));
CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
target = "a"; target = "a";
part = "a"; part = "a";
CPPUNIT_ASSERT(util::startsWith(target, part));
CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(), CPPUNIT_ASSERT(util::startsWith(target.begin(), target.end(),
part.begin(), part.end())); part.begin(), part.end()));
} }