From dc62f1b651fe5fe079ed8c543700f22aeee571c2 Mon Sep 17 00:00:00 2001 From: tadf Date: Mon, 6 Jun 2011 13:00:38 +0000 Subject: * 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 --- test/date/test_switch_hitter.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/date') 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 -- cgit v1.2.1