failing multi chord test from file
This commit is contained in:
47
src/play.rs
Normal file
47
src/play.rs
Normal 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()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user