Sha256: 55de9ad56d07991bedcdb611746525cb8b3e1c8d6b5f540ebb99717fb050dc34
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'richunits/duration' require 'test/unit' class TestDuration < Test::Unit::TestCase def test_to_a d = RichUnits::Duration.new(24*60*60 + 1) r = d.to_a x = [1, 0, 0, 1] assert_equal(x, r) d = RichUnits::Duration.new(10*24*60*60 + 5) r = d.to_a x = [10, 0, 0, 5] assert_equal(x, r) end def test_segmented d = RichUnits::Duration.new(8*24*60*60 + 1) r = d.segmented(:week, :day, :hour, :minute, :second) x = [1, 1, 0, 0, 1] assert_equal(x, r.to_a) end def test_to_h d = RichUnits::Duration.new(24*60*60) r = d.to_h x = { :days=>1, :hours=>0, :minutes=>0, :seconds=>0 } assert_equal(x, r) end def test_repeated_numeric_days a = 10.days r = 10.days.days x = 10 assert_equal(x,r) end def test_repeated_numeric_years a = 10.years r = 10.years.years x = 10 assert_equal(x,r) end def test_repeated_strftime a = RichUnits::Duration[24*60*60 + 1] r = a.strftime('%d:%h:%m:%s') x = "1:0:0:1" assert_equal(x,r) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
richunits-0.6 | test/test_duration.rb |
richunits-0.5.0 | test/test_duration.rb |