Add tests
parent
3c0df12b50
commit
07b18044de
60
src/main.rs
60
src/main.rs
|
@ -86,3 +86,63 @@ struct Song {
|
|||
performer: String,
|
||||
composer: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn bmbmbm() -> Song {
|
||||
Song {
|
||||
title: "bmbmbm".to_string(),
|
||||
performer: "black midi".to_string(),
|
||||
composer: "black midi".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn love_story(performer: &str) -> Song {
|
||||
Song {
|
||||
title: "Love Story".to_string(),
|
||||
performer: performer.to_string(),
|
||||
composer: "Taylor Swift".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn schizoid_man() -> Song {
|
||||
Song {
|
||||
title: "21st Century Schizoid Man".to_string(),
|
||||
performer: "black midi".to_string(),
|
||||
composer: "Greg Lake, Ian McDonald, Michael Giles, Peter Sinfield & Robert Fripp"
|
||||
.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn bm() -> Artist {
|
||||
Artist {
|
||||
name: "black midi".to_string(),
|
||||
catalog: HashSet::from([bmbmbm(), love_story("black midi"), schizoid_man()]),
|
||||
}
|
||||
}
|
||||
|
||||
fn ts() -> Artist {
|
||||
Artist {
|
||||
name: "Taylor Swift".to_string(),
|
||||
catalog: HashSet::from([love_story("Taylor Swift")]),
|
||||
}
|
||||
}
|
||||
|
||||
fn library() -> Library {
|
||||
Library {
|
||||
artists: HashSet::from([bm(), ts()]),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_covered_songs() {
|
||||
assert!(bm().covered_songs() == HashSet::from([&love_story("black midi"), &schizoid_man()]))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_covers() {
|
||||
assert!(library().find_covers() == HashSet::from([&love_story("black midi")]))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue