buffer.t 692 B

123456789101112131415161718192021222324252627282930313233343536
  1. use Test::Nginx::Socket;
  2. our $HttpConfig = <<'_EOC_';
  3. lua_package_path "lib/?.lua;/usr/local/share/lua/5.1/?.lua;;";
  4. _EOC_
  5. repeat_each(3);
  6. plan tests => repeat_each() * (blocks() * 3);
  7. run_tests();
  8. __DATA__
  9. === TEST 1: buffer add
  10. --- http_config eval: $::HttpConfig
  11. --- config
  12. location /t {
  13. content_by_lua_block {
  14. local buffer = require "resty.t1k.buffer"
  15. local b = buffer:new()
  16. b:add("hello")
  17. b:add(" ")
  18. b:add("world")
  19. b:add("!")
  20. ngx.say(b[1], b[2], b[3], b[4])
  21. ngx.say(b:len())
  22. }
  23. }
  24. --- request
  25. GET /t
  26. --- response_body
  27. hello world!
  28. 12
  29. --- no_error_log
  30. [error]