summaryrefslogtreecommitdiffstats
path: root/test/iconv
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-05 01:58:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-05 01:58:49 +0000
commitf3791d5209dd49c2951b9a9d28f94c44c9517386 (patch)
tree4a3fd418cffa0258997f11748c64bc98e2a15125 /test/iconv
parent35289243a83e4842c79bca0275e72f39fc0f9545 (diff)
downloadruby-f3791d5209dd49c2951b9a9d28f94c44c9517386.tar.gz
ruby-f3791d5209dd49c2951b9a9d28f94c44c9517386.tar.xz
ruby-f3791d5209dd49c2951b9a9d28f94c44c9517386.zip
* test/iconv/test_simple.rb: added.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/iconv')
-rw-r--r--test/iconv/test_simple.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/iconv/test_simple.rb b/test/iconv/test_simple.rb
new file mode 100644
index 000000000..e449b2754
--- /dev/null
+++ b/test/iconv/test_simple.rb
@@ -0,0 +1,27 @@
+require 'test/unit'
+begin
+ require 'iconv'
+rescue LoadError
+end
+
+class TestIConv < Test::Unit::TestCase
+ ASCII = "ascii"
+ def test_simple
+ c = Iconv.open(ASCII, ASCII)
+ ref = '[ruby-core:17092]'
+ rescue
+ return
+ else
+ assert_equal("abc", c.iconv("abc"))
+ assert_equal("c", c.iconv("abc", 2), "#{ref}: with start")
+ assert_equal("c", c.iconv("abc", 2, 1), "#{ref}: with start, length")
+ assert_equal("c", c.iconv("abc", 2, 5), "#{ref}: with start, longer length")
+ assert_equal("bc", c.iconv("abc", -2), "#{ref}: with nagative start")
+ assert_equal("b", c.iconv("abc", -2, 1), "#{ref}: with nagative start, length")
+ assert_equal("bc", c.iconv("abc", -2, 5), "#{ref}: with nagative start, longer length")
+ assert_equal("", c.iconv("abc", 5), "#{ref}: with OOB")
+ assert_equal("", c.iconv("abc", 5, 2), "#{ref}: with OOB, length")
+ ensure
+ c.close if c
+ end
+end if defined?(::Iconv)