Sha256: 4509387e8e2e6f9e5eb387dd82477ecc58bdf2b22dec97e3e58dd2617640c52f

Contents?: true

Size: 956 Bytes

Versions: 11

Compression:

Stored size: 956 Bytes

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
  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

11 entries across 11 versions & 1 rubygems

Version Path
unicode-numeric_value-1.8.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.7.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.6.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.5.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.4.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.3.2 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.3.1 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.3.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.2.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.1.0 spec/unicode_numeric_value_spec.rb
unicode-numeric_value-1.0.0 spec/unicode_numeric_value_spec.rb