Sha256: ab8326f1ebea6bdd2540f0f17d22ce514d5acfc091622786bc2c3ec6290a2605

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Fri Feb 29 11:18:48 JST 2008
#

require 'test/unit'

require 'rufus/otime'

#
# testing otime
#

class Time1Test < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end

    def test_0

        tts 0, "0s"
        tts 60, "1m"
        tts 61, "1m1s"
        tts 3661, "1h1m1s"
        tts 24 * 3600, "1d"
        tts 7 * 24 * 3600 + 1, "1w1s"
        tts 30 * 24 * 3600 + 1, "4w2d1s"
    end

    def test_1

        tts 30 * 24 * 3600 + 1, "1M1s", true
    end

    def test_2

        tts 0.120 + 30 * 24 * 3600 + 1, "4w2d1s120"
        tts 0.130, "130"
    end

    protected

        def tts (seconds, time_string, months=false)

            assert_equal(
                time_string,
                Rufus::to_time_string(seconds, months),
                "#{seconds} seconds did not map to '#{time_string}'")
        end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rufus-scheduler-1.0.3 test/time_1_test.rb