test.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. function readfile(n)
  2. local f = io.open(n, "rb")
  3. local s = f:read("*a")
  4. f:close()
  5. return s
  6. end
  7. lf = readfile("t1lf.txt")
  8. os.remove("t1crlf.txt")
  9. os.execute("lua t1.lua < t1lf.txt > t1crlf.txt")
  10. crlf = readfile("t1crlf.txt")
  11. assert(crlf == string.gsub(lf, "\010", "\013\010"), "broken")
  12. gt = readfile("t2gt.qp")
  13. os.remove("t2.qp")
  14. os.execute("lua t2.lua < t2.txt > t2.qp")
  15. t2 = readfile("t2.qp")
  16. assert(gt == t2, "broken")
  17. os.remove("t1crlf.txt")
  18. os.execute("lua t3.lua < t1lf.txt > t1crlf.txt")
  19. crlf = readfile("t1crlf.txt")
  20. assert(crlf == string.gsub(lf, "\010", "\013\010"), "broken")
  21. t = readfile("test.lua")
  22. os.execute("lua t4.lua < test.lua > t")
  23. t2 = readfile("t")
  24. assert(t == t2, "broken")
  25. os.remove("output.b64")
  26. gt = readfile("gt.b64")
  27. os.execute("lua t5.lua")
  28. t5 = readfile("output.b64")
  29. assert(gt == t5, "failed")
  30. print("1 2 5 6 10 passed")
  31. print("2 3 4 5 6 10 passed")
  32. print("2 5 6 7 8 10 passed")
  33. print("5 9 passed")
  34. print("5 6 10 11 passed")
  35. os.remove("t")
  36. os.remove("t2.qp")
  37. os.remove("t1crlf.txt")
  38. os.remove("t11.b64")
  39. os.remove("output.b64")