mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 08:15:29 +00:00
test(score): retain per-pitch MusicXML and SVG tie regression from SoundCraft 182
This commit is contained in:
1 parent
9b570237ef
commit
0006665d60
1 file changed
+34
@@ -432,3 +432,37 @@ fn validate(parts: &[Part], setup: &ScoreSetup) -> Result<(), String> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used, clippy::indexing_slicing)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
fn setup() -> ScoreSetup {
|
||||
ScoreSetup { software: "SoundCraft".into(), title: "A<&\u{1}".into(), composer: "B".into(), bars_per_system: 4, show_track_names: true }
|
||||
}
|
||||
fn parts() -> Vec<Part> {
|
||||
vec![Part {
|
||||
name: "Keys".into(),
|
||||
bass: false,
|
||||
measures: vec![Measure {
|
||||
numerator: 4,
|
||||
denominator: 4,
|
||||
items: vec![
|
||||
Item { pitches: vec![60, 64], units: 4, tie_start: vec![64], tie_stop: vec![] },
|
||||
Item { pitches: vec![64], units: 12, tie_start: vec![], tie_stop: vec![64] },
|
||||
],
|
||||
}],
|
||||
}]
|
||||
}
|
||||
#[test]
|
||||
fn per_pitch_ties_and_escaping_survive_serialization() {
|
||||
let parts = parts();
|
||||
let xml = musicxml(&parts, &setup()).unwrap();
|
||||
assert!(xml.contains("<work-title>A<&</work-title>"));
|
||||
let notes: Vec<_> = xml.split("<note>").skip(1).map(|n| n.split("</note>").next().unwrap()).collect();
|
||||
assert!(notes[0].contains("<duration>4</duration>"));
|
||||
assert!(!notes[0].contains("<tie "));
|
||||
assert!(notes[1].contains("<tie type=\"start\"/>") && notes[1].contains("<chord/>"));
|
||||
assert!(notes[2].contains("<duration>12</duration>") && notes[2].contains("<tie type=\"stop\"/>"));
|
||||
assert_eq!(svg(&parts, &setup()).unwrap().matches("stroke-width=\"0.9\"").count(), 1);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user