test/test_TjTime.rb in taskjuggler-0.0.10 vs test/test_TjTime.rb in taskjuggler-0.0.11
- old
+ new
@@ -12,34 +12,35 @@
#
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'test/unit'
-require 'TjTime'
+require 'taskjuggler/TjTime'
+
class TestTjTime < Test::Unit::TestCase
def setup
- @endTime = TaskJuggler::TjTime.local(2030)
+ @endTime = TaskJuggler::TjTime.new("2030-01-01")
@startTimes = [
- TaskJuggler::TjTime.local(1972, 3, 15, 19, 27),
- TaskJuggler::TjTime.local(1972, 2, 12, 10),
- TaskJuggler::TjTime.local(1984, 11, 1, 12),
- TaskJuggler::TjTime.local(1992, 1, 1),
+ TaskJuggler::TjTime.new([ 1972, 3, 15, 19, 27 ]),
+ TaskJuggler::TjTime.new([ 1972, 2, 12, 10 ]),
+ TaskJuggler::TjTime.new([ 1984, 11, 1, 12 ]),
+ TaskJuggler::TjTime.new([ 1992, 1, 1 ]),
]
end
def teardown
end
def test_sameTimeNextDay
@startTimes.each do |st|
t1 = t2 = st
- t1_a = old_t2_a = t1.localtime.to_a
+ t1_a = old_t2_a = t1.to_a
begin
t2 = t2.sameTimeNextDay
- t2_a = t2.localtime.to_a
+ t2_a = t2.to_a
assert_equal(t1_a[0, 3], t2_a[0, 3])
assert(t2_a[3] == old_t2_a[3] + 1 ||
t2_a[3] == 1, t2_a.join(', '))
assert(t2_a[7] == old_t2_a[7] + 1 ||
t2_a[7] == 1, t2_a.join(', '))
@@ -50,14 +51,14 @@
end
def test_sameTimeNextWeek
@startTimes.each do |st|
t1 = t2 = st
- t1_a = old_t2_a = t1.localtime.to_a
+ t1_a = old_t2_a = t1.to_a
begin
t2 = t2.sameTimeNextWeek
- t2_a = t2.localtime.to_a
+ t2_a = t2.to_a
# Check that hour, minutes and seconds are the same.
assert_equal(t1_a[0, 3], t2_a[0, 3])
# Check that weekday is the same
assert(t2_a[6] == old_t2_a[6],
"old_t2: #{old_t2_a.join(', ')}\nt2: #{t2_a.join(', ')}")
@@ -72,14 +73,14 @@
end
def test_sameTimeNextMonth
@startTimes.each do |st|
t1 = t2 = st
- t1_a = old_t2_a = t1.localtime.to_a
+ t1_a = old_t2_a = t1.to_a
begin
t2 = t2.sameTimeNextMonth
- t2_a = t2.localtime.to_a
+ t2_a = t2.to_a
assert_equal(t1_a[0, 3], t2_a[0, 3])
assert(t2_a[3] == t2_a[3] ||
t2_a[3] > 28,
"old_t2: #{old_t2_a.join(', ')}\nt2: #{t2_a.join(', ')}")
assert(t2_a[4] == old_t2_a[4] + 1 ||
@@ -92,13 +93,13 @@
end
def test_sameTimeNextQuarter
@startTimes.each do |st|
t1 = t2 = st
- t1_a = old_t2_a = t1.localtime.to_a
+ t1_a = old_t2_a = t1.to_a
begin
t2 = t2.sameTimeNextQuarter
- t2_a = t2.localtime.to_a
+ t2_a = t2.to_a
assert_equal(t1_a[0, 3], t2_a[0, 3],
"old_t2: #{old_t2_a.join(', ')}\nt2: #{t2_a.join(', ')}")
assert((t2_a[4] == old_t2_a[4] + 3 &&
t2_a[5] == old_t2_a[5]) ||
(t2_a[4] == old_t2_a[4] - 9 &&