43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use super::*;
|
|
|
|
#[test]
|
|
fn test_subpixel_alignment_computation() {
|
|
{
|
|
// Default case - a non-fractional offset should have an alignment
|
|
// value of zero.
|
|
let pos = vec2f(0., 0.);
|
|
let alignment = SubpixelAlignment::new(pos);
|
|
assert_eq!(alignment.0, 0);
|
|
}
|
|
{
|
|
// 0.1 rounds down to 0 (not up to 0.33 -> 1)
|
|
let pos = vec2f(0.1, 0.);
|
|
let alignment = SubpixelAlignment::new(pos);
|
|
assert_eq!(alignment.0, 0);
|
|
}
|
|
{
|
|
// y-position doesn't affect computation
|
|
let pos = vec2f(0.1, 0.33);
|
|
let alignment = SubpixelAlignment::new(pos);
|
|
assert_eq!(alignment.0, 0);
|
|
}
|
|
{
|
|
// 0.2 rounds up to 0.33 -> 1
|
|
let pos = vec2f(0.2, 0.);
|
|
let alignment = SubpixelAlignment::new(pos);
|
|
assert_eq!(alignment.0, 1);
|
|
}
|
|
{
|
|
// 0.66 doesn't round, and converts to 2
|
|
let pos = vec2f(0.66, 0.);
|
|
let alignment = SubpixelAlignment::new(pos);
|
|
assert_eq!(alignment.0, 2);
|
|
}
|
|
{
|
|
// 0.9 rounds up to 1.0 -> 0
|
|
let pos = vec2f(0.9, 0.);
|
|
let alignment = SubpixelAlignment::new(pos);
|
|
assert_eq!(alignment.0, 0);
|
|
}
|
|
}
|