aboutsummaryrefslogtreecommitdiff
path: root/test/testclnt.lua
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2026-08-31 08:26:32 +0200
committerThijs Schreijer <thijs@thijsschreijer.nl>2026-08-31 08:26:32 +0200
commit4863f32b358a8d533f629084a86fb4932ebbd2f3 (patch)
tree273e8f333d27447ccc42b493e57698e9fc984e1a /test/testclnt.lua
parent827ae20771d34912a8f79b50dc68e6430945b9eb (diff)
downloadluasocket-4863f32b358a8d533f629084a86fb4932ebbd2f3.tar.gz
luasocket-4863f32b358a8d533f629084a86fb4932ebbd2f3.tar.bz2
luasocket-4863f32b358a8d533f629084a86fb4932ebbd2f3.zip
chore(test): add 2 tests reusing partial results
Tests to show the socket isn't left in an undetermined state due to dataloss, since the partial results are returned to the user.
Diffstat (limited to 'test/testclnt.lua')
-rw-r--r--test/testclnt.lua23
1 files changed, 20 insertions, 3 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index ee64d3a..bbe48bb 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -684,6 +684,14 @@ function test_maxsize()
684 assert(d == string.rep("a", 100) and e == nil, "B5 failed: CRLF at boundary") 684 assert(d == string.rep("a", 100) and e == nil, "B5 failed: CRLF at boundary")
685 pass("ok") 685 pass("ok")
686 686
687 remote(string.format([[data:send(string.rep('a',%d) .. '\n')]], 101))
688 d, e, p = data:receive("*l", nil, 100)
689 assert(d == nil and e == "oversized" and p == string.rep("a", 100),
690 "B6 failed: one-over-budget should be oversized")
691 d, e = data:receive("*l", p, 150) -- increase limit, try again with prefix
692 assert(d == string.rep("a", 101) and e == nil,
693 "B6 failed: leftover byte and terminator should still be there")
694
687 -- Group C: *l and I1 (timeout/close at the cap) 695 -- Group C: *l and I1 (timeout/close at the cap)
688 reconnect() 696 reconnect()
689 printf("I1 (timeout/closed at the cap): ") 697 printf("I1 (timeout/closed at the cap): ")
@@ -748,11 +756,20 @@ function test_maxsize()
748 reconnect() 756 reconnect()
749 remote(string.format([[data:send(string.rep('a',%d)) data:close() data = nil]], 250)) 757 remote(string.format([[data:send(string.rep('a',%d)) data:close() data = nil]], 250))
750 d, e, p = data:receive("*a", "", 100) 758 d, e, p = data:receive("*a", "", 100)
751 assert(e == "oversized" and #p == 100, "E3 failed: first chunk") 759 assert(e == "oversized" and #p == 100, "E3a failed: first chunk")
752 d, e, p = data:receive("*a", "", 100) 760 d, e, p = data:receive("*a", "", 100)
753 assert(e == "oversized" and #p == 100, "E3 failed: second chunk") 761 assert(e == "oversized" and #p == 100, "E3a failed: second chunk")
754 d, e = data:receive("*a", "", 100) 762 d, e = data:receive("*a", "", 100)
755 assert(d == string.rep("a", 50) and e == nil, "E3 failed: final chunk") 763 assert(d == string.rep("a", 50) and e == nil, "E3a failed: final chunk")
764
765 reconnect()
766 remote(string.format([[data:send(string.rep('a',%d)) data:close() data = nil]], 250))
767 d, e, p = data:receive("*a", "", 100)
768 assert(e == "oversized" and #p == 100, "E3b failed: first chunk")
769 d, e, p = data:receive("*a", p, 200) -- increase maxsize, try again with prefix
770 assert(e == "oversized" and #p == 200, "E3b failed: second chunk")
771 d, e = data:receive("*a", p, 300) -- increase maxsize, try again with prefix
772 assert(d == string.rep("a", 250) and e == nil, "E3b failed: final chunk")
756 773
757 reconnect() 774 reconnect()
758 remote(string.format([[data:send(string.rep('a',%d))]], 100)) 775 remote(string.format([[data:send(string.rep('a',%d))]], 100))