Sha256: 6244b4aa6073351d556be8e572569c344ed6676ba31cc4b3b710eb9fa4ce9aa2

Contents?: true

Size: 809 Bytes

Versions: 11

Compression:

Stored size: 809 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/utils'

describe HexaPDF::Utils do
  include HexaPDF::Utils

  describe "Numeric refinement" do
    using HexaPDF::Utils

    it "converts mm to points" do
      assert_equal(72, 25.4.mm)
    end

    it "converts cm to points" do
      assert_equal(72, 2.54.cm)
    end

    it "converts inch to points" do
      assert_equal(144, 2.inch)
    end
  end

  it "checks floats for equality with a certain precision" do
    assert(float_equal(1.0, 1))
    assert(float_equal(1.0, 1.0000003))
  end

  it "compares floats like the <=> operator" do
    assert_equal(0, float_compare(1.0, 1))
    assert_equal(0, float_compare(1.0, 1.0000003))
    assert_equal(-1, float_compare(1.0, 1.03))
    assert_equal(1, float_compare(1.0, 0.9997))
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hexapdf-1.2.0 test/hexapdf/test_utils.rb
hexapdf-1.1.1 test/hexapdf/test_utils.rb
hexapdf-1.1.0 test/hexapdf/test_utils.rb
hexapdf-1.0.3 test/hexapdf/test_utils.rb
hexapdf-1.0.2 test/hexapdf/test_utils.rb
hexapdf-1.0.1 test/hexapdf/test_utils.rb
hexapdf-1.0.0 test/hexapdf/test_utils.rb
hexapdf-0.47.0 test/hexapdf/test_utils.rb
hexapdf-0.46.0 test/hexapdf/test_utils.rb
hexapdf-0.45.0 test/hexapdf/test_utils.rb
hexapdf-0.44.0 test/hexapdf/test_utils.rb