use crate::canvas::{Blitter, Canvas};
#[test]
fn test_blitter_variants_exist() {
let _b = Blitter::Braille;
let _s = Blitter::Sextant;
let _h = Blitter::HalfBlock;
let _o = Blitter::Octant;
}
#[test]
fn test_braille_default_unchanged() {
let mut c = Canvas::new(1, 1);
c.set(0, 0); let frame = c.frame();
let expected = char::from_u32(0x2800 + 0x01).unwrap();
assert_eq!(
frame,
expected.to_string(),
"default Braille should still produce U+2801"
);
}
#[test]
fn test_with_blitter_braille_same_as_default() {
let mut default_c = Canvas::new(1, 1);
default_c.set(0, 0);
let mut braille_c = Canvas::new(1, 1).with_blitter(Blitter::Braille);
braille_c.set(0, 0);
assert_eq!(
default_c.frame(),
braille_c.frame(),
"explicit Braille blitter must equal default"
);
}
#[test]
fn test_halfblock_top_pixel() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::HalfBlock);
c.set(0, 0); let frame = c.frame();
assert!(
frame.contains('\u{2580}'),
"top pixel in HalfBlock should produce U+2580 ▀, got: {frame:?}"
);
}
#[test]
fn test_halfblock_bottom_pixel() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::HalfBlock);
c.set(0, 1); let frame = c.frame();
assert!(
frame.contains('\u{2584}'),
"bottom pixel in HalfBlock should produce U+2584 ▄, got: {frame:?}"
);
}
#[test]
fn test_halfblock_both_pixels() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::HalfBlock);
c.set(0, 0);
c.set(0, 1);
let frame = c.frame();
assert!(
frame.contains('\u{2588}'),
"both pixels in HalfBlock should produce U+2588 █, got: {frame:?}"
);
}
#[test]
fn test_halfblock_empty_is_space() {
let c = Canvas::new(1, 1).with_blitter(Blitter::HalfBlock);
let frame = c.frame();
assert_eq!(frame, " ", "empty HalfBlock cell should be a space");
}
#[test]
fn test_sextant_top_left_pixel() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::Sextant);
c.set(0, 0);
let frame = c.frame();
let expected = '\u{1FB00}'; assert!(
frame.contains(expected),
"sextant pixel (0,0) should produce U+1FB00, got: {frame:?}"
);
}
#[test]
fn test_sextant_top_right_pixel() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::Sextant);
c.set(1, 0);
let frame = c.frame();
let expected = '\u{1FB01}';
assert!(
frame.contains(expected),
"sextant pixel (1,0) should produce U+1FB01, got: {frame:?}"
);
}
#[test]
fn test_sextant_top_row() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::Sextant);
c.set(0, 0); c.set(1, 0); let frame = c.frame();
let expected = '\u{1FB02}'; assert!(
frame.contains(expected),
"sextant top row (both pixels) should produce U+1FB02, got: {frame:?}"
);
}
#[test]
fn test_sextant_bottom_left_pixel() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::Sextant);
c.set(0, 2);
let frame = c.frame();
let expected = '\u{1FB0F}';
assert!(
frame.contains(expected),
"sextant pixel (0,2) should produce U+1FB0F, got: {frame:?}"
);
}
#[test]
fn test_sextant_empty_is_space() {
let c = Canvas::new(1, 1).with_blitter(Blitter::Sextant);
let frame = c.frame();
assert_eq!(frame, " ", "empty Sextant cell should be a space");
}
#[test]
fn test_octant_pixel_set_nonempty() {
let mut c = Canvas::new(1, 1).with_blitter(Blitter::Octant);
c.set(0, 0);
let frame = c.frame();
assert!(
!frame.is_empty(),
"Octant frame should be non-empty after setting a pixel"
);
assert_ne!(
frame.trim(),
"",
"frame with set pixel should not be all spaces"
);
}
#[test]
fn test_octant_empty_nonempty_or_space() {
let c = Canvas::new(1, 1).with_blitter(Blitter::Octant);
let frame = c.frame();
let is_space = frame == " ";
let is_empty_braille = frame.contains('\u{2800}');
assert!(
is_space || is_empty_braille,
"empty Octant cell should be space or empty Braille, got: {frame:?}"
);
}