summaryrefslogtreecommitdiff
path: root/test/xmlrpc/test_datetime.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-16 02:41:11 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-16 02:41:11 +0000
commite2bb529c8f77a1a2911b13f1949c8813ee29f740 (patch)
tree004c8510182e620692051a84f1ee34e276a5107a /test/xmlrpc/test_datetime.rb
parentb14c93e6caafe9f8eef40e0912a61284c16ed6ec (diff)
* lib/xmlrpc.rb, lib/xmlrpc/*, test/xmlrpc: XMLRPC is bundled gem
on Ruby 2.4. [Feature #12160][ruby-core:74239] * gems/bundled_gems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/xmlrpc/test_datetime.rb')
-rw-r--r--test/xmlrpc/test_datetime.rb162
1 files changed, 0 insertions, 162 deletions
diff --git a/test/xmlrpc/test_datetime.rb b/test/xmlrpc/test_datetime.rb
deleted file mode 100644
index 6a46e15f842..00000000000
--- a/test/xmlrpc/test_datetime.rb
+++ /dev/null
@@ -1,162 +0,0 @@
-# frozen_string_literal: false
-require 'test/unit'
-require "xmlrpc/datetime"
-
-module TestXMLRPC
-class Test_DateTime < Test::Unit::TestCase
-
- def test_new
- dt = createDateTime()
-
- assert_instance_of(XMLRPC::DateTime, dt)
- end
-
- def test_new_exception
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(4.5, 13, 32, 25, 60, 60) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 32, 25, 60, 60) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 25, 60, 60) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 24, 60, 60) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 24, 59, 60) }
- assert_nothing_raised(ArgumentError) { XMLRPC::DateTime.new(2001, 12, 31, 24, 59, 59) }
-
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 0, 0, -1, -1, -1) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 0, -1, -1, -1) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, -1, -1, -1) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, 0, -1, -1) }
- assert_raise(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, 0, 0, -1) }
- assert_nothing_raised(ArgumentError) { XMLRPC::DateTime.new(2001, 1, 1, 0, 0, 0) }
- end
-
-
- def test_get_values
- y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5
- dt = XMLRPC::DateTime.new(y, m, d, h, mi, s)
-
- assert_equal(y, dt.year)
- assert_equal(m, dt.month)
- assert_equal(m, dt.mon)
- assert_equal(d, dt.day)
-
- assert_equal(h, dt.hour)
- assert_equal(mi,dt.min)
- assert_equal(s, dt.sec)
- end
-
- def test_set_values
- dt = createDateTime()
- y, m, d, h, mi, s = 1950, 12, 9, 8, 52, 30
-
- dt.year = y
- dt.month = m
- dt.day = d
- dt.hour = h
- dt.min = mi
- dt.sec = s
-
- assert_equal(y, dt.year)
- assert_equal(m, dt.month)
- assert_equal(m, dt.mon)
- assert_equal(d, dt.day)
-
- assert_equal(h, dt.hour)
- assert_equal(mi,dt.min)
- assert_equal(s, dt.sec)
-
- dt.mon = 5
- assert_equal(5, dt.month)
- assert_equal(5, dt.mon)
- end
-
- def test_set_exception
- dt = createDateTime()
-
- assert_raise(ArgumentError) { dt.year = 4.5 }
- assert_nothing_raised(ArgumentError) { dt.year = -2000 }
-
- assert_raise(ArgumentError) { dt.month = 0 }
- assert_raise(ArgumentError) { dt.month = 13 }
- assert_nothing_raised(ArgumentError) { dt.month = 7 }
-
- assert_raise(ArgumentError) { dt.mon = 0 }
- assert_raise(ArgumentError) { dt.mon = 13 }
- assert_nothing_raised(ArgumentError) { dt.mon = 7 }
-
- assert_raise(ArgumentError) { dt.day = 0 }
- assert_raise(ArgumentError) { dt.day = 32 }
- assert_nothing_raised(ArgumentError) { dt.day = 16 }
-
- assert_raise(ArgumentError) { dt.hour = -1 }
- assert_raise(ArgumentError) { dt.hour = 25 }
- assert_nothing_raised(ArgumentError) { dt.hour = 12 }
-
- assert_raise(ArgumentError) { dt.min = -1 }
- assert_raise(ArgumentError) { dt.min = 60 }
- assert_nothing_raised(ArgumentError) { dt.min = 30 }
-
- assert_raise(ArgumentError) { dt.sec = -1 }
- assert_raise(ArgumentError) { dt.sec = 60 }
- assert_nothing_raised(ArgumentError) { dt.sec = 30 }
- end
-
- def test_to_a
- y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5
- dt = XMLRPC::DateTime.new(y, m, d, h, mi, s)
- a = dt.to_a
-
- assert_instance_of(Array, a)
- assert_equal(6, a.size, "Returned array has wrong size")
-
- assert_equal(y, a[0])
- assert_equal(m, a[1])
- assert_equal(d, a[2])
- assert_equal(h, a[3])
- assert_equal(mi, a[4])
- assert_equal(s, a[5])
- end
-
- def test_to_time1
- y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5
- dt = XMLRPC::DateTime.new(y, m, d, h, mi, s)
- time = dt.to_time
-
- assert_not_nil(time)
-
- assert_equal(y, time.year)
- assert_equal(m, time.month)
- assert_equal(d, time.day)
- assert_equal(h, time.hour)
- assert_equal(mi, time.min)
- assert_equal(s, time.sec)
- end
-
- def test_to_time2
- dt = createDateTime()
- dt.year = 1969
-
- assert_nil(dt.to_time)
- end
-
- def test_to_date1
- y, m, d, h, mi, s = 1970, 3, 24, 12, 0, 5
- dt = XMLRPC::DateTime.new(y, m, d, h, mi, s)
- date = dt.to_date
-
- assert_equal(y, date.year)
- assert_equal(m, date.month)
- assert_equal(d, date.day)
- end
-
- def test_to_date2
- dt = createDateTime()
- dt.year = 666
-
- assert_equal(666, dt.to_date.year)
- end
-
-
- def createDateTime
- XMLRPC::DateTime.new(1970, 3, 24, 12, 0, 5)
- end
-
-end
-end