Skip to content

Commit

Permalink
More render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Feb 20, 2024
1 parent f47f805 commit b04b31d
Showing 1 changed file with 67 additions and 3 deletions.
70 changes: 67 additions & 3 deletions fidget/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ mod test {

const HI: &str =
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../models/hi.vm"));
const QUARTER: &str = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../models/quarter.vm"
));

fn render_and_compare<S: Shape>(shape: S, expected: &'static str) {
let cfg = RenderConfig::<2> {
Expand All @@ -50,10 +54,9 @@ mod test {
}
}

#[test]
fn render_hi_vm() {
fn check_hi<S: Shape + MathShape>() {
let (ctx, root) = Context::from_text(HI.as_bytes()).unwrap();
let shape = VmShape::new(&ctx, root).unwrap();
let shape = S::new(&ctx, root).unwrap();
const EXPECTED: &str = "
.................X..............
.................X..............
Expand Down Expand Up @@ -89,4 +92,65 @@ mod test {
................................";
render_and_compare(shape, EXPECTED);
}

fn check_quarter<S: Shape + MathShape>() {
let (ctx, root) = Context::from_text(QUARTER.as_bytes()).unwrap();
let shape = S::new(&ctx, root).unwrap();
const EXPECTED: &str = "
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
................................
.....XXXXXXXXXXX................
.....XXXXXXXXXXX................
......XXXXXXXXXX................
......XXXXXXXXXX................
......XXXXXXXXXX................
.......XXXXXXXXX................
........XXXXXXXX................
.........XXXXXXX................
..........XXXXXX................
...........XXXXX................
..............XX................
................................
................................
................................
................................
................................";
render_and_compare(shape, EXPECTED);
}

#[test]
fn render_hi_vm() {
check_hi::<VmShape>();
}

#[cfg(feature = "jit")]
#[test]
fn render_hi_jit() {
check_hi::<crate::jit::JitShape>();
}

#[test]
fn render_quarter_vm() {
check_quarter::<VmShape>();
}

#[cfg(feature = "jit")]
#[test]
fn render_quarter_jit() {
check_quarter::<crate::jit::JitShape>();
}
}

0 comments on commit b04b31d

Please sign in to comment.