strutil_test.cc 1.0 KB

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