]>
git.saurik.com Git - apt.git/blob - test/libapt/strutil_test.cc
3 #include <apt-pkg/strutl.h>
12 std::string input
, output
, expected
;
17 output
= DeEscapeString(input
);
18 equals(output
, expected
);
21 input
= "foo\\040bar\\x0abaz";
22 expected
= "foo bar\nbaz";
23 output
= DeEscapeString(input
);
24 equals(output
, expected
);
29 output
= DeEscapeString(input
);
30 equals(output
, expected
);
35 output
= DeEscapeString(input
);
36 equals(output
, expected
);
38 // double escape at the end
39 input
= "\\\\foo\\\\";
41 output
= DeEscapeString(input
);
42 equals(output
, expected
);
44 // the string that we actually need it for
45 input
= "/media/Ubuntu\\04011.04\\040amd64";
46 expected
= "/media/Ubuntu 11.04 amd64";
47 output
= DeEscapeString(input
);
48 equals(output
, expected
);
51 input
= "status: libnet1:amd64: unpacked";
52 std::vector
<std::string
> result
= StringSplit(input
, ": ");
53 equals(result
[0], "status");
54 equals(result
[1], "libnet1:amd64");
55 equals(result
[2], "unpacked");
56 equals(result
.size(), 3);
58 input
= "status: libnet1:amd64: unpacked";
59 result
= StringSplit(input
, "xxx");
60 equals(result
[0], input
);
61 equals(result
.size(), 1);
63 input
= "status: libnet1:amd64: unpacked";
64 result
= StringSplit(input
, "");
65 equals(result
.size(), 0);
68 result
= StringSplit(input
, ":", 2);
69 equals(result
.size(), 2);
70 equals(result
[0], "x");
71 equals(result
[1], "y:z");
74 result
= StringSplit(input
, "");
75 equals(result
.size(), 0);
80 b
= APT::String::Endswith(input
, "d");
83 b
= APT::String::Endswith(input
, "cd");
86 b
= APT::String::Endswith(input
, "abcd");
89 b
= APT::String::Endswith(input
, "x");
92 b
= APT::String::Endswith(input
, "abcndefg");