read.es.tst 590 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. read.tst - Various Http read tests
  3. */
  4. const HTTP = tget('TM_HTTP') || "127.0.0.1:8080"
  5. let http: Http = new Http
  6. // Test http.read() into a byte array
  7. http.get(HTTP + "/big.jst")
  8. buf = new ByteArray
  9. count = 0
  10. while (http.read(buf) > 0) {
  11. count += buf.length
  12. }
  13. if (count != 61491) {
  14. print("COUNT IS " + count + " code " + http.status)
  15. }
  16. ttrue(count == 61491)
  17. http.close()
  18. http.get(HTTP + "/lines.txt")
  19. lines = http.readLines()
  20. for (l in lines) {
  21. line = lines[l]
  22. ttrue(line.contains("LINE"))
  23. ttrue(line.contains((l+1).toString()))
  24. }
  25. ttrue(http.status == 200)