Sha256: f1687deca107d9b9d9e1030397f55c7323275f30bae9085dc58370d48b0adc52

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require_relative "../lib/unicode/numeric_value"
require "minitest/autorun"

describe Unicode::NumericValue do
  describe ".numeric_value (alias .of)" do
    it "will return integers values" do
      assert_equal 1, Unicode::NumericValue.of("1")
      assert_equal 8, Unicode::NumericValue.of("Ⅷ")
      assert_equal 19, Unicode::NumericValue.of("⓳")
      assert_equal 1000000000000, Unicode::NumericValue.of("𖭡")
    end

    it "will return rational values" do
      assert_equal  3/4r, Unicode::NumericValue.of("¾")
      assert_equal -1/2r, Unicode::NumericValue.of("༳")
    end

    it "will return nil if no numeric value associated" do
      assert_equal nil, Unicode::NumericValue.of("A")
      assert_equal nil, Unicode::NumericValue.of("\0")
    end

    it "works with numbers from recent Unicode versions" do
      assert_equal 0, Unicode::NumericValue.of("𝋀") # Unicode 15.0
    end
  end

  describe ".chars" do
    it "will return all characters that have an numerical value" do
      assert_equal true, Unicode::NumericValue.chars.include?("⑸")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unicode-numeric_value-1.9.0 spec/unicode_numeric_value_spec.rb