Sha256: 7af4eb211ee1e91ff2b9fea0c28b6f51b89338a853f0aa47b0d96984f2310c37

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

# coding: utf-8

require 'wcswidth/kernel_method'

describe 'wcswidth()' do
  describe '[east asian width]' do
    it 'returns 2 for F chars' do
      expect( wcswidth('!') ).to eq 2
    end

    it 'returns 2 for W chars' do
      expect( wcswidth('一') ).to eq 2
    end

    it 'returns 1 for N chars' do
      expect( wcswidth('À') ).to eq 1
    end

    it 'returns 1 for Na chars' do
      expect( wcswidth('A') ).to eq 1
    end

    it 'returns 1 for H chars' do
      expect( wcswidth('。') ).to eq 1
    end

    # NOTE: This is not always correct
    it 'returns 1 for A chars' do
      expect( wcswidth('·') ).to eq 1
    end
  end

  describe '[general category]' do
    it 'returns 1 for non-special (non east width) chars' do
      expect( wcswidth('A') ).to eq 1
    end

    it 'returns 0 for Mn chars' do
      expect( wcswidth('ֿ') ).to eq 0
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wcswidth-1.0.1 spec/display_width_spec.rb
wcswidth-1.0.0 spec/display_width_spec.rb