48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use client_domain::{BoundingBox, HAlign, VAlign, align_offset};
|
|
|
|
#[test]
|
|
fn halign_left_is_zero_offset() {
|
|
let offset = align_offset(100, 60, HAlign::Left);
|
|
assert_eq!(offset, 0);
|
|
}
|
|
|
|
#[test]
|
|
fn halign_center_centers_content() {
|
|
// 100px container, 60px content → 20px offset
|
|
let offset = align_offset(100, 60, HAlign::Center);
|
|
assert_eq!(offset, 20);
|
|
}
|
|
|
|
#[test]
|
|
fn halign_right_pushes_to_end() {
|
|
// 100px container, 60px content → 40px offset
|
|
let offset = align_offset(100, 60, HAlign::Right);
|
|
assert_eq!(offset, 40);
|
|
}
|
|
|
|
#[test]
|
|
fn valign_top_is_zero_offset() {
|
|
let offset = align_offset(200, 30, VAlign::Top);
|
|
assert_eq!(offset, 0);
|
|
}
|
|
|
|
#[test]
|
|
fn valign_middle_centers_content() {
|
|
// 200px container, 30px content → 85px offset
|
|
let offset = align_offset(200, 30, VAlign::Middle);
|
|
assert_eq!(offset, 85);
|
|
}
|
|
|
|
#[test]
|
|
fn valign_bottom_pushes_to_end() {
|
|
// 200px container, 30px content → 170px offset
|
|
let offset = align_offset(200, 30, VAlign::Bottom);
|
|
assert_eq!(offset, 170);
|
|
}
|
|
|
|
#[test]
|
|
fn content_larger_than_container_clamps_to_zero() {
|
|
let offset = align_offset(50, 100, HAlign::Center);
|
|
assert_eq!(offset, 0);
|
|
}
|