2004-03-01 15:24:42 +03:00
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# scanf for Ruby
|
|
|
|
#
|
|
|
|
# Ad hoc tests of IO#scanf (needs to be expanded)
|
|
|
|
|
|
|
|
|
2004-03-02 14:21:32 +03:00
|
|
|
require "scanf"
|
|
|
|
|
2009-10-21 07:44:56 +04:00
|
|
|
class TestScanfIO < Test::Unit::TestCase
|
2004-03-02 14:21:32 +03:00
|
|
|
def test_io
|
|
|
|
fh = File.new(File.join(File.dirname(__FILE__), "data.txt"), "r")
|
|
|
|
assert_equal(0, fh.pos)
|
|
|
|
assert_equal(["this", "is"], fh.scanf("%s%s"))
|
2009-10-21 07:44:56 +04:00
|
|
|
assert_equal([33, "little"], fh.scanf("%da fun%s"))
|
|
|
|
ensure
|
|
|
|
fh.close
|
2004-03-02 14:21:32 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|