nl.tests 587 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 "nl numbers all lines" \
  7. "nl -b a input" \
  8. "\
  9. 1 line 1
  10. 2
  11. 3 line 3
  12. " \
  13. "line 1\n\nline 3\n" \
  14. ""
  15. testing "nl numbers non-empty lines" \
  16. "nl -b t input" \
  17. "\
  18. 1 line 1
  19. 2 line 3
  20. " \
  21. "line 1\n\nline 3\n" \
  22. ""
  23. testing "nl numbers no lines" \
  24. "nl -b n input" \
  25. "\
  26. line 1
  27. line 3
  28. " \
  29. "line 1\n\nline 3\n" \
  30. ""
  31. exit $FAILCOUNT