diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2011-02-25 21:07:23 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-25 14:08:10 -0800 |
commit | 365ae37aba229c4ca9c4232cfa7b5275c64647d1 (patch) | |
tree | 313d13ae97dba19a4eb29d3559b605aac65df94d | |
parent | 2087329bda3cdc81df4545be68c9450b7ebb5c6f (diff) | |
download | psych-365ae37aba229c4ca9c4232cfa7b5275c64647d1.zip |
improved time scanning tests
-rw-r--r-- | test/psych/test_scalar_scanner.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb index 69dc127..636030f 100644 --- a/test/psych/test_scalar_scanner.rb +++ b/test/psych/test_scalar_scanner.rb @@ -2,18 +2,6 @@ require_relative 'helper' module Psych class TestScalarScanner < TestCase - def test_scan_time - [ '2001-12-15T02:59:43.1Z', - '2001-12-14t21:59:43.10-05:00', - '2001-12-14 21:59:43.10 -5', - '2010-01-06 00:00:00 -08:00', - '2001-12-15 2:59:43.10', - ].each do |time| - ss = Psych::ScalarScanner.new - assert_instance_of Time, ss.tokenize(time) - end - end - attr_reader :ss def setup @@ -21,6 +9,16 @@ module Psych @ss = Psych::ScalarScanner.new end + def test_scan_time + { '2001-12-15T02:59:43.1Z' => Time.utc(2001, 12, 15, 02, 59, 43, 100000), + '2001-12-14t21:59:43.10-05:00' => Time.utc(2001, 12, 15, 02, 59, 43, 100000), + '2001-12-14 21:59:43.10 -5' => Time.utc(2001, 12, 15, 02, 59, 43, 100000), + '2001-12-15 2:59:43.10' => Time.utc(2001, 12, 15, 02, 59, 43, 100000) + }.each do |time_str, time| + assert_equal time, @ss.tokenize(time_str) + end + end + def test_scan_date date = '1980-12-16' token = @ss.tokenize date |