From 00f4d9ffa3468e899abf8fbda8db71fc3143b8e5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 7 Sep 2013 12:19:51 +0200 Subject: implement StringSplit() as we need this to fix the dpkg status-fd output parsing --- test/libapt/strutil_test.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/libapt') diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index bfe0d7222..bac9dd2f1 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -42,5 +42,22 @@ 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); + return 0; } -- cgit v1.2.3