diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-07-26 12:25:17 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-07-26 12:25:17 +0200 |
commit | 1a51e3db1af215ffd65ab2347baead7b1179ad80 (patch) | |
tree | a90d0a88304f7654ea494ba0fe6aa4307ef5d691 /test/libapt/strutil_test.cc | |
parent | 822b344dacd3154df859ce6dbb1cb713ed96fc44 (diff) | |
parent | 27b16a2ed9a5cfdde955a0a49cd2fd73edce09c8 (diff) |
merged from debian-sid
Diffstat (limited to 'test/libapt/strutil_test.cc')
-rw-r--r-- | test/libapt/strutil_test.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc new file mode 100644 index 000000000..af6eb2cc6 --- /dev/null +++ b/test/libapt/strutil_test.cc @@ -0,0 +1,46 @@ +#include <apt-pkg/strutl.h> + +#include "assert.h" + +int main(int argc,char *argv[]) +{ + string input, output, expected; + + // no input + input = "foobar"; + expected = "foobar"; + output = DeEscapeString(input); + equals(output, expected); + + // hex and octal + input = "foo\\040bar\\x0abaz"; + expected = "foo bar\nbaz"; + output = DeEscapeString(input); + equals(output, expected); + + // at the end + input = "foo\\040"; + expected = "foo "; + output = DeEscapeString(input); + equals(output, expected); + + // double escape + input = "foo\\\\ x"; + expected = "foo\\ x"; + output = DeEscapeString(input); + equals(output, expected); + + // double escape at the end + input = "\\\\foo\\\\"; + expected = "\\foo\\"; + output = DeEscapeString(input); + equals(output, expected); + + // the string that we actually need it for + input = "/media/Ubuntu\\04011.04\\040amd64"; + expected = "/media/Ubuntu 11.04 amd64"; + output = DeEscapeString(input); + equals(output, expected); + + return 0; +} |