Skip to content

Commit

Permalink
test: add test for flank_rate_of_spread
Browse files Browse the repository at this point in the history
  • Loading branch information
calebissharp committed May 17, 2024
1 parent a24f636 commit 28df885
Show file tree
Hide file tree
Showing 2 changed files with 2,282 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/fbp/ros/flank_rate_of_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,32 @@
pub fn flank_rate_of_spread(ros: f64, bros: f64, lb: f64) -> f64 {
(ros + bros) / lb / 2.
}

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

#[derive(Debug, serde::Deserialize)]
struct TestRow {
ros: f64,
bros: f64,
lb: f64,
fros: f64,
}

#[test]
fn test_flank_rate_of_spread() -> Result<(), Box<dyn std::error::Error>> {
let fixture = std::fs::File::open("./tests/fixtures/flank_rate_of_spread.csv")?;
let mut rdr = csv::Reader::from_reader(fixture);

for result in rdr.deserialize() {
let record: TestRow = result?;
let fros = flank_rate_of_spread(record.ros, record.bros, record.lb);

assert_eq!(precision_f64(fros, 4), record.fros);
}

Ok(())
}
}
Loading

0 comments on commit 28df885

Please sign in to comment.