Sha256: 269e839bdb79ca17f22a374a32e2a32f6521058e64d1528b941f946b11123026

Contents?: true

Size: 1.19 KB

Versions: 65

Compression:

Stored size: 1.19 KB

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 width and the given height if width is zero" do
      assert_equal([10, 6], calculate_dimensions(0, 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

    it "returns the requested height and the given width if height is zero" do
      assert_equal([5, 12], calculate_dimensions(5, 0, 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

65 entries across 65 versions & 1 rubygems

Version Path
hexapdf-1.1.1 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-1.1.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-1.0.3 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-1.0.2 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-1.0.1 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-1.0.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.47.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.46.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.45.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.44.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.41.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.40.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.39.1 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.39.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.38.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.37.2 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.37.1 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.37.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.36.0 test/hexapdf/utils/test_graphics_helpers.rb
hexapdf-0.35.1 test/hexapdf/utils/test_graphics_helpers.rb