]>
git.saurik.com Git - apt.git/blob - test/libapt/strutil_test.cc
1 #include <apt-pkg/strutl.h>
5 int main(int argc
,char *argv
[])
7 std::string input
, output
, expected
;
12 output
= DeEscapeString(input
);
13 equals(output
, expected
);
16 input
= "foo\\040bar\\x0abaz";
17 expected
= "foo bar\nbaz";
18 output
= DeEscapeString(input
);
19 equals(output
, expected
);
24 output
= DeEscapeString(input
);
25 equals(output
, expected
);
30 output
= DeEscapeString(input
);
31 equals(output
, expected
);
33 // double escape at the end
34 input
= "\\\\foo\\\\";
36 output
= DeEscapeString(input
);
37 equals(output
, expected
);
39 // the string that we actually need it for
40 input
= "/media/Ubuntu\\04011.04\\040amd64";
41 expected
= "/media/Ubuntu 11.04 amd64";
42 output
= DeEscapeString(input
);
43 equals(output
, expected
);
46 input
= "status: libnet1:amd64: unpacked";
47 vector
<std::string
> result
= StringSplit(input
, ": ");
48 equals(result
[0], "status");
49 equals(result
[1], "libnet1:amd64");
50 equals(result
[2], "unpacked");
51 equals(result
.size(), 3);
53 input
= "status: libnet1:amd64: unpacked";
54 result
= StringSplit(input
, "xxx");
55 equals(result
[0], input
);
56 equals(result
.size(), 1);
58 input
= "status: libnet1:amd64: unpacked";
59 result
= StringSplit(input
, "");
60 equals(result
.size(), 0);
63 result
= StringSplit(input
, ":", 2);
64 equals(result
.size(), 2);
65 equals(result
[0], "x");
66 equals(result
[1], "y:z");
69 result
= StringSplit(input
, "");
70 equals(result
.size(), 0);
75 b
= APT::String::Endswith(input
, "d");
78 b
= APT::String::Endswith(input
, "cd");
81 b
= APT::String::Endswith(input
, "abcd");
84 b
= APT::String::Endswith(input
, "x");
87 b
= APT::String::Endswith(input
, "abcndefg");