uuencode.tests 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/sh
  2. # unit test for uuencode to test functionality.
  3. # Copyright 2006 by Erik Hovland <erik@hovland.org>
  4. # Licensed under GPLv2, see file LICENSE in this source tree.
  5. # AUDIT: Unit tests for uuencode
  6. . ./testing.sh
  7. # testing "test name" "command(s)" "expected result" "file input" "stdin"
  8. # file input will be file called "input"
  9. # test can create a file "actual" instead of writing to stdout
  10. # Test setup of standard input
  11. umask 0
  12. testing "uuencode sets standard input mode correctly" \
  13. "uuencode foo </dev/null | head -n 1 | grep -q 666 && echo yes" "yes\n" "" ""
  14. umask 022
  15. testing "uuencode correct encoding" "uuencode bb_uuenc_test.out" \
  16. "begin 644 bb_uuenc_test.out\nM5&AE(&9A<W0@9W)E>2!F;W@@:G5M<&5D(&]V97(@=&AE(&QA>GD@8G)O=VX@\n%9&]G+@H\`\n\`\nend\n" \
  17. "" "The fast grey fox jumped over the lazy brown dog.\n"
  18. testing "uuencode correct base64 encoding" "uuencode -m bb_uuenc_test.out" \
  19. "begin-base64 644 bb_uuenc_test.out\nVGhlIGZhc3QgZ3JleSBmb3gganVtcGVkIG92ZXIgdGhlIGxhenkgYnJvd24g\nZG9nLgo=\n====\n" \
  20. "" "The fast grey fox jumped over the lazy brown dog.\n"
  21. testing "uuencode empty file" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  22. 'begin 644 FILE
  23. `
  24. end
  25. ' "" ""
  26. testing "uuencode -m empty file" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  27. 'begin-base64 644 FILE
  28. ====
  29. ' "" ""
  30. testing "uuencode file 'A'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  31. 'begin 644 FILE
  32. !00``
  33. `
  34. end
  35. A' "" "A"
  36. testing "uuencode -m file 'A'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  37. 'begin-base64 644 FILE
  38. QQ==
  39. ====
  40. A' "" "A"
  41. testing "uuencode file 'AB'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  42. 'begin 644 FILE
  43. "04(`
  44. `
  45. end
  46. AB' "" "AB"
  47. testing "uuencode -m file 'AB'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  48. 'begin-base64 644 FILE
  49. QUI=
  50. ====
  51. AB' "" "AB"
  52. testing "uuencode file 'ABC'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  53. 'begin 644 FILE
  54. #04)#
  55. `
  56. end
  57. ABC' "" "ABC"
  58. testing "uuencode -m file 'ABC'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  59. 'begin-base64 644 FILE
  60. QUJD
  61. ====
  62. ABC' "" "ABC"
  63. testing "uuencode file 'ABCD'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  64. 'begin 644 FILE
  65. $04)#1```
  66. `
  67. end
  68. ABCD' "" "ABCD"
  69. testing "uuencode -m file 'ABCD'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  70. 'begin-base64 644 FILE
  71. QUJDRA==
  72. ====
  73. ABCD' "" "ABCD"
  74. testing "uuencode file 'ABCDE'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  75. 'begin 644 FILE
  76. %04)#1$4`
  77. `
  78. end
  79. ABCDE' "" "ABCDE"
  80. testing "uuencode -m file 'ABCDE'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  81. 'begin-base64 644 FILE
  82. QUJDREU=
  83. ====
  84. ABCDE' "" "ABCDE"
  85. testing "uuencode file 'ABCDEF'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  86. 'begin 644 FILE
  87. &04)#1$5&
  88. `
  89. end
  90. ABCDEF' "" "ABCDEF"
  91. testing "uuencode -m file 'ABCDEF'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  92. 'begin-base64 644 FILE
  93. QUJDREVG
  94. ====
  95. ABCDEF' "" "ABCDEF"
  96. testing "uuencode file 'A<NUL><0xff>Z'" 'r=`uuencode FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  97. 'begin 644 FILE
  98. $00#_6@``
  99. `
  100. end
  101. A\x0\xffZ' "" "A\x0\xffZ"
  102. testing "uuencode -m file 'A<NUL><0xff>Z'" 'r=`uuencode -m FILE`; echo "$r"; echo "$r" | uudecode -o -;' \
  103. 'begin-base64 644 FILE
  104. QQD/Wg==
  105. ====
  106. A\x0\xffZ' "" "A\x0\xffZ"
  107. exit $FAILCOUNT