3
0

unexpand.tests 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. # Copyright 2008 by Denys Vlasenko
  3. # Licensed under GPLv2, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. test -f "$bindir/.config" && . "$bindir/.config"
  6. # testing "test name" "options" "expected result" "file input" "stdin"
  7. testing "unexpand case 1" "unexpand" \
  8. "\t12345678\n" "" " 12345678\n" \
  9. testing "unexpand case 2" "unexpand" \
  10. "\t 12345678\n" "" " 12345678\n" \
  11. testing "unexpand case 3" "unexpand" \
  12. "\t 12345678\n" "" " 12345678\n" \
  13. testing "unexpand case 4" "unexpand" \
  14. "\t12345678\n" "" " \t12345678\n" \
  15. testing "unexpand case 5" "unexpand" \
  16. "\t12345678\n" "" " \t12345678\n" \
  17. testing "unexpand case 6" "unexpand" \
  18. "\t12345678\n" "" " \t12345678\n" \
  19. testing "unexpand case 7" "unexpand" \
  20. "123\t 45678\n" "" "123 \t 45678\n" \
  21. testing "unexpand case 8" "unexpand" \
  22. "a b\n" "" "a b\n" \
  23. testcase()
  24. {
  25. testing "unexpand flags $*" "unexpand $*" \
  26. "$want" "" ' a b c'
  27. }
  28. # tabs=8, Convert only leading sequences of blanks
  29. want='\ta b c'
  30. testcase
  31. testcase -f
  32. testcase -f -t8
  33. testcase -t8 -f
  34. testcase -t8 --first-only
  35. # tabs=8, Convert all blanks
  36. want='\ta\tb c'
  37. testcase -a
  38. testcase -t8
  39. testcase -a -t8
  40. # tabs=4, Convert all blanks
  41. want='\t\ta\t\tb\t c'
  42. testcase -t4
  43. testcase -a -t4
  44. testcase -t4 -a
  45. # tabs=4, Convert only leading sequences of blanks
  46. want='\t\ta b c'
  47. testcase -t4 -f
  48. testcase -f -t4
  49. testcase -t4 --first-only
  50. testcase --first-only -t4
  51. test x"$CONFIG_UNICODE_SUPPORT" = x"y" \
  52. && test x"$CONFIG_UNICODE_USING_LOCALE" != x"y" \
  53. && testing "unexpand with unicode characher 0x394" "unexpand" \
  54. "1ΔΔΔ5\t99999\n" "" "1ΔΔΔ5 99999\n"
  55. exit $FAILCOUNT