failing multi chord test from file

This commit is contained in:
Bel LaPointe
2026-03-11 16:00:41 -06:00
parent 05b49a3777
commit 8f4c7596c4
4 changed files with 57 additions and 2 deletions

47
src/play.rs Normal file
View File

@@ -0,0 +1,47 @@
use std::io::Read;
pub fn new<S: ToString>(s: S) -> Vec<String> {
parse(from_string(s.to_string()))
}
fn from_string(s: String) -> String {
match std::fs::File::open(s.clone()) {
Ok(mut reader) => {
let mut content = String::new();
reader
.read_to_string(&mut content)
.expect(format!("failed to read {}", s).as_ref());
content.split_whitespace().collect::<Vec<_>>().join(" ")
}
Err(_) => s,
}
}
fn parse(s: String) -> Vec<String> {
vec![s]
}
#[cfg(test)]
mod test {
#[test]
fn test_string() {
assert_eq!(super::new("a b c")[0], "a b c".to_string());
assert_eq!(super::new("a b c".to_string())[0], "a b c".to_string());
}
#[test]
fn test_single_line_file() {
assert_eq!(
super::new("src/testdata/single_line_file.txt")[0],
"a b c".to_string()
);
}
#[test]
fn test_two_channels_one_bar() {
assert_eq!(
super::new("src/testdata/two_channels_one_bar.txt")[0],
"a b c".to_string()
);
}
}