]>
Commit | Line | Data |
---|---|---|
1 | #include <apt-pkg/strutl.h> | |
2 | ||
3 | #include "assert.h" | |
4 | ||
5 | int main(int argc,char *argv[]) | |
6 | { | |
7 | std::string input, output, expected; | |
8 | ||
9 | // no input | |
10 | input = "foobar"; | |
11 | expected = "foobar"; | |
12 | output = DeEscapeString(input); | |
13 | equals(output, expected); | |
14 | ||
15 | // hex and octal | |
16 | input = "foo\\040bar\\x0abaz"; | |
17 | expected = "foo bar\nbaz"; | |
18 | output = DeEscapeString(input); | |
19 | equals(output, expected); | |
20 | ||
21 | // at the end | |
22 | input = "foo\\040"; | |
23 | expected = "foo "; | |
24 | output = DeEscapeString(input); | |
25 | equals(output, expected); | |
26 | ||
27 | // double escape | |
28 | input = "foo\\\\ x"; | |
29 | expected = "foo\\ x"; | |
30 | output = DeEscapeString(input); | |
31 | equals(output, expected); | |
32 | ||
33 | // double escape at the end | |
34 | input = "\\\\foo\\\\"; | |
35 | expected = "\\foo\\"; | |
36 | output = DeEscapeString(input); | |
37 | equals(output, expected); | |
38 | ||
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); | |
44 | ||
45 | return 0; | |
46 | } |