use crate::convert::{srgb8_to_rgb12, rgb12_to_srgb8};
use crate::blend::blend_srgb8;

#[test]
fn is_12_bit() {
	for i in 0..255u8 {
		assert!(srgb8_to_rgb12(i) <= 4095);
	}
}

#[test]
fn round_trip() {
	for i in 0..=255u8 {
		assert_eq!(i, rgb12_to_srgb8(srgb8_to_rgb12(i)));
		assert_ne!(i, rgb12_to_srgb8(srgb8_to_rgb12(i.wrapping_sub(1))));
		assert_ne!(i, rgb12_to_srgb8(srgb8_to_rgb12(i.wrapping_add(1))));
	}
}

#[test]
fn limits() {
	assert_eq!(srgb8_to_rgb12(0), 0);
	assert_eq!(srgb8_to_rgb12(255), 4095);
	assert_eq!(rgb12_to_srgb8(0), 0);
}

#[test]
fn blend_same() {
	for c in 0..=255u8 {
		let color = (c, c, c);

		for alpha in 0..=255u8 {
			assert_eq!(blend_srgb8(color, color, alpha), color);
		}
	}
}
