Sha256: 8561e5ba4739fab52642b47758d0d6d1f6399f4c018563e69260a705a26fb58a

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'spec_helper'

include TwitterCldr::Tokenizers

describe DateTokenizer do
  describe "#tokens" do
    it "should tokenize a time string correctly (i.e. German)" do
      tokenizer = TimeTokenizer.new(:locale => :de)
      got = tokenizer.tokens(:type => :full)
      expected = [{ :value => "HH", :type => :pattern },
                  { :value => ":", :type => :plaintext },
                  { :value => "mm", :type => :pattern },
                  { :value => ":", :type => :plaintext },
                  { :value => "ss", :type => :pattern },
                  { :value => " ", :type => :plaintext },
                  { :value => "zzzz", :type => :pattern }]
      check_token_list(got, expected)
    end

    it "should tokenize patterns with non-latin characters correctly (i.e. Korean)" do
      tokenizer = TimeTokenizer.new(:locale => :ko)
      got = tokenizer.tokens(:type => :full)
      expected  = [{ :value => "a", :type => :pattern },
                   { :value => " ", :type => :plaintext },
                   { :value => "hh", :type => :pattern },
                   { :value => "시 ", :type => :plaintext },
                   { :value => "mm", :type => :pattern },
                   { :value => "분 ", :type => :plaintext },
                   { :value => "ss", :type => :pattern },
                   { :value => "초 ", :type => :plaintext },
                   { :value => "zzzz", :type => :pattern }]
      check_token_list(got, expected)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_cldr-1.2.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-1.1.0 spec/tokenizers/calendars/time_tokenizer_spec.rb