X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b9dc47069ab90a79ca3b9eae3cc85d38062d57ee..62f6ecbf2f204d95e98fc5480c5a0db43b52d2be:/test/libapt/strutil_test.cc diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index af6eb2cc6..8215654d0 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -4,7 +4,7 @@ int main(int argc,char *argv[]) { - string input, output, expected; + std::string input, output, expected; // no input input = "foobar"; @@ -42,5 +42,50 @@ int main(int argc,char *argv[]) output = DeEscapeString(input); equals(output, expected); + // Split + input = "status: libnet1:amd64: unpacked"; + vector result = StringSplit(input, ": "); + equals(result[0], "status"); + equals(result[1], "libnet1:amd64"); + equals(result[2], "unpacked"); + equals(result.size(), 3); + + input = "status: libnet1:amd64: unpacked"; + result = StringSplit(input, "xxx"); + equals(result[0], input); + equals(result.size(), 1); + + input = "status: libnet1:amd64: unpacked"; + result = StringSplit(input, ""); + equals(result.size(), 0); + + input = "x:y:z"; + result = StringSplit(input, ":", 2); + equals(result.size(), 2); + equals(result[0], "x"); + equals(result[1], "y:z"); + + input = "abc"; + result = StringSplit(input, ""); + equals(result.size(), 0); + + // endswith + bool b; + input = "abcd"; + b = APT::String::Endswith(input, "d"); + equals(b, true); + + b = APT::String::Endswith(input, "cd"); + equals(b, true); + + b = APT::String::Endswith(input, "abcd"); + equals(b, true); + + b = APT::String::Endswith(input, "x"); + equals(b, false); + + b = APT::String::Endswith(input, "abcndefg"); + equals(b, false); + return 0; }