aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-01-21 18:40:52 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-01-21 18:40:52 +0000
commit195069cf5f929f445b0ce20e531cd482d2559083 (patch)
tree6444d37c4ce32395428ba26ee0d16c0c372bd9da /test
parente63f500d24ff0238425c9e13f220daf09a277ef5 (diff)
downloadluasocket-195069cf5f929f445b0ce20e531cd482d2559083.tar.gz
luasocket-195069cf5f929f445b0ce20e531cd482d2559083.tar.bz2
luasocket-195069cf5f929f445b0ce20e531cd482d2559083.zip
Fixed functions that return messages in ?socket.c.
Moved complexity of connect and accept there. Created a new options.c module to take care of options. Auxiliar.c is now cleaner.
Diffstat (limited to 'test')
-rw-r--r--test/httptest.lua5
-rw-r--r--test/testclnt.lua16
2 files changed, 18 insertions, 3 deletions
diff --git a/test/httptest.lua b/test/httptest.lua
index 4667605..8bf3980 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -49,8 +49,7 @@ local check_result = function(response, expect, ignore)
49 for i,v in response do 49 for i,v in response do
50 if not ignore[i] then 50 if not ignore[i] then
51 if v ~= expect[i] then 51 if v ~= expect[i] then
52 v = string.sub(type(v) == "string" and v or "", 1, 70) 52 print(string.sub(tostring(v), 1, 70))
53 print(v)
54 fail(i .. " differs!") 53 fail(i .. " differs!")
55 end 54 end
56 end 55 end
@@ -59,7 +58,7 @@ local check_result = function(response, expect, ignore)
59 if not ignore[i] then 58 if not ignore[i] then
60 if v ~= response[i] then 59 if v ~= response[i] then
61 v = string.sub(type(v) == "string" and v or "", 1, 70) 60 v = string.sub(type(v) == "string" and v or "", 1, 70)
62 print(v) 61 print(string.sub(tostring(v), 1, 70))
63 fail(i .. " differs!") 62 fail(i .. " differs!")
64 end 63 end
65 end 64 end
diff --git a/test/testclnt.lua b/test/testclnt.lua
index 5a001b3..a0d9fda 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -379,6 +379,19 @@ function connect_timeout()
379end 379end
380 380
381------------------------------------------------------------------------ 381------------------------------------------------------------------------
382function rebind_test()
383 local c = socket.bind("localhost", 0)
384 local i, p = c:getsockname()
385 local s, e = socket.tcp()
386 assert(s, e)
387 s:setoption("reuseaddr", false)
388 r, e = s:bind("localhost", p)
389 assert(not r, "managed to rebind!")
390 assert(e == "address already in use")
391 print("ok")
392end
393
394------------------------------------------------------------------------
382test("method registration") 395test("method registration")
383test_methods(socket.tcp(), { 396test_methods(socket.tcp(), {
384 "connect", 397 "connect",
@@ -416,6 +429,9 @@ test_selectbugs()
416test("empty host connect: ") 429test("empty host connect: ")
417empty_connect() 430empty_connect()
418 431
432test("rebinding: ")
433rebind_test()
434
419test("active close: ") 435test("active close: ")
420active_close() 436active_close()
421 437