Sha256: 02017413b823ad5f529547eab3fc7361c1963e3d390a0d4610c4be70d047eb93

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

# coding: utf-8
require 'helper'

describe ProperProperties::Encoding::Unicode do
  subject{ ProperProperties::Encoding::Unicode }

  let(:encoded) { 'this is some \u0024 text \U05D4 with unicode' }
  let(:encoded_normalized) { 'this is some $ text \u05d4 with unicode' }
  let(:decoded) { 'this is some $ text ה with unicode' }

  it "decodes unicode chars" do
    subject.decode!(encoded.dup).must_equal decoded
  end

  it "encodes unicode chars" do
    subject.encode!(decoded.dup).must_equal encoded_normalized
  end

  it "encodes unicode chars but has 2-based hex size" do
    subject.encode!("ה").must_equal '\u05d4'
    subject.encode!("ᘓ").must_equal '\u1613'
  end

  it "decodes and encodes" do
    encoded  = subject.encode!(decoded.dup)
    deconded = subject.decode!(encoded.dup)
    deconded.must_equal decoded
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proper_properties-0.0.2 spec/proper_properties/encoding/unicode_spec.rb
proper_properties-0.0.1 spec/proper_properties/encoding/unicode_spec.rb