OSDN Git Service

d3d4931e60215f8cf3654c7421082eb5f484d8a5
[shogi-server/shogi-server.git] / test / TC_util.rb
1 $:.unshift File.join(File.dirname(__FILE__), "..")
2 require 'test/unit'
3 require 'shogi_server/util'
4
5 class TestShogiServer < Test::Unit::TestCase
6
7   def test_datetime2time
8     now = DateTime.new(2010, 6, 10, 21, 20, 15) # Thu
9
10     assert_instance_of Time, ShogiServer::datetime2time(now) 
11     assert_equal Time.mktime(2010, 6, 10, 21, 20, 15), ShogiServer::datetime2time(now) 
12   end
13
14   def test_time2datetime
15     now = Time.mktime(2010, 6, 10, 21, 20, 15)
16     assert_instance_of DateTime, ShogiServer::time2datetime(now)
17     assert_equal DateTime.new(2010, 6, 10, 21, 20, 15), ShogiServer::time2datetime(now)
18   end
19
20   def test_parse_dow
21     assert_equal 7, ShogiServer.parse_dow("Sun")
22     assert_equal 1, ShogiServer.parse_dow("Mon")
23     assert_equal 2, ShogiServer.parse_dow("Tue")
24     assert_equal 3, ShogiServer.parse_dow("Wed")
25     assert_equal 4, ShogiServer.parse_dow("Thu")
26     assert_equal 5, ShogiServer.parse_dow("Fri")
27     assert_equal 6, ShogiServer.parse_dow("Sat")
28     assert_equal 7, ShogiServer.parse_dow("Sunday")
29     assert_equal 1, ShogiServer.parse_dow("Monday")
30     assert_equal 2, ShogiServer.parse_dow("Tuesday")
31     assert_equal 3, ShogiServer.parse_dow("Wednesday")
32     assert_equal 4, ShogiServer.parse_dow("Thursday")
33     assert_equal 5, ShogiServer.parse_dow("Friday")
34     assert_equal 6, ShogiServer.parse_dow("Saturday")
35   end
36
37 end