Sha256: 0c98d474e1e084912209f99424051a207d7c63a61625482cb189a57d4e08760e

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

# encoding: UTF-8

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

require 'spec_helper'

include TwitterCldr::Parsers

describe UnicodeRegexParser::CharacterSet do
  describe "#to_set" do
    it "should return a set containing codepoints for the given general property" do
      char_set = UnicodeRegexParser::CharacterSet.new("Zs")
      expect(char_set.to_set.to_a(true)).to eq([
        32, 160, 5760, 6158, 8192..8202, 8239, 8287, 12288
      ])
    end

    it "should return a set containing codepoints for the given named property" do
      char_set = UnicodeRegexParser::CharacterSet.new("Sentence_Break=Sp")
      expect(char_set.to_set.to_a(true)).to eq([
        9, 11..12, 32, 160, 5760, 6158, 8192..8202, 8239, 8287, 12288
      ])
    end

    it "should return a set containing codepoints for the given script" do
      char_set = UnicodeRegexParser::CharacterSet.new('Katakana')
      expect(char_set.to_set.to_a(true)).to eq([
        12449..12538, 12541..12543, 12784..12799, 13008..13054, 13056..13143,
        65382..65391, 65393..65437, 110592
      ])
    end

    it "should raise an exception when given an invalid property name or value" do
      expect do
        UnicodeRegexParser::CharacterSet.new("Foobar=Sp").to_set
      end.to raise_error(UnicodeRegexParserError)

      expect do
        UnicodeRegexParser::CharacterSet.new("Sentence_Break=Foo").to_set
      end.to raise_error(UnicodeRegexParserError)
    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/parsers/unicode_regex/character_set_spec.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/twitter_cldr-4.4.5/spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.4.5 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.4.4 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.4.3 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.4.2 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.4.1 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.4.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.3.1 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.3.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.2.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.1.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-4.0.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-3.6.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-3.5.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-3.4.0 spec/parsers/unicode_regex/character_set_spec.rb
twitter_cldr-3.3.0 spec/parsers/unicode_regex/character_set_spec.rb