logo

utils-std

Collection of commonly available Unix tools

seq (3146B)


  1. #!/usr/bin/env atf-sh
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. atf_test_case one
  5. one_body() {
  6. atf_check -o "inline:1\n" ../cmd/seq 1
  7. atf_check -o "inline:1\n2\n3\n4\n5\n" ../cmd/seq 5
  8. atf_check -o "inline:1\n0\n-1\n" -- ../cmd/seq -- -1
  9. atf_check -o "inline:1\n0\n-1\n-2\n-3\n-4\n-5\n" -- ../cmd/seq -- -5
  10. }
  11. atf_test_case two
  12. two_body() {
  13. atf_check -o "inline:0\n1\n" ../cmd/seq 0 1
  14. atf_check -o "inline:0\n1\n2\n3\n4\n5\n" ../cmd/seq 0 5
  15. atf_check -o "inline:10\n11\n12\n13\n14\n15\n" ../cmd/seq 10 15
  16. atf_check -o "inline:0\n-1\n" -- ../cmd/seq 0 -1
  17. atf_check -o "inline:0\n-1\n-2\n-3\n-4\n-5\n" -- ../cmd/seq 0 -5
  18. atf_check -o "inline:-10\n-11\n-12\n-13\n-14\n-15\n" -- ../cmd/seq -- -10 -15
  19. atf_check -o "inline:2\n1\n0\n-1\n-2\n" -- ../cmd/seq 2 -2
  20. atf_check -o "inline:-2\n-1\n0\n1\n2\n" -- ../cmd/seq -- -2 2
  21. }
  22. atf_test_case three
  23. three_body() {
  24. atf_check -o "inline:0\n1\n" ../cmd/seq 0 1 1
  25. atf_check -o "inline:0\n1\n2\n3\n4\n5\n" ../cmd/seq 0 1 5
  26. atf_check -o "inline:10\n11\n12\n13\n14\n15\n" ../cmd/seq 10 1 15
  27. atf_check -o "inline:0\n2\n4\n" ../cmd/seq 0 2 5
  28. atf_check -o "inline:10\n12\n14\n" ../cmd/seq 10 2 15
  29. atf_check -o "inline:0\n-1\n" -- ../cmd/seq 0 1 -1
  30. atf_check -o "inline:0\n-1\n-2\n-3\n-4\n-5\n" -- ../cmd/seq 0 1 -5
  31. atf_check -o "inline:-10\n-11\n-12\n-13\n-14\n-15\n" -- ../cmd/seq -- -10 1 -15
  32. atf_check -o "inline:0\n-1\n" -- ../cmd/seq 0 -1 -1
  33. atf_check -o "inline:0\n-2\n-4\n" -- ../cmd/seq 0 2 -5
  34. atf_check -o "inline:-10\n-12\n-14\n" -- ../cmd/seq -- -10 2 -15
  35. }
  36. atf_test_case sep
  37. sep_body() {
  38. atf_check -o "inline:1-2-3\n" ../cmd/seq -s - 3
  39. }
  40. atf_test_case term
  41. term_body() {
  42. atf_check -o "inline:1-2-3:" ../cmd/seq -s - -t: 3
  43. }
  44. atf_test_case noarg
  45. noarg_body() {
  46. atf_check -s exit:1 -e 'inline:usage: seq [-w] [-s separator] [first [step]] last\n' ../cmd/seq
  47. }
  48. atf_test_case badflag
  49. badflag_body() {
  50. atf_check -s exit:1 -e 'inline:usage: seq [-w] [-s separator] [first [step]] last\n' ../cmd/seq -f
  51. }
  52. atf_test_case limits
  53. limits_body() {
  54. atf_check ../cmd/seq 9223372036854775806 9223372036854775807
  55. atf_check -s exit:1 ../cmd/seq 9223372036854775806 9223372036854775808
  56. atf_check ../cmd/seq -- -9223372036854775807 -9223372036854775808
  57. atf_check -s exit:1 ../cmd/seq -- -9223372036854775807 -9223372036854775809
  58. }
  59. atf_test_case initial_d
  60. initial_d_body() {
  61. atf_check -e "inline:seq: Warning: Pass -- if the first non-option argument starts with a dash(-)\n" -o "inline:-3\n-2\n-1\n0\n" ../cmd/seq -3 0
  62. }
  63. atf_test_case width
  64. width_body() {
  65. atf_check -o "inline:-1\n04\n09\n14\n" ../cmd/seq -w -- -1 5 15
  66. atf_check -o "inline:-3\n-2\n-1\n00\n" ../cmd/seq -w -- -3 1 0
  67. atf_check -o "inline:-10\n-11\n-12\n-13\n-14\n-15\n" ../cmd/seq -w -- -10 1 -15
  68. }
  69. atf_init_test_cases() {
  70. cd "$(atf_get_srcdir)" || exit 1
  71. atf_add_test_case one
  72. atf_add_test_case two
  73. atf_add_test_case three
  74. atf_add_test_case sep
  75. atf_add_test_case term
  76. atf_add_test_case noarg
  77. atf_add_test_case badflag
  78. #atf_add_test_case limits
  79. atf_add_test_case initial_d
  80. atf_add_test_case width
  81. }