sort.tests 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. # SUSv3 compliant sort tests.
  3. # Copyright 2005 by Rob Landley <rob@landley.net>
  4. # Licensed under GPL v2, see file LICENSE for details.
  5. . testing.sh
  6. # The basic tests. These should work even with the small busybox.
  7. testing "sort" "sort input" "a\nb\nc\n" "c\na\nb\n" ""
  8. testing "sort #2" "sort input" "010\n1\n3\n" "3\n1\n010\n" ""
  9. testing "sort stdin" "sort" "a\nb\nc\n" "" "b\na\nc\n"
  10. testing "sort numeric" "sort -n input" "1\n3\n010\n" "3\n1\n010\n" ""
  11. testing "sort reverse" "sort -r input" "wook\nwalrus\npoint\npabst\naargh\n" \
  12. "point\nwook\npabst\naargh\nwalrus\n" ""
  13. # These tests require the full option set.
  14. optional FEATURE_SORT_BIG
  15. # Longish chunk of data re-used by the next few tests
  16. data="42 1 3 woot
  17. 42 1 010 zoology
  18. egg 1 2 papyrus
  19. 7 3 42 soup
  20. 999 3 0 algebra
  21. "
  22. # Sorting with keys
  23. testing "sort one key" "sort -k4,4 input" \
  24. "999 3 0 algebra
  25. egg 1 2 papyrus
  26. 7 3 42 soup
  27. 42 1 3 woot
  28. 42 1 010 zoology
  29. " "$data" ""
  30. testing "sort key range with numeric option" "sort -k2,3n input" \
  31. "42 1 010 zoology
  32. 42 1 3 woot
  33. egg 1 2 papyrus
  34. 7 3 42 soup
  35. 999 3 0 algebra
  36. " "$data" ""
  37. # Busybox is definitely doing this one wrong just now. FIXME
  38. testing "sort key range with numeric option and global reverse" \
  39. "sort -k2,3n -r input" \
  40. "egg 1 2 papyrus
  41. 42 1 3 woot
  42. 42 1 010 zoology
  43. 999 3 0 algebra
  44. 7 3 42 soup
  45. " "$data" ""
  46. #
  47. testing "sort key range with multiple options" "sort -k2,3rn input" \
  48. "7 3 42 soup
  49. 999 3 0 algebra
  50. 42 1 010 zoology
  51. 42 1 3 woot
  52. egg 1 2 papyrus
  53. " "$data" ""
  54. exit $FAILCOUNT