67 lines
2.2 KiB
Ruby
67 lines
2.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
class SizingTest < Minitest::Test
|
|
def setup
|
|
@data = MoonModel::DataSet.new
|
|
end
|
|
|
|
def datum_config(exaggeration, assembly: "auto")
|
|
MoonModel::Config.new(
|
|
"size" => { "input" => "diameter", "value" => 8.0, "unit" => "in", "meaning" => "datum" },
|
|
"vertical_exaggeration" => exaggeration,
|
|
"assembly" => assembly,
|
|
"resolution" => { "longitude_segments" => 48 }
|
|
)
|
|
end
|
|
|
|
def test_eight_inch_relief_uses_consistent_units
|
|
one = MoonModel::Sizing.calculate(datum_config(1), @data)
|
|
ten = MoonModel::Sizing.calculate(datum_config(10), @data)
|
|
|
|
assert_in_delta 1.153, one.relief_range_mm, 0.001
|
|
assert_in_delta 11.532, ten.relief_range_mm, 0.001
|
|
assert_operator ten.final_envelope_mm, :>, one.final_envelope_mm
|
|
assert_operator ten.maximum_radius_mm, :>, ten.minimum_radius_mm
|
|
assert_operator ten.maximum_radius_mm, :>, ten.datum_diameter_mm / 2.0
|
|
end
|
|
|
|
|
|
def test_single_color_grid_is_included_in_conservative_minimum_radius
|
|
plain = datum_config(5)
|
|
grid = datum_config(5)
|
|
grid = MoonModel::Config.new(grid.to_h.merge("grid" => { "enabled" => true, "depth_mm" => 0.7 }))
|
|
|
|
plain_result = MoonModel::Sizing.calculate(plain, @data)
|
|
grid_result = MoonModel::Sizing.calculate(grid, @data)
|
|
|
|
assert_in_delta 0.7, plain_result.minimum_radius_mm - grid_result.minimum_radius_mm, 0.001
|
|
end
|
|
|
|
def test_unsafe_exaggeration_is_rejected_with_limit
|
|
error = assert_raises(ArgumentError) { MoonModel::Sizing.calculate(datum_config(1000), @data) }
|
|
|
|
assert_match(/maximum is 18[89]x/, error.message)
|
|
end
|
|
|
|
def test_exaggerated_datum_can_automatically_select_sections
|
|
result = MoonModel::Sizing.calculate(datum_config(100), @data)
|
|
|
|
assert result.segmented?
|
|
assert_equal "automatic", result.mode_source
|
|
end
|
|
|
|
def test_final_envelope_remains_requested_size
|
|
config = MoonModel::Config.new(
|
|
"size" => { "input" => "diameter", "value" => 8.0, "unit" => "in", "meaning" => "final_envelope" },
|
|
"vertical_exaggeration" => 10,
|
|
"resolution" => { "longitude_segments" => 48 }
|
|
)
|
|
result = MoonModel::Sizing.calculate(config, @data)
|
|
|
|
assert_in_delta 203.2, result.final_envelope_mm, 0.001
|
|
refute result.segmented?
|
|
end
|
|
end
|