From 6453a60c4aaf90beb47f2ff57f61d02984bec280 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 4 Sep 2014 18:16:33 +0500 Subject: [PATCH] Update test --- test/test_easy.lua | 52 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/test/test_easy.lua b/test/test_easy.lua index a55298c..b90f00f 100644 --- a/test/test_easy.lua +++ b/test/test_easy.lua @@ -38,48 +38,40 @@ function test_write_to_file() assert_equal(c, c:perform()) end -function test_write_to_file_abort_01() +function test_write_abort_01() c = assert(scurl.easy{ url = url; - writefunction = function(str) - return #str - 1 - end; + writefunction = function(str) return #str - 1 end; }) local _, e = assert_nil(c:perform()) assert_equal(curl.error(curl.ERROR_EASY, curl.E_WRITE_ERROR), e) end -function test_write_to_file_abort_02() +function test_write_abort_02() c = assert(scurl.easy{ url = url; - writefunction = function(str) - return false - end; + writefunction = function(str) return false end; }) local _, e = assert_nil(c:perform()) assert_equal(curl.error(curl.ERROR_EASY, curl.E_WRITE_ERROR), e) end -function test_write_to_file_abort_03() +function test_write_abort_03() c = assert(scurl.easy{ url = url; - writefunction = function(str) - return nil, "WRITEERROR" - end; + writefunction = function(str) return nil, "WRITEERROR" end; }) local _, e = assert_nil(c:perform()) assert_equal("WRITEERROR", e) end -function test_write_to_file_abort_04() +function test_write_abort_04() c = assert(scurl.easy{ url = url; - writefunction = function(str) - return nil - end; + writefunction = function(str) return nil end; }) local _, e = assert_nil(c:perform()) @@ -94,6 +86,34 @@ function test_reset_write_callback() assert_equal(c, c:setopt_writefunction(print)) end +function test_write_pass_01() + c = assert(curl.easy{ + url = url; + writefunction = function(s) return #s end + }) + + assert_equal(c, c:perform()) +end + +function test_write_pass_02() + c = assert(curl.easy{ + url = url; + writefunction = function() return end + }) + + assert_equal(c, c:perform()) +end + +function test_write_pass_03() + c = assert(curl.easy{ + url = url; + writefunction = function() return true end + }) + + assert_equal(c, c:perform()) +end + + end local _ENV = TEST_CASE'escape' do