2 # -*- coding: utf-8 -*-
5 require File.join(File.dirname(__FILE__), 'setup_variant')
9 class TestJsonStringMatching < Test::Unit::TestCase
12 class TestTime < ::Time
13 def self.json_create(string)
18 %{"#{strftime('%FT%T%z')}"}
28 t_json = [ t ].to_json
30 JSON.parse(t_json, :create_additions => true,
31 :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
32 assert_equal [ t.strftime('%FT%T%z') ],
33 JSON.parse(t_json, :create_additions => true,
34 :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })
35 assert_equal [ t.strftime('%FT%T%z') ],
37 :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime })