diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-07-26 10:49:28 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-07-26 10:49:28 +0200 |
commit | a513ace2d2e3b71d607257990893199c6105b072 (patch) | |
tree | 71610b3a2034dd7cd2d06156baea8df2d8bc989c /test/libapt/strutil_test.cc | |
parent | f748b4760d0f8247001c0b46e9eaf02b379bc3c4 (diff) |
* apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc:
- add new DeEscapeString() similar to DeQuoteQuotedWord but
unescape charackter escapes like \0XXX and \xXX (plus add test)
Diffstat (limited to 'test/libapt/strutil_test.cc')
-rw-r--r-- | test/libapt/strutil_test.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc new file mode 100644 index 000000000..8d81a0c6c --- /dev/null +++ b/test/libapt/strutil_test.cc @@ -0,0 +1,40 @@ +#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); + + return 0; +} |