Sha256: 852228094452eac673615440669ff9cca5c2d25f9a56af7c7a4d7ce54a8dce85

Contents?: true

Size: 1.44 KB

Versions: 17

Compression:

Stored size: 1.44 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Tokenizers

describe TimeTokenizer do
  describe "#tokens" do
    it "should tokenize a time string correctly (i.e. German)" do
      data_reader = TwitterCldr::DataReaders::TimeDataReader.new(:de, type: :full)
      got = data_reader.tokenizer.tokenize(data_reader.pattern)
      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
      data_reader = TwitterCldr::DataReaders::TimeDataReader.new(:ko, type: :full)
      got = data_reader.tokenizer.tokenize(data_reader.pattern)
      expected  = [
        { value: "a", type: :pattern },
        { value: " ", type: :plaintext },
        { value: "h", type: :pattern },
        { value: "시 ", type: :plaintext },
        { value: "m", type: :pattern },
        { value: "분 ", type: :plaintext },
        { value: "s", type: :pattern },
        { value: "초 ", type: :plaintext },
        { value: "zzzz", type: :pattern }
      ]
      check_token_list(got, expected)
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/tokenizers/calendars/time_tokenizer_spec.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.4.5 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.4.4 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.4.3 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.4.2 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.4.1 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.4.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.3.1 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.3.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.2.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.1.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-4.0.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-3.6.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-3.5.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-3.4.0 spec/tokenizers/calendars/time_tokenizer_spec.rb
twitter_cldr-3.3.0 spec/tokenizers/calendars/time_tokenizer_spec.rb