rev.tests 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # Copyright 2021 by Ron Yorston
  3. # Licensed under GPLv2, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. # testing "test name" "commands" "expected result" "file input" "stdin"
  6. testing "rev works" \
  7. "rev input" \
  8. "\
  9. 1 enil
  10. 3 enil
  11. " \
  12. "line 1\n\nline 3\n" \
  13. ""
  14. testing "rev file with missing newline" \
  15. "rev input" \
  16. "\
  17. 1 enil
  18. 3 enil" \
  19. "line 1\n\nline 3" \
  20. ""
  21. testing "rev file with NUL character" \
  22. "rev input" \
  23. "\
  24. nil
  25. 3 enil
  26. " \
  27. "lin\000e 1\n\nline 3\n" \
  28. ""
  29. testing "rev file with long line" \
  30. "rev input" \
  31. "\
  32. +--------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------
  33. cba
  34. " \
  35. "---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+---------------+--------------+\nabc\n" \
  36. ""
  37. exit $FAILCOUNT