Sha256: 8971977dfa07f2c901ce6824478ad745cc8a11d46d0a17c272e10c28af5dc656

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

require 'minitest/autorun'
require 'rmagick'

class TmpnamTest < Minitest::Test
  # test the @@_tmpnam_ class variable
  # the count is incremented by Image::Info#texture=,
  # ImageList::Montage#texture=, and Draw.composite
  def test_tmpnam
    tmpfiles = Dir[ENV['HOME'] + '/tmp/magick*'].length

    texture = Magick::Image.read('granite:') { self.size = '20x20' }.first
    info = Magick::Image::Info.new

    # does not exist at first
    assert_raise(NameError) { x = Magick._tmpnam_ }

    info.texture = texture

    # now it exists
    assert_nothing_raised { x = Magick._tmpnam_ }
    assert_equal(1, Magick._tmpnam_)

    info.texture = texture
    assert_equal(2, Magick._tmpnam_)

    mon = Magick::ImageList::Montage.new
    mon.texture = texture
    assert_equal(3, Magick._tmpnam_)

    mon.texture = texture
    assert_equal(4, Magick._tmpnam_)

    gc = Magick::Draw.new
    gc.composite(0, 0, 20, 20, texture)
    assert_equal(5, Magick._tmpnam_)

    gc.composite(0, 0, 20, 20, texture)
    assert_equal(6, Magick._tmpnam_)

    tmpfiles2 = Dir[ENV['HOME'] + '/tmp/magick*'].length

    # The 2nd montage texture deletes the first.
    # The 2nd info texture deletes the first.
    # Both composite images are still alive.
    # Therefore only 4 tmp files are left.
    #assert_equal(tmpfiles+4, tmpfiles2)
    # 6.4.1-5 - only 1 tmpfile?
    assert_equal(tmpfiles, tmpfiles2)
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 test/tmpnam_test.rb
rmagick-windows-2.16.4 test/tmpnam_test.rb
rmagick-windows-2.16.3 test/tmpnam_test.rb
rmagick-windows-2.16.2 test/tmpnam_test.rb
rmagick-windows-2.16.1 test/tmpnam_test.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/test/tmpnam_test.rb
rmagick-2.16.0 test/tmpnam_test.rb
rmagick-2.15.4 test/tmpnam_test.rb
rmagick-2.15.3 test/tmpnam_test.rb
rmagick-2.15.2 test/tmpnam_test.rb
rmagick-2.15.1 test/tmpnam_test.rb
rmagick-2.15.0 test/tmpnam_test.rb
rmagick-2.14.0 test/tmpnam_test.rb