strings.test 1.1 KB

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. [ -f testing.sh ] && . testing.sh
  3. #testing "name" "command" "result" "infile" "stdin"
  4. testing "stdin" "strings" "foobar\n" "" "foobar\n"
  5. testing "file" "strings input" "foobar\n" "foobar\n" ""
  6. testing "string to the end" "strings input" "foobar\n" "foobar" ""
  7. testing "short strings" "strings input" "" "foo\nbar\n" ""
  8. testing "-n6" "strings -n6 input" "foobar\n" "foobar\nbaz\n" ""
  9. testing "string and nulls" "strings input" "foobar\nbazfoo\n" \
  10. "\0foobar\0\0bazfoo\0foo" ""
  11. testing "-f" "strings -f input" "input: foobar\n" "foobar\n" ""
  12. testing "-o" "strings -o input | sed 's/^ *//'" "6 foobar\n" \
  13. "\0\0\0\0\0\0foobar\n" ""
  14. testing "-o, multiple strings" "strings -n3 -o input | sed 's/^ *//'" \
  15. "1 foo\n7 bar\n" "\0foo\0b\0bar\n" ""
  16. testing "-fo" "strings -fo input | sed 's/: */: /'" "input: 6 foobar\n" \
  17. "\0\0\0\0\0\0foobar\n" ""
  18. OFFSET_10="\0\0\0\0\0\0\0\0\0\0foobar\n"
  19. testing "-t o" "strings -t o | sed 's/^ *//'" "12 foobar\n" "" $OFFSET_10
  20. testing "-t d" "strings -t d | sed 's/^ *//'" "10 foobar\n" "" $OFFSET_10
  21. testing "-t x" "strings -t x | sed 's/^ *//'" "a foobar\n" "" $OFFSET_10