2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2004-03-01 07:24:42 -05:00
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# scanf for Ruby
|
|
|
|
#
|
|
|
|
# Ad hoc tests of IO#scanf (needs to be expanded)
|
|
|
|
|
|
|
|
|
2004-03-02 06:21:32 -05:00
|
|
|
require "scanf"
|
|
|
|
|
2009-10-20 23:44:56 -04:00
|
|
|
class TestScanfIO < Test::Unit::TestCase
|
2004-03-02 06:21:32 -05: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-20 23:44:56 -04:00
|
|
|
assert_equal([33, "little"], fh.scanf("%da fun%s"))
|
|
|
|
ensure
|
|
|
|
fh.close
|
2004-03-02 06:21:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|