Skip to content

Commit

Permalink
test: drop unused testing method
Browse files Browse the repository at this point in the history
  • Loading branch information
YeungOnion committed May 27, 2024
1 parent 75ecd2b commit 5d6f4be
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions src/testing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
//! Provides testing helpers and utilities
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::str;

/// Loads a test data file into a vector of `f64`'s.
/// Path is relative to /data.
///
/// # Panics
///
/// Panics if the file does not exist or could not be opened, or
/// there was an error reading the file.
#[cfg(test)]
pub fn load_data(path: &str) -> Vec<f64> {
// note: the copious use of unwrap is because this is a test helper and
// if reading the data file fails, we want to panic immediately

let path_prefix = "./data/".to_string();
let true_path = path_prefix + path.trim().trim_start_matches('/');

let f = File::open(true_path).unwrap();
let mut reader = BufReader::new(f);

let mut buf = String::new();
let mut data: Vec<f64> = vec![];
while reader.read_line(&mut buf).unwrap() > 0 {
data.push(buf.trim().parse::<f64>().unwrap());
buf.clear();
}
data
}

0 comments on commit 5d6f4be

Please sign in to comment.