Sha256: 5388a769fd075c9004f314df1c6fad0eaef574d6da891e0cd4e49b360cdb013d

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# encoding: UTF-8

require 'spec_helper'

module ICU
  module Collation
    describe Collator do

      before { @c = Collator.new("no") }
      after { @c.close }

      it "should collate an array of strings" do
        @c.collate(%w[å ø æ]).should == %w[æ ø å]
      end

      it "should return available locales" do
        locales = ICU::Collation.available_locales
        locales.should be_kind_of(Array)
        locales.should_not be_empty
      end

      it "should return the locale of the collator" do
        l = @c.locale
        l.should be_kind_of(String)
        l.should == "nb"
      end

      it "should compare two strings" do
        @c.compare("blåbærsyltetøy", "blah").should == 1
        @c.compare("blah", "blah").should == 0
        @c.compare("baah", "blah").should == -1
      end

      it "should know if a string is greater than another" do
        @c.should be_greater("z", "a")
        @c.should_not be_greater("a", "z")
      end

      it "should know if a string is greater or equal to another" do
        @c.should be_greater_or_equal("z", "a")
        @c.should be_greater_or_equal("z", "z")
        @c.should_not be_greater_or_equal("a", "z")
      end

      it "should know if a string is equal to another" do
        @c.should be_same("a", "a")
      end

    end
  end # Collate
end # ICU

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffi-icu-0.0.1 spec/collation_spec.rb