Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add two new test cases

  • Loading branch information...
commit 49eb7b534f4a604d7700316ec3e6b477faa5dd1e 1 parent 6f265de
@ittner ittner authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 test_iconv.lua
View
14 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")
Please sign in to comment.
Something went wrong with that request. Please try again.