From 49eb7b534f4a604d7700316ec3e6b477faa5dd1e Mon Sep 17 00:00:00 2001 From: Alexandre Erwin Ittner Date: Tue, 22 May 2012 00:58:48 -0300 Subject: [PATCH] Add two new test cases --- test_iconv.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test_iconv.lua b/test_iconv.lua index a70b0d0..a0fa097 100644 --- a/test_iconv.lua +++ b/test_iconv.lua @@ -1,3 +1,5 @@ +-- -*- coding: utf-8 -*- + local iconv = require("iconv") -- Set your terminal encoding here @@ -108,3 +110,15 @@ gc(cd) local _, e = cd:iconv("atenção") assert(e == iconv.ERROR_FINALIZED, "Failed to detect double-freed objects") gc(cd) + + +-- Test expected return values +local cd = iconv.new("ascii", "utf-8") +local _, e = cd:iconv("atenção") +assert(e == iconv.ERROR_INVALID, "Unexpected return value for invalid conversion") + + +local cd = iconv.new("iso-8859-1", "utf-8") +local s, e = cd:iconv("atenção") +assert(s == "aten\231\227o", "Unexpected result for valid conversion") +assert(e == nil, "Unexpected return value for valid conversion")