Sha256: ed3f4bc4ed9a87229d6bec3471284e411c98bfb482efd25002e74c66656809e9

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

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

require 'test/unit'

require 'openwfe/util/otime'

#
# testing otime and the scheduler
#

class TimeTest < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end

    #def test_to_iso_date
    def XXXX_to_iso_date
        #
        # well... this test is not timezone friendly...
        # commented out thus...

        t = 1169019813.93468

        s = OpenWFE.to_iso8601_date(t)
        puts s

        assert \
            OpenWFE.to_iso8601_date(t) == "2007-01-17 02:43:33-0500",
            "conversion to iso8601 date failed"

        d = OpenWFE.to_ruby_time(s)

        #puts d.to_s

        assert \
            d.to_s == "2007-01-17T02:43:33-0500",
            "iso8601 date parsing failed"
    end

    def test_is_digit

        for i in 0...9
            si = "#{i}"
            assert \
                OpenWFE::is_digit?(si),
                "'#{si}' should be a digit"
        end

        assert \
            (not OpenWFE::is_digit?(1)),
            "the integer 1 is not a character digit"
        assert \
            (not OpenWFE::is_digit?("a")),
            "the character 'a' is not a character digit"
    end

    def test_parse_time_string

        pts("500", 0.5)
        pts("1000", 1.0)
        pts("1h", 3600.0)
        pts("1h10s", 3610.0)
    end

    protected

        def pts (time_string, seconds)

            assert \
                OpenWFE::parse_time_string(time_string) == seconds,
                "'#{time_string}' did not map to #{seconds} seconds"
        end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
openwferu-0.9.10.653 test/time_test.rb
openwferu-0.9.12 test/time_test.rb
openwferu-0.9.12.863 test/time_test.rb
openwferu-0.9.10 test/time_test.rb
openwferu-0.9.11 test/time_test.rb
openwferu-0.9.13 test/time_test.rb
openwferu-0.9.14 test/time_test.rb
openwferu-0.9.15 test/time_test.rb
openwferu-0.9.9 test/time_test.rb
openwferu-0.9.16 test/time_test.rb
openwferu-0.9.3 test/time_test.rb
openwferu-0.9.8 test/time_test.rb
openwferu-0.9.4 test/time_test.rb
openwferu-0.9.5 test/time_test.rb
openwferu-0.9.6 test/time_test.rb
openwferu-0.9.7 test/time_test.rb