Sha256: 354afebc88af038c82fe66d13277f58f3458f125671dae20151a4dcc57db5317

Contents?: true

Size: 1.5 KB

Versions: 12

Compression:

Stored size: 1.5 KB

Contents

require 'test_helper'
require 'tins'

module Tins
  class DurationTest < Test::Unit::TestCase
    def test_short_to_s
      assert_equal '00:11:06', Tins::Duration.new(666).to_s
    end

    def test_to_s_with_days
      assert_equal '7+17:11:06', Tins::Duration.new(666666).to_s
    end

    def test_to_s_with_fractional_seconds
      assert_equal '00:11:06.123', Tins::Duration.new(666.123456).to_s
    end

    def test_to_s_with_days_and_fractional_seconds
      assert_equal '7+17:11:06.123', Tins::Duration.new(666666.123456).to_s
    end

    def test_format_without_precision
      assert_equal '0+00:11:06.123456', Tins::Duration.new(666.123456).format
    end

    def test_predicate_days
      s = 0
      assert_false Tins::Duration.new(s).days?
      s += 86_400
      assert_true Tins::Duration.new(s).days?
    end

    def test_predicate_hours
      s = 0
      assert_false Tins::Duration.new(s).hours?
      s += 3600
      assert_true Tins::Duration.new(s).hours?
    end

    def test_predicate_minutes
      s = 0
      assert_false Tins::Duration.new(s).minutes?
      s += 60
      assert_true Tins::Duration.new(s).minutes?
    end

    def test_predicate_seconds
      s = 0
      assert_false Tins::Duration.new(s).seconds?
      s += 1
      assert_true Tins::Duration.new(s).seconds?
    end

    def test_predicate_fractional_seconds
      s = 0
      assert_false Tins::Duration.new(s).fractional_seconds?
      s += 0.1
      assert_true Tins::Duration.new(s).fractional_seconds?
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/tins-1.13.0/tests/duaration_test.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/tins-1.13.0/tests/duaration_test.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/tins-1.13.0/tests/duaration_test.rb
tins-1.13.0 tests/duaration_test.rb
tdiary-5.0.2 vendor/bundle/gems/tins-1.12.0/tests/duaration_test.rb
tins-1.12.0 tests/duaration_test.rb
tins-1.11.0 tests/duaration_test.rb
tdiary-5.0.1 vendor/bundle/gems/tins-1.10.2/tests/duaration_test.rb
tins-1.10.2 tests/duaration_test.rb
tins-1.10.1 tests/duaration_test.rb
tins-1.10.0 tests/duaration_test.rb
tins-1.9.0 tests/duaration_test.rb