Sha256: af2975e825cdac2e3e555f893fd4ee1f659de8f4b300535c7b717b2a87c339ff

Contents?: true

Size: 1.82 KB

Versions: 61

Compression:

Stored size: 1.82 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

describe TwitterCldr::Utils::CodePoints do

  describe '#to_char' do
    it 'converts unicode code points to the actual character' do
      expect(TwitterCldr::Utils::CodePoints.to_char(0x221E)).to eq('∞')
    end
  end

  describe '#from_char' do
    it 'converts a character to a unicode code point' do
      expect(TwitterCldr::Utils::CodePoints.from_char('∞')).to eq(0x221E)
    end
  end

  describe '#to_chars' do
    it 'should handle an empty array' do
      expect(TwitterCldr::Utils::CodePoints.to_chars([])).to eq([])
    end

    it 'converts an array of unicode code points to an array of chars' do
      expect(TwitterCldr::Utils::CodePoints.to_chars([0x65, 0x73, 0x70])).to eq(%w[e s p])
    end
  end

  describe '#from_chars' do
    it 'should handle an empty array' do
      expect(TwitterCldr::Utils::CodePoints.from_chars([])).to eq([])
    end

    it 'converts an array of chars to an array of unicode code points' do
      expect(TwitterCldr::Utils::CodePoints.from_chars(%w[e s p])).to eq([0x65, 0x73, 0x70])
    end
  end

  describe '#to_string' do
    it 'should handle an empty array' do
      expect(TwitterCldr::Utils::CodePoints.to_string([])).to eq('')
    end

    it 'converts an array of unicode code points to a string' do
      expect(TwitterCldr::Utils::CodePoints.to_string([0x65, 0x73, 0x70, 0x61, 0xF1, 0x6F, 0x6C])).to eq('español')
    end
  end

  describe '#from_string' do
    it 'should handle an empty string' do
      expect(TwitterCldr::Utils::CodePoints.from_string('')).to eq([])
    end

    it 'converts a string into an array of unicode code points' do
      expect(TwitterCldr::Utils::CodePoints.from_string('español')).to eq([0x65, 0x73, 0x70, 0x61, 0xF1, 0x6F, 0x6C])
    end
  end

end

Version data entries

61 entries across 61 versions & 3 rubygems

Version Path
twitter_cldr-6.12.0 spec/utils/code_points_spec.rb
twitter_cldr-6.11.5 spec/utils/code_points_spec.rb
twitter_cldr-6.11.4 spec/utils/code_points_spec.rb
twitter_cldr-6.11.3 spec/utils/code_points_spec.rb
twitter_cldr-6.11.2 spec/utils/code_points_spec.rb
twitter_cldr-6.11.1 spec/utils/code_points_spec.rb
twitter_cldr-6.11.0 spec/utils/code_points_spec.rb
twitter_cldr-6.10.0 spec/utils/code_points_spec.rb
twitter_cldr-6.9.0 spec/utils/code_points_spec.rb
twitter_cldr-6.8.0 spec/utils/code_points_spec.rb
twitter_cldr-6.7.0 spec/utils/code_points_spec.rb
twitter_cldr-6.6.2 spec/utils/code_points_spec.rb
twitter_cldr-6.6.1 spec/utils/code_points_spec.rb
twitter_cldr-6.6.0 spec/utils/code_points_spec.rb
twitter_cldr-6.5.0 spec/utils/code_points_spec.rb
twitter_cldr-6.4.0 spec/utils/code_points_spec.rb
twitter_cldr-6.3.0 spec/utils/code_points_spec.rb
twitter_cldr-6.2.0 spec/utils/code_points_spec.rb
twitter_cldr-6.1.0 spec/utils/code_points_spec.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/utils/code_points_spec.rb