Sha256: fcb9e4233b638e4503906ededb2d2d8b236a88ec57425bc2c6417e68ed723130

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

# -*- encoding : utf-8 -*-
#!/usr/bin/env ruby

require 'vpim/duration'
require 'test/unit'

include Vpim

class TestVpimDate < Test::Unit::TestCase

  def duration(d0, h0, m0, s0)
    # 3 hours, 2 mins, 39 secs
    d = Duration.secs(d0 * 24 * 60 * 60 + h0 * 60 * 60 + m0 * 60 + s0)

    assert_equal(d.secs,  d0 * 24 * 60 * 60 + h0 * 60 * 60 + m0 * 60 + s0)
    assert_equal(d.mins,  d0 * 24 * 60 + h0 * 60 + m0)
    assert_equal(d.hours, d0 * 24 + h0)
    assert_equal(d.days,  d0)
    assert_equal(d.by_hours, [d0*24 + h0, m0, s0])
    assert_equal(d.by_days,  [d0,     h0, m0, s0])

    h, m, s = d.by_hours

    assert_equal(h, h0 + d0*24)
    assert_equal(m, m0)
    assert_equal(s, s0)

    d, h, m, s = d.by_days

    assert_equal(d, d0)
    assert_equal(h, h0)
    assert_equal(m, m0)
    assert_equal(s, s0)
  end

  def test_1
    duration(0, 3, 2, 39)
    duration(5, 23, 39, 1)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vpim-24.2.20 test/test_dur.rb
vpim-13.11.11 test/test_dur.rb