Sha256: 73b151f13c26ab8213612059585c9d1142ccdbbbbec684d6bd6e34759c3b3e16

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#

require 'pp'
require 'test/unit'

require 'openwfe/util/scheduler'


#
# testing the Scheduler's CronLine system
#
class CronLineTest < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end

    def do_cltest (line, array)
        cl = OpenWFE::CronLine.new(line)

        unless cl.to_array == array
            puts
            pp cl.to_array
            puts "   should be"
            pp array
        end

        assert \
            cl.to_array == array
    end

    def test_0

        do_cltest "* * * * *", [ [0], nil, nil, nil, nil, nil ]
        do_cltest "10-12 * * * *", [ [0], [10, 11, 12], nil, nil, nil, nil ]
        do_cltest "* * * * sun,mon", [ [0], nil, nil, nil, nil, [7, 1] ]
        do_cltest "* * * * mon-wed", [ [0], nil, nil, nil, nil, [1, 2, 3] ]

        #do_cltest "* * * * sun,mon-tue", [ [0], nil, nil, nil, nil, [7, 1, 2] ]
        #do_cltest "* * * * 7-1", [ [0], nil, nil, nil, nil, [7, 1, 2] ]
    end

    def test_1

        do_cltest "* * * * * *", [ nil, nil, nil, nil, nil, nil ]
        do_cltest "1 * * * * *", [ [1], nil, nil, nil, nil, nil ]
        do_cltest "7 10-12 * * * *", [ [7], [10, 11, 12], nil, nil, nil, nil ]
        do_cltest "1-5 * * * * *", [ [1,2,3,4,5], nil, nil, nil, nil, nil ]
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openwferu-0.9.16 test/cronline_test.rb