Skip to content

Commit

Permalink
[write-fonts] Migrate LocaFormat tests from fontc
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyr committed Aug 7, 2023
1 parent eff6340 commit 472cfa3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions write-fonts/src/tables/loca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,31 @@ impl FontWrite for Loca {
impl Validate for Loca {
fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn no_glyphs_is_short() {
assert_eq!(LocaFormat::Short, LocaFormat::new(&Vec::new()));
}

#[test]
fn some_glyphs_is_short() {
assert_eq!(LocaFormat::Short, LocaFormat::new(&[24, 48, 112]));
}

#[test]
fn unpadded_glyphs_is_long() {
assert_eq!(LocaFormat::Long, LocaFormat::new(&[24, 7, 112]));
}

#[test]
fn big_glyphs_is_long() {
assert_eq!(
LocaFormat::Long,
LocaFormat::new(&(0..=32).map(|i| i * 0x1000).collect::<Vec<_>>())
);
}
}

0 comments on commit 472cfa3

Please sign in to comment.