Sha256: b8f3cac642e8c5672bbcdc3715a4e6bd663c5e00ecb0ba52705a910502469794

Contents?: true

Size: 906 Bytes

Versions: 31

Compression:

Stored size: 906 Bytes

Contents

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

require 'test_helper'
require 'hexapdf/utils/graphics_helpers'

describe HexaPDF::Utils::GraphicsHelpers do
  include HexaPDF::Utils::GraphicsHelpers

  describe "calculate_dimensions" do
    it "returns the requested dimensions if both are specified" do
      assert_equal([7, 8], calculate_dimensions(5, 6, rwidth: 7, rheight: 8))
    end

    it "returns the requested width and an adjusted height" do
      assert_equal([10, 12], calculate_dimensions(5, 6, rwidth: 10))
    end

    it "returns the requested height and an adjusted width" do
      assert_equal([10, 12], calculate_dimensions(5, 6, rheight: 12))
    end
  end

  describe "point_on_line" do
    it "returns the correct point" do
      assert_equal([5, 5], point_on_line(0, 0, 10, 10, distance: Math.sqrt(50)))
      assert_equal([5, 5], point_on_line(10, 10, 0, 0, distance: Math.sqrt(50)))
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hexapdf-0.15.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.14.4 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.14.3 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.14.2 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.14.1 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.14.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.13.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.12.3 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.12.2 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.12.1 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.12.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.9 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.8 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.7 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.6 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.5 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.4 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.3 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.2 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.11.1 test/hexapdf/utils/test_graphics_helpers.rb