# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'spec_helper' describe TwitterCldr::Segmentation::RuleSet do let(:test_path) do File.join( TwitterCldr::RESOURCES_DIR, 'shared', 'segments', 'tests' ) end def parse(test_data) parts = test_data .split(/([÷×])/) .map(&:strip) .reject(&:empty?) .map do |part| if part =~ /[÷×]/ part else [part.to_i(16)].pack('U*') end end end def boundaries(test_parts) idx = 0 [].tap do |boundaries| test_parts.each do |part| if part =~ /[÷×]/ boundaries << idx if part == '÷' else idx += 1 end end end end def string(test_parts) test_parts.select.with_index do |part, idx| idx % 2 == 1 end.join end def error_message(test, test_case_boundaries, result_boundaries) <