summaryrefslogtreecommitdiff
path: root/test/date/test_switch_hitter.rb
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-06 13:00:38 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-06 13:00:38 +0000
commitdc62f1b651fe5fe079ed8c543700f22aeee571c2 (patch)
treea3874c5e5f7d60823194bda2bc7ed46db3af21f2 /test/date/test_switch_hitter.rb
parent0ac1621a20f44dd4e56cb7891324161430713374 (diff)
* test/date/test_switch_hitter.rb: added a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/date/test_switch_hitter.rb')
-rw-r--r--test/date/test_switch_hitter.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb
index 6031708928..8f7accf793 100644
--- a/test/date/test_switch_hitter.rb
+++ b/test/date/test_switch_hitter.rb
@@ -384,6 +384,33 @@ class TestSH < Test::Unit::TestCase
assert_equal(true, s.tainted?)
end
+ def test_enc
+ h = Date._strptime('15:43+09:00'.force_encoding('euc-jp'), '%R%z')
+ assert_equal(Encoding::EUC_JP, h[:zone].encoding)
+ h = Date._strptime('15:43+09:00'.force_encoding('ascii-8bit'), '%R%z')
+ assert_equal(Encoding::ASCII_8BIT, h[:zone].encoding)
+
+ h = Date._strptime('1;1/0'.force_encoding('euc-jp'), '%d')
+ assert_equal(Encoding::EUC_JP, h[:leftover].encoding)
+ h = Date._strptime('1;1/0'.force_encoding('ascii-8bit'), '%d')
+ assert_equal(Encoding::ASCII_8BIT, h[:leftover].encoding)
+
+ h = Date._parse('15:43+09:00'.force_encoding('euc-jp'))
+ assert_equal(Encoding::EUC_JP, h[:zone].encoding)
+ h = Date._parse('15:43+09:00'.force_encoding('ascii-8bit'))
+ assert_equal(Encoding::ASCII_8BIT, h[:zone].encoding)
+
+ s = Date.today.strftime('new 105'.force_encoding('euc-jp'))
+ assert_equal(Encoding::EUC_JP, s.encoding)
+ s = Date.today.strftime('new 105'.force_encoding('ascii-8bit'))
+ assert_equal(Encoding::ASCII_8BIT, s.encoding)
+
+ s = DateTime.now.strftime('super $record'.force_encoding('euc-jp'))
+ assert_equal(Encoding::EUC_JP, s.encoding)
+ s = DateTime.now.strftime('super $record'.force_encoding('ascii-8bit'))
+ assert_equal(Encoding::ASCII_8BIT, s.encoding)
+ end
+
def test_dup
d = Date.new(2001,2,3)
d2 = d.dup