logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

seq (2457B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
  4. atf_test_case one
  5. one_body() {
  6. atf_check -o "inline:1\n" ../bin/seq 1
  7. atf_check -o "inline:1\n2\n3\n4\n5\n" ../bin/seq 5
  8. atf_check -o "inline:1\n0\n-1\n" -- ../bin/seq -- -1
  9. atf_check -o "inline:1\n0\n-1\n-2\n-3\n-4\n-5\n" -- ../bin/seq -- -5
  10. }
  11. atf_test_case two
  12. two_body() {
  13. atf_check -o "inline:0\n1\n" ../bin/seq 0 1
  14. atf_check -o "inline:0\n1\n2\n3\n4\n5\n" ../bin/seq 0 5
  15. atf_check -o "inline:10\n11\n12\n13\n14\n15\n" ../bin/seq 10 15
  16. atf_check -o "inline:0\n-1\n" -- ../bin/seq 0 -1
  17. atf_check -o "inline:0\n-1\n-2\n-3\n-4\n-5\n" -- ../bin/seq 0 -5
  18. atf_check -o "inline:-10\n-11\n-12\n-13\n-14\n-15\n" -- ../bin/seq -- -10 -15
  19. atf_check -o "inline:2\n1\n0\n-1\n-2\n" -- ../bin/seq 2 -2
  20. atf_check -o "inline:-2\n-1\n0\n1\n2\n" -- ../bin/seq -- -2 2
  21. }
  22. atf_test_case three
  23. three_body() {
  24. atf_check -o "inline:0\n1\n" ../bin/seq 0 1 1
  25. atf_check -o "inline:0\n1\n2\n3\n4\n5\n" ../bin/seq 0 1 5
  26. atf_check -o "inline:10\n11\n12\n13\n14\n15\n" ../bin/seq 10 1 15
  27. atf_check -o "inline:0\n2\n4\n" ../bin/seq 0 2 5
  28. atf_check -o "inline:10\n12\n14\n" ../bin/seq 10 2 15
  29. atf_check -o "inline:0\n-1\n" -- ../bin/seq 0 1 -1
  30. atf_check -o "inline:0\n-1\n-2\n-3\n-4\n-5\n" -- ../bin/seq 0 1 -5
  31. atf_check -o "inline:-10\n-11\n-12\n-13\n-14\n-15\n" -- ../bin/seq -- -10 1 -15
  32. atf_check -o "inline:0\n-1\n" -- ../bin/seq 0 -1 -1
  33. atf_check -o "inline:0\n-2\n-4\n" -- ../bin/seq 0 2 -5
  34. atf_check -o "inline:-10\n-12\n-14\n" -- ../bin/seq -- -10 2 -15
  35. }
  36. atf_test_case noarg
  37. noarg_body() {
  38. atf_check -s exit:1 -e 'inline:usage: seq [-w] [-s separator] [first [step]] last\n' ../bin/seq
  39. }
  40. atf_test_case badflag
  41. badflag_body() {
  42. atf_check -s exit:1 -e 'inline:usage: seq [-w] [-s separator] [first [step]] last\n' ../bin/seq -f
  43. }
  44. atf_test_case limits
  45. limits_body() {
  46. atf_check ../bin/seq 9223372036854775806 9223372036854775807
  47. atf_check -s exit:1 ../bin/seq 9223372036854775806 9223372036854775808
  48. atf_check ../bin/seq -- -9223372036854775807 -9223372036854775808
  49. atf_check -s exit:1 ../bin/seq -- -9223372036854775807 -9223372036854775809
  50. }
  51. atf_init_test_cases() {
  52. cd "$(atf_get_srcdir)" || exit 1
  53. atf_add_test_case one
  54. atf_add_test_case two
  55. atf_add_test_case three
  56. atf_add_test_case noarg
  57. atf_add_test_case badflag
  58. #atf_add_test_case limits
  59. }