# # 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