Sha256: 1751bc5188a65328727acfd91499fbc509084db0fdfd29c9189d129a96708fc7

Contents?: true

Size: 1.62 KB

Versions: 34

Compression:

Stored size: 1.62 KB

Contents

# -*- coding: utf-8 -*-
require 'helper'
require 'pathname'

class TestUnf < Test::Unit::TestCase
  test "raise ArgumentError if an unknown normalization form is given" do
    normalizer = UNF::Normalizer.new
    assert_raises(ArgumentError) { normalizer.normalize("が", :nfck) }
  end

  test "pass all tests bundled with the original unf" do
    normalizer = UNF::Normalizer.new
    open(Pathname(__FILE__).dirname + 'normalization-test.txt', 'r:utf-8').each_slice(6) { |lines|
      flunk "broken test file" if lines.size != 6 || lines.pop !~ /^$/
      str, nfd, nfc, nfkd, nfkc = lines
      assert nfd,  normalizer.normalize(str,  :nfd)
      assert nfd,  normalizer.normalize(nfd,  :nfd)
      assert nfd,  normalizer.normalize(nfc,  :nfd)
      assert nfkd, normalizer.normalize(nfkc, :nfd)
      assert nfkd, normalizer.normalize(nfkc, :nfd)

      assert nfc,  normalizer.normalize(str,  :nfd)
      assert nfc,  normalizer.normalize(nfd,  :nfc)
      assert nfc,  normalizer.normalize(nfc,  :nfc)
      assert nfkc, normalizer.normalize(nfkc, :nfc)
      assert nfkc, normalizer.normalize(nfkd, :nfc)

      assert nfkd, normalizer.normalize(str,  :nfkd)
      assert nfkd, normalizer.normalize(nfd,  :nfkd)
      assert nfkd, normalizer.normalize(nfc,  :nfkd)
      assert nfkd, normalizer.normalize(nfkc, :nfkd)
      assert nfkd, normalizer.normalize(nfkd, :nfkd)

      assert nfkc, normalizer.normalize(str,  :nfkc)
      assert nfkc, normalizer.normalize(nfd,  :nfkc)
      assert nfkc, normalizer.normalize(nfc,  :nfkc)
      assert nfkc, normalizer.normalize(nfkc, :nfkc)
      assert nfkc, normalizer.normalize(nfkd, :nfkc)
    }
  end
end

Version data entries

34 entries across 32 versions & 7 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
unf_ext-0.0.7.3-x86-mingw32 test/test_unf_ext.rb
unf_ext-0.0.7.3-x64-mingw32 test/test_unf_ext.rb
unf_ext-0.0.7.3 test/test_unf_ext.rb
tdiary-5.0.4 vendor/bundle/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
tdiary-5.0.2 vendor/bundle/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
tdiary-5.0.1 vendor/bundle/gems/unf_ext-0.0.7.2/test/test_unf_ext.rb
unf_ext-0.0.7.2-x86-mingw32 test/test_unf_ext.rb
unf_ext-0.0.7.2-x64-mingw32 test/test_unf_ext.rb
unf_ext-0.0.7.2 test/test_unf_ext.rb