aboutsummaryrefslogtreecommitdiffstats
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
parent0ac1621a20f44dd4e56cb7891324161430713374 (diff)
downloadruby-dc62f1b651fe5fe079ed8c543700f22aeee571c2.tar.gz
* 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
-rw-r--r--ChangeLog4
-rw-r--r--test/date/test_switch_hitter.rb27
2 files changed, 31 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 79ded3964a..06a877ae6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Jun 6 21:59:23 2011 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * test/date/test_switch_hitter.rb: added a test.
+
Mon Jun 6 21:37:45 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c: added notes.
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