Sha256: 314d0c58eb3359a9261b92c0049e9327de3ec05e81a99f5e1932d8bc8613a3b9

Contents?: true

Size: 709 Bytes

Versions: 5

Compression:

Stored size: 709 Bytes

Contents

#!/usr/local/bin/ruby
if $0 == __FILE__
  Dir.chdir File.dirname(__FILE__)+'/../'
  $:.unshift File.expand_path('../lib/')
end
require 'rio'
require 'tc/testcase'
require 'pp'

class TC_truncate < Test::RIO::TestCase
  @@once = false
  def self.once
    @@once = true

  end

  def setup
    super
    self.class.once unless @@once

  end

  def test_basic
    str = "1234567890"
    f = rio("out")
    f.print!(str)
    assert_equal(str,f.contents)
    assert_equal(str.size,f.size)
    n = 5
    f.truncate(n)
    assert_equal(str[0,n],f.contents)
    assert_equal(n,f.size)
    n = 2
    assert_equal(str[0,n],f.read(n))
    assert_equal(n,f.truncate.size)
    assert_equal(str[0,n],f.contents)
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
wishdev-rio-0.4.3.1 test/tc/truncate.rb
rio-0.3.9 test/tc/truncate.rb
rio-0.4.2 test/tc/truncate.rb
rio-0.4.0 test/tc/truncate.rb
rio-0.4.1 test/tc/truncate.rb