# Tests res://scripts/zoom_band_config.gd (NEO-16 discrete bands).
extends GdUnitTestSuite

const ZoomBandConfigScript := preload("res://scripts/zoom_band_config.gd")


func test_empty_bands_band_count_zero() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array()
	assert_that(c.band_count()).is_equal(0)


func test_empty_bands_clamp_index_zero() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array()
	assert_that(c.clamp_index(0)).is_equal(0)
	assert_that(c.clamp_index(99)).is_equal(0)


func test_empty_bands_distance_at_zero() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array()
	assert_that(c.distance_at(0)).is_equal(0.0)


func test_single_band_clamp_always_zero() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array([42.0])
	assert_that(c.clamp_index(-1)).is_equal(0)
	assert_that(c.clamp_index(0)).is_equal(0)
	assert_that(c.clamp_index(9)).is_equal(0)


func test_multi_band_clamp_and_distance_at() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array([10.0, 20.0, 30.0])
	assert_that(c.clamp_index(-5)).is_equal(0)
	assert_that(c.clamp_index(1)).is_equal(1)
	assert_that(c.clamp_index(99)).is_equal(2)
	assert_that(c.distance_at(1)).is_equal(20.0)
	assert_that(c.distance_at(100)).is_equal(30.0)


func test_default_index_clamped_via_clamp_index() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array([1.0, 2.0, 3.0])
	c.default_band_index = 99
	assert_that(c.clamp_index(c.default_band_index)).is_equal(2)


func test_all_band_distances_positive_vacuous_when_empty() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array()
	assert_that(c.all_band_distances_positive()).is_true()


func test_all_band_distances_positive_true_when_all_positive() -> void:
	var c = ZoomBandConfigScript.new()
	c.band_distances = PackedFloat32Array([1.0, 2.5, 10.0])
	assert_that(c.all_band_distances_positive()).is_true()


func test_all_band_distances_positive_false_when_zero_or_negative() -> void:
	var c0 = ZoomBandConfigScript.new()
	c0.band_distances = PackedFloat32Array([10.0, 0.0, 20.0])
	assert_that(c0.all_band_distances_positive()).is_false()
	var cn = ZoomBandConfigScript.new()
	cn.band_distances = PackedFloat32Array([5.0, -1.0])
	assert_that(cn.all_band_distances_positive()).is_false()
