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