Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 43 lines (32 sloc) 1.426 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

#! /usr/local/bin/ruby -w

require 'RMagick'
require 'test/unit'
require 'test/unit/ui/console/testrunner'

class Magick_UT < Test::Unit::TestCase

    def test_limit_resources
        cur = new = nil

        assert_nothing_raised {cur = Magick::limit_resource(:memory, 500)}
        assert_equal(756, cur)
        assert_nothing_raised {new = Magick::limit_resource("memory")}
        assert_equal(500, new)

        assert_nothing_raised {cur = Magick::limit_resource(:map, 3500)}
        assert_equal(4032, cur)
        assert_nothing_raised {new = Magick::limit_resource("map")}
        assert_equal(3500, new)

        assert_nothing_raised {cur = Magick::limit_resource(:disk, 3*1024*1024*1024)}
        assert_equal(4294967295, cur)
        assert_nothing_raised {new = Magick::limit_resource("disk")}
        assert_equal(3221225472, new)

        assert_nothing_raised {cur = Magick::limit_resource(:file, 500)}
        assert_equal(768, cur)
        assert_nothing_raised {new = Magick::limit_resource("file")}
        assert_equal(500, new)

        assert_raise(ArgumentError) { Magick::limit_resource(:xxx) }
        assert_raise(ArgumentError) { Magick::limit_resource("xxx") }
        assert_raise(ArgumentError) { Magick::limit_resource("map", 3500, 2) }
        assert_raise(ArgumentError) { Magick::limit_resource() }

    end
end

if __FILE__ == $0
Test::Unit::UI::Console::TestRunner.run(Magick_UT)
end
Something went wrong with that request. Please try again.