// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>

use super::clamp_offset;

#[ test ]
fn offset_zero_when_content_fits()
{
	// Content shorter than viewport — no scrolling possible
	assert_eq!( clamp_offset( 50.0, 300.0, 500.0 ), 0.0 );
}

#[ test ]
fn offset_clamped_to_zero_when_negative()
{
	assert_eq!( clamp_offset( -10.0, 600.0, 400.0 ), 0.0 );
}

#[ test ]
fn offset_clamped_to_max()
{
	// max = 600 - 400 = 200; offset 999 → clamped to 200
	assert_eq!( clamp_offset( 999.0, 600.0, 400.0 ), 200.0 );
}

#[ test ]
fn offset_within_range_unchanged()
{
	// max = 600 - 400 = 200; offset 100 stays 100
	assert_eq!( clamp_offset( 100.0, 600.0, 400.0 ), 100.0 );
}

#[ test ]
fn zero_offset_stays_zero()
{
	assert_eq!( clamp_offset( 0.0, 600.0, 400.0 ), 0.0 );
}

#[ test ]
fn exact_max_offset_is_valid()
{
	assert_eq!( clamp_offset( 200.0, 600.0, 400.0 ), 200.0 );
}

#[ test ]
fn content_equal_to_viewport_gives_zero_max()
{
	// No overflow — max = 0
	assert_eq!( clamp_offset( 10.0, 400.0, 400.0 ), 0.0 );
}
