summaryrefslogtreecommitdiffstats
path: root/test/utility_test.rb
blob: b0fb09c6a5fc343229d4ad0d5c89945bdc311562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'test_helper'

class UtilityTest < HCl::TestCase
  include HCl::Utility

  def test_get_task_ids
    @settings = {'task.taco'=>'123 456'}
    assert_equal ['123', '456'], get_task_ids('taco', [])
  end

  def test_get_ident_with_symbol
    assert_equal 'taco', get_ident(%w[ +:25 @taco makin tacos ])
  end

  def test_get_ident_without_symbol
    assert_equal 'burrito', get_ident(%w[ burrito +:32 makin burritos ])
  end

  def test_get_starting_time_minutes
    assert_equal 0.25, get_starting_time(%w[ @taco +:15 makin tacos ])
  end

  def test_get_starting_time_decimal
    assert_equal 0.25, get_starting_time(%w[ @taco +.25 makin tacos ])
  end

  def test_time2float_decimal
    assert_equal 2.5, time2float("2.5")
  end

  def test_time2float_hhmm
    assert_equal 2.5, time2float("2:30")
  end

  def test_time2float_assume_decimal
    assert_equal 2.0, time2float("2")
  end
end